| Differences between
and this patch
- Source/JavaScriptCore/ChangeLog +63 lines
Lines 1-3 Source/JavaScriptCore/ChangeLog_sec1
1
2013-04-04  Filip Pizlo  <fpizlo@apple.com>
2
3
        FTL should have OSR exit
4
        https://bugs.webkit.org/show_bug.cgi?id=113623
5
6
        Reviewed by NOBODY (OOPS!).
7
        
8
        Work in progress.
9
10
        * dfg/DFGOSRExit.cpp:
11
        (JSC::DFG::OSRExit::OSRExit):
12
        (DFG):
13
        * dfg/DFGOSRExit.h:
14
        (OSRExit):
15
        * dfg/DFGOSRExitBase.cpp: Added.
16
        (DFG):
17
        (JSC::DFG::OSRExitBase::considerAddingAsFrequentExitSiteSlow):
18
        * dfg/DFGOSRExitBase.h: Added.
19
        (DFG):
20
        (JSC::DFG::OSRExitBase::OSRExitBase):
21
        (OSRExitBase):
22
        (JSC::DFG::OSRExitBase::considerAddingAsFrequentExitSite):
23
        * ftl/FTLExitArgument.cpp: Added.
24
        (FTL):
25
        (JSC::FTL::ExitArgument::dump):
26
        * ftl/FTLExitArgument.h: Added.
27
        (FTL):
28
        (ExitArgumentRepresentation):
29
        (ExitArgument):
30
        (JSC::FTL::ExitArgument::ExitArgument):
31
        (JSC::FTL::ExitArgument::operator!):
32
        (JSC::FTL::ExitArgument::format):
33
        (JSC::FTL::ExitArgument::argument):
34
        (JSC::FTL::ExitArgument::representation):
35
        * ftl/FTLExitValue.cpp: Added.
36
        (FTL):
37
        (JSC::FTL::ExitValue::dump):
38
        * ftl/FTLExitValue.h: Added.
39
        (FTL):
40
        (ExitValue):
41
        (JSC::FTL::ExitValue::ExitValue):
42
        (JSC::FTL::ExitValue::operator!):
43
        (JSC::FTL::ExitValue::dead):
44
        (JSC::FTL::ExitValue::inJSStack):
45
        (JSC::FTL::ExitValue::constant):
46
        (JSC::FTL::ExitValue::argument):
47
        (JSC::FTL::ExitValue::kind):
48
        (JSC::FTL::ExitValue::isDead):
49
        (JSC::FTL::ExitValue::isInJSStack):
50
        (JSC::FTL::ExitValue::isConstant):
51
        (JSC::FTL::ExitValue::isArgument):
52
        * ftl/FTLFormattedValue.h:
53
        (FTL):
54
        * ftl/FTLOSRExit.h: Added.
55
        (FTL):
56
        (OSRExit):
57
        * ftl/FTLValueFormat.cpp: Added.
58
        (WTF):
59
        (WTF::printInternal):
60
        * ftl/FTLValueFormat.h: Added.
61
        (FTL):
62
        (WTF):
63
1
2013-04-03  Filip Pizlo  <fpizlo@apple.com>
64
2013-04-03  Filip Pizlo  <fpizlo@apple.com>
2
65
3
        fourthTier: put DFG data into a DFG::JITCode, and put common DFG and FTL data into something accessible from both DFG::JITCode and FTL::JITCode
66
        fourthTier: put DFG data into a DFG::JITCode, and put common DFG and FTL data into something accessible from both DFG::JITCode and FTL::JITCode
