Changeset 209196 in webkit
- Timestamp:
- Dec 1, 2016, 1:23:27 PM (9 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r209175 r209196 1 2016-12-01 Geoffrey Garen <ggaren@apple.com> 2 3 Removed some unnecessary indirection in code generation 4 https://bugs.webkit.org/show_bug.cgi?id=165264 5 6 Reviewed by Keith Miller. 7 8 There's no need to route through JSGlobalObject when producing code -- 9 it just made the code harder to read. 10 11 This patch moves functions from JSGlobalObject to their singleton 12 call sites. 13 14 * runtime/CodeCache.cpp: 15 (JSC::CodeCache::getUnlinkedEvalCodeBlock): 16 (JSC::CodeCache::getUnlinkedGlobalEvalCodeBlock): Deleted. 17 * runtime/CodeCache.h: 18 * runtime/DirectEvalExecutable.cpp: 19 (JSC::DirectEvalExecutable::create): 20 * runtime/IndirectEvalExecutable.cpp: 21 (JSC::IndirectEvalExecutable::create): 22 * runtime/JSGlobalObject.cpp: 23 (JSC::JSGlobalObject::createProgramCodeBlock): Deleted. 24 (JSC::JSGlobalObject::createLocalEvalCodeBlock): Deleted. 25 (JSC::JSGlobalObject::createGlobalEvalCodeBlock): Deleted. 26 (JSC::JSGlobalObject::createModuleProgramCodeBlock): Deleted. 27 * runtime/JSGlobalObject.h: 28 * runtime/ModuleProgramExecutable.cpp: 29 (JSC::ModuleProgramExecutable::create): 30 * runtime/ProgramExecutable.cpp: 31 (JSC::ProgramExecutable::initializeGlobalProperties): 32 * runtime/ProgramExecutable.h: 33 1 34 2016-11-30 JF Bastien <jfbastien@apple.com> 2 35 -
trunk/Source/JavaScriptCore/runtime/CodeCache.cpp
r208830 r209196 86 86 } 87 87 88 UnlinkedEvalCodeBlock* CodeCache::getUnlinked GlobalEvalCodeBlock(VM& vm, IndirectEvalExecutable* executable, const SourceCode& source, JSParserStrictMode strictMode, DebuggerMode debuggerMode, ParserError& error, EvalContextType evalContextType)88 UnlinkedEvalCodeBlock* CodeCache::getUnlinkedEvalCodeBlock(VM& vm, IndirectEvalExecutable* executable, const SourceCode& source, JSParserStrictMode strictMode, DebuggerMode debuggerMode, ParserError& error, EvalContextType evalContextType) 89 89 { 90 90 return getUnlinkedGlobalCodeBlock<UnlinkedEvalCodeBlock>(vm, executable, source, strictMode, JSParserScriptMode::Classic, debuggerMode, error, evalContextType); -
trunk/Source/JavaScriptCore/runtime/CodeCache.h
r208830 r209196 195 195 public: 196 196 UnlinkedProgramCodeBlock* getUnlinkedProgramCodeBlock(VM&, ProgramExecutable*, const SourceCode&, JSParserStrictMode, DebuggerMode, ParserError&); 197 UnlinkedEvalCodeBlock* getUnlinked GlobalEvalCodeBlock(VM&, IndirectEvalExecutable*, const SourceCode&, JSParserStrictMode, DebuggerMode, ParserError&, EvalContextType);197 UnlinkedEvalCodeBlock* getUnlinkedEvalCodeBlock(VM&, IndirectEvalExecutable*, const SourceCode&, JSParserStrictMode, DebuggerMode, ParserError&, EvalContextType); 198 198 UnlinkedModuleProgramCodeBlock* getUnlinkedModuleProgramCodeBlock(VM&, ModuleProgramExecutable*, const SourceCode&, DebuggerMode, ParserError&); 199 199 UnlinkedFunctionExecutable* getUnlinkedGlobalFunctionExecutable(VM&, const Identifier&, const SourceCode&, DebuggerMode, ParserError&); -
trunk/Source/JavaScriptCore/runtime/DirectEvalExecutable.cpp
r208950 r209196 27 27 #include "DirectEvalExecutable.h" 28 28 29 #include "CodeCache.h" 30 #include "Debugger.h" 29 31 #include "Error.h" 30 32 #include "HeapInlines.h" 31 33 #include "JSCJSValueInlines.h" 34 #include "ParserError.h" 32 35 33 36 namespace JSC { … … 47 50 executable->finishCreation(vm); 48 51 49 UnlinkedEvalCodeBlock* unlinkedEvalCode = globalObject->createLocalEvalCodeBlock(exec, executable, variablesUnderTDZ); 50 ASSERT(!!scope.exception() == !unlinkedEvalCode); 51 if (!unlinkedEvalCode) 52 return 0; 52 ParserError error; 53 JSParserStrictMode strictMode = executable->isStrictMode() ? JSParserStrictMode::Strict : JSParserStrictMode::NotStrict; 54 DebuggerMode debuggerMode = globalObject->hasInteractiveDebugger() ? DebuggerOn : DebuggerOff; 55 56 // We don't bother with CodeCache here because direct eval uses a specialized EvalCodeCache. 57 UnlinkedEvalCodeBlock* unlinkedEvalCode = generateUnlinkedCodeBlock<UnlinkedEvalCodeBlock>( 58 vm, executable, executable->source(), strictMode, JSParserScriptMode::Classic, debuggerMode, error, evalContextType, variablesUnderTDZ); 59 60 if (globalObject->hasDebugger()) 61 globalObject->debugger()->sourceParsed(exec, executable->source().provider(), error.line(), error.message()); 62 63 if (error.isValid()) { 64 throwVMError(exec, scope, error.toErrorObject(globalObject, executable->source())); 65 return nullptr; 66 } 53 67 54 68 executable->m_unlinkedEvalCodeBlock.set(vm, executable, unlinkedEvalCode); -
trunk/Source/JavaScriptCore/runtime/IndirectEvalExecutable.cpp
r208950 r209196 27 27 #include "IndirectEvalExecutable.h" 28 28 29 #include "CodeCache.h" 30 #include "Debugger.h" 29 31 #include "Error.h" 30 32 #include "HeapInlines.h" 31 33 #include "JSCJSValueInlines.h" 34 #include "ParserError.h" 32 35 33 36 namespace JSC { … … 47 50 executable->finishCreation(vm); 48 51 49 UnlinkedEvalCodeBlock* unlinkedEvalCode = globalObject->createGlobalEvalCodeBlock(exec, executable); 50 ASSERT(!!scope.exception() == !unlinkedEvalCode); 51 if (!unlinkedEvalCode) 52 return 0; 52 ParserError error; 53 JSParserStrictMode strictMode = executable->isStrictMode() ? JSParserStrictMode::Strict : JSParserStrictMode::NotStrict; 54 DebuggerMode debuggerMode = globalObject->hasInteractiveDebugger() ? DebuggerOn : DebuggerOff; 55 56 UnlinkedEvalCodeBlock* unlinkedEvalCode = vm.codeCache()->getUnlinkedEvalCodeBlock( 57 vm, executable, executable->source(), strictMode, debuggerMode, error, evalContextType); 58 59 if (globalObject->hasDebugger()) 60 globalObject->debugger()->sourceParsed(exec, executable->source().provider(), error.line(), error.message()); 61 62 if (error.isValid()) { 63 throwVMError(exec, scope, error.toErrorObject(globalObject, executable->source())); 64 return nullptr; 65 } 53 66 54 67 executable->m_unlinkedEvalCodeBlock.set(vm, executable, unlinkedEvalCode); -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r209123 r209196 1333 1333 } 1334 1334 1335 UnlinkedProgramCodeBlock* JSGlobalObject::createProgramCodeBlock(CallFrame* callFrame, ProgramExecutable* executable, JSObject** exception)1336 {1337 ParserError error;1338 JSParserStrictMode strictMode = executable->isStrictMode() ? JSParserStrictMode::Strict : JSParserStrictMode::NotStrict;1339 DebuggerMode debuggerMode = hasInteractiveDebugger() ? DebuggerOn : DebuggerOff;1340 UnlinkedProgramCodeBlock* unlinkedCodeBlock = vm().codeCache()->getUnlinkedProgramCodeBlock(1341 vm(), executable, executable->source(), strictMode,1342 debuggerMode, error);1343 1344 if (hasDebugger())1345 debugger()->sourceParsed(callFrame, executable->source().provider(), error.line(), error.message());1346 1347 if (error.isValid()) {1348 *exception = error.toErrorObject(this, executable->source());1349 return nullptr;1350 }1351 1352 return unlinkedCodeBlock;1353 }1354 1355 UnlinkedEvalCodeBlock* JSGlobalObject::createLocalEvalCodeBlock(CallFrame* callFrame, DirectEvalExecutable* executable, const VariableEnvironment* variablesUnderTDZ)1356 {1357 VM& vm = this->vm();1358 auto scope = DECLARE_THROW_SCOPE(vm);1359 1360 ParserError error;1361 JSParserStrictMode strictMode = executable->isStrictMode() ? JSParserStrictMode::Strict : JSParserStrictMode::NotStrict;1362 DebuggerMode debuggerMode = hasInteractiveDebugger() ? DebuggerOn : DebuggerOff;1363 EvalContextType evalContextType = executable->executableInfo().evalContextType();1364 1365 // We don't bother with CodeCache here because local eval uses a specialized EvalCodeCache.1366 UnlinkedEvalCodeBlock* unlinkedCodeBlock = generateUnlinkedCodeBlock<UnlinkedEvalCodeBlock>(1367 vm, executable, executable->source(), strictMode, JSParserScriptMode::Classic, debuggerMode, error, evalContextType, variablesUnderTDZ);1368 1369 if (hasDebugger())1370 debugger()->sourceParsed(callFrame, executable->source().provider(), error.line(), error.message());1371 1372 if (error.isValid()) {1373 throwVMError(callFrame, scope, error.toErrorObject(this, executable->source()));1374 return nullptr;1375 }1376 1377 return unlinkedCodeBlock;1378 }1379 1380 UnlinkedEvalCodeBlock* JSGlobalObject::createGlobalEvalCodeBlock(CallFrame* callFrame, IndirectEvalExecutable* executable)1381 {1382 VM& vm = this->vm();1383 auto scope = DECLARE_THROW_SCOPE(vm);1384 1385 ParserError error;1386 JSParserStrictMode strictMode = executable->isStrictMode() ? JSParserStrictMode::Strict : JSParserStrictMode::NotStrict;1387 DebuggerMode debuggerMode = hasInteractiveDebugger() ? DebuggerOn : DebuggerOff;1388 EvalContextType evalContextType = executable->executableInfo().evalContextType();1389 1390 UnlinkedEvalCodeBlock* unlinkedCodeBlock = vm.codeCache()->getUnlinkedGlobalEvalCodeBlock(1391 vm, executable, executable->source(), strictMode, debuggerMode, error, evalContextType);1392 1393 if (hasDebugger())1394 debugger()->sourceParsed(callFrame, executable->source().provider(), error.line(), error.message());1395 1396 if (error.isValid()) {1397 throwVMError(callFrame, scope, error.toErrorObject(this, executable->source()));1398 return nullptr;1399 }1400 1401 return unlinkedCodeBlock;1402 }1403 1404 UnlinkedModuleProgramCodeBlock* JSGlobalObject::createModuleProgramCodeBlock(CallFrame* callFrame, ModuleProgramExecutable* executable)1405 {1406 VM& vm = this->vm();1407 auto scope = DECLARE_THROW_SCOPE(vm);1408 1409 ParserError error;1410 DebuggerMode debuggerMode = hasInteractiveDebugger() ? DebuggerOn : DebuggerOff;1411 UnlinkedModuleProgramCodeBlock* unlinkedCodeBlock = vm.codeCache()->getUnlinkedModuleProgramCodeBlock(1412 vm, executable, executable->source(), debuggerMode, error);1413 1414 if (hasDebugger())1415 debugger()->sourceParsed(callFrame, executable->source().provider(), error.line(), error.message());1416 1417 if (error.isValid()) {1418 throwVMError(callFrame, scope, error.toErrorObject(this, executable->source()));1419 return nullptr;1420 }1421 1422 return unlinkedCodeBlock;1423 }1424 1425 1335 void JSGlobalObject::setRemoteDebuggingEnabled(bool enabled) 1426 1336 { -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h
r209123 r209196 835 835 WeakRandom& weakRandom() { return m_weakRandom; } 836 836 837 UnlinkedProgramCodeBlock* createProgramCodeBlock(CallFrame*, ProgramExecutable*, JSObject** exception);838 UnlinkedEvalCodeBlock* createLocalEvalCodeBlock(CallFrame*, DirectEvalExecutable*, const VariableEnvironment*);839 UnlinkedEvalCodeBlock* createGlobalEvalCodeBlock(CallFrame*, IndirectEvalExecutable*);840 UnlinkedModuleProgramCodeBlock* createModuleProgramCodeBlock(CallFrame*, ModuleProgramExecutable*);841 842 837 bool needsSiteSpecificQuirks() const { return m_needsSiteSpecificQuirks; } 843 838 -
trunk/Source/JavaScriptCore/runtime/ModuleProgramExecutable.cpp
r208309 r209196 28 28 #include "BatchedTransitionOptimizer.h" 29 29 #include "CodeBlock.h" 30 #include "CodeCache.h" 30 31 #include "Debugger.h" 31 32 #include "JIT.h" … … 54 55 ModuleProgramExecutable* ModuleProgramExecutable::create(ExecState* exec, const SourceCode& source) 55 56 { 57 VM& vm = exec->vm(); 58 auto scope = DECLARE_THROW_SCOPE(vm); 59 56 60 JSGlobalObject* globalObject = exec->lexicalGlobalObject(); 57 61 ModuleProgramExecutable* executable = new (NotNull, allocateCell<ModuleProgramExecutable>(*exec->heap())) ModuleProgramExecutable(exec, source); 58 62 executable->finishCreation(exec->vm()); 59 63 60 UnlinkedModuleProgramCodeBlock* unlinkedModuleProgramCode = globalObject->createModuleProgramCodeBlock(exec, executable); 61 if (!unlinkedModuleProgramCode) 64 ParserError error; 65 DebuggerMode debuggerMode = globalObject->hasInteractiveDebugger() ? DebuggerOn : DebuggerOff; 66 UnlinkedModuleProgramCodeBlock* unlinkedModuleProgramCode = vm.codeCache()->getUnlinkedModuleProgramCodeBlock( 67 vm, executable, executable->source(), debuggerMode, error); 68 69 if (globalObject->hasDebugger()) 70 globalObject->debugger()->sourceParsed(exec, executable->source().provider(), error.line(), error.message()); 71 72 if (error.isValid()) { 73 throwVMError(exec, scope, error.toErrorObject(globalObject, executable->source())); 62 74 return nullptr; 75 } 76 63 77 executable->m_unlinkedModuleProgramCodeBlock.set(exec->vm(), executable, unlinkedModuleProgramCode); 64 78 -
trunk/Source/JavaScriptCore/runtime/ProgramExecutable.cpp
r209149 r209196 28 28 #include "BatchedTransitionOptimizer.h" 29 29 #include "CodeBlock.h" 30 #include "CodeCache.h" 30 31 #include "Debugger.h" 31 32 #include "Exception.h" … … 80 81 ASSERT(&globalObject->vm() == &vm); 81 82 83 ParserError error; 84 JSParserStrictMode strictMode = isStrictMode() ? JSParserStrictMode::Strict : JSParserStrictMode::NotStrict; 85 DebuggerMode debuggerMode = globalObject->hasInteractiveDebugger() ? DebuggerOn : DebuggerOff; 86 87 UnlinkedProgramCodeBlock* unlinkedCodeBlock = vm.codeCache()->getUnlinkedProgramCodeBlock( 88 vm, this, source(), strictMode, debuggerMode, error); 89 90 if (globalObject->hasDebugger()) 91 globalObject->debugger()->sourceParsed(callFrame, source().provider(), error.line(), error.message()); 92 93 if (error.isValid()) 94 return error.toErrorObject(globalObject, source()); 95 82 96 JSValue nextPrototype = globalObject->getPrototypeDirect(); 83 97 while (nextPrototype && nextPrototype.isObject()) { … … 89 103 } 90 104 91 JSObject* exception = nullptr;92 UnlinkedProgramCodeBlock* unlinkedCodeBlock = globalObject->createProgramCodeBlock(callFrame, this, &exception);93 if (UNLIKELY(exception))94 return exception;95 96 105 JSGlobalLexicalEnvironment* globalLexicalEnvironment = globalObject->globalLexicalEnvironment(); 97 106 const VariableEnvironment& variableDeclarations = unlinkedCodeBlock->variableDeclarations(); -
trunk/Source/JavaScriptCore/runtime/ProgramExecutable.h
r208063 r209196 43 43 } 44 44 45 46 45 JSObject* initializeGlobalProperties(VM&, CallFrame*, JSScope*); 47 46
Note:
See TracChangeset
for help on using the changeset viewer.