| Differences between
and this patch
- Source/JavaScriptCore/ChangeLog +81 lines
Lines 1-3 Source/JavaScriptCore/ChangeLog_sec1
1
2014-06-27  Mark Lam  <mark.lam@apple.com>
2
3
        [ftlopt] DebuggerCallFrame::scope() should return a DebuggerScope.
4
        <https://webkit.org/b/134420>
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Previously, DebuggerCallFrame::scope() returns a JSActivation (and relevant
9
        peers) which the WebInspector will use to introspect CallFrame variables.
10
        Instead, we should be returning a DebuggerScope as an abstraction layer that
11
        provides the introspection functionality that the WebInspector needs.  This
12
        is the first step towards not forcing every frame to have a JSActivation
13
        object just because the debugger is enabled.
14
15
        1. Instantiate the debuggerScopeStructure as a member of the JSGlobalObject
16
           instead of the VM.  This allows JSObject::globalObject() to be able to
17
           return the global object for the DebuggerScope.
18
19
           Instead of initializing the debuggerScopeStructure unconditionally,
20
           I lazily initialize it only when a debugger is attached. 
21
22
        2. The DebuggerScope now takes care of instantiating the JSActivation object
23
           for the scope instead of explicitly doing it in DebuggerCallFrame::scope().
24
           This allows the DebuggerScope to hide how the inspector gets introspection
25
           information about scopes of CallFrames on the stack.
26
27
        * debugger/Debugger.cpp:
28
        (JSC::Debugger::attach):
29
        * debugger/Debugger.h:
30
        * debugger/DebuggerCallFrame.cpp:
31
        (JSC::DebuggerCallFrame::scope):
32
        (JSC::DebuggerCallFrame::evaluate):
33
        (JSC::DebuggerCallFrame::invalidate):
34
        (JSC::DebuggerCallFrame::vm):
35
        (JSC::DebuggerCallFrame::lexicalGlobalObject):
36
        * debugger/DebuggerCallFrame.h:
37
        * debugger/DebuggerScope.cpp:
38
        (JSC::DebuggerScope::DebuggerScope):
39
        (JSC::DebuggerScope::finishCreation):
40
        (JSC::DebuggerScope::visitChildren):
41
        (JSC::DebuggerScope::className):
42
        (JSC::DebuggerScope::getOwnPropertySlot):
43
        (JSC::DebuggerScope::put):
44
        (JSC::DebuggerScope::deleteProperty):
45
        (JSC::DebuggerScope::getOwnPropertyNames):
46
        (JSC::DebuggerScope::defineOwnProperty):
47
        (JSC::DebuggerScope::next):
48
        (JSC::DebuggerScope::invalidateChain):
49
        (JSC::DebuggerScope::isWithScope):
50
        (JSC::DebuggerScope::isGlobalScope):
51
        (JSC::DebuggerScope::isFunctionScope):
52
        (JSC::DebuggerScope::objectAtScope):
53
        * debugger/DebuggerScope.h:
54
        (JSC::DebuggerScope::create):
55
        (JSC::DebuggerScope::Iterator::Iterator):
56
        (JSC::DebuggerScope::Iterator::get):
57
        (JSC::DebuggerScope::Iterator::operator++):
58
        (JSC::DebuggerScope::Iterator::operator==):
59
        (JSC::DebuggerScope::Iterator::operator!=):
60
        (JSC::DebuggerScope::isValid):
61
        (JSC::DebuggerScope::toJSScope):
62
        (JSC::DebuggerScope::begin):
63
        (JSC::DebuggerScope::end):
64
        * inspector/JSJavaScriptCallFrame.cpp:
65
        (Inspector::JSJavaScriptCallFrame::scopeType):
66
        (Inspector::JSJavaScriptCallFrame::scopeChain):
67
        * inspector/JavaScriptCallFrame.h:
68
        (Inspector::JavaScriptCallFrame::scopeChain):
69
        * inspector/ScriptDebugServer.cpp:
70
        * runtime/JSGlobalObject.cpp:
71
        (JSC::JSGlobalObject::visitChildren):
72
        (JSC::JSGlobalObject::ensureDebuggerScopeStructureIsInitialized):
73
        * runtime/JSGlobalObject.h:
74
        (JSC::JSGlobalObject::debuggerScopeStructure):
75
        * runtime/JSObject.h:
76
        (JSC::JSObject::isWithScope):
77
        * runtime/JSScope.h:
78
        * runtime/VM.cpp:
79
        (JSC::VM::VM):
80
        * runtime/VM.h:
81
1
2014-06-27  Michael Saboff  <msaboff@apple.com>
82
2014-06-27  Michael Saboff  <msaboff@apple.com>
2
83
3
        Unreviewed build fix after r169795.
84
        Unreviewed build fix after r169795.