- Source/JavaScriptCore/dfg/DFGOSRExit.cpp -21 / +2 lines
Lines 36-50 Source/JavaScriptCore/dfg/DFGOSRExit.cpp_sec1
36
namespace JSC { namespace DFG {
36
namespace JSC { namespace DFG {
37
37
38
OSRExit::OSRExit(ExitKind kind, JSValueSource jsValueSource, MethodOfGettingAValueProfile valueProfile, SpeculativeJIT* jit, unsigned streamIndex, unsigned recoveryIndex)
38
OSRExit::OSRExit(ExitKind kind, JSValueSource jsValueSource, MethodOfGettingAValueProfile valueProfile, SpeculativeJIT* jit, unsigned streamIndex, unsigned recoveryIndex)
39
    : m_jsValueSource(jsValueSource)
39
    : OSRExitBase(kind, jit->m_codeOriginForOSR)
40
    , m_jsValueSource(jsValueSource)
40
    , m_valueProfile(valueProfile)
41
    , m_valueProfile(valueProfile)
41
    , m_patchableCodeOffset(0)
42
    , m_patchableCodeOffset(0)
42
    , m_codeOrigin(jit->m_codeOriginForOSR)
43
    , m_codeOrigin(jit->m_codeOriginForOSR)
43
    , m_codeOriginForExitProfile(m_codeOrigin)
44
    , m_recoveryIndex(recoveryIndex)
44
    , m_recoveryIndex(recoveryIndex)
45
    , m_watchpointIndex(std::numeric_limits<unsigned>::max())
45
    , m_watchpointIndex(std::numeric_limits<unsigned>::max())
46
    , m_kind(kind)
47
    , m_count(0)
48
    , m_streamIndex(streamIndex)
46
    , m_streamIndex(streamIndex)
49
    , m_lastSetOperand(jit->m_lastSetOperand)
47
    , m_lastSetOperand(jit->m_lastSetOperand)
50
{
48
{
Lines 73-95 void OSRExit::correctJump(LinkBuffer& li Source/JavaScriptCore/dfg/DFGOSRExit.cpp_sec2
73
    m_patchableCodeOffset = linkBuffer.offsetOf(label);
71
    m_patchableCodeOffset = linkBuffer.offsetOf(label);
74
}
72
}
75
73
76
bool OSRExit::considerAddingAsFrequentExitSiteSlow(CodeBlock* dfgCodeBlock, CodeBlock* profiledCodeBlock)
77
{
78
    if (static_cast<double>(m_count) / dfgCodeBlock->osrExitCounter() <= Options::osrExitProminenceForFrequentExitSite())
79
        return false;
80
    
81
    FrequentExitSite exitSite;
82
    
83
    if (m_kind == ArgumentsEscaped) {
84
        // Count this one globally. It doesn't matter where in the code block the arguments excaped;
85
        // the fact that they did is not associated with any particular instruction.
86
        exitSite = FrequentExitSite(m_kind);
87
    } else
88
        exitSite = FrequentExitSite(m_codeOriginForExitProfile.bytecodeIndex, m_kind);
89
    
90
    return baselineCodeBlockForOriginAndBaselineCodeBlock(m_codeOriginForExitProfile, profiledCodeBlock)->addFrequentExitSite(exitSite);
91
}
92
93
void OSRExit::convertToForward(BasicBlock* block, Node* currentNode, unsigned nodeIndex, const ValueRecovery& valueRecovery)
74
void OSRExit::convertToForward(BasicBlock* block, Node* currentNode, unsigned nodeIndex, const ValueRecovery& valueRecovery)
94
{
75
{
95
    // Check that either the current node is a SetLocal, or the preceding node was a
76
    // Check that either the current node is a SetLocal, or the preceding node was a
- Source/JavaScriptCore/dfg/DFGOSRExit.h -16 / +3 lines
Lines 1-5 Source/JavaScriptCore/dfg/DFGOSRExit.h_sec1
1
/*
1
/*
2
 * Copyright (C) 2011 Apple Inc. All rights reserved.
2
 * Copyright (C) 2011, 2013 Apple Inc. All rights reserved.
3
 *
3
 *
4
 * Redistribution and use in source and binary forms, with or without
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
5
 * modification, are permitted provided that the following conditions
Lines 34-39 Source/JavaScriptCore/dfg/DFGOSRExit.h_sec2
34
#include "DFGCommon.h"
34
#include "DFGCommon.h"
35
#include "DFGExitProfile.h"
35
#include "DFGExitProfile.h"
36
#include "DFGGPRInfo.h"
36
#include "DFGGPRInfo.h"
37
#include "DFGOSRExitBase.h"
37
#include "DFGValueRecoveryOverride.h"
38
#include "DFGValueRecoveryOverride.h"
38
#include "MacroAssembler.h"
39
#include "MacroAssembler.h"
39
#include "MethodOfGettingAValueProfile.h"
40
#include "MethodOfGettingAValueProfile.h"
Lines 84-90 private: Source/JavaScriptCore/dfg/DFGOSRExit.h_sec3
84
//
85
//
85
// This structure describes how to exit the speculative path by
86
// This structure describes how to exit the speculative path by
86
// going into baseline code.
87
// going into baseline code.
87
struct OSRExit {
88
struct OSRExit : public OSRExitBase {
88
    OSRExit(ExitKind, JSValueSource, MethodOfGettingAValueProfile, SpeculativeJIT*, unsigned streamIndex, unsigned recoveryIndex = UINT_MAX);
89
    OSRExit(ExitKind, JSValueSource, MethodOfGettingAValueProfile, SpeculativeJIT*, unsigned streamIndex, unsigned recoveryIndex = UINT_MAX);
89
    
90
    
90
    MacroAssemblerCodeRef m_code;
91
    MacroAssemblerCodeRef m_code;
Lines 94-114 struct OSRExit { Source/JavaScriptCore/dfg/DFGOSRExit.h_sec4
94
95
95
    unsigned m_patchableCodeOffset;
96
    unsigned m_patchableCodeOffset;
96
    CodeOrigin m_codeOrigin;
97
    CodeOrigin m_codeOrigin;
97
    CodeOrigin m_codeOriginForExitProfile;
98
    
98
    
99
    unsigned m_recoveryIndex;
99
    unsigned m_recoveryIndex;
100
    unsigned m_watchpointIndex;
100
    unsigned m_watchpointIndex;
101
    
101
    
102
    ExitKind m_kind;
103
    uint32_t m_count;
104
    
105
    bool considerAddingAsFrequentExitSite(CodeBlock* dfgCodeBlock, CodeBlock* profiledCodeBlock)
106
    {
107
        if (!m_count || !exitKindIsCountable(m_kind))
108
            return false;
109
        return considerAddingAsFrequentExitSiteSlow(dfgCodeBlock, profiledCodeBlock);
110
    }
111
112
    void setPatchableCodeOffset(MacroAssembler::PatchableJump);
102
    void setPatchableCodeOffset(MacroAssembler::PatchableJump);
113
    MacroAssembler::Jump getPatchableCodeOffsetAsJump() const;
103
    MacroAssembler::Jump getPatchableCodeOffsetAsJump() const;
114
    CodeLocationJump codeLocationForRepatch(CodeBlock*) const;
104
    CodeLocationJump codeLocationForRepatch(CodeBlock*) const;
Lines 120-128 struct OSRExit { Source/JavaScriptCore/dfg/DFGOSRExit.h_sec5
120
    int m_lastSetOperand;
110
    int m_lastSetOperand;
121
    
111
    
122
    RefPtr<ValueRecoveryOverride> m_valueRecoveryOverride;
112
    RefPtr<ValueRecoveryOverride> m_valueRecoveryOverride;
123
124
private:
125
    bool considerAddingAsFrequentExitSiteSlow(CodeBlock* dfgCodeBlock, CodeBlock* profiledCodeBlock);
126
};
113
};
127
114
128
struct SpeculationFailureDebugInfo {
115
struct SpeculationFailureDebugInfo {
- Source/JavaScriptCore/dfg/DFGOSRExitBase.cpp +53 lines
Line 0 Source/JavaScriptCore/dfg/DFGOSRExitBase.cpp_sec1
1
/*
2
 * Copyright (C) 2013 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24
 */
25
26
#include "config.h"
27
#include "DFGOSRExitBase.h"
28
29
#if ENABLE(DFG_JIT)
30
31
namespace JSC { namespace DFG {
32
33
bool OSRExitBase::considerAddingAsFrequentExitSiteSlow(CodeBlock* dfgCodeBlock, CodeBlock* profiledCodeBlock)
34
{
35
    if (static_cast<double>(m_count) / dfgCodeBlock->osrExitCounter() <= Options::osrExitProminenceForFrequentExitSite())
36
        return false;
37
    
38
    FrequentExitSite exitSite;
39
    
40
    if (m_kind == ArgumentsEscaped) {
41
        // Count this one globally. It doesn't matter where in the code block the arguments excaped;
42
        // the fact that they did is not associated with any particular instruction.
43
        exitSite = FrequentExitSite(m_kind);
44
    } else
45
        exitSite = FrequentExitSite(m_codeOriginForExitProfile.bytecodeIndex, m_kind);
46
    
47
    return baselineCodeBlockForOriginAndBaselineCodeBlock(m_codeOriginForExitProfile, profiledCodeBlock)->addFrequentExitSite(exitSite);
48
}
49
50
} } // namespace JSC::DFG
51
52
#endif // ENABLE(DFG_JIT)
53
- Source/JavaScriptCore/dfg/DFGOSRExitBase.h +70 lines
Line 0 Source/JavaScriptCore/dfg/DFGOSRExitBase.h_sec1
1
/*
2
 * Copyright (C) 2013 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24
 */
25
26
#ifndef DFGOSRExitBase_h
27
#define DFGOSRExitBase_h
28
29
#include <wtf/Platform.h>
30
31
#if ENABLE(DFG_JIT)
32
33
#include "CodeOrigin.h"
34
#include "DFGExitProfile.h"
35
36
namespace JSC { namespace DFG {
37
38
// Provides for the OSR exit profiling functionality that is common between the DFG
39
// and the FTL.
40
41
struct OSRExitBase {
42
    OSRExitBase(ExitKind kind, CodeOrigin origin)
43
        : m_kind(kind)
44
        , m_count(0)
45
        , m_codeOriginForExitProfile(origin)
46
    {
47
    }
48
    
49
    ExitKind m_kind;
50
    uint32_t m_count;
51
    
52
    CodeOrigin m_codeOriginForExitProfile;
53
54
    bool considerAddingAsFrequentExitSite(CodeBlock* dfgCodeBlock, CodeBlock* profiledCodeBlock)
55
    {
56
        if (!m_count || !exitKindIsCountable(m_kind))
57
            return false;
58
        return considerAddingAsFrequentExitSiteSlow(dfgCodeBlock, profiledCodeBlock);
59
    }
60
61
private:
62
    bool considerAddingAsFrequentExitSiteSlow(CodeBlock* dfgCodeBlock, CodeBlock* profiledCodeBlock);
63
};
64
65
} } // namespace JSC::DFG
66
67
#endif // ENABLE(DFG_JIT)
68
69
#endif // DFGOSRExitBase_h
70
- Source/JavaScriptCore/ftl/FTLExitArgument.cpp +41 lines
Line 0 Source/JavaScriptCore/ftl/FTLExitArgument.cpp_sec1
1
/*
2
 * Copyright (C) 2013 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24
 */
25
26
#include "config.h"
27
#include "FTLExitArgument.h"
28
29
#if ENABLE(FTL_JIT)
30
31
namespace JSC { namespace FTL {
32
33
void ExitArgument::dump(PrintStream& out) const
34
{
35
    out.print("arg", argument(), " as ", format());
36
}
37
38
} } // namespace JSC::FTL
39
40
#endif // ENABLE(FTL_JIT)
41
- Source/JavaScriptCore/ftl/FTLExitArgument.h +88 lines
Line 0 Source/JavaScriptCore/ftl/FTLExitArgument.h_sec1
1
/*
2
 * Copyright (C) 2013 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24
 */
25
26
#ifndef FTLExitArgument_h
27
#define FTLExitArgument_h
28
29
#include <wtf/Platform.h>
30
31
#if ENABLE(FTL_JIT)
32
33
#include "FTLValueFormat.h"
34
#include <wtf/PrintStream.h>
35
36
namespace JSC { namespace FTL {
37
38
struct ExitArgumentRepresentation {
39
    ValueFormat format;
40
    unsigned argument;
41
};
42
43
class ExitArgument {
44
public:
45
    ExitArgument()
46
    {
47
        m_representation.format = InvalidValueFormat;
48
    }
49
    
50
    ExitArgument(ValueFormat format, unsigned argument)
51
    {
52
        m_representation.format = format;
53
        m_representation.argument = argument;
54
    }
55
    
56
    explicit ExitArgument(ExitArgumentRepresentation representation)
57
    {
58
        m_representation = representation;
59
    }
60
    
61
    bool operator!() const { return m_representation.format == InvalidValueFormat; }
62
    
63
    ValueFormat format() const
64
    {
65
        ASSERT(*this);
66
        return m_representation.format;
67
    }
68
    
69
    unsigned argument() const
70
    {
71
        ASSERT(*this);
72
        return m_representation.argument;
73
    }
74
    
75
    ExitArgumentRepresentation representation() const { return m_representation; }
76
    
77
    void dump(PrintStream&) const;
78
    
79
private:
80
    ExitArgumentRepresentation m_representation;
81
};
82
83
} } // namespace JSC::FTL
84
85
#endif // ENABLE(FTL_JIT)
86
87
#endif // FTLExitArgument_h
88
- Source/JavaScriptCore/ftl/FTLExitValue.cpp +59 lines
Line 0 Source/JavaScriptCore/ftl/FTLExitValue.cpp_sec1
1
/*
2
 * Copyright (C) 2013 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24
 */
25
26
#include "config.h"
27
#include "FTLExitValue.h"
28
29
#if ENABLE(FTL_JIT)
30
31
namespace JSC { namespace FTL {
32
33
void ExitValue::dump(PrintStream& out) const
34
{
35
    switch (kind()) {
36
    case InvalidExitValue:
37
        out.print("Invalid");
38
        return;
39
    case ExitValueDead:
40
        out.print("Dead");
41
        return;
42
    case ExitValueArgument:
43
        out.print("Argument(", argument(), ")");
44
        return;
45
    case ExitValueConstant:
46
        out.print("Constant(", constant(), ")");
47
        return;
48
    case ExitValueInJSStack:
49
        out.print("InJSStack");
50
        return;
51
    }
52
    
53
    RELEASE_ASSERT_NOT_REACHED();
54
}
55
56
} } // namespace JSC::FTL
57
58
#endif // ENABLE(FTL_JIT)
59
- Source/JavaScriptCore/ftl/FTLExitValue.h +125 lines
Line 0 Source/JavaScriptCore/ftl/FTLExitValue.h_sec1
1
/*
2
 * Copyright (C) 2013 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24
 */
25
26
#ifndef FTLExitValue_h
27
#define FTLExitValue_h
28
29
#include <wtf/Platform.h>
30
31
#if ENABLE(FTL_JIT)
32
33
#include "FTLExitArgument.h"
34
#include "JSCJSValue.h"
35
#include <wtf/PrintStream.h>
36
37
namespace JSC { namespace FTL {
38
39
// This is like ValueRecovery, but respects the way that the FTL does OSR
40
// exit: the live non-constant non-flushed values are passed as arguments
41
// to a noreturn tail call. ExitValue is hence mostly responsible for
42
// telling us the mapping between operands in bytecode and the arguments to
43
// the call.
44
45
enum ExitValueKind {
46
    InvalidExitValue,
47
    ExitValueDead,
48
    ExitValueArgument,
49
    ExitValueConstant
50
    ExitValueInJSStack
51
};
52
53
class ExitValue {
54
public:
55
    ExitValue()
56
        : m_kind(InvalidExitValue)
57
    {
58
    }
59
    
60
    bool operator!() const { return m_kind == InvalidExitValue; }
61
    
62
    static ExitValue dead()
63
    {
64
        ExitValue result;
65
        result.m_kind = ExitValueDead;
66
        return result;
67
    }
68
    
69
    static ExitValue inJSStack()
70
    {
71
        ExitValue result;
72
        result.m_kind = ExitValueInJSStack;
73
        return result;
74
    }
75
    
76
    static ExitValue constant(JSValue value)
77
    {
78
        ExitValue result;
79
        result.m_kind = ExitValueConstant;
80
        result.u.constant = JSValue::encode(value);
81
        return result;
82
    }
83
    
84
    static ExitValue argument(const ExitArgument& argument)
85
    {
86
        ExitValue result;
87
        result.m_kind = ExitValueArgument;
88
        result.u.argument = argument.representation();
89
        return result;
90
    }
91
    
92
    ExitValueKind kind() const { return m_kind; }
93
    
94
    bool isDead() const { return kind() == ExitValueDead; }
95
    bool isInJSStack() const { return kind() == ExitValueInJSStack; }
96
    bool isConstant() const { return kind() == ExitValueConstant; }
97
    bool isArgument() const { return kind() == ExitValueArgument; }
98
    
99
    ExitArgument argument() const
100
    {
101
        ASSERT(isArgument());
102
        return ExitArgument(u.argument);
103
    }
104
    
105
    JSValue constant() const
106
    {
107
        ASSERT(isConstant());
108
        return JSValue::decode(u.constant);
109
    }
110
    
111
    void dump(PrintStream&) const;
112
    
113
private:
114
    ExitValueKind m_kind;
115
    union {
116
        ExitArgumentRepresentation argument;
117
        EncodedJSValue constant;
118
    } u;
119
};
120
121
} } // namespace JSC::FTL
122
123
#endif // ENABLE(FTL_JIT)
124
125
#endif // FTLExitValue_h
- Source/JavaScriptCore/ftl/FTLFormattedValue.h -12 / +1 lines
Lines 31-36 Source/JavaScriptCore/ftl/FTLFormattedValue.h_sec1
31
#if ENABLE(FTL_JIT)
31
#if ENABLE(FTL_JIT)
32
32
33
#include "FTLAbbreviations.h"
33
#include "FTLAbbreviations.h"
34
#include "FTLValueFormat.h"
34
35
35
namespace JSC { namespace FTL {
36
namespace JSC { namespace FTL {
36
37
Lines 41-58 namespace JSC { namespace FTL { Source/JavaScriptCore/ftl/FTLFormattedValue.h_sec2
41
// use this in situations where there is no good way to say what node the value came
42
// use this in situations where there is no good way to say what node the value came
42
// from.
43
// from.
43
44
44
// Note that this is awkwardly similar to DataFormat in other parts of JSC, except that
45
// unlike DataFormat and like ValueRecovery, it distinguishes between UInt32 and Int32.
46
47
enum ValueFormat {
48
    InvalidValueFormat,
49
    ValueFormatInt32,
50
    ValueFormatUInt32,
51
    ValueFormatBoolean,
52
    ValueFormatJSValue,
53
    ValueFormatDouble
54
};
55
56
class FormattedValue {
45
class FormattedValue {
57
public:
46
public:
58
    FormattedValue()
47
    FormattedValue()
- Source/JavaScriptCore/ftl/FTLOSRExit.h +78 lines
Line 0 Source/JavaScriptCore/ftl/FTLOSRExit.h_sec1
1
/*
2
 * Copyright (C) 2013 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24
 */
25
26
#ifndef FTLOSRExit_h
27
#define FTLOSRExit_h
28
29
#include <wtf/Platform.h>
30
31
#if ENABLE(FTL_JIT)
32
33
#include "CodeOrigin.h"
34
#include "DFGExitProfile.h"
35
#include "DFGOSRExitBase.h"
36
#include "FTLAbbreviations.h"
37
#include "FTLExitValue.h"
38
#include "MethodOfGettingAValueProfile.h"
39
#include "Operands.h"
40
#include "ValueProfile.h"
41
42
namespace JSC { namespace FTL {
43
44
struct OSRExit : public OSRExitBase {
45
    OSRExit(
46
        ExitKind, ValueFormat profileValueFormat, MethodOfGettingAValueProfile,
47
        CodeOrigin, int lastSetOperand);
48
    
49
    MacroAssemblerCodeRef m_code;
50
    
51
    // The first argument to the exit call may be a value we wish to profile.
52
    // If that's the case, the format will be not Invalid and we'll have a
53
    // method of getting a value profile.
54
    ValueFormat m_profileValueFormat;
55
    MethodOfGettingAValueProfile m_valueProfile;
56
    
57
    CodeOrigin m_codeOrigin;
58
    
59
    // Offset within the exit stubs of the stub for this exit.
60
    unsigned m_patchableCodeOffset;
61
    LValue m_exitStubAddress; // FIXME: Move this out of OSRExit, so it doesn't pollute CodeBlock.
62
    
63
    int m_lastSetOperand;
64
    
65
    Operands<ExitValue> m_values;
66
    
67
    void setPatchableCodeOffset(MacroAssembler::PatchableJump);
68
    CodeLocationJump codeLocationForRepatch(CodeBlock* ftlCodeBlock) const;
69
    
70
    void convertToForward(BasicBlock*, Node* currentNode, unsigned nodeIndex, const FormattedValue& value);
71
};
72
73
} } // namespace JSC::FTL
74
75
#endif // ENABLE(FTL_JIT)
76
77
#endif // FTLOSRExit_h
78
- Source/JavaScriptCore/ftl/FTLValueFormat.cpp +64 lines
Line 0 Source/JavaScriptCore/ftl/FTLValueFormat.cpp_sec1
1
/*
2
 * Copyright (C) 2013 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24
 */
25
26
#include "config.h"
27
#include "FTLValueFormat.h"
28
29
#if ENABLE(FTL_JIT)
30
31
namespace WTF {
32
33
using namespace JSC::FTL;
34
35
void printInternal(PrintStream& out, ValueFormat format)
36
{
37
    switch (format) {
38
    case InvalidValueFormat:
39
        out.print("Invalid");
40
        return;
41
    case ValueFormatInt32:
42
        out.print("Int32");
43
        return;
44
    case ValueFormatUInt32:
45
        out.print("UInt32");
46
        return;
47
    case ValueFormatBoolean:
48
        out.print("Boolean");
49
        return;
50
    case ValueFormatJSValue:
51
        out.print("JSValue");
52
        return;
53
    case ValueFormatDouble:
54
        out.print("Double");
55
        return;
56
    }
57
    
58
    RELEASE_ASSERT_NOT_REACHED();
59
}
60
61
} // namespace WTF
62
63
#endif // ENABLE(FTL_JIT)
64
- Source/JavaScriptCore/ftl/FTLValueFormat.h +60 lines
Line 0 Source/JavaScriptCore/ftl/FTLValueFormat.h_sec1
1
/*
2
 * Copyright (C) 2013 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24
 */
25
26
#ifndef FTLValueFormat_h
27
#define FTLValueFormat_h
28
29
#include <wtf/Platform.h>
30
31
#if ENABLE(FTL_JIT)
32
33
#include <wtf/PrintStream.h>
34
35
namespace JSC { namespace FTL {
36
37
// Note that this is awkwardly similar to DataFormat in other parts of JSC, except that
38
// unlike DataFormat and like ValueRecovery, it distinguishes between UInt32 and Int32.
39
40
enum ValueFormat {
41
    InvalidValueFormat,
42
    ValueFormatInt32,
43
    ValueFormatUInt32,
44
    ValueFormatBoolean,
45
    ValueFormatJSValue,
46
    ValueFormatDouble
47
};
48
49
} } // namespace JSC::FTL
50
51
namespace WTF {
52
53
void printInternal(PrintStream&, JSC::FTL::ValueFormat);
54
55
} // namespace WTF
56
57
#endif // ENABLE(FTL_JIT)
58
59
#endif // FTLValueFormat_h
60

Return to Bug 113623