- Source/JavaScriptCore/ChangeLog +21 lines
Lines 1-3 Source/JavaScriptCore/ChangeLog_sec1
1
2013-12-22  Mark Lam  <mark.lam@apple.com>
2
3
        CStack: Add #if ENABLE(LLINT_C_LOOP) to C loop LLINT only parts of JSStack.
4
        https://bugs.webkit.org/show_bug.cgi?id=126140.
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Also moved startOfFrameFor() to the ENABLE(DEBUG_JSSTACK) section because
9
        it's only needed there.
10
11
        * interpreter/JSStack.cpp:
12
        (JSC::JSStack::JSStack):
13
        (JSC::JSStack::gatherConservativeRoots):
14
        (JSC::JSStack::sanitizeStack):
15
        * interpreter/JSStack.h:
16
        (JSC::JSStack::gatherConservativeRoots):
17
        (JSC::JSStack::sanitizeStack):
18
        (JSC::JSStack::initializeThreading):
19
        * interpreter/JSStackInlines.h:
20
        (JSC::JSStack::topOfFrameFor):
21
1
2013-12-22  Mark Lam  <mark.lam@apple.com>
22
2013-12-22  Mark Lam  <mark.lam@apple.com>
2
23
3
        CStack: Fixed some JSStack on C Stack boundary computations.
24
        CStack: Fixed some JSStack on C Stack boundary computations.
- Source/JavaScriptCore/interpreter/JSStack.cpp -14 / +11 lines
Lines 35-40 Source/JavaScriptCore/interpreter/JSStack.cpp_sec1
35
35
36
namespace JSC {
36
namespace JSC {
37
37
38
#if ENABLE(LLINT_C_LOOP)
38
static size_t committedBytesCount = 0;
39
static size_t committedBytesCount = 0;
39
40
40
static Mutex& stackStatisticsMutex()
41
static Mutex& stackStatisticsMutex()
Lines 42-53 static Mutex& stackStatisticsMutex() Source/JavaScriptCore/interpreter/JSStack.cpp_sec2
42
    DEFINE_STATIC_LOCAL(Mutex, staticMutex, ());
43
    DEFINE_STATIC_LOCAL(Mutex, staticMutex, ());
43
    return staticMutex;
44
    return staticMutex;
44
}    
45
}    
46
#endif // ENABLE(LLINT_C_LOOP)
45
47
46
JSStack::JSStack(VM& vm, size_t capacity)
48
JSStack::JSStack(VM& vm)
47
    : m_vm(vm)
49
    : m_vm(vm)
48
    , m_end(0)
49
    , m_topCallFrame(vm.topCallFrame)
50
    , m_topCallFrame(vm.topCallFrame)
51
#if ENABLE(LLINT_C_LOOP)
52
    , m_end(0)