- Source/JavaScriptCore/debugger/Debugger.cpp +2 lines
Lines 179-184 void Debugger::attach(JSGlobalObject* gl Source/JavaScriptCore/debugger/Debugger.cpp_sec1
179
        ASSERT(m_vm == &globalObject->vm());
179
        ASSERT(m_vm == &globalObject->vm());
180
    globalObject->setDebugger(this);
180
    globalObject->setDebugger(this);
181
    m_globalObjects.add(globalObject);
181
    m_globalObjects.add(globalObject);
182
183
    globalObject->ensureDebuggerScopeStructureIsInitialized();
182
}
184
}
183
185
184
void Debugger::detach(JSGlobalObject* globalObject, ReasonForDetach reason)
186
void Debugger::detach(JSGlobalObject* globalObject, ReasonForDetach reason)
- Source/JavaScriptCore/debugger/Debugger.h +1 lines
Lines 34-39 Source/JavaScriptCore/debugger/Debugger.h_sec1
34
34
35
namespace JSC {
35
namespace JSC {
36
36
37
class CodeBlock;
37
class ExecState;
38
class ExecState;
38
class JSGlobalObject;
39
class JSGlobalObject;
39
class SourceProvider;
40
class SourceProvider;
- Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp -9 / +22 lines
Lines 30-41 Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp_sec1
30
#include "DebuggerCallFrame.h"
30
#include "DebuggerCallFrame.h"
31
31
32
#include "CodeBlock.h"
32
#include "CodeBlock.h"
33
#include "DebuggerScope.h"
33
#include "Interpreter.h"
34
#include "Interpreter.h"
34
#include "JSActivation.h"
35
#include "JSActivation.h"
35
#include "JSFunction.h"
36
#include "JSFunction.h"
36
#include "JSCInlines.h"
37
#include "JSCInlines.h"
37
#include "Parser.h"
38
#include "Parser.h"
38
#include "StackVisitor.h"
39
#include "StackVisitor.h"
40
#include "StrongInlines.h"
39
41
40
namespace JSC {
42
namespace JSC {
41
43
Lines 106-125 String DebuggerCallFrame::functionName() Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp_sec2
106
    return getCalculatedDisplayName(m_callFrame, function);
108
    return getCalculatedDisplayName(m_callFrame, function);
107
}
109
}
108
110
109
JSScope* DebuggerCallFrame::scope() const
111
DebuggerScope* DebuggerCallFrame::scope()
110
{
112
{
111
    ASSERT(isValid());
113
    ASSERT(isValid());
112
    if (!isValid())
114
    if (!isValid())
113
        return 0;
115
        return 0;
114
116
115
    CodeBlock* codeBlock = m_callFrame->codeBlock();
117
    if (!m_scope) {
116
    if (codeBlock && codeBlock->needsActivation() && !m_callFrame->hasActivation()) {
118
        VM& vm = m_callFrame->vm();
117
        JSActivation* activation = JSActivation::create(*codeBlock->vm(), m_callFrame, codeBlock);
119
        m_scope.set(vm, DebuggerScope::create(vm, this));
118
        m_callFrame->setActivation(activation);
119
        m_callFrame->setScope(activation);
120
    }
120
    }
121
121
    return m_scope.get();
122
    return m_callFrame->scope();
123
}
122
}
124
123
125
DebuggerCallFrame::Type DebuggerCallFrame::type() const
124
DebuggerCallFrame::Type DebuggerCallFrame::type() const
Lines 162-168 JSValue DebuggerCallFrame::evaluate(cons Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp_sec3
162
    }
161
    }
163
162
164
    JSValue thisValue = thisValueForCallFrame(callFrame);
163
    JSValue thisValue = thisValueForCallFrame(callFrame);
165
    JSValue result = vm.interpreter->execute(eval, callFrame, thisValue, scope());
164
    JSValue result = vm.interpreter->execute(eval, callFrame, thisValue, scope()->toJSScope());
166
    if (vm.exception()) {
165
    if (vm.exception()) {
167
        exception = vm.exception();
166
        exception = vm.exception();
168
        vm.clearException();
167
        vm.clearException();
Lines 174-179 JSValue DebuggerCallFrame::evaluate(cons Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp_sec4
174
void DebuggerCallFrame::invalidate()
173
void DebuggerCallFrame::invalidate()
175
{
174
{
176
    m_callFrame = nullptr;
175
    m_callFrame = nullptr;
176
    if (m_scope) {
177
        m_scope->invalidateChain();
178
        m_scope.clear();
179
    }
177
    RefPtr<DebuggerCallFrame> frame = m_caller.release();
180
    RefPtr<DebuggerCallFrame> frame = m_caller.release();
178
    while (frame) {
181
    while (frame) {
179
        frame->m_callFrame = nullptr;
182
        frame->m_callFrame = nullptr;
Lines 213-216 JSValue DebuggerCallFrame::thisValueForC Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp_sec5
213
    return thisValue;
216
    return thisValue;
214
}
217
}
215
218
219
VM& DebuggerCallFrame::vm() const
220
{
221
    return m_callFrame->vm();
222
}
223
224
JSGlobalObject* DebuggerCallFrame::lexicalGlobalObject() const
225
{
226
    return m_callFrame->lexicalGlobalObject();
227
}
228
216
} // namespace JSC
229
} // namespace JSC
- Source/JavaScriptCore/debugger/DebuggerCallFrame.h -2 / +12 lines
Lines 29-42 Source/JavaScriptCore/debugger/DebuggerCallFrame.h_sec1
29
#ifndef DebuggerCallFrame_h
29
#ifndef DebuggerCallFrame_h
30
#define DebuggerCallFrame_h
30
#define DebuggerCallFrame_h
31
31
32
#include "CallFrame.h"
33
#include "DebuggerPrimitives.h"
32
#include "DebuggerPrimitives.h"
33
#include "Strong.h"
34
#include <wtf/PassRefPtr.h>
34
#include <wtf/PassRefPtr.h>
35
#include <wtf/RefCounted.h>
35
#include <wtf/RefCounted.h>
36
#include <wtf/text/TextPosition.h>
36
#include <wtf/text/TextPosition.h>
37
37
38
namespace JSC {
38
namespace JSC {
39
39
40
class DebuggerScope;
41
class ExecState;
42
typedef ExecState CallFrame;
43
40
class DebuggerCallFrame : public RefCounted<DebuggerCallFrame> {
44
class DebuggerCallFrame : public RefCounted<DebuggerCallFrame> {
41
public:
45
public:
42
    enum Type { ProgramType, FunctionType };
46
    enum Type { ProgramType, FunctionType };
Lines 58-64 public: Source/JavaScriptCore/debugger/DebuggerCallFrame.h_sec2
58
    JS_EXPORT_PRIVATE const TextPosition& position() const { return m_position; }
62
    JS_EXPORT_PRIVATE const TextPosition& position() const { return m_position; }
59
63
60
    JS_EXPORT_PRIVATE JSGlobalObject* vmEntryGlobalObject() const;
64
    JS_EXPORT_PRIVATE JSGlobalObject* vmEntryGlobalObject() const;
61
    JS_EXPORT_PRIVATE JSScope* scope() const;
65
    JS_EXPORT_PRIVATE DebuggerScope* scope();
62
    JS_EXPORT_PRIVATE String functionName() const;
66
    JS_EXPORT_PRIVATE String functionName() const;
63
    JS_EXPORT_PRIVATE Type type() const;
67
    JS_EXPORT_PRIVATE Type type() const;
64
    JS_EXPORT_PRIVATE JSValue thisValue() const;
68
    JS_EXPORT_PRIVATE JSValue thisValue() const;
Lines 74-83 public: Source/JavaScriptCore/debugger/DebuggerCallFrame.h_sec3
74
    JS_EXPORT_PRIVATE static SourceID sourceIDForCallFrame(CallFrame*);
78
    JS_EXPORT_PRIVATE static SourceID sourceIDForCallFrame(CallFrame*);
75
    static JSValue thisValueForCallFrame(CallFrame*);
79
    static JSValue thisValueForCallFrame(CallFrame*);
76
80
81
    VM& vm() const;
82
    JSGlobalObject* lexicalGlobalObject() const;
83
77
private:
84
private:
78
    CallFrame* m_callFrame;
85
    CallFrame* m_callFrame;
79
    RefPtr<DebuggerCallFrame> m_caller;
86
    RefPtr<DebuggerCallFrame> m_caller;
80
    TextPosition m_position;
87
    TextPosition m_position;
88
    Strong<DebuggerScope> m_scope;
89
90
    friend class DebuggerScope;
81
};
91
};
82
92
83
} // namespace JSC
93
} // namespace JSC
- Source/JavaScriptCore/debugger/DebuggerScope.cpp -19 / +94 lines
Lines 26-33 Source/JavaScriptCore/debugger/DebuggerScope.cpp_sec1
26
#include "config.h"
26
#include "config.h"
27
#include "DebuggerScope.h"
27
#include "DebuggerScope.h"
28
28
29
#include "DebuggerCallFrame.h"
29
#include "JSActivation.h"
30
#include "JSActivation.h"
30
#include "JSCInlines.h"
31
#include "JSCInlines.h"
32
#include "JSWithScope.h"
31
33
32
namespace JSC {
34
namespace JSC {
33
35
Lines 35-51 STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE( Source/JavaScriptCore/debugger/DebuggerScope.cpp_sec2
35
37
36
const ClassInfo DebuggerScope::s_info = { "DebuggerScope", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(DebuggerScope) };
38
const ClassInfo DebuggerScope::s_info = { "DebuggerScope", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(DebuggerScope) };
37
39
38
DebuggerScope::DebuggerScope(VM& vm)
40
DebuggerScope::DebuggerScope(VM& vm, DebuggerCallFrame* callFrame)
39
    : JSNonFinalObject(vm, vm.debuggerScopeStructure.get())
41
    : JSNonFinalObject(vm, callFrame->lexicalGlobalObject()->debuggerScopeStructure())
42
    , m_debuggerCallFrame(callFrame)
40
{
43
{
44
    ASSERT(callFrame->isValid());
41
}
45
}
42
46
43
void DebuggerScope::finishCreation(VM& vm, JSObject* activation)
47
void DebuggerScope::finishCreation(VM& vm, JSScope* scope)
44
{
48
{
45
    Base::finishCreation(vm);
49
    Base::finishCreation(vm);
46
    ASSERT(activation);
50
47
    ASSERT(activation->isActivationObject());
51
    if (!scope) {
48
    m_activation.set(vm, this, jsCast<JSActivation*>(activation));
52
        CallFrame* callFrame = m_debuggerCallFrame->m_callFrame;
53
        CodeBlock* codeBlock = callFrame->codeBlock();
54
        if (codeBlock && codeBlock->needsActivation() && !callFrame->hasActivation()) {
55
            ASSERT(!callFrame->scope()->isWithScope());
56
            JSActivation* activation = JSActivation::create(vm, callFrame, codeBlock);
57
            callFrame->setActivation(activation);
58
            callFrame->setScope(activation);
59
        }
60
        scope = callFrame->scope();
61
    }
62
63
    ASSERT(scope);
64
    m_scope.set(vm, this, scope);
49
}
65
}
50
66
51
void DebuggerScope::visitChildren(JSCell* cell, SlotVisitor& visitor)
67
void DebuggerScope::visitChildren(JSCell* cell, SlotVisitor& visitor)
Lines 56-98 void DebuggerScope::visitChildren(JSCell Source/JavaScriptCore/debugger/DebuggerScope.cpp_sec3
56
    ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
72
    ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
57
73
58
    JSObject::visitChildren(thisObject, visitor);
74
    JSObject::visitChildren(thisObject, visitor);
59
    visitor.append(&thisObject->m_activation);
75
    visitor.append(&thisObject->m_scope);
76
    visitor.append(&thisObject->m_next);
60
}
77
}
61
78
62
String DebuggerScope::className(const JSObject* object)
79
String DebuggerScope::className(const JSObject* object)
63
{
80
{
64
    const DebuggerScope* thisObject = jsCast<const DebuggerScope*>(object);
81
    const DebuggerScope* scope = jsCast<const DebuggerScope*>(object);
65
    return thisObject->m_activation->methodTable()->className(thisObject->m_activation.get());
82
    ASSERT(scope->isValid());
83
    JSObject* thisObject = scope->objectAtScope();
84
    return thisObject->methodTable()->className(thisObject);
66
}
85
}
67
86
68
bool DebuggerScope::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
87
bool DebuggerScope::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
69
{
88
{
70
    DebuggerScope* thisObject = jsCast<DebuggerScope*>(object);
89
    DebuggerScope* scope = jsCast<DebuggerScope*>(object);
71
    return thisObject->m_activation->methodTable()->getOwnPropertySlot(thisObject->m_activation.get(), exec, propertyName, slot);
90
    ASSERT(scope->isValid());
91
    JSObject* thisObject = scope->objectAtScope();
92
    return thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, propertyName, slot);
72
}
93
}
73
94
74
void DebuggerScope::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
95
void DebuggerScope::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
75
{
96
{
76
    DebuggerScope* thisObject = jsCast<DebuggerScope*>(cell);
97
    DebuggerScope* scope = jsCast<DebuggerScope*>(cell);
77
    thisObject->m_activation->methodTable()->put(thisObject->m_activation.get(), exec, propertyName, value, slot);
98
    ASSERT(scope->isValid());
99
    JSObject* thisObject = scope->objectAtScope();
100
    thisObject->methodTable()->put(thisObject, exec, propertyName, value, slot);
78
}
101
}
79
102
80
bool DebuggerScope::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName)
103
bool DebuggerScope::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName)
81
{
104
{
82
    DebuggerScope* thisObject = jsCast<DebuggerScope*>(cell);
105
    DebuggerScope* scope = jsCast<DebuggerScope*>(cell);
83
    return thisObject->m_activation->methodTable()->deleteProperty(thisObject->m_activation.get(), exec, propertyName);
106
    ASSERT(scope->isValid());
107
    JSObject* thisObject = scope->objectAtScope();
108
    return thisObject->methodTable()->deleteProperty(thisObject, exec, propertyName);
84
}
109
}
85
110
86
void DebuggerScope::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
111
void DebuggerScope::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
87
{
112
{
88
    DebuggerScope* thisObject = jsCast<DebuggerScope*>(object);
113
    DebuggerScope* scope = jsCast<DebuggerScope*>(object);
89
    thisObject->m_activation->methodTable()->getPropertyNames(thisObject->m_activation.get(), exec, propertyNames, mode);
114
    ASSERT(scope->isValid());
115
    JSObject* thisObject = scope->objectAtScope();
116
    thisObject->methodTable()->getPropertyNames(thisObject, exec, propertyNames, mode);
90
}
117
}
91
118
92
bool DebuggerScope::defineOwnProperty(JSObject* object, ExecState* exec, PropertyName propertyName, const PropertyDescriptor& descriptor, bool shouldThrow)
119
bool DebuggerScope::defineOwnProperty(JSObject* object, ExecState* exec, PropertyName propertyName, const PropertyDescriptor& descriptor, bool shouldThrow)
93
{
120
{
94
    DebuggerScope* thisObject = jsCast<DebuggerScope*>(object);
121
    DebuggerScope* scope = jsCast<DebuggerScope*>(object);
95
    return thisObject->m_activation->methodTable()->defineOwnProperty(thisObject->m_activation.get(), exec, propertyName, descriptor, shouldThrow);
122
    ASSERT(scope->isValid());
123
    JSObject* thisObject = scope->objectAtScope();
124
    return thisObject->methodTable()->defineOwnProperty(thisObject, exec, propertyName, descriptor, shouldThrow);
125
}
126
127
DebuggerScope* DebuggerScope::next()
128
{
129
    ASSERT(isValid());
130
    if (!m_next && m_scope->next()) {
131
        VM& vm = *m_scope->vm();
132
        DebuggerScope* nextScope = create(vm, m_debuggerCallFrame, m_scope->next());
133
        m_next.set(vm, this, nextScope);
134
    }
135
    return m_next.get();
136
}
137
138
void DebuggerScope::invalidateChain()
139
{
140
    DebuggerScope* scope = this;
141
    while (scope) {
142
        ASSERT(scope->isValid());
143
        DebuggerScope* nextScope = scope->m_next.get();
144
        scope->m_next.clear();
145
        scope->m_scope.clear();
146
        scope = nextScope;
147
    }
148
}
149
150
bool DebuggerScope::isWithScope() const
151
{
152
    return m_scope->isWithScope();
153
}
154
155
bool DebuggerScope::isGlobalScope() const
156
{
157
    return m_scope->isGlobalObject();
158
}
159
160
bool DebuggerScope::isFunctionScope() const
161
{
162
    // In the current debugger implementation, every function will create an
163
    // activation object. Hence, an activation object implies a function scope.
164
    return m_scope->isActivationObject();
165
}
166
167
JSObject* DebuggerScope::objectAtScope() const
168
{
169
    ASSERT(isValid());
170
    return JSScope::objectAtScope(m_scope.get());
96
}
171
}
97
172
98
} // namespace JSC
173
} // namespace JSC
- Source/JavaScriptCore/debugger/DebuggerScope.h -9 / +57 lines
Lines 26-44 Source/JavaScriptCore/debugger/DebuggerScope.h_sec1
26
#ifndef DebuggerScope_h
26
#ifndef DebuggerScope_h
27
#define DebuggerScope_h
27
#define DebuggerScope_h
28
28
29
#include "DebuggerCallFrame.h"
29
#include "JSObject.h"
30
#include "JSObject.h"
30
31
31
namespace JSC {
32
namespace JSC {
32
33
34
class JSScope;
35
33
class DebuggerScope : public JSNonFinalObject {
36
class DebuggerScope : public JSNonFinalObject {
34
public:
37
public:
35
    typedef JSNonFinalObject Base;
38
    typedef JSNonFinalObject Base;
36
39
37
    static DebuggerScope* create(VM& vm, JSObject* object)
40
    static DebuggerScope* create(VM& vm, DebuggerCallFrame* callFrame, JSScope* scope = 0)
38
    {
41
    {
39
        DebuggerScope* activation = new (NotNull, allocateCell<DebuggerScope>(vm.heap)) DebuggerScope(vm);
42
        DebuggerScope* debuggerScope = new (NotNull, allocateCell<DebuggerScope>(vm.heap)) DebuggerScope(vm, callFrame);
40
        activation->finishCreation(vm, object);
43
        debuggerScope->finishCreation(vm, scope);
41
        return activation;
44
        return debuggerScope;
42
    }
45
    }
43
46
44
    static void visitChildren(JSCell*, SlotVisitor&);
47
    static void visitChildren(JSCell*, SlotVisitor&);
Lines 56-71 public: Source/JavaScriptCore/debugger/DebuggerScope.h_sec2
56
        return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info()); 
59
        return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info()); 
57
    }
60
    }
58
61
59
protected:
62
    class Iterator {
63
    public:
64
        Iterator(DebuggerScope* node)
65
            : m_node(node)
66
        {
67
        }
68
69
        DebuggerScope* get() { return m_node; }
70
        Iterator& operator++() { m_node = m_node->next(); return *this; }
71
        // postfix ++ intentionally omitted
72
73
        bool operator==(const Iterator& other) const { return m_node == other.m_node; }
74
        bool operator!=(const Iterator& other) const { return m_node != other.m_node; }
75
76
    private:
77
        DebuggerScope* m_node;
78
    };
79
80
    Iterator begin();
81
    Iterator end();
82
    DebuggerScope* next();
83
84
    void invalidateChain();
85
    bool isValid() const { return !!m_scope; }
86
87
    bool isWithScope() const;
88
    bool isGlobalScope() const;
89
    bool isFunctionScope() const;
90
91
private:
92
    JS_EXPORT_PRIVATE DebuggerScope(VM&, DebuggerCallFrame*);
93
    JS_EXPORT_PRIVATE void finishCreation(VM&, JSScope*);
94
95
    JSScope* toJSScope() { return m_scope.get(); }
96
    JSObject* objectAtScope() const;
97
60
    static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesVisitChildren | JSObject::StructureFlags;
98
    static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesVisitChildren | JSObject::StructureFlags;
61
99
62
    JS_EXPORT_PRIVATE void finishCreation(VM&, JSObject* activation);
100
    DebuggerCallFrame* m_debuggerCallFrame;
101
    WriteBarrier<JSScope> m_scope;
102
    WriteBarrier<DebuggerScope> m_next;
63
103
64
private:
104
    friend class DebuggerCallFrame;
65
    JS_EXPORT_PRIVATE DebuggerScope(VM&);
66
    WriteBarrier<JSActivation> m_activation;
67
};
105
};
68
106
107
inline DebuggerScope::Iterator DebuggerScope::begin()
108
{
109
    return Iterator(this); 
110
}
111
112
inline DebuggerScope::Iterator DebuggerScope::end()
113
{ 
114
    return Iterator(0); 
115
}
116
69
} // namespace JSC
117
} // namespace JSC
70
118
71
#endif // DebuggerScope_h
119
#endif // DebuggerScope_h
- Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp -20 / +22 lines
Lines 28-33 Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp_sec1
28
28
29
#if ENABLE(INSPECTOR)
29
#if ENABLE(INSPECTOR)
30
30
31
#include "DebuggerScope.h"
31
#include "Error.h"
32
#include "Error.h"
32
#include "JSCJSValue.h"
33
#include "JSCJSValue.h"
33
#include "JSCellInlines.h"
34
#include "JSCellInlines.h"
Lines 95-123 JSValue JSJavaScriptCallFrame::scopeType Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp_sec2
95
        return jsUndefined();
