Changeset 194251 in webkit
- Timestamp:
- Dec 17, 2015, 5:09:13 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 21 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/inspector/debugger/breakpoint-scope-expected.txt (modified) (1 diff)
-
LayoutTests/inspector/model/resources (added)
-
LayoutTests/inspector/model/resources/all-scopes.js (added)
-
LayoutTests/inspector/model/resources/block-scopes.js (added)
-
LayoutTests/inspector/model/resources/function-name-scopes.js (added)
-
LayoutTests/inspector/model/scope-chain-node-expected.txt (added)
-
LayoutTests/inspector/model/scope-chain-node.html (added)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp (modified) (6 diffs)
-
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h (modified) (2 diffs)
-
Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp (modified) (6 diffs)
-
Source/JavaScriptCore/debugger/DebuggerScope.cpp (modified) (1 diff)
-
Source/JavaScriptCore/debugger/DebuggerScope.h (modified) (1 diff)
-
Source/JavaScriptCore/inspector/InjectedScriptSource.js (modified) (1 diff)
-
Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.h (modified) (1 diff)
-
Source/JavaScriptCore/inspector/protocol/Debugger.json (modified) (1 diff)
-
Source/JavaScriptCore/runtime/JSScope.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/JSScope.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/SymbolTable.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/SymbolTable.h (modified) (2 diffs)
-
Source/WebInspectorUI/ChangeLog (modified) (1 diff)
-
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (modified) (1 diff)
-
Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js (modified) (1 diff)
-
Source/WebInspectorUI/UserInterface/Models/ScopeChainNode.js (modified) (1 diff)
-
Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r194248 r194251 1 2015-12-17 Joseph Pecoraro <pecoraro@apple.com> 2 3 Provide a way to distinguish a nested lexical block from a function's lexical block 4 https://bugs.webkit.org/show_bug.cgi?id=152361 5 6 Reviewed by Saam Barati. 7 8 * inspector/debugger/breakpoint-scope-expected.txt: 9 We will soon remove the backend sending a "Local" scope. 10 The backend was just marking the first closure scope as local. 11 The frontend can do this itself and do a better job of it. 12 13 * inspector/model/resources/all-scopes.js: Added. 14 (testAllScopes.innerScope): 15 (testAllScopes): 16 * inspector/model/resources/block-scopes.js: Added. 17 (testBlockScopes): 18 (testBlockScopes.method): 19 * inspector/model/resources/function-name-scopes.js: Added. 20 (testFunctionNameScope1): 21 * inspector/model/scope-chain-node-expected.txt: Added. 22 * inspector/model/scope-chain-node.html: Added. 23 Tests for ways to get all the different scope types and 24 specific cases of certain scope types. 25 1 26 2015-12-17 Keith Miller <keith_miller@apple.com> 2 27 -
trunk/LayoutTests/inspector/debugger/breakpoint-scope-expected.txt
r193425 r194251 4 4 Starting Test 5 5 Hit breakpoint at line: 4, column: 8 6 scope-chain-type- localproperties:6 scope-chain-type-closure properties: 7 7 resolve 8 8 reject 9 9 scope-chain-type-closure properties: 10 10 p 11 scope-chain-type-global LexicalEnvironment properties:11 scope-chain-type-global-lexical-environment properties: 12 12 lexicalVariable 13 13 scope-chain-type-global (properties not listed) -
trunk/Source/JavaScriptCore/ChangeLog
r194249 r194251 1 2015-12-17 Joseph Pecoraro <pecoraro@apple.com> 2 3 Provide a way to distinguish a nested lexical block from a function's lexical block 4 https://bugs.webkit.org/show_bug.cgi?id=152361 5 6 Reviewed by Saam Barati. 7 8 * bytecompiler/BytecodeGenerator.h: 9 * bytecompiler/BytecodeGenerator.cpp: 10 (JSC::BytecodeGenerator::initializeDefaultParameterValuesAndSetupFunctionScopeStack): 11 (JSC::BytecodeGenerator::initializeArrowFunctionContextScopeIfNeeded): 12 (JSC::BytecodeGenerator::emitPushFunctionNameScope): 13 (JSC::BytecodeGenerator::emitPushCatchScope): 14 Each of these are specialized scopes. They are not nested lexical scopes. 15 16 (JSC::BytecodeGenerator::pushLexicalScope): 17 (JSC::BytecodeGenerator::pushLexicalScopeInternal): 18 Include an extra parameter to mark the SymbolTable as a nested lexical or not. 19 20 * bytecompiler/NodesCodegen.cpp: 21 (JSC::BlockNode::emitBytecode): 22 (JSC::ForNode::emitBytecode): 23 (JSC::ForInNode::emitMultiLoopBytecode): 24 (JSC::ForOfNode::emitBytecode): 25 (JSC::SwitchNode::emitBytecode): 26 (JSC::ClassExprNode::emitBytecode): 27 Each of these are cases of non-function nested lexical scopes. 28 So mark the SymbolTable as nested. 29 30 * inspector/protocol/Debugger.json: 31 * inspector/InjectedScriptSource.js: 32 Include a new scope type. 33 34 * inspector/JSJavaScriptCallFrame.h: 35 * inspector/JSJavaScriptCallFrame.cpp: 36 (Inspector::JSJavaScriptCallFrame::scopeType): 37 Use the new "NestedLexical" scope type for nested, non-function, 38 lexical scopes. The Inspector can use this to better describe 39 this scope in the frontend. 40 41 * debugger/DebuggerScope.cpp: 42 (JSC::DebuggerScope::isNestedLexicalScope): 43 * debugger/DebuggerScope.h: 44 * runtime/JSScope.cpp: 45 (JSC::JSScope::isNestedLexicalScope): 46 * runtime/JSScope.h: 47 * runtime/SymbolTable.cpp: 48 (JSC::SymbolTable::SymbolTable): 49 (JSC::SymbolTable::cloneScopePart): 50 * runtime/SymbolTable.h: 51 Access the isNestedLexicalScope bit. 52 1 53 2015-12-17 Joseph Pecoraro <pecoraro@apple.com> 2 54 -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r194248 r194251 810 810 811 811 // This implements step 25 of section 9.2.12. 812 pushLexicalScopeInternal(environment, true, nullptr, TDZRequirement::UnderTDZ, ScopeType::LetConstScope, ScopeRegisterType::Block);812 pushLexicalScopeInternal(environment, true, false, nullptr, TDZRequirement::UnderTDZ, ScopeType::LetConstScope, ScopeRegisterType::Block); 813 813 814 814 RefPtr<RegisterID> temp = newTemporary(); … … 928 928 929 929 size_t size = m_symbolTableStack.size(); 930 pushLexicalScopeInternal(environment, true, nullptr, TDZRequirement::UnderTDZ, ScopeType::LetConstScope, ScopeRegisterType::Block);930 pushLexicalScopeInternal(environment, true, false, nullptr, TDZRequirement::UnderTDZ, ScopeType::LetConstScope, ScopeRegisterType::Block); 931 931 932 932 ASSERT_UNUSED(size, m_symbolTableStack.size() == size + 1); … … 1798 1798 } 1799 1799 1800 void BytecodeGenerator::pushLexicalScope(VariableEnvironmentNode* node, bool canOptimizeTDZChecks, RegisterID** constantSymbolTableResult)1800 void BytecodeGenerator::pushLexicalScope(VariableEnvironmentNode* node, bool canOptimizeTDZChecks, bool isNestedLexicalScope, RegisterID** constantSymbolTableResult) 1801 1801 { 1802 1802 VariableEnvironment& environment = node->lexicalVariables(); 1803 pushLexicalScopeInternal(environment, canOptimizeTDZChecks, constantSymbolTableResult, TDZRequirement::UnderTDZ, ScopeType::LetConstScope, ScopeRegisterType::Block);1804 } 1805 1806 void BytecodeGenerator::pushLexicalScopeInternal(VariableEnvironment& environment, bool canOptimizeTDZChecks, 1803 pushLexicalScopeInternal(environment, canOptimizeTDZChecks, isNestedLexicalScope, constantSymbolTableResult, TDZRequirement::UnderTDZ, ScopeType::LetConstScope, ScopeRegisterType::Block); 1804 } 1805 1806 void BytecodeGenerator::pushLexicalScopeInternal(VariableEnvironment& environment, bool canOptimizeTDZChecks, bool isNestedLexicalScope, 1807 1807 RegisterID** constantSymbolTableResult, TDZRequirement tdzRequirement, ScopeType scopeType, ScopeRegisterType scopeRegisterType) 1808 1808 { … … 1825 1825 break; 1826 1826 } 1827 1828 if (isNestedLexicalScope) 1829 symbolTable->markIsNestedLexicalScope(); 1827 1830 1828 1831 auto lookUpVarKind = [] (UniquedStringImpl*, const VariableEnvironmentEntry& entry) -> VarKind { … … 3564 3567 addResult.iterator->value.setIsConst(); // The function name scope name acts like a const variable. 3565 3568 unsigned numVars = m_codeBlock->m_numVars; 3566 pushLexicalScopeInternal(nameScopeEnvironment, true, nullptr, TDZRequirement::NotUnderTDZ, ScopeType::FunctionNameScope, ScopeRegisterType::Var);3569 pushLexicalScopeInternal(nameScopeEnvironment, true, false, nullptr, TDZRequirement::NotUnderTDZ, ScopeType::FunctionNameScope, ScopeRegisterType::Var); 3567 3570 ASSERT_UNUSED(numVars, m_codeBlock->m_numVars == static_cast<int>(numVars + 1)); // Should have only created one new "var" for the function name scope. 3568 3571 bool shouldTreatAsLexicalVariable = isStrictMode(); … … 3590 3593 { 3591 3594 RELEASE_ASSERT(environment.contains(property.impl())); 3592 pushLexicalScopeInternal(environment, true, nullptr, TDZRequirement::NotUnderTDZ, ScopeType::CatchScope, ScopeRegisterType::Block);3595 pushLexicalScopeInternal(environment, true, false, nullptr, TDZRequirement::NotUnderTDZ, ScopeType::CatchScope, ScopeRegisterType::Block); 3593 3596 Variable exceptionVar = variable(property); 3594 3597 RELEASE_ASSERT(exceptionVar.isResolved()); -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
r194248 r194251 705 705 enum class ScopeType { CatchScope, LetConstScope, FunctionNameScope }; 706 706 enum class ScopeRegisterType { Var, Block }; 707 void pushLexicalScopeInternal(VariableEnvironment&, bool canOptimizeTDZChecks, RegisterID** constantSymbolTableResult, TDZRequirement, ScopeType, ScopeRegisterType);707 void pushLexicalScopeInternal(VariableEnvironment&, bool canOptimizeTDZChecks, bool isNestedLexicalScope, RegisterID** constantSymbolTableResult, TDZRequirement, ScopeType, ScopeRegisterType); 708 708 void popLexicalScopeInternal(VariableEnvironment&, TDZRequirement); 709 709 template<typename LookUpVarKindFunctor> … … 716 716 717 717 public: 718 void pushLexicalScope(VariableEnvironmentNode*, bool canOptimizeTDZChecks, RegisterID** constantSymbolTableResult = nullptr);718 void pushLexicalScope(VariableEnvironmentNode*, bool canOptimizeTDZChecks, bool isNestedLexicalScope = false, RegisterID** constantSymbolTableResult = nullptr); 719 719 void popLexicalScope(VariableEnvironmentNode*); 720 720 void prepareLexicalScopeForNextForLoopIteration(VariableEnvironmentNode*, RegisterID* loopSymbolTable); -
trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
r194248 r194251 2050 2050 if (!m_statements) 2051 2051 return; 2052 generator.pushLexicalScope(this, true );2052 generator.pushLexicalScope(this, true, true); 2053 2053 m_statements->emitBytecode(generator, dst); 2054 2054 generator.popLexicalScope(this); … … 2255 2255 2256 2256 RegisterID* forLoopSymbolTable = nullptr; 2257 generator.pushLexicalScope(this, true, &forLoopSymbolTable);2257 generator.pushLexicalScope(this, true, true, &forLoopSymbolTable); 2258 2258 2259 2259 generator.emitDebugHook(WillExecuteStatement, firstLine(), startOffset(), lineStartOffset()); … … 2383 2383 2384 2384 RegisterID* forLoopSymbolTable = nullptr; 2385 generator.pushLexicalScope(this, true, &forLoopSymbolTable);2385 generator.pushLexicalScope(this, true, true, &forLoopSymbolTable); 2386 2386 2387 2387 generator.emitDebugHook(WillExecuteStatement, firstLine(), startOffset(), lineStartOffset()); … … 2533 2533 2534 2534 RegisterID* forLoopSymbolTable = nullptr; 2535 generator.pushLexicalScope(this, true, &forLoopSymbolTable);2535 generator.pushLexicalScope(this, true, true, &forLoopSymbolTable); 2536 2536 generator.emitDebugHook(WillExecuteStatement, firstLine(), startOffset(), lineStartOffset()); 2537 2537 auto extractor = [this, dst](BytecodeGenerator& generator, RegisterID* value) … … 2849 2849 RefPtr<RegisterID> r0 = generator.emitNode(m_expr); 2850 2850 2851 generator.pushLexicalScope(this, false );2851 generator.pushLexicalScope(this, false, true); 2852 2852 m_block->emitBytecodeForBlock(generator, r0.get(), dst); 2853 2853 generator.popLexicalScope(this); … … 3182 3182 { 3183 3183 if (!m_name.isNull()) 3184 generator.pushLexicalScope(this, true );3184 generator.pushLexicalScope(this, true, true); 3185 3185 3186 3186 RefPtr<RegisterID> superclass; -
trunk/Source/JavaScriptCore/debugger/DebuggerScope.cpp
r189279 r194251 198 198 } 199 199 200 bool DebuggerScope::isNestedLexicalScope() const 201 { 202 return m_scope->isNestedLexicalScope(); 203 } 204 200 205 JSValue DebuggerScope::caughtValue(ExecState* exec) const 201 206 { -
trunk/Source/JavaScriptCore/debugger/DebuggerScope.h
r189279 r194251 92 92 bool isClosureScope() const; 93 93 bool isGlobalLexicalEnvironment() const; 94 bool isNestedLexicalScope() const; 94 95 95 96 JSValue caughtValue(ExecState*) const; -
trunk/Source/JavaScriptCore/inspector/InjectedScriptSource.js
r194247 r194251 1370 1370 5: "functionName", // FUNCTION_NAME_SCOPE 1371 1371 6: "globalLexicalEnvironment", // GLOBAL_LEXICAL_ENVIRONMENT_SCOPE 1372 7: "nestedLexical", // NESTED_LEXICAL_SCOPE 1372 1373 } 1373 1374 -
trunk/Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp
r193425 r194251 96 96 DebuggerScope::iterator end = scopeChain->end(); 97 97 98 bool foundLocalScope = false;99 98 for (DebuggerScope::iterator iter = scopeChain->begin(); iter != end; ++iter) { 100 99 DebuggerScope* scope = iter.get(); 101 102 if (!foundLocalScope && scope->isClosureScope()) {103 // First closure scope is the local scope, each successive one is a true closure.104 if (!index)105 return jsNumber(JSJavaScriptCallFrame::LOCAL_SCOPE);106 foundLocalScope = true;107 }108 100 109 101 if (!index) { … … 114 106 if (scope->isWithScope()) 115 107 return jsNumber(JSJavaScriptCallFrame::WITH_SCOPE); 108 if (scope->isNestedLexicalScope()) 109 return jsNumber(JSJavaScriptCallFrame::NESTED_LEXICAL_SCOPE); 116 110 if (scope->isGlobalLexicalEnvironment()) 117 111 return jsNumber(JSJavaScriptCallFrame::GLOBAL_LEXICAL_ENVIRONMENT_SCOPE); -
trunk/Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.h
r193425 r194251 79 79 static const unsigned short FUNCTION_NAME_SCOPE = 5; 80 80 static const unsigned short GLOBAL_LEXICAL_ENVIRONMENT_SCOPE = 6; 81 static const unsigned short NESTED_LEXICAL_SCOPE = 7; 81 82 82 83 protected: -
trunk/Source/JavaScriptCore/inspector/protocol/Debugger.json
r193425 r194251 82 82 "type": "object", 83 83 "properties": [ 84 { "name": "type", "type": "string", "enum": ["global", "local", "with", "closure", "catch", "functionName", "globalLexicalEnvironment" ], "description": "Scope type." },84 { "name": "type", "type": "string", "enum": ["global", "local", "with", "closure", "catch", "functionName", "globalLexicalEnvironment", "nestedLexical"], "description": "Scope type." }, 85 85 { "name": "object", "$ref": "Runtime.RemoteObject", "description": "Object representing the scope. For <code>global</code> and <code>with</code> scopes it represents the actual object; for the rest of the scopes, it is artificial transient object enumerating scope variables as its properties." } 86 86 ], -
trunk/Source/JavaScriptCore/runtime/JSScope.cpp
r189501 r194251 287 287 } 288 288 289 bool JSScope::isNestedLexicalScope() 290 { 291 if (JSLexicalEnvironment* environment = jsDynamicCast<JSLexicalEnvironment*>(this)) 292 return environment->symbolTable()->isNestedLexicalScope(); 293 return false; 294 } 295 289 296 JSScope* JSScope::constantScopeForCodeBlock(ResolveType type, CodeBlock* codeBlock) 290 297 { -
trunk/Source/JavaScriptCore/runtime/JSScope.h
r189339 r194251 62 62 bool isCatchScope(); 63 63 bool isFunctionNameScopeObject(); 64 65 bool isNestedLexicalScope(); 64 66 65 67 ScopeChainIterator begin(); -
trunk/Source/JavaScriptCore/runtime/SymbolTable.cpp
r187515 r194251 85 85 : JSCell(vm, vm.symbolTableStructure.get()) 86 86 , m_usesNonStrictEval(false) 87 , m_nestedLexicalScope(false) 87 88 , m_scopeType(VarScope) 88 89 { … … 143 144 144 145 result->m_usesNonStrictEval = m_usesNonStrictEval; 146 result->m_nestedLexicalScope = m_nestedLexicalScope; 145 147 result->m_scopeType = m_scopeType; 146 148 -
trunk/Source/JavaScriptCore/runtime/SymbolTable.h
r189279 r194251 647 647 RefPtr<TypeSet> globalTypeSetForVariable(const ConcurrentJITLocker&, UniquedStringImpl* key, VM&); 648 648 649 bool usesNonStrictEval() { return m_usesNonStrictEval; }649 bool usesNonStrictEval() const { return m_usesNonStrictEval; } 650 650 void setUsesNonStrictEval(bool usesNonStrictEval) { m_usesNonStrictEval = usesNonStrictEval; } 651 652 bool isNestedLexicalScope() const { return m_nestedLexicalScope; } 653 void markIsNestedLexicalScope() { ASSERT(scopeType() == LexicalScope); m_nestedLexicalScope = true; } 651 654 652 655 enum ScopeType { … … 687 690 688 691 bool m_usesNonStrictEval : 1; 692 bool m_nestedLexicalScope : 1; // Non-function LexicalScope. 689 693 unsigned m_scopeType : 3; // ScopeType 690 694 -
trunk/Source/WebInspectorUI/ChangeLog
r194247 r194251 1 2015-12-17 Joseph Pecoraro <pecoraro@apple.com> 2 3 Provide a way to distinguish a nested lexical block from a function's lexical block 4 https://bugs.webkit.org/show_bug.cgi?id=152361 5 6 Reviewed by Saam Barati. 7 8 * Localizations/en.lproj/localizedStrings.js: 9 * UserInterface/Views/ScopeChainDetailsSidebarPanel.js: 10 (WebInspector.ScopeChainDetailsSidebarPanel.prototype._generateCallFramesSection): 11 New "Block Variables" string. 12 13 * UserInterface/Models/ScopeChainNode.js: 14 New "Block" scope type, and update existing types. 15 16 * UserInterface/Controllers/DebuggerManager.js: 17 (WebInspector.DebuggerManager.prototype._scopeChainNodeFromPayload): 18 Parse the protocol type to frontend types. Use the protocol generated enum. 19 1 20 2015-12-17 Joseph Pecoraro <pecoraro@apple.com> 2 21 -
trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
r194243 r194251 96 96 localizedStrings["Basis"] = "Basis"; 97 97 localizedStrings["Begin Capturing"] = "Begin Capturing"; 98 localizedStrings["Block Variables"] = "Block Variables"; 98 99 localizedStrings["Blur"] = "Blur"; 99 100 localizedStrings["Border"] = "Border"; -
trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js
r194247 r194251 586 586 var type = null; 587 587 switch (payload.type) { 588 case "local":588 case DebuggerAgent.ScopeType.Local: 589 589 type = WebInspector.ScopeChainNode.Type.Local; 590 590 break; 591 case "global":591 case DebuggerAgent.ScopeType.Global: 592 592 type = WebInspector.ScopeChainNode.Type.Global; 593 593 break; 594 case "with":594 case DebuggerAgent.ScopeType.With: 595 595 type = WebInspector.ScopeChainNode.Type.With; 596 596 break; 597 case "closure":597 case DebuggerAgent.ScopeType.Closure: 598 598 type = WebInspector.ScopeChainNode.Type.Closure; 599 599 break; 600 case "catch":600 case DebuggerAgent.ScopeType.Catch: 601 601 type = WebInspector.ScopeChainNode.Type.Catch; 602 602 break; 603 case "functionName":603 case DebuggerAgent.ScopeType.FunctionName: 604 604 type = WebInspector.ScopeChainNode.Type.FunctionName; 605 605 break; 606 case "globalLexicalEnvironment": 606 case DebuggerAgent.ScopeType.NestedLexical: 607 type = WebInspector.ScopeChainNode.Type.Block; 608 break; 609 case DebuggerAgent.ScopeType.GlobalLexicalEnvironment: 607 610 type = WebInspector.ScopeChainNode.Type.GlobalLexicalEnvironment; 608 611 break; -
trunk/Source/WebInspectorUI/UserInterface/Models/ScopeChainNode.js
r193425 r194251 56 56 Local: "scope-chain-type-local", 57 57 Global: "scope-chain-type-global", 58 GlobalLexicalEnvironment: "scope-chain-type-global-lexical-environment", 58 59 With: "scope-chain-type-with", 59 60 Closure: "scope-chain-type-closure", 60 61 Catch: "scope-chain-type-catch", 61 FunctionName: "scope-chain-type-function Name",62 GlobalLexicalEnvironment: "scope-chain-type-globalLexicalEnvironment",62 FunctionName: "scope-chain-type-function-name", 63 Block: "scope-chain-type-block", 63 64 }; -
trunk/Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js
r194116 r194251 185 185 break; 186 186 187 case WebInspector.ScopeChainNode.Type.Block: 188 title = WebInspector.UIString("Block Variables"); 189 collapsedByDefault = false; 190 break; 191 187 192 case WebInspector.ScopeChainNode.Type.Closure: 188 193 title = WebInspector.UIString("Closure Variables");
Note:
See TracChangeset
for help on using the changeset viewer.