53
#endif
50
{
54
{
55
#if ENABLE(LLINT_C_LOOP)
56
    size_t capacity = defaultCapacity;
51
    ASSERT(capacity && isPageAligned(capacity));
57
    ASSERT(capacity && isPageAligned(capacity));
52
58
53
    m_reservation = PageReservation::reserve(roundUpAllocationSize(capacity * sizeof(Register), commitSize), OSAllocator::JSVMStackPages);
59
    m_reservation = PageReservation::reserve(roundUpAllocationSize(capacity * sizeof(Register), commitSize), OSAllocator::JSVMStackPages);
Lines 57-66 JSStack::JSStack(VM& vm, size_t capacity Source/JavaScriptCore/interpreter/JSStack.cpp_sec3
57
    m_lastStackTop = baseOfStack();
63
    m_lastStackTop = baseOfStack();
58
64
59
    disableErrorStackReserve();
65
    disableErrorStackReserve();
66
#endif // ENABLE(LLINT_C_LOOP)
60
67
61
    m_topCallFrame = 0;
68
    m_topCallFrame = 0;
62
}
69
}
63
70
71
#if ENABLE(LLINT_C_LOOP)
64
JSStack::~JSStack()
72
JSStack::~JSStack()
65
{
73
{
66
    void* highAddress = reinterpret_cast<void*>(static_cast<char*>(m_reservation.base()) + m_reservation.size());
74
    void* highAddress = reinterpret_cast<void*>(static_cast<char*>(m_reservation.base()) + m_reservation.size());
Lines 96-122 bool JSStack::growSlowCase(Register* new Source/JavaScriptCore/interpreter/JSStack.cpp_sec4
96
104
97
void JSStack::gatherConservativeRoots(ConservativeRoots& conservativeRoots)
105
void JSStack::gatherConservativeRoots(ConservativeRoots& conservativeRoots)
98
{
106
{
99
#if ENABLE(LLINT_CLOOP)
100
    conservativeRoots.add(baseOfStack(), topOfStack());
107
    conservativeRoots.add(baseOfStack(), topOfStack());
101
#else
102
    UNUSED_PARAM(conservativeRoots);
103
#endif
104
}
108
}
105
109
106
void JSStack::gatherConservativeRoots(ConservativeRoots& conservativeRoots, JITStubRoutineSet& jitStubRoutines, CodeBlockSet& codeBlocks)
110
void JSStack::gatherConservativeRoots(ConservativeRoots& conservativeRoots, JITStubRoutineSet& jitStubRoutines, CodeBlockSet& codeBlocks)
107
{
111
{
108
#if ENABLE(LLINT_CLOOP)
109
    conservativeRoots.add(baseOfStack(), topOfStack(), jitStubRoutines, codeBlocks);
112
    conservativeRoots.add(baseOfStack(), topOfStack(), jitStubRoutines, codeBlocks);
110
#else
111
    UNUSED_PARAM(conservativeRoots);
112
    UNUSED_PARAM(jitStubRoutines);
113
    UNUSED_PARAM(codeBlocks);
114
#endif
115
}
113
}
116
114
117
void JSStack::sanitizeStack()
115
void JSStack::sanitizeStack()
118
{
116
{
119
#if ENABLE(LLINT_CLOOP)
120
    ASSERT(topOfStack() <= baseOfStack());
117
    ASSERT(topOfStack() <= baseOfStack());
121
    
118
    
122
    if (m_lastStackTop < topOfStack()) {
119
    if (m_lastStackTop < topOfStack()) {
Lines 126-132 void JSStack::sanitizeStack() Source/JavaScriptCore/interpreter/JSStack.cpp_sec5
126
    }
123
    }
127
    
124
    
128
    m_lastStackTop = topOfStack();
125
    m_lastStackTop = topOfStack();
129
#endif
130
}
126
}
131
127
132
void JSStack::releaseExcessCapacity()
128
void JSStack::releaseExcessCapacity()
Lines 169-174 void JSStack::disableErrorStackReserve() Source/JavaScriptCore/interpreter/JSStack.cpp_sec6
169
        shrink(m_useableEnd);
165
        shrink(m_useableEnd);
170
    }
166
    }
171
}
167
}
168
#endif // ENABLE(LLINT_C_LOOP)
172
169
173
#if !ENABLE(LLINT_C_LOOP)
170
#if !ENABLE(LLINT_C_LOOP)
174
Register* JSStack::lowAddress() const
171
Register* JSStack::lowAddress() const
- Source/JavaScriptCore/interpreter/JSStack.h -5 / +18 lines
Lines 35-44 Source/JavaScriptCore/interpreter/JSStack.h_sec1
35
#include <wtf/PageReservation.h>
35
#include <wtf/PageReservation.h>
36
#include <wtf/VMTags.h>
36
#include <wtf/VMTags.h>
37
37
38
#if ENABLE(LLINT_C_LOOP)
38
#define ENABLE_DEBUG_JSSTACK 0
39
#define ENABLE_DEBUG_JSSTACK 0
39
#if !defined(NDEBUG) && !defined(ENABLE_DEBUG_JSSTACK)
40
#if !defined(NDEBUG) && !defined(ENABLE_DEBUG_JSSTACK)
40
#define ENABLE_DEBUG_JSSTACK 1
41
#define ENABLE_DEBUG_JSSTACK 1
41
#endif
42
#endif
43
#endif // ENABLE(LLINT_C_LOOP)
42
44
43
namespace JSC {
45
namespace JSC {
44
46
Lines 78-85 namespace JSC { Source/JavaScriptCore/interpreter/JSStack.h_sec2
78
        // Allow 8k of excess registers before we start trying to reap the stack
80
        // Allow 8k of excess registers before we start trying to reap the stack
79
        static const ptrdiff_t maxExcessCapacity = 8 * 1024;
81
        static const ptrdiff_t maxExcessCapacity = 8 * 1024;
80
82
81
        JSStack(VM&, size_t capacity = defaultCapacity);
83
        JSStack(VM&);
82
        ~JSStack();
83
        
84
        
84
        bool ensureCapacityFor(Register* newTopOfStack);
85
        bool ensureCapacityFor(Register* newTopOfStack);
85
86
Lines 88-93 namespace JSC { Source/JavaScriptCore/interpreter/JSStack.h_sec3
88
        bool containsAddress(Register* address) { return (lowAddress() <= address && address < highAddress()); }
89
        bool containsAddress(Register* address) { return (lowAddress() <= address && address < highAddress()); }
89
        static size_t committedByteCount();
90
        static size_t committedByteCount();
90
91
92
#if !ENABLE(LLINT_C_LOOP)
93
        void gatherConservativeRoots(ConservativeRoots&) { }
94
        void gatherConservativeRoots(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&) { }
95
        void sanitizeStack() { }
96
        static void initializeThreading() { }
97
#else
98
        ~JSStack();
99
91
        void gatherConservativeRoots(ConservativeRoots&);
100
        void gatherConservativeRoots(ConservativeRoots&);
92
        void gatherConservativeRoots(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&);
101
        void gatherConservativeRoots(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&);
93
        void sanitizeStack();
102
        void sanitizeStack();
Lines 101-108 namespace JSC { Source/JavaScriptCore/interpreter/JSStack.h_sec4
101
110
102
        static void initializeThreading();
111
        static void initializeThreading();
103
112
104
        Register* startOfFrameFor(CallFrame*);
105
106
        CallFrame* pushFrame(class CodeBlock*, JSScope*, int argsCount, JSObject* callee);
113
        CallFrame* pushFrame(class CodeBlock*, JSScope*, int argsCount, JSObject* callee);
107
114
108
        void popFrame(CallFrame*);
115
        void popFrame(CallFrame*);
Lines 115-120 namespace JSC { Source/JavaScriptCore/interpreter/JSStack.h_sec5
115
        void installFence(CallFrame*, const char* = "", int = 0) { }
122
        void installFence(CallFrame*, const char* = "", int = 0) { }
116
        void validateFence(CallFrame*, const char* = "", int = 0) { }
123
        void validateFence(CallFrame*, const char* = "", int = 0) { }
117
#endif // !ENABLE(DEBUG_JSSTACK)
124
#endif // !ENABLE(DEBUG_JSSTACK)
125
#endif // ENABLE(LLINT_C_LOOP)
118
126
119
    private:
127
    private:
120
128
Lines 137-142 namespace JSC { Source/JavaScriptCore/interpreter/JSStack.h_sec6
137
        Register* highAddress() const;
145
        Register* highAddress() const;
138
#endif // ENABLE(LLINT_C_LOOP)
146
#endif // ENABLE(LLINT_C_LOOP)
139
147
148
#if ENABLE(LLINT_C_LOOP)
140
        Register* reservationEnd() const
149
        Register* reservationEnd() const
141
        {
150
        {
142
            char* reservationEnd = static_cast<char*>(m_reservation.base());
151
            char* reservationEnd = static_cast<char*>(m_reservation.base());
Lines 146-151 namespace JSC { Source/JavaScriptCore/interpreter/JSStack.h_sec7
146
#if ENABLE(DEBUG_JSSTACK)
155
#if ENABLE(DEBUG_JSSTACK)
147
        static JSValue generateFenceValue(size_t argIndex);
156
        static JSValue generateFenceValue(size_t argIndex);
148
        void installTrapsAfterFrame(CallFrame*);
157
        void installTrapsAfterFrame(CallFrame*);
158
        Register* startOfFrameFor(CallFrame*);
149
#else
159
#else
150
        void installTrapsAfterFrame(CallFrame*) { }
160
        void installTrapsAfterFrame(CallFrame*) { }
151
#endif
161
#endif
Lines 157-173 namespace JSC { Source/JavaScriptCore/interpreter/JSStack.h_sec8
157
        void addToCommittedByteCount(long);
167
        void addToCommittedByteCount(long);
158
168
159
        void setStackLimit(Register* newEnd);
169
        void setStackLimit(Register* newEnd);
170
#endif // ENABLE(LLINT_C_LOOP)
160
171
161
        void enableErrorStackReserve();
172
        void enableErrorStackReserve();
162
        void disableErrorStackReserve();
173
        void disableErrorStackReserve();
163
174
164
        VM& m_vm;
175
        VM& m_vm;
176
        CallFrame*& m_topCallFrame;
177
#if ENABLE(LLINT_C_LOOP)
165
        Register* m_end;
178
        Register* m_end;
166
        Register* m_commitEnd;
179
        Register* m_commitEnd;
167
        Register* m_useableEnd;
180
        Register* m_useableEnd;
168
        PageReservation m_reservation;
181
        PageReservation m_reservation;
169
        CallFrame*& m_topCallFrame;
170
        Register* m_lastStackTop;
182
        Register* m_lastStackTop;
183
#endif // ENABLE(LLINT_C_LOOP)
171
184
172
        friend class LLIntOffsetsExtractor;
185
        friend class LLIntOffsetsExtractor;
173
    };
186
    };
- Source/JavaScriptCore/interpreter/JSStackInlines.h +7 lines
Lines 65-72 inline Register* JSStack::topOfStackForC Source/JavaScriptCore/interpreter/JSStackInlines.h_sec1
65
65
66
inline Register* JSStack::topOfFrameFor(CallFrame* frame)
66
inline Register* JSStack::topOfFrameFor(CallFrame* frame)
67
{
67
{
68
#if ENABLE(LLINT_C_LOOP)
68
    if (UNLIKELY(!frame))
69
    if (UNLIKELY(!frame))
69
        return baseOfStack();
70
        return baseOfStack();
71
#endif
70
    return frame->topOfFrame() - 1;
72
    return frame->topOfFrame() - 1;
71
}
73
}
72
74
Lines 75-85 inline Register* JSStack::topOfStack() Source/JavaScriptCore/interpreter/JSStackInlines.h_sec2
75
    return topOfFrameFor(m_topCallFrame);
77
    return topOfFrameFor(m_topCallFrame);
76
}
78
}
77
79
80
#if ENABLE(LLINT_C_LOOP)
81
82
#if ENABLE(DEBUG_JSSTACK)
78
inline Register* JSStack::startOfFrameFor(CallFrame* frame)
83
inline Register* JSStack::startOfFrameFor(CallFrame* frame)
79
{
84
{
80
    CallFrame* callerFrame = frame->callerFrameSkippingVMEntrySentinel();
85
    CallFrame* callerFrame = frame->callerFrameSkippingVMEntrySentinel();
81
    return topOfFrameFor(callerFrame);
86
    return topOfFrameFor(callerFrame);
82
}
87
}
88
#endif // ENABLE(DEBUG_JSSTACK)
83
89
84
inline CallFrame* JSStack::pushFrame(class CodeBlock* codeBlock, JSScope* scope, int argsCount, JSObject* callee)
90
inline CallFrame* JSStack::pushFrame(class CodeBlock* codeBlock, JSScope* scope, int argsCount, JSObject* callee)
85
{
91
{
Lines 291-296 inline void JSStack::installTrapsAfterFr Source/JavaScriptCore/interpreter/JSStackInlines.h_sec3
291
        *p-- = 0xabadcafe; // A bad word to trigger a crash if deref'ed.
297
        *p-- = 0xabadcafe; // A bad word to trigger a crash if deref'ed.
292
}
298
}
293
#endif // ENABLE(DEBUG_JSSTACK)
299
#endif // ENABLE(DEBUG_JSSTACK)
300
#endif // ENABLE(LLINT_C_LOOP)
294
301
295
} // namespace JSC
302
} // namespace JSC
296
303

Return to Bug 126140