96
        return jsUndefined();
96
    int index = exec->argument(0).asInt32();
97
    int index = exec->argument(0).asInt32();
97
98
98
    JSScope* scopeChain = impl().scopeChain();
99
    DebuggerScope* scopeChain = impl().scopeChain();
99
    ScopeChainIterator end = scopeChain->end();
100
    DebuggerScope::Iterator end = scopeChain->end();
100
101
    // FIXME: We should be identifying and returning CATCH_SCOPE appropriately.
102
101
103
    bool foundLocalScope = false;
102
    bool foundLocalScope = false;
104
    for (ScopeChainIterator iter = scopeChain->begin(); iter != end; ++iter) {
103
    for (DebuggerScope::Iterator iter = scopeChain->begin(); iter != end; ++iter) {
105
        JSObject* scope = iter.get();
104
        DebuggerScope* scope = iter.get();
106
        if (scope->isActivationObject()) {
105
107
            if (!foundLocalScope) {
106
        if (!foundLocalScope && scope->isFunctionScope()) {
108
                // First activation object is local scope, each successive activation object is closure.
107
            // First function scope is the local scope, each successive one is a closure.
109
                if (!index)
108
            if (!index)
110
                    return jsNumber(JSJavaScriptCallFrame::LOCAL_SCOPE);
109
                return jsNumber(JSJavaScriptCallFrame::LOCAL_SCOPE);
111
                foundLocalScope = true;
110
            foundLocalScope = true;
112
            } else if (!index)
113
                return jsNumber(JSJavaScriptCallFrame::CLOSURE_SCOPE);
114
        }
111
        }
115
112
116
        if (!index) {
113
        if (!index) {
117
            // Last in the chain is global scope.
114
            if (scope->isWithScope())
118
            if (++iter == end)
115
                return jsNumber(JSJavaScriptCallFrame::WITH_SCOPE);
116
            if (scope->isGlobalScope()) {
117
                ASSERT(++iter == end);
119
                return jsNumber(JSJavaScriptCallFrame::GLOBAL_SCOPE);
118
                return jsNumber(JSJavaScriptCallFrame::GLOBAL_SCOPE);
120
            return jsNumber(JSJavaScriptCallFrame::WITH_SCOPE);
119
            }
120
            // FIXME: We should be identifying and returning CATCH_SCOPE appropriately.
121
            ASSERT(scope->isFunctionScope());
122
            return jsNumber(JSJavaScriptCallFrame::CLOSURE_SCOPE);
121
        }
123
        }
122
124
123
        --index;
125
        --index;
Lines 157-165 JSValue JSJavaScriptCallFrame::scopeChai Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp_sec3
157
    if (!impl().scopeChain())
159
    if (!impl().scopeChain())
158
        return jsNull();
160
        return jsNull();
159
161
160
    JSScope* scopeChain = impl().scopeChain();
162
    DebuggerScope* scopeChain = impl().scopeChain();
161
    ScopeChainIterator iter = scopeChain->begin();
163
    DebuggerScope::Iterator iter = scopeChain->begin();
162
    ScopeChainIterator end = scopeChain->end();
164
    DebuggerScope::Iterator end = scopeChain->end();
163
165
164
    // We must always have something in the scope chain.
166
    // We must always have something in the scope chain.
165
    ASSERT(iter != end);
167
    ASSERT(iter != end);
- Source/JavaScriptCore/inspector/JavaScriptCallFrame.h -2 / +2 lines
Lines 1-5 Source/JavaScriptCore/inspector/JavaScriptCallFrame.h_sec1
1
/*
1
/*
2
 * Copyright (C) 2008, 2013 Apple Inc. All Rights Reserved.
2
 * Copyright (C) 2008, 2013-2014 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 53-59 public: Source/JavaScriptCore/inspector/JavaScriptCallFrame.h_sec2
53
53
54
    String functionName() const { return m_debuggerCallFrame->functionName(); }
54
    String functionName() const { return m_debuggerCallFrame->functionName(); }
55
    JSC::DebuggerCallFrame::Type type() const { return m_debuggerCallFrame->type(); }
55
    JSC::DebuggerCallFrame::Type type() const { return m_debuggerCallFrame->type(); }
56
    JSC::JSScope* scopeChain() const { return m_debuggerCallFrame->scope(); }
56
    JSC::DebuggerScope* scopeChain() const { return m_debuggerCallFrame->scope(); }
57
    JSC::JSGlobalObject* vmEntryGlobalObject() const { return m_debuggerCallFrame->vmEntryGlobalObject(); }
57
    JSC::JSGlobalObject* vmEntryGlobalObject() const { return m_debuggerCallFrame->vmEntryGlobalObject(); }
58
58
59
    JSC::JSValue thisValue() const { return m_debuggerCallFrame->thisValue(); }
59
    JSC::JSValue thisValue() const { return m_debuggerCallFrame->thisValue(); }
- Source/JavaScriptCore/inspector/ScriptDebugServer.cpp +1 lines
Lines 34-39 Source/JavaScriptCore/inspector/ScriptDebugServer.cpp_sec1
34
#if ENABLE(INSPECTOR)
34
#if ENABLE(INSPECTOR)
35
35
36
#include "DebuggerCallFrame.h"
36
#include "DebuggerCallFrame.h"
37
#include "DebuggerScope.h"
37
#include "JSJavaScriptCallFrame.h"
38
#include "JSJavaScriptCallFrame.h"
38
#include "JSLock.h"
39
#include "JSLock.h"
39
#include "JavaScriptCallFrame.h"
40
#include "JavaScriptCallFrame.h"
- Source/JavaScriptCore/runtime/JSGlobalObject.cpp +8 lines
Lines 45-50 Source/JavaScriptCore/runtime/JSGlobalObject.cpp_sec1
45
#include "DateConstructor.h"
45
#include "DateConstructor.h"
46
#include "DatePrototype.h"
46
#include "DatePrototype.h"
47
#include "Debugger.h"
47
#include "Debugger.h"
48
#include "DebuggerScope.h"
48
#include "Error.h"
49
#include "Error.h"
49
#include "ErrorConstructor.h"
50
#include "ErrorConstructor.h"
50
#include "ErrorPrototype.h"
51
#include "ErrorPrototype.h"
Lines 661-666 void JSGlobalObject::visitChildren(JSCel Source/JavaScriptCore/runtime/JSGlobalObject.cpp_sec2
661
    visitor.append(&thisObject->m_promisePrototype);
662
    visitor.append(&thisObject->m_promisePrototype);
662
#endif
663
#endif
663
664
665
    visitor.append(&thisObject->m_debuggerScopeStructure);
664
    visitor.append(&thisObject->m_withScopeStructure);
666
    visitor.append(&thisObject->m_withScopeStructure);
665
    visitor.append(&thisObject->m_strictEvalActivationStructure);
667
    visitor.append(&thisObject->m_strictEvalActivationStructure);
666
    visitor.append(&thisObject->m_activationStructure);
668
    visitor.append(&thisObject->m_activationStructure);
Lines 844-847 void JSGlobalObject::queueMicrotask(Pass Source/JavaScriptCore/runtime/JSGlobalObject.cpp_sec3
844
        WTFLogAlways("ERROR: Event loop not supported.");
846
        WTFLogAlways("ERROR: Event loop not supported.");
845
}
847
}
846
848
849
void JSGlobalObject::ensureDebuggerScopeStructureIsInitialized()
850
{
851
    if (!m_debuggerScopeStructure)
852
        m_debuggerScopeStructure.set(m_vm, this, DebuggerScope::createStructure(m_vm, this, jsNull()));
853
}
854
847
} // namespace JSC
855
} // namespace JSC
- Source/JavaScriptCore/runtime/JSGlobalObject.h +4 lines
Lines 183-188 protected: Source/JavaScriptCore/runtime/JSGlobalObject.h_sec1
183
    WriteBarrier<JSPromisePrototype> m_promisePrototype;
183
    WriteBarrier<JSPromisePrototype> m_promisePrototype;
184
#endif
184
#endif
185
185
186
    WriteBarrier<Structure> m_debuggerScopeStructure;
186
    WriteBarrier<Structure> m_withScopeStructure;
187
    WriteBarrier<Structure> m_withScopeStructure;
187
    WriteBarrier<Structure> m_strictEvalActivationStructure;
188
    WriteBarrier<Structure> m_strictEvalActivationStructure;
188
    WriteBarrier<Structure> m_activationStructure;
189
    WriteBarrier<Structure> m_activationStructure;
Lines 388-393 public: Source/JavaScriptCore/runtime/JSGlobalObject.h_sec2
388
    JSPromisePrototype* promisePrototype() const { return m_promisePrototype.get(); }
389
    JSPromisePrototype* promisePrototype() const { return m_promisePrototype.get(); }
389
#endif
390
#endif
390
391
392
    void ensureDebuggerScopeStructureIsInitialized();
393
    Structure* debuggerScopeStructure() const { return m_debuggerScopeStructure.get(); }
394
391
    Structure* withScopeStructure() const { return m_withScopeStructure.get(); }
395
    Structure* withScopeStructure() const { return m_withScopeStructure.get(); }
392
    Structure* strictEvalActivationStructure() const { return m_strictEvalActivationStructure.get(); }
396
    Structure* strictEvalActivationStructure() const { return m_strictEvalActivationStructure.get(); }
393
    Structure* activationStructure() const { return m_activationStructure.get(); }
397
    Structure* activationStructure() const { return m_activationStructure.get(); }
- Source/JavaScriptCore/runtime/JSObject.h +6 lines
Lines 599-604 public: Source/JavaScriptCore/runtime/JSObject.h_sec1
599
    bool isNameScopeObject() const;
599
    bool isNameScopeObject() const;
600
    bool isActivationObject() const;
600
    bool isActivationObject() const;
601
    bool isErrorInstance() const;
601
    bool isErrorInstance() const;
602
    bool isWithScope() const;
602
603
603
    JS_EXPORT_PRIVATE void seal(VM&);
604
    JS_EXPORT_PRIVATE void seal(VM&);
604
    JS_EXPORT_PRIVATE void freeze(VM&);
605
    JS_EXPORT_PRIVATE void freeze(VM&);
Lines 1147-1152 inline bool JSObject::isErrorInstance() Source/JavaScriptCore/runtime/JSObject.h_sec2
1147
    return type() == ErrorInstanceType;
1148
    return type() == ErrorInstanceType;
1148
}
1149
}
1149
1150
1151
inline bool JSObject::isWithScope() const
1152
{
1153
    return type() == WithScopeType;
1154
}
1155
1150
inline void JSObject::setStructureAndButterfly(VM& vm, Structure* structure, Butterfly* butterfly)
1156
inline void JSObject::setStructureAndButterfly(VM& vm, Structure* structure, Butterfly* butterfly)
1151
{
1157
{
1152
    ASSERT(structure);
1158
    ASSERT(structure);
- Source/JavaScriptCore/runtime/JSScope.h -1 / +1 lines
Lines 150-156 public: Source/JavaScriptCore/runtime/JSScope.h_sec1
150
    friend class LLIntOffsetsExtractor;
150
    friend class LLIntOffsetsExtractor;
151
    static size_t offsetOfNext();
151
    static size_t offsetOfNext();
152
152
153
    JS_EXPORT_PRIVATE static JSObject* objectAtScope(JSScope*);
153
    static JSObject* objectAtScope(JSScope*);
154
154
155
    static JSValue resolve(ExecState*, JSScope*, const Identifier&);
155
    static JSValue resolve(ExecState*, JSScope*, const Identifier&);
156
    static ResolveOp abstractResolve(ExecState*, JSScope*, const Identifier&, GetOrPut, ResolveType);
156
    static ResolveOp abstractResolve(ExecState*, JSScope*, const Identifier&, GetOrPut, ResolveType);
- Source/JavaScriptCore/runtime/VM.cpp -2 lines
Lines 39-45 Source/JavaScriptCore/runtime/VM.cpp_sec1
39
#include "CommonSlowPaths.h"
39
#include "CommonSlowPaths.h"
40
#include "DFGLongLivedState.h"
40
#include "DFGLongLivedState.h"
41
#include "DFGWorklist.h"
41
#include "DFGWorklist.h"
42
#include "DebuggerScope.h"
43
#include "ErrorInstance.h"
42
#include "ErrorInstance.h"
44
#include "FTLThunks.h"
43
#include "FTLThunks.h"
45
#include "FunctionConstructor.h"
44
#include "FunctionConstructor.h"
Lines 255-261 VM::VM(VMType vmType, HeapType heapType) Source/JavaScriptCore/runtime/VM.cpp_sec2
255
    propertyNames = new CommonIdentifiers(this);
254
    propertyNames = new CommonIdentifiers(this);
256
    structureStructure.set(*this, Structure::createStructure(*this));
255
    structureStructure.set(*this, Structure::createStructure(*this));
257
    structureRareDataStructure.set(*this, StructureRareData::createStructure(*this, 0, jsNull()));
256
    structureRareDataStructure.set(*this, StructureRareData::createStructure(*this, 0, jsNull()));
258
    debuggerScopeStructure.set(*this, DebuggerScope::createStructure(*this, 0, jsNull()));
259
    terminatedExecutionErrorStructure.set(*this, TerminatedExecutionError::createStructure(*this, 0, jsNull()));
257
    terminatedExecutionErrorStructure.set(*this, TerminatedExecutionError::createStructure(*this, 0, jsNull()));
260
    stringStructure.set(*this, JSString::createStructure(*this, 0, jsNull()));
258
    stringStructure.set(*this, JSString::createStructure(*this, 0, jsNull()));
261
    notAnObjectStructure.set(*this, JSNotAnObject::createStructure(*this, 0, jsNull()));
259
    notAnObjectStructure.set(*this, JSNotAnObject::createStructure(*this, 0, jsNull()));
- Source/JavaScriptCore/runtime/VM.h -1 lines
Lines 262-268 namespace JSC { Source/JavaScriptCore/runtime/VM.h_sec1
262
262
263
        Strong<Structure> structureStructure;
263
        Strong<Structure> structureStructure;
264
        Strong<Structure> structureRareDataStructure;
264
        Strong<Structure> structureRareDataStructure;
265
        Strong<Structure> debuggerScopeStructure;
266
        Strong<Structure> terminatedExecutionErrorStructure;
265
        Strong<Structure> terminatedExecutionErrorStructure;
267
        Strong<Structure> stringStructure;
266
        Strong<Structure> stringStructure;
268
        Strong<Structure> notAnObjectStructure;
267
        Strong<Structure> notAnObjectStructure;
- Source/WebCore/ChangeLog +15 lines
Lines 1-3 Source/WebCore/ChangeLog_sec1
1
2014-06-27  Mark Lam  <mark.lam@apple.com>
2
3
        [ftlopt] DebuggerCallFrame::scope() should return a DebuggerScope.
4
        <https://webkit.org/b/134420>
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        No new tests.
9
10
        * ForwardingHeaders/debugger/DebuggerCallFrame.h: Removed.
11
        - This is not in use.  Hence, we can remove it.
12
        * bindings/js/ScriptController.cpp:
13
        (WebCore::ScriptController::attachDebugger):
14
        - We should acquire the JSLock before modifying a JS global object.
15
1
2014-06-24  Mark Lam  <mark.lam@apple.com>
16
2014-06-24  Mark Lam  <mark.lam@apple.com>
2
17
3
        [ftlopt] Renamed DebuggerActivation to DebuggerScope.
18
        [ftlopt] Renamed DebuggerActivation to DebuggerScope.
- Source/WebCore/ForwardingHeaders/debugger/DebuggerCallFrame.h -4 lines
Lines 1-4 Source/WebCore/ForwardingHeaders/debugger/DebuggerCallFrame.h_sec1
1
#ifndef WebCore_FWD_DebuggerCallFrame_h
2
#define WebCore_FWD_DebuggerCallFrame_h
3
#include <JavaScriptCore/DebuggerCallFrame.h>
4
#endif
- Source/WebCore/bindings/js/ScriptController.cpp +1 lines
Lines 295-300 void ScriptController::attachDebugger(JS Source/WebCore/bindings/js/ScriptController.cpp_sec1
295
        return;
295
        return;
296
296
297
    JSDOMWindow* globalObject = shell->window();
297
    JSDOMWindow* globalObject = shell->window();
298
    JSLockHolder lock(globalObject->vm());
298
    if (debugger)
299
    if (debugger)
299
        debugger->attach(globalObject);
300
        debugger->attach(globalObject);
300
    else if (JSC::Debugger* currentDebugger = globalObject->debugger())
301
    else if (JSC::Debugger* currentDebugger = globalObject->debugger())

Return to Bug 134420