Changeset 47412 in webkit for trunk/JavaScriptCore
- Timestamp:
- Aug 17, 2009, 10:34:52 PM (16 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 1 added
- 41 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSCallbackFunction.cpp
r43160 r47412 29 29 30 30 #include "APICast.h" 31 #include "CodeBlock.h" 31 32 #include "JSFunction.h" 32 33 #include "FunctionPrototype.h" -
trunk/JavaScriptCore/API/JSObjectRef.cpp
r46431 r47412 29 29 30 30 #include "APICast.h" 31 #include "CodeBlock.h" 31 32 #include "DateConstructor.h" 32 33 #include "ErrorConstructor.h" -
trunk/JavaScriptCore/ChangeLog
r47405 r47412 1 2009-08-17 Gavin Barraclough <[email protected]> 2 3 Reviewed by Sam Weinig. 4 5 No, silly runtime, AST nodes are not for you. 6 7 We still use AST nodes (ScopeNodes, particularly FunctionBodyNodes) within 8 the runtime, which means that these nodes must be persisted outside of the 9 arena, contain both parser & runtime data, etc. This is all a bit of a mess. 10 11 Move functionality into a new FunctionExecutable class. 12 13 * API/JSCallbackFunction.cpp: 14 * API/JSObjectRef.cpp: 15 * JavaScriptCore.exp: 16 * JavaScriptCore.xcodeproj/project.pbxproj: 17 * bytecode/CodeBlock.cpp: 18 (JSC::CodeBlock::CodeBlock): 19 (JSC::CodeBlock::markAggregate): 20 (JSC::CodeBlock::reparseForExceptionInfoIfNecessary): 21 (JSC::CodeBlock::lineNumberForBytecodeOffset): 22 (JSC::CodeBlock::shrinkToFit): 23 * bytecode/CodeBlock.h: 24 (JSC::CodeBlock::getBytecodeIndex): 25 (JSC::CodeBlock::discardBytecode): 26 (JSC::CodeBlock::instructionCount): 27 (JSC::CodeBlock::getJITCode): 28 (JSC::CodeBlock::executablePool): 29 (JSC::CodeBlock::ownerExecutable): 30 (JSC::CodeBlock::extractExceptionInfo): 31 (JSC::CodeBlock::addFunctionDecl): 32 (JSC::CodeBlock::functionDecl): 33 (JSC::CodeBlock::numberOfFunctionDecls): 34 (JSC::CodeBlock::addFunctionExpr): 35 (JSC::CodeBlock::functionExpr): 36 (JSC::GlobalCodeBlock::GlobalCodeBlock): 37 (JSC::ProgramCodeBlock::ProgramCodeBlock): 38 (JSC::EvalCodeBlock::EvalCodeBlock): 39 (JSC::FunctionCodeBlock::FunctionCodeBlock): 40 (JSC::NativeCodeBlock::NativeCodeBlock): 41 * bytecode/EvalCodeCache.h: 42 * bytecode/SamplingTool.cpp: 43 (JSC::SamplingTool::doRun): 44 * bytecompiler/BytecodeGenerator.cpp: 45 (JSC::BytecodeGenerator::BytecodeGenerator): 46 (JSC::BytecodeGenerator::emitNewFunction): 47 (JSC::BytecodeGenerator::emitNewFunctionExpression): 48 * bytecompiler/BytecodeGenerator.h: 49 * debugger/Debugger.cpp: 50 (JSC::Debugger::recompileAllJSFunctions): 51 * interpreter/CachedCall.h: 52 (JSC::CachedCall::CachedCall): 53 * interpreter/CallFrameClosure.h: 54 * interpreter/Interpreter.cpp: 55 (JSC::Interpreter::unwindCallFrame): 56 (JSC::Interpreter::throwException): 57 (JSC::Interpreter::execute): 58 (JSC::Interpreter::prepareForRepeatCall): 59 (JSC::Interpreter::debug): 60 (JSC::Interpreter::privateExecute): 61 (JSC::Interpreter::retrieveLastCaller): 62 * interpreter/Interpreter.h: 63 * jit/JIT.cpp: 64 (JSC::JIT::privateCompile): 65 * jit/JIT.h: 66 (JSC::JIT::compile): 67 * jit/JITOpcodes.cpp: 68 (JSC::JIT::privateCompileCTIMachineTrampolines): 69 (JSC::JIT::emit_op_new_func): 70 (JSC::JIT::emit_op_new_func_exp): 71 * jit/JITStubs.cpp: 72 (JSC::DEFINE_STUB_FUNCTION): 73 * jit/JITStubs.h: 74 (JSC::): 75 * parser/Nodes.cpp: 76 (JSC::FunctionBodyNode::reparseDataIfNecessary): 77 * parser/Nodes.h: 78 (JSC::EvalNode::partialDestroyData): 79 * parser/Parser.h: 80 * profiler/ProfileGenerator.cpp: 81 * profiler/Profiler.cpp: 82 (JSC::Profiler::createCallIdentifier): 83 (JSC::createCallIdentifierFromFunctionImp): 84 * runtime/Arguments.h: 85 (JSC::Arguments::getArgumentsData): 86 (JSC::Arguments::Arguments): 87 (JSC::JSActivation::copyRegisters): 88 * runtime/ArrayPrototype.cpp: 89 (JSC::isNumericCompareFunction): 90 * runtime/CallData.h: 91 (JSC::): 92 * runtime/Collector.cpp: 93 (JSC::Heap::collect): 94 * runtime/ConstructData.h: 95 (JSC::): 96 * runtime/ExceptionHelpers.cpp: 97 (JSC::createUndefinedVariableError): 98 (JSC::createInvalidParamError): 99 (JSC::createNotAConstructorError): 100 (JSC::createNotAFunctionError): 101 (JSC::createNotAnObjectError): 102 * runtime/Executable.cpp: Added. 103 (JSC::EvalExecutable::generateBytecode): 104 (JSC::ProgramExecutable::generateBytecode): 105 (JSC::FunctionExecutable::generateBytecode): 106 (JSC::EvalExecutable::generateJITCode): 107 (JSC::ProgramExecutable::generateJITCode): 108 (JSC::FunctionExecutable::generateJITCode): 109 (JSC::FunctionExecutable::isHostFunction): 110 (JSC::FunctionExecutable::markAggregate): 111 (JSC::FunctionExecutable::reparseExceptionInfo): 112 (JSC::EvalExecutable::reparseExceptionInfo): 113 (JSC::FunctionExecutable::recompile): 114 (JSC::FunctionExecutable::FunctionExecutable): 115 * runtime/Executable.h: 116 (JSC::ExecutableBase::~ExecutableBase): 117 (JSC::ExecutableBase::ExecutableBase): 118 (JSC::ExecutableBase::source): 119 (JSC::ExecutableBase::sourceID): 120 (JSC::ExecutableBase::lastLine): 121 (JSC::ExecutableBase::usesEval): 122 (JSC::ExecutableBase::usesArguments): 123 (JSC::ExecutableBase::needsActivation): 124 (JSC::ExecutableBase::astNode): 125 (JSC::ExecutableBase::generatedJITCode): 126 (JSC::ExecutableBase::getExecutablePool): 127 (JSC::EvalExecutable::EvalExecutable): 128 (JSC::EvalExecutable::bytecode): 129 (JSC::EvalExecutable::varStack): 130 (JSC::EvalExecutable::evalNode): 131 (JSC::EvalExecutable::jitCode): 132 (JSC::ProgramExecutable::ProgramExecutable): 133 (JSC::ProgramExecutable::reparseExceptionInfo): 134 (JSC::ProgramExecutable::bytecode): 135 (JSC::ProgramExecutable::programNode): 136 (JSC::ProgramExecutable::jitCode): 137 (JSC::FunctionExecutable::FunctionExecutable): 138 (JSC::FunctionExecutable::name): 139 (JSC::FunctionExecutable::bytecode): 140 (JSC::FunctionExecutable::generatedBytecode): 141 (JSC::FunctionExecutable::usesEval): 142 (JSC::FunctionExecutable::usesArguments): 143 (JSC::FunctionExecutable::parameterCount): 144 (JSC::FunctionExecutable::paramString): 145 (JSC::FunctionExecutable::isGenerated): 146 (JSC::FunctionExecutable::body): 147 (JSC::FunctionExecutable::jitCode): 148 (JSC::FunctionExecutable::createNativeThunk): 149 * runtime/FunctionConstructor.cpp: 150 (JSC::constructFunction): 151 * runtime/FunctionPrototype.cpp: 152 (JSC::functionProtoFuncToString): 153 * runtime/JSActivation.cpp: 154 (JSC::JSActivation::JSActivation): 155 (JSC::JSActivation::markChildren): 156 (JSC::JSActivation::isDynamicScope): 157 (JSC::JSActivation::argumentsGetter): 158 * runtime/JSActivation.h: 159 (JSC::JSActivation::JSActivationData::JSActivationData): 160 * runtime/JSFunction.cpp: 161 (JSC::JSFunction::isHostFunction): 162 (JSC::JSFunction::JSFunction): 163 (JSC::JSFunction::~JSFunction): 164 (JSC::JSFunction::markChildren): 165 (JSC::JSFunction::getCallData): 166 (JSC::JSFunction::call): 167 (JSC::JSFunction::lengthGetter): 168 (JSC::JSFunction::getConstructData): 169 (JSC::JSFunction::construct): 170 * runtime/JSFunction.h: 171 (JSC::JSFunction::executable): 172 (JSC::FunctionExecutable::make): 173 * runtime/JSGlobalData.cpp: 174 (JSC::JSGlobalData::JSGlobalData): 175 (JSC::JSGlobalData::numericCompareFunction): 176 * runtime/JSGlobalData.h: 177 1 178 2009-08-17 Mark Rowe <[email protected]> 2 179 -
trunk/JavaScriptCore/JavaScriptCore.exp
r47272 r47412 331 331 __ZNK3JSC12StringObject8toStringEPNS_9ExecStateE 332 332 __ZNK3JSC14JSGlobalObject14isDynamicScopeEv 333 __ZNK3JSC16FunctionBodyNode14isHostFunctionEv334 333 __ZNK3JSC16InternalFunction9classInfoEv 335 334 __ZNK3JSC16JSVariableObject16isVariableObjectEv -
trunk/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
r47022 r47412 642 642 <File 643 643 RelativePath="..\..\runtime\ErrorPrototype.h" 644 > 645 </File> 646 <File 647 RelativePath="..\..\runtime\Executable.cpp" 644 648 > 645 649 </File> -
trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r47304 r47412 133 133 86ADD1460FDDEA980006EEC2 /* MacroAssemblerARMv7.h in Headers */ = {isa = PBXBuildFile; fileRef = 86ADD1440FDDEA980006EEC2 /* MacroAssemblerARMv7.h */; }; 134 134 86C36EEA0EE1289D00B3DF59 /* MacroAssembler.h in Headers */ = {isa = PBXBuildFile; fileRef = 86C36EE90EE1289D00B3DF59 /* MacroAssembler.h */; }; 135 86CA032E1038E8440028A609 /* Executable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86CA032D1038E8440028A609 /* Executable.cpp */; }; 135 136 86CAFEE31035DDE60028A609 /* Executable.h in Headers */ = {isa = PBXBuildFile; fileRef = 86CAFEE21035DDE60028A609 /* Executable.h */; settings = {ATTRIBUTES = (Private, ); }; }; 136 137 86CC85A10EE79A4700288682 /* JITInlineMethods.h in Headers */ = {isa = PBXBuildFile; fileRef = 86CC85A00EE79A4700288682 /* JITInlineMethods.h */; }; … … 648 649 86ADD1440FDDEA980006EEC2 /* MacroAssemblerARMv7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerARMv7.h; sourceTree = "<group>"; }; 649 650 86C36EE90EE1289D00B3DF59 /* MacroAssembler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssembler.h; sourceTree = "<group>"; }; 651 86CA032D1038E8440028A609 /* Executable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Executable.cpp; sourceTree = "<group>"; }; 650 652 86CAFEE21035DDE60028A609 /* Executable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Executable.h; sourceTree = "<group>"; }; 651 653 86CC85A00EE79A4700288682 /* JITInlineMethods.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITInlineMethods.h; sourceTree = "<group>"; }; … … 1380 1382 1429D8770ED21ACD00B89619 /* ExceptionHelpers.cpp */, 1381 1383 A72701B30DADE94900E548D7 /* ExceptionHelpers.h */, 1384 86CA032D1038E8440028A609 /* Executable.cpp */, 1382 1385 86CAFEE21035DDE60028A609 /* Executable.h */, 1383 1386 BC2680C00E16D4E900A06E92 /* FunctionConstructor.cpp */, … … 2277 2280 A7C530E4102A3813005BC741 /* MarkStackPosix.cpp in Sources */, 2278 2281 A74B3499102A5F8E0032AB98 /* MarkStack.cpp in Sources */, 2282 86CA032E1038E8440028A609 /* Executable.cpp in Sources */, 2279 2283 ); 2280 2284 runOnlyForDeploymentPostprocessing = 0; -
trunk/JavaScriptCore/bytecode/CodeBlock.cpp
r47089 r47412 1249 1249 } 1250 1250 1251 CodeBlock::CodeBlock( ScopeNode* ownerNode)1251 CodeBlock::CodeBlock(ExecutableBase* ownerExecutable) 1252 1252 : m_numCalleeRegisters(0) 1253 1253 , m_numVars(0) 1254 1254 , m_numParameters(0) 1255 , m_owner Node(ownerNode)1255 , m_ownerExecutable(ownerExecutable) 1256 1256 , m_globalData(0) 1257 1257 #ifndef NDEBUG … … 1271 1271 } 1272 1272 1273 CodeBlock::CodeBlock( ScopeNode* ownerNode, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset)1273 CodeBlock::CodeBlock(ExecutableBase* ownerExecutable, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset) 1274 1274 : m_numCalleeRegisters(0) 1275 1275 , m_numVars(0) 1276 1276 , m_numParameters(0) 1277 , m_owner Node(ownerNode)1277 , m_ownerExecutable(ownerExecutable) 1278 1278 , m_globalData(0) 1279 1279 #ifndef NDEBUG 1280 1280 , m_instructionCount(0) 1281 1281 #endif 1282 , m_needsFullScopeChain(owner Node->needsActivation())1283 , m_usesEval(owner Node->usesEval())1282 , m_needsFullScopeChain(ownerExecutable->needsActivation()) 1283 , m_usesEval(ownerExecutable->usesEval()) 1284 1284 , m_isNumericCompareFunction(false) 1285 1285 , m_codeType(codeType) … … 1438 1438 } 1439 1439 1440 for (size_t i = 0; i < m_functions.size(); ++i) 1441 m_functions[i]->markAggregate(markStack); 1442 1443 if (m_rareData) 1444 m_rareData->m_evalCodeCache.markAggregate(markStack); 1440 for (size_t i = 0; i < m_functionExprs.size(); ++i) 1441 m_functionExprs[i]->markAggregate(markStack); 1442 for (size_t i = 0; i < m_functionDecls.size(); ++i) 1443 m_functionDecls[i]->markAggregate(markStack); 1445 1444 } 1446 1445 … … 1464 1463 } 1465 1464 1466 switch (m_codeType) { 1467 case FunctionCode: { 1468 FunctionBodyNode* ownerFunctionBodyNode = static_cast<FunctionBodyNode*>(m_ownerNode); 1469 RefPtr<FunctionBodyNode> newFunctionBody = m_globalData->parser->reparse<FunctionBodyNode>(m_globalData, ownerFunctionBodyNode); 1470 ASSERT(newFunctionBody); 1471 newFunctionBody->finishParsing(ownerFunctionBodyNode->copyParameters(), ownerFunctionBodyNode->parameterCount(), ownerFunctionBodyNode->ident()); 1472 1473 m_globalData->scopeNodeBeingReparsed = newFunctionBody.get(); 1474 1475 CodeBlock& newCodeBlock = newFunctionBody->bytecodeForExceptionInfoReparse(scopeChain, this); 1476 ASSERT(newCodeBlock.m_exceptionInfo); 1477 ASSERT(newCodeBlock.m_instructionCount == m_instructionCount); 1478 1479 #if ENABLE(JIT) 1480 JIT::compile(m_globalData, &newCodeBlock); 1481 ASSERT(newFunctionBody->generatedJITCode().size() == ownerNode()->generatedJITCode().size()); 1482 #endif 1483 1484 m_exceptionInfo.set(newCodeBlock.m_exceptionInfo.release()); 1485 1486 m_globalData->scopeNodeBeingReparsed = 0; 1487 1488 break; 1489 } 1490 case EvalCode: { 1491 EvalNode* ownerEvalNode = static_cast<EvalNode*>(m_ownerNode); 1492 RefPtr<EvalNode> newEvalBody = m_globalData->parser->reparse<EvalNode>(m_globalData, ownerEvalNode); 1493 1494 m_globalData->scopeNodeBeingReparsed = newEvalBody.get(); 1495 1496 EvalCodeBlock& newCodeBlock = newEvalBody->bytecodeForExceptionInfoReparse(scopeChain, this); 1497 ASSERT(newCodeBlock.m_exceptionInfo); 1498 ASSERT(newCodeBlock.m_instructionCount == m_instructionCount); 1499 1500 #if ENABLE(JIT) 1501 JIT::compile(m_globalData, &newCodeBlock); 1502 ASSERT(newEvalBody->generatedJITCode().size() == ownerNode()->generatedJITCode().size()); 1503 #endif 1504 1505 m_exceptionInfo.set(newCodeBlock.m_exceptionInfo.release()); 1506 1507 m_globalData->scopeNodeBeingReparsed = 0; 1508 1509 break; 1510 } 1511 default: 1512 // CodeBlocks for Global code blocks are transient and therefore to not gain from 1513 // from throwing out there exception information. 1514 ASSERT_NOT_REACHED(); 1515 } 1465 m_exceptionInfo.set(m_ownerExecutable->reparseExceptionInfo(m_globalData, scopeChain, this)); 1516 1466 } 1517 1467 … … 1544 1494 1545 1495 if (!m_exceptionInfo->m_lineInfo.size()) 1546 return m_owner Node->source().firstLine(); // Empty function1496 return m_ownerExecutable->source().firstLine(); // Empty function 1547 1497 1548 1498 int low = 0; … … 1557 1507 1558 1508 if (!low) 1559 return m_owner Node->source().firstLine();1509 return m_ownerExecutable->source().firstLine(); 1560 1510 return m_exceptionInfo->m_lineInfo[low - 1].lineNumber; 1561 1511 } … … 1697 1647 return false; 1698 1648 return true; 1699 }1700 #endif1701 1702 #if ENABLE(JIT)1703 void CodeBlock::setJITCode(JITCode jitCode)1704 {1705 ASSERT(m_codeType != NativeCode);1706 ownerNode()->setJITCode(jitCode);1707 #if !ENABLE(OPCODE_SAMPLING)1708 if (!BytecodeGenerator::dumpsGeneratedCode())1709 m_instructions.clear();1710 #endif1711 1649 } 1712 1650 #endif … … 1727 1665 1728 1666 m_identifiers.shrinkToFit(); 1729 m_functions.shrinkToFit(); 1667 m_functionDecls.shrinkToFit(); 1668 m_functionExprs.shrinkToFit(); 1730 1669 m_constantRegisters.shrinkToFit(); 1731 1670 -
trunk/JavaScriptCore/bytecode/CodeBlock.h
r47304 r47412 249 249 #endif 250 250 251 struct ExceptionInfo : FastAllocBase { 252 Vector<ExpressionRangeInfo> m_expressionInfo; 253 Vector<LineInfo> m_lineInfo; 254 Vector<GetByIdExceptionInfo> m_getByIdExceptionInfo; 255 256 #if ENABLE(JIT) 257 Vector<CallReturnOffsetToBytecodeIndex> m_callReturnIndexVector; 258 #endif 259 }; 260 251 261 class CodeBlock : public FastAllocBase { 252 262 friend class JIT; 253 263 protected: 254 CodeBlock( ScopeNode* ownerNode);255 CodeBlock( ScopeNode* ownerNode, CodeType, PassRefPtr<SourceProvider>, unsigned sourceOffset);264 CodeBlock(ExecutableBase* ownerExecutable); 265 CodeBlock(ExecutableBase* ownerExecutable, CodeType, PassRefPtr<SourceProvider>, unsigned sourceOffset); 256 266 public: 257 267 ~CodeBlock(); … … 331 341 { 332 342 reparseForExceptionInfoIfNecessary(callFrame); 333 return binaryChop<CallReturnOffsetToBytecodeIndex, unsigned, getCallReturnOffset>(callReturnIndexVector().begin(), callReturnIndexVector().size(), owner Node()->generatedJITCode().offsetOf(returnAddress.value()))->bytecodeIndex;343 return binaryChop<CallReturnOffsetToBytecodeIndex, unsigned, getCallReturnOffset>(callReturnIndexVector().begin(), callReturnIndexVector().size(), ownerExecutable()->generatedJITCode().offsetOf(returnAddress.value()))->bytecodeIndex; 334 344 } 335 345 … … 341 351 342 352 Vector<Instruction>& instructions() { return m_instructions; } 353 void discardBytecode() { m_instructions.clear(); } 354 343 355 #ifndef NDEBUG 356 unsigned instructionCount() { return m_instructionCount; } 344 357 void setInstructionCount(unsigned instructionCount) { m_instructionCount = instructionCount; } 345 358 #endif 346 359 347 360 #if ENABLE(JIT) 348 JITCode& getJITCode() { return ownerNode()->generatedJITCode(); } 349 void setJITCode(JITCode); 350 ExecutablePool* executablePool() { return ownerNode()->getExecutablePool(); } 351 #endif 352 353 ScopeNode* ownerNode() const { return m_ownerNode; } 361 JITCode& getJITCode() { return ownerExecutable()->generatedJITCode(); } 362 ExecutablePool* executablePool() { return ownerExecutable()->getExecutablePool(); } 363 #endif 364 365 ExecutableBase* ownerExecutable() const { return m_ownerExecutable; } 354 366 355 367 void setGlobalData(JSGlobalData* globalData) { m_globalData = globalData; } … … 406 418 bool hasExceptionInfo() const { return m_exceptionInfo; } 407 419 void clearExceptionInfo() { m_exceptionInfo.clear(); } 420 ExceptionInfo* extractExceptionInfo() { ASSERT(m_exceptionInfo); return m_exceptionInfo.release(); } 408 421 409 422 void addExpressionInfo(const ExpressionRangeInfo& expressionInfo) { ASSERT(m_exceptionInfo); m_exceptionInfo->m_expressionInfo.append(expressionInfo); } … … 430 443 ALWAYS_INLINE JSValue getConstant(int index) const { return m_constantRegisters[index - FirstConstantRegisterIndex].jsValue(); } 431 444 432 unsigned addFunction(PassRefPtr<FunctionBodyNode> n) { unsigned size = m_functions.size(); m_functions.append(n); return size; } 433 FunctionBodyNode* function(int index) { return m_functions[index].get(); } 445 unsigned addFunctionDecl(PassRefPtr<FunctionExecutable> n) { unsigned size = m_functionDecls.size(); m_functionDecls.append(n); return size; } 446 FunctionExecutable* functionDecl(int index) { return m_functionDecls[index].get(); } 447 int numberOfFunctionDecls() { return m_functionDecls.size(); } 448 unsigned addFunctionExpr(PassRefPtr<FunctionExecutable> n) { unsigned size = m_functionExprs.size(); m_functionExprs.append(n); return size; } 449 FunctionExecutable* functionExpr(int index) { return m_functionExprs[index].get(); } 434 450 435 451 unsigned addRegExp(RegExp* r) { createRareDataIfNecessary(); unsigned size = m_rareData->m_regexps.size(); m_rareData->m_regexps.append(r); return size; } … … 478 494 } 479 495 480 ScopeNode* m_ownerNode;496 ExecutableBase* m_ownerExecutable; 481 497 JSGlobalData* m_globalData; 482 498 … … 514 530 Vector<Identifier> m_identifiers; 515 531 Vector<Register> m_constantRegisters; 516 Vector< RefPtr<FunctionBodyNode> > m_functions; 532 Vector<RefPtr<FunctionExecutable> > m_functionDecls; 533 Vector<RefPtr<FunctionExecutable> > m_functionExprs; 517 534 518 535 SymbolTable m_symbolTable; 519 536 520 struct ExceptionInfo : FastAllocBase {521 Vector<ExpressionRangeInfo> m_expressionInfo;522 Vector<LineInfo> m_lineInfo;523 Vector<GetByIdExceptionInfo> m_getByIdExceptionInfo;524 525 #if ENABLE(JIT)526 Vector<CallReturnOffsetToBytecodeIndex> m_callReturnIndexVector;527 #endif528 };529 537 OwnPtr<ExceptionInfo> m_exceptionInfo; 530 538 … … 554 562 class GlobalCodeBlock : public CodeBlock { 555 563 public: 556 GlobalCodeBlock( ScopeNode* ownerNode, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, JSGlobalObject* globalObject)557 : CodeBlock(owner Node, codeType, sourceProvider, sourceOffset)564 GlobalCodeBlock(ExecutableBase* ownerExecutable, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, JSGlobalObject* globalObject) 565 : CodeBlock(ownerExecutable, codeType, sourceProvider, sourceOffset) 558 566 , m_globalObject(globalObject) 559 567 { … … 575 583 class ProgramCodeBlock : public GlobalCodeBlock { 576 584 public: 577 ProgramCodeBlock( ScopeNode* ownerNode, CodeType codeType, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider)578 : GlobalCodeBlock(owner Node, codeType, sourceProvider, 0, globalObject)585 ProgramCodeBlock(ProgramExecutable* ownerExecutable, CodeType codeType, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider) 586 : GlobalCodeBlock(ownerExecutable, codeType, sourceProvider, 0, globalObject) 579 587 { 580 588 } … … 583 591 class EvalCodeBlock : public GlobalCodeBlock { 584 592 public: 585 EvalCodeBlock( ScopeNode* ownerNode, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider, int baseScopeDepth)586 : GlobalCodeBlock(owner Node, EvalCode, sourceProvider, 0, globalObject)593 EvalCodeBlock(EvalExecutable* ownerExecutable, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider, int baseScopeDepth) 594 : GlobalCodeBlock(ownerExecutable, EvalCode, sourceProvider, 0, globalObject) 587 595 , m_baseScopeDepth(baseScopeDepth) 588 596 { … … 597 605 class FunctionCodeBlock : public CodeBlock { 598 606 public: 599 FunctionCodeBlock( ScopeNode* ownerNode, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset)600 : CodeBlock(owner Node, codeType, sourceProvider, sourceOffset)607 FunctionCodeBlock(FunctionExecutable* ownerExecutable, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset) 608 : CodeBlock(ownerExecutable, codeType, sourceProvider, sourceOffset) 601 609 { 602 610 } … … 605 613 class NativeCodeBlock : public CodeBlock { 606 614 public: 607 NativeCodeBlock( ScopeNode* ownerNode)608 : CodeBlock(owner Node)615 NativeCodeBlock(FunctionExecutable* ownerExecutable) 616 : CodeBlock(ownerExecutable) 609 617 { 610 618 } -
trunk/JavaScriptCore/bytecode/EvalCodeCache.h
r47405 r47412 65 65 bool isEmpty() const { return m_cacheMap.isEmpty(); } 66 66 67 void markAggregate(MarkStack& markStack)68 {69 EvalCacheMap::iterator end = m_cacheMap.end();70 for (EvalCacheMap::iterator ptr = m_cacheMap.begin(); ptr != end; ++ptr)71 ptr->second->markAggregate(markStack);72 }73 67 private: 74 68 static const int maxCacheableSourceLength = 256; -
trunk/JavaScriptCore/bytecode/SamplingTool.cpp
r43663 r47412 198 198 if (CodeBlock* codeBlock = sample.codeBlock()) { 199 199 MutexLocker locker(m_scopeSampleMapMutex); 200 ScopeSampleRecord* record = m_scopeSampleMap->get(codeBlock->owner Node());200 ScopeSampleRecord* record = m_scopeSampleMap->get(codeBlock->ownerExecutable()); 201 201 ASSERT(record); 202 202 record->sample(codeBlock, sample.vPC()); -
trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r47236 r47412 274 274 for (size_t i = 0; i < functionStack.size(); ++i) { 275 275 FunctionBodyNode* function = functionStack[i]; 276 globalObject->putWithAttributes(exec, function->ident(), function->make(exec, scopeChain.node()), DontDelete);276 globalObject->putWithAttributes(exec, function->ident(), new (exec) JSFunction(exec, adoptRef(new FunctionExecutable(function->ident(), function)), scopeChain.node()), DontDelete); 277 277 } 278 278 for (size_t i = 0; i < varStack.size(); ++i) { … … 398 398 m_codeBlock->m_numParameters = 1; // Allocate space for "this" 399 399 400 const DeclarationStacks::FunctionStack& functionStack = evalNode->functionStack(); 401 for (size_t i = 0; i < functionStack.size(); ++i) { 402 FunctionBodyNode* function = functionStack[i]; 403 m_codeBlock->addFunctionDecl(adoptRef(new FunctionExecutable(function->ident(), function))); 404 } 405 400 406 preserveLastVar(); 401 407 } … … 765 771 instructions().append(target->offsetFrom(instructions().size())); 766 772 return target; 767 }768 769 unsigned BytecodeGenerator::addConstant(FunctionBodyNode* n)770 {771 // No need to explicitly unique function body nodes -- they're unique already.772 return m_codeBlock->addFunction(n);773 773 } 774 774 … … 1309 1309 } 1310 1310 1311 RegisterID* BytecodeGenerator::emitNewFunction(RegisterID* dst, FunctionBodyNode* body) 1312 { 1311 RegisterID* BytecodeGenerator::emitNewFunction(RegisterID* dst, FunctionBodyNode* function) 1312 { 1313 unsigned index = m_codeBlock->addFunctionDecl(adoptRef(new FunctionExecutable(function->ident(), function))); 1314 1313 1315 emitOpcode(op_new_func); 1314 1316 instructions().append(dst->index()); 1315 instructions().append( addConstant(body));1317 instructions().append(index); 1316 1318 return dst; 1317 1319 } … … 1328 1330 RegisterID* BytecodeGenerator::emitNewFunctionExpression(RegisterID* r0, FuncExprNode* n) 1329 1331 { 1332 FunctionBodyNode* function = n->body(); 1333 unsigned index = m_codeBlock->addFunctionExpr(adoptRef(new FunctionExecutable(function->ident(), function))); 1334 1330 1335 emitOpcode(op_new_func_exp); 1331 1336 instructions().append(r0->index()); 1332 instructions().append( addConstant(n->body()));1337 instructions().append(index); 1333 1338 return r0; 1334 1339 } -
trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.h
r47265 r47412 414 414 } 415 415 416 unsigned addConstant(FunctionBodyNode*);417 416 unsigned addConstant(const Identifier&); 418 417 RegisterID* addConstantValue(JSValue); -
trunk/JavaScriptCore/debugger/Debugger.cpp
r47304 r47412 62 62 return; 63 63 64 Vector<ProtectedPtr<JSFunction> > functions; 64 typedef HashSet<FunctionExecutable*> FunctionExecutableSet; 65 typedef HashMap<SourceProvider*, ExecState*> SourceProviderMap; 66 67 FunctionExecutableSet functionExecutables; 68 SourceProviderMap sourceProviders; 69 65 70 Heap::iterator heapEnd = globalData->heap.primaryHeapEnd(); 66 71 for (Heap::iterator it = globalData->heap.primaryHeapBegin(); it != heapEnd; ++it) { 67 if ((*it)->inherits(&JSFunction::info)) { 68 JSFunction* function = asFunction(*it); 69 if (!function->body()->isHostFunction()) 70 functions.append(function); 71 } 72 if (!(*it)->inherits(&JSFunction::info)) 73 continue; 74 75 JSFunction* function = asFunction(*it); 76 if (function->executable()->isHostFunction()) 77 continue; 78 79 FunctionExecutable* executable = function->executable(); 80 81 // Check if the function is already in the set - if so, 82 // we've already retranslated it, nothing to do here. 83 if (!functionExecutables.add(executable).second) 84 continue; 85 86 ExecState* exec = function->scope().globalObject()->JSGlobalObject::globalExec(); 87 executable->recompile(exec); 88 if (function->scope().globalObject()->debugger() == this) 89 sourceProviders.add(executable->source().provider(), exec); 72 90 } 73 91 74 typedef HashMap<RefPtr<FunctionBodyNode>, RefPtr<FunctionBodyNode> > FunctionBodyMap;75 typedef HashMap<SourceProvider*, ExecState*> SourceProviderMap;76 77 FunctionBodyMap functionBodies;78 SourceProviderMap sourceProviders;79 80 size_t size = functions.size();81 for (size_t i = 0; i < size; ++i) {82 JSFunction* function = functions[i];83 84 FunctionBodyNode* oldBody = function->body();85 pair<FunctionBodyMap::iterator, bool> result = functionBodies.add(oldBody, 0);86 if (!result.second) {87 function->setBody(result.first->second);88 continue;89 }90 91 ExecState* exec = function->scope().globalObject()->JSGlobalObject::globalExec();92 const SourceCode& sourceCode = oldBody->source();93 94 RefPtr<FunctionBodyNode> newBody = globalData->parser->parse<FunctionBodyNode>(exec, 0, sourceCode);95 ASSERT(newBody);96 newBody->finishParsing(oldBody->copyParameters(), oldBody->parameterCount(), oldBody->ident());97 98 result.first->second = newBody;99 function->setBody(newBody.release());100 101 if (function->scope().globalObject()->debugger() == this)102 sourceProviders.add(sourceCode.provider(), exec);103 }104 92 105 93 // Call sourceParsed() after reparsing all functions because it will execute -
trunk/JavaScriptCore/interpreter/CachedCall.h
r45891 r47412 41 41 , m_globalObjectScope(callFrame, callFrame->globalData().dynamicGlobalObject ? callFrame->globalData().dynamicGlobalObject : function->scope().node()->globalObject()) 42 42 { 43 m_closure = m_interpreter->prepareForRepeatCall(function-> body(), callFrame, function, argCount, function->scope().node(), exception);43 m_closure = m_interpreter->prepareForRepeatCall(function->executable(), callFrame, function, argCount, function->scope().node(), exception); 44 44 m_valid = !*exception; 45 45 } -
trunk/JavaScriptCore/interpreter/CallFrameClosure.h
r46598 r47412 33 33 CallFrame* newCallFrame; 34 34 JSFunction* function; 35 Function BodyNode* functionBody;35 FunctionExecutable* functionExecutable; 36 36 JSGlobalData* globalData; 37 37 Register* oldEnd; -
trunk/JavaScriptCore/interpreter/Interpreter.cpp
r47405 r47412 490 490 DebuggerCallFrame debuggerCallFrame(callFrame, exceptionValue); 491 491 if (callFrame->callee()) 492 debugger->returnEvent(debuggerCallFrame, codeBlock->owner Node()->sourceID(), codeBlock->ownerNode()->lastLine());492 debugger->returnEvent(debuggerCallFrame, codeBlock->ownerExecutable()->sourceID(), codeBlock->ownerExecutable()->lastLine()); 493 493 else 494 debugger->didExecuteProgram(debuggerCallFrame, codeBlock->owner Node()->sourceID(), codeBlock->ownerNode()->lastLine());494 debugger->didExecuteProgram(debuggerCallFrame, codeBlock->ownerExecutable()->sourceID(), codeBlock->ownerExecutable()->lastLine()); 495 495 } 496 496 … … 499 499 profiler->didExecute(callFrame, callFrame->callee()); 500 500 else 501 profiler->didExecute(callFrame, codeBlock->owner Node()->sourceURL(), codeBlock->ownerNode()->lineNo());501 profiler->didExecute(callFrame, codeBlock->ownerExecutable()->sourceURL(), codeBlock->ownerExecutable()->lineNo()); 502 502 } 503 503 … … 555 555 } else 556 556 exception->putWithAttributes(callFrame, Identifier(callFrame, "line"), jsNumber(callFrame, codeBlock->lineNumberForBytecodeOffset(callFrame, bytecodeOffset)), ReadOnly | DontDelete); 557 exception->putWithAttributes(callFrame, Identifier(callFrame, "sourceId"), jsNumber(callFrame, codeBlock->owner Node()->sourceID()), ReadOnly | DontDelete);558 exception->putWithAttributes(callFrame, Identifier(callFrame, "sourceURL"), jsOwnedString(callFrame, codeBlock->owner Node()->sourceURL()), ReadOnly | DontDelete);557 exception->putWithAttributes(callFrame, Identifier(callFrame, "sourceId"), jsNumber(callFrame, codeBlock->ownerExecutable()->sourceID()), ReadOnly | DontDelete); 558 exception->putWithAttributes(callFrame, Identifier(callFrame, "sourceURL"), jsOwnedString(callFrame, codeBlock->ownerExecutable()->sourceURL()), ReadOnly | DontDelete); 559 559 } 560 560 … … 570 570 if (Debugger* debugger = callFrame->dynamicGlobalObject()->debugger()) { 571 571 DebuggerCallFrame debuggerCallFrame(callFrame, exceptionValue); 572 debugger->exception(debuggerCallFrame, codeBlock->owner Node()->sourceID(), codeBlock->lineNumberForBytecodeOffset(callFrame, bytecodeOffset));572 debugger->exception(debuggerCallFrame, codeBlock->ownerExecutable()->sourceID(), codeBlock->lineNumberForBytecodeOffset(callFrame, bytecodeOffset)); 573 573 } 574 574 … … 671 671 } 672 672 673 JSValue Interpreter::execute(Function BodyNode* functionBodyNode, CallFrame* callFrame, JSFunction* function, JSObject* thisObj, const ArgList& args, ScopeChainNode* scopeChain, JSValue* exception)673 JSValue Interpreter::execute(FunctionExecutable* functionExecutable, CallFrame* callFrame, JSFunction* function, JSObject* thisObj, const ArgList& args, ScopeChainNode* scopeChain, JSValue* exception) 674 674 { 675 675 ASSERT(!scopeChain->globalData->exception); … … 699 699 newCallFrame->r(++dst) = *it; 700 700 701 CodeBlock* codeBlock = &function BodyNode->bytecode(scopeChain);701 CodeBlock* codeBlock = &functionExecutable->bytecode(scopeChain); 702 702 newCallFrame = slideRegisterWindowForCall(codeBlock, &m_registerFile, newCallFrame, argc + RegisterFile::CallFrameHeaderSize, argc); 703 703 if (UNLIKELY(!newCallFrame)) { … … 719 719 m_reentryDepth++; 720 720 #if ENABLE(JIT) 721 result = function BodyNode->jitCode(scopeChain).execute(&m_registerFile, newCallFrame, scopeChain->globalData, exception);721 result = functionExecutable->jitCode(scopeChain).execute(&m_registerFile, newCallFrame, scopeChain->globalData, exception); 722 722 #else 723 723 result = privateExecute(Normal, &m_registerFile, newCallFrame, exception); … … 733 733 } 734 734 735 CallFrameClosure Interpreter::prepareForRepeatCall(Function BodyNode* functionBodyNode, CallFrame* callFrame, JSFunction* function, int argCount, ScopeChainNode* scopeChain, JSValue* exception)735 CallFrameClosure Interpreter::prepareForRepeatCall(FunctionExecutable* FunctionExecutable, CallFrame* callFrame, JSFunction* function, int argCount, ScopeChainNode* scopeChain, JSValue* exception) 736 736 { 737 737 ASSERT(!scopeChain->globalData->exception); … … 757 757 newCallFrame->r(++dst) = jsUndefined(); 758 758 759 CodeBlock* codeBlock = & functionBodyNode->bytecode(scopeChain);759 CodeBlock* codeBlock = &FunctionExecutable->bytecode(scopeChain); 760 760 newCallFrame = slideRegisterWindowForCall(codeBlock, &m_registerFile, newCallFrame, argc + RegisterFile::CallFrameHeaderSize, argc); 761 761 if (UNLIKELY(!newCallFrame)) { … … 767 767 newCallFrame->init(codeBlock, 0, scopeChain, callFrame->addHostCallFrameFlag(), 0, argc, function); 768 768 #if ENABLE(JIT) 769 functionBodyNode->jitCode(scopeChain);769 FunctionExecutable->jitCode(scopeChain); 770 770 #endif 771 771 772 CallFrameClosure result = { callFrame, newCallFrame, function, functionBodyNode, scopeChain->globalData, oldEnd, scopeChain, codeBlock->m_numParameters, argc };772 CallFrameClosure result = { callFrame, newCallFrame, function, FunctionExecutable, scopeChain->globalData, oldEnd, scopeChain, codeBlock->m_numParameters, argc }; 773 773 return result; 774 774 } … … 787 787 m_reentryDepth++; 788 788 #if ENABLE(JIT) 789 result = closure.function Body->generatedJITCode().execute(&m_registerFile, closure.newCallFrame, closure.globalData, exception);789 result = closure.functionExecutable->generatedJITCode().execute(&m_registerFile, closure.newCallFrame, closure.globalData, exception); 790 790 #else 791 791 result = privateExecute(Normal, &m_registerFile, closure.newCallFrame, exception); … … 837 837 BatchedTransitionOptimizer optimizer(variableObject); 838 838 839 const DeclarationStacks::VarStack& varStack = codeBlock->ownerNode()->varStack();839 const DeclarationStacks::VarStack& varStack = static_cast<EvalExecutable*>(codeBlock->ownerExecutable())->varStack(); 840 840 DeclarationStacks::VarStack::const_iterator varStackEnd = varStack.end(); 841 841 for (DeclarationStacks::VarStack::const_iterator it = varStack.begin(); it != varStackEnd; ++it) { … … 847 847 } 848 848 849 const DeclarationStacks::FunctionStack& functionStack = codeBlock->ownerNode()->functionStack();850 DeclarationStacks::FunctionStack::const_iterator functionStackEnd = functionStack.end();851 for (DeclarationStacks::FunctionStack::const_iterator it = functionStack.begin(); it != functionStackEnd; ++it) {849 int numFunctions = codeBlock->numberOfFunctionDecls(); 850 for (int i = 0; i < numFunctions; ++i) { 851 FunctionExecutable* function = codeBlock->functionDecl(i); 852 852 PutPropertySlot slot; 853 variableObject->put(callFrame, (*it)->ident(), (*it)->make(callFrame, scopeChain), slot);853 variableObject->put(callFrame, function->name(), function->make(callFrame, scopeChain), slot); 854 854 } 855 855 … … 904 904 switch (debugHookID) { 905 905 case DidEnterCallFrame: 906 debugger->callEvent(callFrame, callFrame->codeBlock()->owner Node()->sourceID(), firstLine);906 debugger->callEvent(callFrame, callFrame->codeBlock()->ownerExecutable()->sourceID(), firstLine); 907 907 return; 908 908 case WillLeaveCallFrame: 909 debugger->returnEvent(callFrame, callFrame->codeBlock()->owner Node()->sourceID(), lastLine);909 debugger->returnEvent(callFrame, callFrame->codeBlock()->ownerExecutable()->sourceID(), lastLine); 910 910 return; 911 911 case WillExecuteStatement: 912 debugger->atStatement(callFrame, callFrame->codeBlock()->owner Node()->sourceID(), firstLine);912 debugger->atStatement(callFrame, callFrame->codeBlock()->ownerExecutable()->sourceID(), firstLine); 913 913 return; 914 914 case WillExecuteProgram: 915 debugger->willExecuteProgram(callFrame, callFrame->codeBlock()->owner Node()->sourceID(), firstLine);915 debugger->willExecuteProgram(callFrame, callFrame->codeBlock()->ownerExecutable()->sourceID(), firstLine); 916 916 return; 917 917 case DidExecuteProgram: 918 debugger->didExecuteProgram(callFrame, callFrame->codeBlock()->owner Node()->sourceID(), lastLine);918 debugger->didExecuteProgram(callFrame, callFrame->codeBlock()->ownerExecutable()->sourceID(), lastLine); 919 919 return; 920 920 case DidReachBreakpoint: 921 debugger->didReachBreakpoint(callFrame, callFrame->codeBlock()->owner Node()->sourceID(), lastLine);921 debugger->didReachBreakpoint(callFrame, callFrame->codeBlock()->ownerExecutable()->sourceID(), lastLine); 922 922 return; 923 923 } … … 2921 2921 int func = (++vPC)->u.operand; 2922 2922 2923 callFrame->r(dst) = JSValue(callFrame->codeBlock()->function (func)->make(callFrame, callFrame->scopeChain()));2923 callFrame->r(dst) = JSValue(callFrame->codeBlock()->functionDecl(func)->make(callFrame, callFrame->scopeChain())); 2924 2924 2925 2925 ++vPC; … … 2937 2937 int funcIndex = (++vPC)->u.operand; 2938 2938 2939 Function BodyNode* body = callFrame->codeBlock()->function(funcIndex);2940 JSFunction* func = body->make(callFrame, callFrame->scopeChain());2939 FunctionExecutable* function = callFrame->codeBlock()->functionExpr(funcIndex); 2940 JSFunction* func = function->make(callFrame, callFrame->scopeChain()); 2941 2941 2942 2942 /* … … 2947 2947 does not affect the scope enclosing the FunctionExpression. 2948 2948 */ 2949 if (! body->ident().isNull()) {2950 JSStaticScopeObject* functionScopeObject = new (callFrame) JSStaticScopeObject(callFrame, body->ident(), func, ReadOnly | DontDelete);2949 if (!function->name().isNull()) { 2950 JSStaticScopeObject* functionScopeObject = new (callFrame) JSStaticScopeObject(callFrame, function->name(), func, ReadOnly | DontDelete); 2951 2951 func->scope().push(functionScopeObject); 2952 2952 } … … 3018 3018 if (callType == CallTypeJS) { 3019 3019 ScopeChainNode* callDataScopeChain = callData.js.scopeChain; 3020 FunctionBodyNode* functionBodyNode = callData.js.functionBody; 3021 CodeBlock* newCodeBlock = &functionBodyNode->bytecode(callDataScopeChain); 3020 CodeBlock* newCodeBlock = &callData.js.functionExecutable->bytecode(callDataScopeChain); 3022 3021 3023 3022 CallFrame* previousCallFrame = callFrame; … … 3085 3084 goto vm_throw; 3086 3085 } 3087 int32_t expectedParams = callFrame->callee()-> body()->parameterCount();3086 int32_t expectedParams = callFrame->callee()->executable()->parameterCount(); 3088 3087 int32_t inplaceArgs = min(argCount, expectedParams); 3089 3088 int32_t i = 0; … … 3172 3171 if (callType == CallTypeJS) { 3173 3172 ScopeChainNode* callDataScopeChain = callData.js.scopeChain; 3174 FunctionBodyNode* functionBodyNode = callData.js.functionBody; 3175 CodeBlock* newCodeBlock = &functionBodyNode->bytecode(callDataScopeChain); 3173 CodeBlock* newCodeBlock = &callData.js.functionExecutable->bytecode(callDataScopeChain); 3176 3174 3177 3175 CallFrame* previousCallFrame = callFrame; … … 3335 3333 3336 3334 int dst = (++vPC)->u.operand; 3337 JSActivation* activation = new (globalData) JSActivation(callFrame, static_cast<Function BodyNode*>(codeBlock->ownerNode()));3335 JSActivation* activation = new (globalData) JSActivation(callFrame, static_cast<FunctionExecutable*>(codeBlock->ownerExecutable())); 3338 3336 callFrame->r(dst) = JSValue(activation); 3339 3337 callFrame->setScopeChain(callFrame->scopeChain()->copy()->push(activation)); … … 3421 3419 if (constructType == ConstructTypeJS) { 3422 3420 ScopeChainNode* callDataScopeChain = constructData.js.scopeChain; 3423 FunctionBodyNode* functionBodyNode = constructData.js.functionBody; 3424 CodeBlock* newCodeBlock = &functionBodyNode->bytecode(callDataScopeChain); 3421 CodeBlock* newCodeBlock = &constructData.js.functionExecutable->bytecode(callDataScopeChain); 3425 3422 3426 3423 Structure* structure; … … 3672 3669 3673 3670 CodeBlock* codeBlock = callFrame->codeBlock(); 3674 callFrame->r(dst) = JSValue(Error::create(callFrame, (ErrorType)type, callFrame->r(message).jsValue().toString(callFrame), codeBlock->lineNumberForBytecodeOffset(callFrame, vPC - codeBlock->instructions().begin()), codeBlock->owner Node()->sourceID(), codeBlock->ownerNode()->sourceURL()));3671 callFrame->r(dst) = JSValue(Error::create(callFrame, (ErrorType)type, callFrame->r(message).jsValue().toString(callFrame), codeBlock->lineNumberForBytecodeOffset(callFrame, vPC - codeBlock->instructions().begin()), codeBlock->ownerExecutable()->sourceID(), codeBlock->ownerExecutable()->sourceURL())); 3675 3672 3676 3673 ++vPC; … … 3900 3897 unsigned bytecodeOffset = bytecodeOffsetForPC(callerFrame, callerCodeBlock, callFrame->returnPC()); 3901 3898 lineNumber = callerCodeBlock->lineNumberForBytecodeOffset(callerFrame, bytecodeOffset - 1); 3902 sourceID = callerCodeBlock->owner Node()->sourceID();3903 sourceURL = callerCodeBlock->owner Node()->sourceURL();3899 sourceID = callerCodeBlock->ownerExecutable()->sourceID(); 3900 sourceURL = callerCodeBlock->ownerExecutable()->sourceURL(); 3904 3901 function = callerFrame->callee(); 3905 3902 } -
trunk/JavaScriptCore/interpreter/Interpreter.h
r47304 r47412 44 44 class CodeBlock; 45 45 class EvalExecutable; 46 class Function BodyNode;46 class FunctionExecutable; 47 47 class InternalFunction; 48 48 class JSFunction; … … 97 97 98 98 JSValue execute(ProgramExecutable*, CallFrame*, ScopeChainNode*, JSObject* thisObj, JSValue* exception); 99 JSValue execute(Function BodyNode*, CallFrame*, JSFunction*, JSObject* thisObj, const ArgList& args, ScopeChainNode*, JSValue* exception);99 JSValue execute(FunctionExecutable*, CallFrame*, JSFunction*, JSObject* thisObj, const ArgList& args, ScopeChainNode*, JSValue* exception); 100 100 JSValue execute(EvalExecutable* evalNode, CallFrame* exec, JSObject* thisObj, ScopeChainNode* scopeChain, JSValue* exception); 101 101 … … 116 116 enum ExecutionFlag { Normal, InitializeAndReturn }; 117 117 118 CallFrameClosure prepareForRepeatCall(Function BodyNode*, CallFrame*, JSFunction*, int argCount, ScopeChainNode*, JSValue* exception);118 CallFrameClosure prepareForRepeatCall(FunctionExecutable*, CallFrame*, JSFunction*, int argCount, ScopeChainNode*, JSValue* exception); 119 119 void endRepeatCall(CallFrameClosure&); 120 120 JSValue execute(CallFrameClosure&, JSValue* exception); -
trunk/JavaScriptCore/jit/JIT.cpp
r46879 r47412 439 439 } 440 440 441 voidJIT::privateCompile()441 JITCode JIT::privateCompile() 442 442 { 443 443 sampleCodeBlock(m_codeBlock); … … 553 553 } 554 554 555 m_codeBlock->setJITCode(patchBuffer.finalizeCode());555 return patchBuffer.finalizeCode(); 556 556 } 557 557 -
trunk/JavaScriptCore/jit/JIT.h
r47186 r47412 278 278 279 279 public: 280 static void compile(JSGlobalData* globalData, CodeBlock* codeBlock) 281 { 282 JIT jit(globalData, codeBlock); 283 jit.privateCompile(); 280 static JITCode compile(JSGlobalData* globalData, CodeBlock* codeBlock) 281 { 282 return JIT(globalData, codeBlock).privateCompile(); 284 283 } 285 284 … … 354 353 void privateCompileLinkPass(); 355 354 void privateCompileSlowCases(); 356 voidprivateCompile();355 JITCode privateCompile(); 357 356 void privateCompileGetByIdProto(StructureStubInfo*, Structure*, Structure* prototypeStructure, size_t cachedOffset, ReturnAddressPtr returnAddress, CallFrame* callFrame); 358 357 void privateCompileGetByIdSelfList(StructureStubInfo*, PolymorphicAccessStructureList*, int, Structure*, size_t cachedOffset); -
trunk/JavaScriptCore/jit/JITOpcodes.cpp
r47089 r47412 69 69 70 70 // regT0 holds callee, regT1 holds argCount. 71 loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_ body)), regT2);72 loadPtr(Address(regT2, OBJECT_OFFSETOF(Function BodyNode, m_code)), regT2);71 loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_executable)), regT2); 72 loadPtr(Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_codeBlock)), regT2); 73 73 Jump hasCodeBlock2 = branchTestPtr(NonZero, regT2); 74 74 … … 115 115 116 116 // regT0 holds callee, regT1 holds argCount. 117 loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_ body)), regT2);118 loadPtr(Address(regT2, OBJECT_OFFSETOF(Function BodyNode, m_code)), regT2);117 loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_executable)), regT2); 118 loadPtr(Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_codeBlock)), regT2); 119 119 Jump hasCodeBlock3 = branchTestPtr(NonZero, regT2); 120 120 … … 147 147 isNativeFunc3.link(this); 148 148 compileOpCallInitializeCallFrame(); 149 loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_ body)), regT0);150 loadPtr(Address(regT0, OBJECT_OFFSETOF(Function BodyNode, m_jitCode)), regT0);149 loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_executable)), regT0); 150 loadPtr(Address(regT0, OBJECT_OFFSETOF(FunctionExecutable, m_jitCode)), regT0); 151 151 jump(regT0); 152 152 … … 545 545 { 546 546 JITStubCall stubCall(this, cti_op_new_func); 547 stubCall.addArgument(ImmPtr(m_codeBlock->function (currentInstruction[2].u.operand)));547 stubCall.addArgument(ImmPtr(m_codeBlock->functionDecl(currentInstruction[2].u.operand))); 548 548 stubCall.call(currentInstruction[1].u.operand); 549 549 } … … 1181 1181 { 1182 1182 JITStubCall stubCall(this, cti_op_new_func_exp); 1183 stubCall.addArgument(ImmPtr(m_codeBlock->function (currentInstruction[2].u.operand)));1183 stubCall.addArgument(ImmPtr(m_codeBlock->functionExpr(currentInstruction[2].u.operand))); 1184 1184 stubCall.call(currentInstruction[1].u.operand); 1185 1185 } … … 1488 1488 1489 1489 // Load the callee CodeBlock* into eax 1490 loadPtr(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_ body)), regT3);1491 loadPtr(Address(regT3, OBJECT_OFFSETOF(Function BodyNode, m_code)), regT0);1490 loadPtr(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_executable)), regT3); 1491 loadPtr(Address(regT3, OBJECT_OFFSETOF(FunctionExecutable, m_codeBlock)), regT0); 1492 1492 Jump hasCodeBlock2 = branchTestPtr(NonZero, regT0); 1493 1493 preserveReturnAddressAfterCall(regT3); … … 1528 1528 1529 1529 // Load the callee CodeBlock* into eax 1530 loadPtr(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_ body)), regT3);1531 loadPtr(Address(regT3, OBJECT_OFFSETOF(Function BodyNode, m_code)), regT0);1530 loadPtr(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_executable)), regT3); 1531 loadPtr(Address(regT3, OBJECT_OFFSETOF(FunctionExecutable, m_codeBlock)), regT0); 1532 1532 Jump hasCodeBlock3 = branchTestPtr(NonZero, regT0); 1533 1533 preserveReturnAddressAfterCall(regT3); … … 1537 1537 emitGetJITStubArg(3, regT1); 1538 1538 restoreReturnAddressBeforeReturn(regT3); 1539 loadPtr(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_ body)), regT3); // reload the function body nody, so we can reload the code pointer.1539 loadPtr(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_executable)), regT3); // reload the function body nody, so we can reload the code pointer. 1540 1540 hasCodeBlock3.link(this); 1541 1541 … … 1553 1553 emitGetJITStubArg(3, regT1); 1554 1554 restoreReturnAddressBeforeReturn(regT3); 1555 loadPtr(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_ body)), regT3); // reload the function body nody, so we can reload the code pointer.1555 loadPtr(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_executable)), regT3); // reload the function body nody, so we can reload the code pointer. 1556 1556 arityCheckOkay3.link(this); 1557 1557 isNativeFunc3.link(this); 1558 1558 1559 1559 // load ctiCode from the new codeBlock. 1560 loadPtr(Address(regT3, OBJECT_OFFSETOF(Function BodyNode, m_jitCode)), regT0);1560 loadPtr(Address(regT3, OBJECT_OFFSETOF(FunctionExecutable, m_jitCode)), regT0); 1561 1561 1562 1562 compileOpCallInitializeCallFrame(); … … 1972 1972 { 1973 1973 JITStubCall stubCall(this, cti_op_new_func); 1974 stubCall.addArgument(ImmPtr(m_codeBlock->function (currentInstruction[2].u.operand)));1974 stubCall.addArgument(ImmPtr(m_codeBlock->functionDecl(currentInstruction[2].u.operand))); 1975 1975 stubCall.call(currentInstruction[1].u.operand); 1976 1976 } … … 2326 2326 { 2327 2327 JITStubCall stubCall(this, cti_op_new_func_exp); 2328 stubCall.addArgument(ImmPtr(m_codeBlock->function (currentInstruction[2].u.operand)));2328 stubCall.addArgument(ImmPtr(m_codeBlock->functionExpr(currentInstruction[2].u.operand))); 2329 2329 stubCall.call(currentInstruction[1].u.operand); 2330 2330 } -
trunk/JavaScriptCore/jit/JITStubs.cpp
r47236 r47412 1481 1481 1482 1482 JSFunction* function = asFunction(stackFrame.args[0].jsValue()); 1483 Function BodyNode* body = function->body();1484 ASSERT(! body->isHostFunction());1483 FunctionExecutable* executable = function->executable(); 1484 ASSERT(!executable->isHostFunction()); 1485 1485 ScopeChainNode* callDataScopeChain = function->scope().node(); 1486 body->jitCode(callDataScopeChain);1487 1488 return & body->generatedBytecode();1486 executable->jitCode(callDataScopeChain); 1487 1488 return &executable->generatedBytecode(); 1489 1489 } 1490 1490 … … 1540 1540 STUB_INIT_STACK_FRAME(stackFrame); 1541 1541 JSFunction* callee = asFunction(stackFrame.args[0].jsValue()); 1542 Function BodyNode* body = callee->body();1543 JITCode& jitCode = body->generatedJITCode();1542 FunctionExecutable* executable = callee->executable(); 1543 JITCode& jitCode = executable->generatedJITCode(); 1544 1544 1545 1545 CodeBlock* codeBlock = 0; 1546 if (! body->isHostFunction())1547 codeBlock = & body->bytecode(callee->scope().node());1546 if (!executable->isHostFunction()) 1547 codeBlock = &executable->bytecode(callee->scope().node()); 1548 1548 else 1549 codeBlock = & body->generatedBytecode();1549 codeBlock = &executable->generatedBytecode(); 1550 1550 CallLinkInfo* callLinkInfo = &stackFrame.callFrame->callerFrame()->codeBlock()->getCallLinkInfo(stackFrame.args[1].returnAddress()); 1551 1551 … … 1563 1563 STUB_INIT_STACK_FRAME(stackFrame); 1564 1564 1565 JSActivation* activation = new (stackFrame.globalData) JSActivation(stackFrame.callFrame, static_cast<Function BodyNode*>(stackFrame.callFrame->codeBlock()->ownerNode()));1565 JSActivation* activation = new (stackFrame.globalData) JSActivation(stackFrame.callFrame, static_cast<FunctionExecutable*>(stackFrame.callFrame->codeBlock()->ownerExecutable())); 1566 1566 stackFrame.callFrame->setScopeChain(stackFrame.callFrame->scopeChain()->copy()->push(activation)); 1567 1567 return activation; … … 1717 1717 1718 1718 JSFunction* constructor = asFunction(stackFrame.args[0].jsValue()); 1719 Function BodyNode* body = constructor->body();1720 if ( body && body->isHostFunction()) {1719 FunctionExecutable* executable = constructor->executable(); 1720 if (executable && executable->isHostFunction()) { 1721 1721 CallFrame* callFrame = stackFrame.callFrame; 1722 1722 CodeBlock* codeBlock = callFrame->codeBlock(); … … 2045 2045 VM_THROW_EXCEPTION(); 2046 2046 } 2047 int32_t expectedParams = callFrame->callee()-> body()->parameterCount();2047 int32_t expectedParams = callFrame->callee()->executable()->parameterCount(); 2048 2048 int32_t inplaceArgs = min(providedParams, expectedParams); 2049 2049 … … 2522 2522 CallFrame* callFrame = stackFrame.callFrame; 2523 2523 2524 Function BodyNode* body= stackFrame.args[0].function();2525 JSFunction* func = body->make(callFrame, callFrame->scopeChain());2524 FunctionExecutable* function = stackFrame.args[0].function(); 2525 JSFunction* func = function->make(callFrame, callFrame->scopeChain()); 2526 2526 2527 2527 /* … … 2532 2532 does not affect the scope enclosing the FunctionExpression. 2533 2533 */ 2534 if (! body->ident().isNull()) {2535 JSStaticScopeObject* functionScopeObject = new (callFrame) JSStaticScopeObject(callFrame, body->ident(), func, ReadOnly | DontDelete);2534 if (!function->name().isNull()) { 2535 JSStaticScopeObject* functionScopeObject = new (callFrame) JSStaticScopeObject(callFrame, function->name(), func, ReadOnly | DontDelete); 2536 2536 func->scope().push(functionScopeObject); 2537 2537 } … … 2997 2997 2998 2998 unsigned lineNumber = codeBlock->lineNumberForBytecodeOffset(callFrame, bytecodeOffset); 2999 return Error::create(callFrame, static_cast<ErrorType>(type), message.toString(callFrame), lineNumber, codeBlock->owner Node()->sourceID(), codeBlock->ownerNode()->sourceURL());2999 return Error::create(callFrame, static_cast<ErrorType>(type), message.toString(callFrame), lineNumber, codeBlock->ownerExecutable()->sourceID(), codeBlock->ownerExecutable()->sourceURL()); 3000 3000 } 3001 3001 -
trunk/JavaScriptCore/jit/JITStubs.h
r47089 r47412 43 43 class CodeBlock; 44 44 class ExecutablePool; 45 class Function BodyNode;45 class FunctionExecutable; 46 46 class Identifier; 47 47 class JSGlobalData; … … 67 67 int32_t int32() { return asInt32; } 68 68 CodeBlock* codeBlock() { return static_cast<CodeBlock*>(asPointer); } 69 Function BodyNode* function() { return static_cast<FunctionBodyNode*>(asPointer); }69 FunctionExecutable* function() { return static_cast<FunctionExecutable*>(asPointer); } 70 70 RegExp* regExp() { return static_cast<RegExp*>(asPointer); } 71 71 JSPropertyNameIterator* propertyNameIterator() { return static_cast<JSPropertyNameIterator*>(asPointer); } -
trunk/JavaScriptCore/parser/Nodes.cpp
r47304 r47412 1825 1825 } 1826 1826 1827 void ScopeNodeData::markAggregate(MarkStack& markStack)1828 {1829 FunctionStack::iterator end = m_functionStack.end();1830 for (FunctionStack::iterator ptr = m_functionStack.begin(); ptr != end; ++ptr) {1831 FunctionBodyNode* body = *ptr;1832 if (!body->isGenerated())1833 continue;1834 body->generatedBytecode().markAggregate(markStack);1835 }1836 }1837 1838 1827 // ------------------------------ ScopeNode ----------------------------- 1839 1828 … … 1893 1882 } 1894 1883 1895 void ProgramNode::generateBytecode(ScopeChainNode* scopeChainNode)1896 {1897 ScopeChain scopeChain(scopeChainNode);1898 JSGlobalObject* globalObject = scopeChain.globalObject();1899 1900 m_code.set(new ProgramCodeBlock(this, GlobalCode, globalObject, source().provider()));1901 1902 OwnPtr<BytecodeGenerator> generator(new BytecodeGenerator(this, globalObject->debugger(), scopeChain, &globalObject->symbolTable(), m_code.get()));1903 generator->generate();1904 1905 destroyData();1906 }1907 1908 #if ENABLE(JIT)1909 void ProgramNode::generateJITCode(ScopeChainNode* scopeChainNode)1910 {1911 bytecode(scopeChainNode);1912 ASSERT(m_code);1913 ASSERT(!m_jitCode);1914 JIT::compile(scopeChainNode->globalData, m_code.get());1915 ASSERT(m_jitCode);1916 }1917 #endif1918 1919 1884 // ------------------------------ EvalNode ----------------------------- 1920 1885 … … 1947 1912 return 0; 1948 1913 } 1949 1950 void EvalNode::generateBytecode(ScopeChainNode* scopeChainNode)1951 {1952 ScopeChain scopeChain(scopeChainNode);1953 JSGlobalObject* globalObject = scopeChain.globalObject();1954 1955 m_code.set(new EvalCodeBlock(this, globalObject, source().provider(), scopeChain.localDepth()));1956 1957 OwnPtr<BytecodeGenerator> generator(new BytecodeGenerator(this, globalObject->debugger(), scopeChain, &m_code->symbolTable(), m_code.get()));1958 generator->generate();1959 1960 // Eval code needs to hang on to its declaration stacks to keep declaration info alive until Interpreter::execute time,1961 // so the entire ScopeNodeData cannot be destoyed.1962 children().clear();1963 }1964 1965 EvalCodeBlock& EvalNode::bytecodeForExceptionInfoReparse(ScopeChainNode* scopeChainNode, CodeBlock* codeBlockBeingRegeneratedFrom)1966 {1967 ASSERT(!m_code);1968 1969 ScopeChain scopeChain(scopeChainNode);1970 JSGlobalObject* globalObject = scopeChain.globalObject();1971 1972 m_code.set(new EvalCodeBlock(this, globalObject, source().provider(), scopeChain.localDepth()));1973 1974 OwnPtr<BytecodeGenerator> generator(new BytecodeGenerator(this, globalObject->debugger(), scopeChain, &m_code->symbolTable(), m_code.get()));1975 generator->setRegeneratingForExceptionInfo(codeBlockBeingRegeneratedFrom);1976 generator->generate();1977 1978 return *m_code;1979 }1980 1981 void EvalNode::markAggregate(MarkStack& markStack)1982 {1983 // We don't need to mark our own CodeBlock as the JSGlobalObject takes care of that1984 data()->markAggregate(markStack);1985 }1986 1987 #if ENABLE(JIT)1988 void EvalNode::generateJITCode(ScopeChainNode* scopeChainNode)1989 {1990 bytecode(scopeChainNode);1991 ASSERT(m_code);1992 ASSERT(!m_jitCode);1993 JIT::compile(scopeChainNode->globalData, m_code.get());1994 ASSERT(m_jitCode);1995 }1996 #endif1997 1914 1998 1915 // ------------------------------ FunctionBodyNode ----------------------------- … … 2038 1955 } 2039 1956 2040 void FunctionBodyNode::markAggregate(MarkStack& markStack)2041 {2042 if (m_code)2043 m_code->markAggregate(markStack);2044 }2045 2046 #if ENABLE(JIT)2047 PassRefPtr<FunctionBodyNode> FunctionBodyNode::createNativeThunk(JSGlobalData* globalData)2048 {2049 RefPtr<FunctionBodyNode> body = new FunctionBodyNode(globalData);2050 globalData->parser->arena().reset();2051 body->m_code.set(new NativeCodeBlock(body.get()));2052 body->m_jitCode = JITCode(JITCode::HostFunction(globalData->jitStubs.ctiNativeCallThunk()));2053 return body.release();2054 }2055 #endif2056 2057 bool FunctionBodyNode::isHostFunction() const2058 {2059 return m_code && m_code->codeType() == NativeCode;2060 }2061 2062 1957 FunctionBodyNode* FunctionBodyNode::create(JSGlobalData* globalData) 2063 1958 { … … 2076 1971 } 2077 1972 2078 void FunctionBodyNode:: generateBytecode(ScopeChainNode* scopeChainNode)1973 void FunctionBodyNode::reparseDataIfNecessary(ScopeChainNode* scopeChainNode) 2079 1974 { 2080 1975 // This branch is only necessary since you can still create a non-stub FunctionBodyNode by … … 2083 1978 scopeChainNode->globalData->parser->reparseInPlace(scopeChainNode->globalData, this); 2084 1979 ASSERT(data()); 2085 2086 ScopeChain scopeChain(scopeChainNode);2087 JSGlobalObject* globalObject = scopeChain.globalObject();2088 2089 m_code.set(new FunctionCodeBlock(this, FunctionCode, source().provider(), source().startOffset()));2090 2091 OwnPtr<BytecodeGenerator> generator(new BytecodeGenerator(this, globalObject->debugger(), scopeChain, &m_code->symbolTable(), m_code.get()));2092 generator->generate();2093 2094 destroyData();2095 }2096 2097 #if ENABLE(JIT)2098 void FunctionBodyNode::generateJITCode(ScopeChainNode* scopeChainNode)2099 {2100 bytecode(scopeChainNode);2101 ASSERT(m_code);2102 ASSERT(!m_jitCode);2103 JIT::compile(scopeChainNode->globalData, m_code.get());2104 ASSERT(m_jitCode);2105 }2106 #endif2107 2108 CodeBlock& FunctionBodyNode::bytecodeForExceptionInfoReparse(ScopeChainNode* scopeChainNode, CodeBlock* codeBlockBeingRegeneratedFrom)2109 {2110 ASSERT(!m_code);2111 2112 ScopeChain scopeChain(scopeChainNode);2113 JSGlobalObject* globalObject = scopeChain.globalObject();2114 2115 m_code.set(new FunctionCodeBlock(this, FunctionCode, source().provider(), source().startOffset()));2116 2117 OwnPtr<BytecodeGenerator> generator(new BytecodeGenerator(this, globalObject->debugger(), scopeChain, &m_code->symbolTable(), m_code.get()));2118 generator->setRegeneratingForExceptionInfo(codeBlockBeingRegeneratedFrom);2119 generator->generate();2120 2121 return *m_code;2122 1980 } 2123 1981 … … 2157 2015 } 2158 2016 2159 JSFunction* FunctionBodyNode::make(ExecState* exec, ScopeChainNode* scopeChain)2160 {2161 return new (exec) JSFunction(exec, m_ident, this, scopeChain);2162 }2163 2164 2017 // ------------------------------ FuncDeclNode --------------------------------- 2165 2018 -
trunk/JavaScriptCore/parser/Nodes.h
r47259 r47412 40 40 41 41 class ArgumentListNode; 42 class BytecodeGenerator; 42 43 class CodeBlock; 43 class BytecodeGenerator; 44 class EvalCodeBlock; 45 class EvalExecutable; 44 46 class FuncDeclNode; 45 class EvalCodeBlock; 47 class FunctionBodyNode; 48 class FunctionCodeBlock; 46 49 class JSFunction; 47 50 class ProgramCodeBlock; 51 class ProgramExecutable; 48 52 class PropertyListNode; 49 53 class ReadModifyResolveNode; … … 1391 1395 int m_numConstants; 1392 1396 StatementVector m_children; 1393 1394 void markAggregate(MarkStack&);1395 1397 }; 1396 1398 … … 1438 1440 } 1439 1441 1440 virtual void markAggregate(MarkStack&) { }1441 1442 #if ENABLE(JIT)1443 JITCode& generatedJITCode()1444 {1445 ASSERT(m_jitCode);1446 return m_jitCode;1447 }1448 1449 ExecutablePool* getExecutablePool()1450 {1451 return m_jitCode.getExecutablePool();1452 }1453 1454 void setJITCode(const JITCode jitCode)1455 {1456 m_jitCode = jitCode;1457 }1458 #endif1459 1460 1442 protected: 1461 1443 void setSource(const SourceCode& source) { m_source = source; } 1462 1463 #if ENABLE(JIT)1464 JITCode m_jitCode;1465 #endif1466 1444 1467 1445 private: … … 1475 1453 static PassRefPtr<ProgramNode> create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants); 1476 1454 1477 ProgramCodeBlock& bytecode(ScopeChainNode* scopeChain) 1455 private: 1456 ProgramNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants); 1457 1458 virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); 1459 }; 1460 1461 class EvalNode : public ScopeNode { 1462 public: 1463 static PassRefPtr<EvalNode> create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants); 1464 1465 void partialDestroyData() 1478 1466 { 1479 if (!m_code)1480 generateBytecode(scopeChain);1481 return *m_code;1467 // Eval code needs to hang on to its declaration stacks to keep declaration info alive until Interpreter::execute time, 1468 // so the entire ScopeNodeData cannot be destoyed. 1469 children().clear(); 1482 1470 } 1483 1471 1484 #if ENABLE(JIT)1485 JITCode& jitCode(ScopeChainNode* scopeChain)1486 {1487 if (!m_jitCode)1488 generateJITCode(scopeChain);1489 return m_jitCode;1490 }1491 #endif1492 1493 private:1494 ProgramNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants);1495 1496 void generateBytecode(ScopeChainNode*);1497 virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);1498 1499 #if ENABLE(JIT)1500 void generateJITCode(ScopeChainNode*);1501 #endif1502 1503 OwnPtr<ProgramCodeBlock> m_code;1504 };1505 1506 class EvalNode : public ScopeNode {1507 public:1508 static PassRefPtr<EvalNode> create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants);1509 1510 EvalCodeBlock& bytecode(ScopeChainNode* scopeChain)1511 {1512 if (!m_code)1513 generateBytecode(scopeChain);1514 return *m_code;1515 }1516 1517 EvalCodeBlock& bytecodeForExceptionInfoReparse(ScopeChainNode*, CodeBlock*);1518 1519 virtual void markAggregate(MarkStack&);1520 1521 #if ENABLE(JIT)1522 JITCode& jitCode(ScopeChainNode* scopeChain)1523 {1524 if (!m_jitCode)1525 generateJITCode(scopeChain);1526 return m_jitCode;1527 }1528 #endif1529 1530 1472 private: 1531 1473 EvalNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants); 1532 1474 1533 void generateBytecode(ScopeChainNode*); 1534 virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); 1535 1536 #if ENABLE(JIT) 1537 void generateJITCode(ScopeChainNode*); 1538 #endif 1539 1540 OwnPtr<EvalCodeBlock> m_code; 1475 virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); 1541 1476 }; 1542 1477 … … 1544 1479 friend class JIT; 1545 1480 public: 1546 #if ENABLE(JIT)1547 static PassRefPtr<FunctionBodyNode> createNativeThunk(JSGlobalData*);1548 #endif1549 1481 static FunctionBodyNode* create(JSGlobalData*); 1550 1482 static PassRefPtr<FunctionBodyNode> create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants); … … 1558 1490 virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); 1559 1491 1560 bool isGenerated() const1561 {1562 return m_code;1563 }1564 1565 bool isHostFunction() const;1566 1567 virtual void markAggregate(MarkStack&);1568 1569 1492 void finishParsing(const SourceCode&, ParameterNode*, const Identifier& ident); 1570 1493 void finishParsing(Identifier* parameters, size_t parameterCount, const Identifier& ident); 1571 1494 1572 UString toSourceString() const { return source().toString(); }1573 1574 CodeBlock& bytecodeForExceptionInfoReparse(ScopeChainNode*, CodeBlock*);1575 #if ENABLE(JIT)1576 JITCode& jitCode(ScopeChainNode* scopeChain)1577 {1578 if (!m_jitCode)1579 generateJITCode(scopeChain);1580 return m_jitCode;1581 }1582 #endif1583 1584 CodeBlock& bytecode(ScopeChainNode* scopeChain)1585 {1586 ASSERT(scopeChain);1587 if (!m_code)1588 generateBytecode(scopeChain);1589 return *m_code;1590 }1591 1592 CodeBlock& generatedBytecode()1593 {1594 ASSERT(m_code);1595 return *m_code;1596 }1597 1598 1495 const Identifier& ident() { return m_ident; } 1599 1496 1600 JSFunction* make(ExecState*, ScopeChainNode*);1497 void reparseDataIfNecessary(ScopeChainNode* scopeChainNode); 1601 1498 1602 1499 private: 1603 1500 FunctionBodyNode(JSGlobalData*); 1604 1501 FunctionBodyNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants); 1605 1606 void generateBytecode(ScopeChainNode*);1607 #if ENABLE(JIT)1608 void generateJITCode(ScopeChainNode*);1609 #endif1610 1502 Identifier m_ident; 1611 1503 Identifier* m_parameters; 1612 1504 size_t m_parameterCount; 1613 OwnPtr<CodeBlock> m_code;1614 1505 }; 1615 1506 -
trunk/JavaScriptCore/profiler/ProfileGenerator.cpp
r43122 r47412 28 28 29 29 #include "CallFrame.h" 30 #include "CodeBlock.h" 30 31 #include "JSGlobalObject.h" 31 32 #include "JSStringRef.h" -
trunk/JavaScriptCore/profiler/Profiler.cpp
r47236 r47412 32 32 #include "CommonIdentifiers.h" 33 33 #include "CallFrame.h" 34 #include "CodeBlock.h" 34 35 #include "JSFunction.h" 35 36 #include "JSGlobalObject.h" … … 143 144 if (asObject(functionValue)->inherits(&JSFunction::info)) { 144 145 JSFunction* function = asFunction(functionValue); 145 if (!function-> body()->isHostFunction())146 if (!function->executable()->isHostFunction()) 146 147 return createCallIdentifierFromFunctionImp(globalData, function); 147 148 } … … 154 155 { 155 156 const UString& name = function->calculatedDisplayName(globalData); 156 return CallIdentifier(name.isEmpty() ? AnonymousFunction : name, function-> body()->sourceURL(), function->body()->lineNo());157 return CallIdentifier(name.isEmpty() ? AnonymousFunction : name, function->executable()->sourceURL(), function->executable()->lineNo()); 157 158 } 158 159 -
trunk/JavaScriptCore/runtime/Arguments.h
r47404 r47412 117 117 function = callFrame->callee(); 118 118 119 CodeBlock* codeBlock = &function-> body()->generatedBytecode();119 CodeBlock* codeBlock = &function->executable()->generatedBytecode(); 120 120 int numParameters = codeBlock->m_numParameters; 121 121 argc = callFrame->argumentCount(); … … 140 140 getArgumentsData(callFrame, callee, firstParameterIndex, argv, numArguments); 141 141 142 d->numParameters = callee-> body()->parameterCount();142 d->numParameters = callee->executable()->parameterCount(); 143 143 d->firstParameterIndex = firstParameterIndex; 144 144 d->numArguments = numArguments; … … 171 171 , d(new ArgumentsData) 172 172 { 173 ASSERT(!callFrame->callee()-> body()->parameterCount());173 ASSERT(!callFrame->callee()->executable()->parameterCount()); 174 174 175 175 unsigned numArguments = callFrame->argumentCount() - 1; … … 217 217 ASSERT(!d()->registerArray); 218 218 219 size_t numParametersMinusThis = d()->function Body->generatedBytecode().m_numParameters - 1;220 size_t numVars = d()->function Body->generatedBytecode().m_numVars;219 size_t numParametersMinusThis = d()->functionExecutable->generatedBytecode().m_numParameters - 1; 220 size_t numVars = d()->functionExecutable->generatedBytecode().m_numVars; 221 221 size_t numLocals = numVars + numParametersMinusThis; 222 222 -
trunk/JavaScriptCore/runtime/ArrayPrototype.cpp
r47288 r47412 76 76 // If the JIT is enabled then we need to preserve the invariant that every 77 77 // function with a CodeBlock also has JIT code. 78 callData.js.function Body->jitCode(callData.js.scopeChain);79 CodeBlock& codeBlock = callData.js.function Body->generatedBytecode();78 callData.js.functionExecutable->jitCode(callData.js.scopeChain); 79 CodeBlock& codeBlock = callData.js.functionExecutable->generatedBytecode(); 80 80 #else 81 CodeBlock& codeBlock = callData.js.function Body->bytecode(callData.js.scopeChain);81 CodeBlock& codeBlock = callData.js.functionExecutable->bytecode(callData.js.scopeChain); 82 82 #endif 83 83 -
trunk/JavaScriptCore/runtime/CallData.h
r43372 r47412 36 36 class ArgList; 37 37 class ExecState; 38 class Function BodyNode;38 class FunctionExecutable; 39 39 class JSObject; 40 40 class JSValue; … … 54 54 } native; 55 55 struct { 56 Function BodyNode* functionBody;56 FunctionExecutable* functionExecutable; 57 57 ScopeChainNode* scopeChain; 58 58 } js; -
trunk/JavaScriptCore/runtime/Collector.cpp
r47284 r47412 1139 1139 m_globalData->interpreter->registerFile().markCallFrames(markStack, this); 1140 1140 m_globalData->smallStrings.mark(); 1141 if (m_globalData-> scopeNodeBeingReparsed)1142 m_globalData-> scopeNodeBeingReparsed->markAggregate(markStack);1141 if (m_globalData->functionCodeBlockBeingReparsed) 1142 m_globalData->functionCodeBlockBeingReparsed->markAggregate(markStack); 1143 1143 if (m_globalData->firstStringifierToMark) 1144 1144 JSONObject::markStringifiers(markStack, m_globalData->firstStringifierToMark); -
trunk/JavaScriptCore/runtime/ConstructData.h
r43122 r47412 34 34 class ArgList; 35 35 class ExecState; 36 class Function BodyNode;36 class FunctionExecutable; 37 37 class JSObject; 38 38 class JSValue; … … 52 52 } native; 53 53 struct { 54 Function BodyNode* functionBody;54 FunctionExecutable* functionExecutable; 55 55 ScopeChainNode* scopeChain; 56 56 } js; -
trunk/JavaScriptCore/runtime/ExceptionHelpers.cpp
r43122 r47412 75 75 UString message = "Can't find variable: "; 76 76 message.append(ident.ustring()); 77 JSObject* exception = Error::create(exec, ReferenceError, message, line, codeBlock->owner Node()->sourceID(), codeBlock->ownerNode()->sourceURL());77 JSObject* exception = Error::create(exec, ReferenceError, message, line, codeBlock->ownerExecutable()->sourceID(), codeBlock->ownerExecutable()->sourceURL()); 78 78 exception->putWithAttributes(exec, Identifier(exec, expressionBeginOffsetPropertyName), jsNumber(exec, divotPoint - startOffset), ReadOnly | DontDelete); 79 79 exception->putWithAttributes(exec, Identifier(exec, expressionCaretOffsetPropertyName), jsNumber(exec, divotPoint), ReadOnly | DontDelete); … … 137 137 int line = codeBlock->expressionRangeForBytecodeOffset(exec, bytecodeOffset, divotPoint, startOffset, endOffset); 138 138 UString errorMessage = createErrorMessage(exec, codeBlock, line, divotPoint, divotPoint + endOffset, value, message); 139 JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->owner Node()->sourceID(), codeBlock->ownerNode()->sourceURL());139 JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerExecutable()->sourceID(), codeBlock->ownerExecutable()->sourceURL()); 140 140 exception->putWithAttributes(exec, Identifier(exec, expressionBeginOffsetPropertyName), jsNumber(exec, divotPoint - startOffset), ReadOnly | DontDelete); 141 141 exception->putWithAttributes(exec, Identifier(exec, expressionCaretOffsetPropertyName), jsNumber(exec, divotPoint), ReadOnly | DontDelete); … … 158 158 159 159 UString errorMessage = createErrorMessage(exec, codeBlock, line, startPoint, divotPoint, value, "not a constructor"); 160 JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->owner Node()->sourceID(), codeBlock->ownerNode()->sourceURL());160 JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerExecutable()->sourceID(), codeBlock->ownerExecutable()->sourceURL()); 161 161 exception->putWithAttributes(exec, Identifier(exec, expressionBeginOffsetPropertyName), jsNumber(exec, divotPoint - startOffset), ReadOnly | DontDelete); 162 162 exception->putWithAttributes(exec, Identifier(exec, expressionCaretOffsetPropertyName), jsNumber(exec, divotPoint), ReadOnly | DontDelete); … … 172 172 int line = codeBlock->expressionRangeForBytecodeOffset(exec, bytecodeOffset, divotPoint, startOffset, endOffset); 173 173 UString errorMessage = createErrorMessage(exec, codeBlock, line, divotPoint - startOffset, divotPoint, value, "not a function"); 174 JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->owner Node()->sourceID(), codeBlock->ownerNode()->sourceURL());174 JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerExecutable()->sourceID(), codeBlock->ownerExecutable()->sourceURL()); 175 175 exception->putWithAttributes(exec, Identifier(exec, expressionBeginOffsetPropertyName), jsNumber(exec, divotPoint - startOffset), ReadOnly | DontDelete); 176 176 exception->putWithAttributes(exec, Identifier(exec, expressionCaretOffsetPropertyName), jsNumber(exec, divotPoint), ReadOnly | DontDelete); … … 202 202 int line = codeBlock->expressionRangeForBytecodeOffset(exec, bytecodeOffset, divotPoint, startOffset, endOffset); 203 203 UString errorMessage = createErrorMessage(exec, codeBlock, line, divotPoint - startOffset, divotPoint, error->isNull() ? jsNull() : jsUndefined(), "not an object"); 204 JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->owner Node()->sourceID(), codeBlock->ownerNode()->sourceURL());204 JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerExecutable()->sourceID(), codeBlock->ownerExecutable()->sourceURL()); 205 205 exception->putWithAttributes(exec, Identifier(exec, expressionBeginOffsetPropertyName), jsNumber(exec, divotPoint - startOffset), ReadOnly | DontDelete); 206 206 exception->putWithAttributes(exec, Identifier(exec, expressionCaretOffsetPropertyName), jsNumber(exec, divotPoint), ReadOnly | DontDelete); -
trunk/JavaScriptCore/runtime/Executable.h
r47405 r47412 31 31 namespace JSC { 32 32 33 template<class ASTNodeType, class CodeBlockType> 34 class TemplateExecutable { 35 public: 36 TemplateExecutable(const SourceCode& source) 33 class CodeBlock; 34 class EvalCodeBlock; 35 class ProgramCodeBlock; 36 class ScopeChainNode; 37 38 struct ExceptionInfo; 39 40 class ExecutableBase { 41 friend class JIT; 42 public: 43 virtual ~ExecutableBase() {} 44 45 ExecutableBase(const SourceCode& source) 37 46 : m_source(source) 38 47 { 39 48 } 40 49 41 void markAggregate(MarkStack& markStack) 42 { 43 m_node->markAggregate(markStack); 44 } 45 50 const SourceCode& source() { return m_source; } 51 intptr_t sourceID() const { return m_node->sourceID(); } 46 52 const UString& sourceURL() const { return m_node->sourceURL(); } 47 53 int lineNo() const { return m_node->lineNo(); } 48 CodeBlockType& bytecode(ScopeChainNode* scopeChainNode) { return m_node->bytecode(scopeChainNode); } 49 50 #if ENABLE(JIT) 51 JITCode& jitCode(ScopeChainNode* scopeChainNode) { return m_node->jitCode(scopeChainNode); } 52 #endif 54 int lastLine() const { return m_node->lastLine(); } 55 56 bool usesEval() const { return m_node->usesEval(); } 57 bool usesArguments() const { return m_node->usesArguments(); } 58 bool needsActivation() const { return m_node->needsActivation(); } 59 60 virtual ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*) = 0; 61 62 ScopeNode* astNode() { return m_node.get(); } 53 63 54 64 protected: 55 RefPtr< ASTNodeType> m_node;65 RefPtr<ScopeNode> m_node; 56 66 SourceCode m_source; 57 }; 58 59 class EvalExecutable : public TemplateExecutable<EvalNode, EvalCodeBlock> { 67 68 private: 69 // For use making native thunk. 70 friend class FunctionExecutable; 71 ExecutableBase() 72 { 73 } 74 75 #if ENABLE(JIT) 76 public: 77 JITCode& generatedJITCode() 78 { 79 ASSERT(m_jitCode); 80 return m_jitCode; 81 } 82 83 ExecutablePool* getExecutablePool() 84 { 85 return m_jitCode.getExecutablePool(); 86 } 87 88 protected: 89 JITCode m_jitCode; 90 #endif 91 }; 92 93 class EvalExecutable : public ExecutableBase { 60 94 public: 61 95 EvalExecutable(const SourceCode& source) 62 : TemplateExecutable<EvalNode, EvalCodeBlock>(source) 63 { 64 } 96 : ExecutableBase(source) 97 , m_evalCodeBlock(0) 98 { 99 } 100 101 ~EvalExecutable(); 65 102 66 103 JSObject* parse(ExecState* exec, bool allowDebug = true); 104 105 EvalCodeBlock& bytecode(ScopeChainNode* scopeChainNode) 106 { 107 if (!m_evalCodeBlock) 108 generateBytecode(scopeChainNode); 109 return *m_evalCodeBlock; 110 } 111 112 DeclarationStacks::VarStack& varStack() { return m_node->varStack(); } 113 114 ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*); 115 116 private: 117 EvalNode* evalNode() { return static_cast<EvalNode*>(m_node.get()); } 118 119 void generateBytecode(ScopeChainNode*); 120 121 EvalCodeBlock* m_evalCodeBlock; 122 123 #if ENABLE(JIT) 124 public: 125 JITCode& jitCode(ScopeChainNode* scopeChainNode) 126 { 127 if (!m_jitCode) 128 generateJITCode(scopeChainNode); 129 return m_jitCode; 130 } 131 132 private: 133 void generateJITCode(ScopeChainNode*); 134 #endif 67 135 }; 68 136 … … 78 146 }; 79 147 80 class ProgramExecutable : public TemplateExecutable<ProgramNode, ProgramCodeBlock>{148 class ProgramExecutable : public ExecutableBase { 81 149 public: 82 150 ProgramExecutable(const SourceCode& source) 83 : TemplateExecutable<ProgramNode, ProgramCodeBlock>(source) 84 { 85 } 151 : ExecutableBase(source) 152 , m_programCodeBlock(0) 153 { 154 } 155 156 ~ProgramExecutable(); 86 157 87 158 JSObject* parse(ExecState* exec, bool allowDebug = true); 159 160 // CodeBlocks for program code are transient and therefore to not gain from from throwing out there exception information. 161 ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*) { ASSERT_NOT_REACHED(); return 0; } 162 163 ProgramCodeBlock& bytecode(ScopeChainNode* scopeChainNode) 164 { 165 if (!m_programCodeBlock) 166 generateBytecode(scopeChainNode); 167 return *m_programCodeBlock; 168 } 169 170 private: 171 ProgramNode* programNode() { return static_cast<ProgramNode*>(m_node.get()); } 172 173 void generateBytecode(ScopeChainNode*); 174 175 ProgramCodeBlock* m_programCodeBlock; 176 177 #if ENABLE(JIT) 178 public: 179 JITCode& jitCode(ScopeChainNode* scopeChainNode) 180 { 181 if (!m_jitCode) 182 generateJITCode(scopeChainNode); 183 return m_jitCode; 184 } 185 186 private: 187 void generateJITCode(ScopeChainNode*); 188 #endif 189 }; 190 191 class FunctionExecutable : public ExecutableBase, public RefCounted<FunctionExecutable> { 192 friend class JIT; 193 public: 194 FunctionExecutable(const Identifier& name, FunctionBodyNode* body) 195 : ExecutableBase(body->source()) 196 , m_codeBlock(0) 197 , m_name(name) 198 { 199 m_node = body; 200 } 201 202 ~FunctionExecutable(); 203 204 const Identifier& name() { return m_name; } 205 206 JSFunction* make(ExecState* exec, ScopeChainNode* scopeChain); 207 208 CodeBlock& bytecode(ScopeChainNode* scopeChainNode) 209 { 210 ASSERT(scopeChainNode); 211 if (!m_codeBlock) 212 generateBytecode(scopeChainNode); 213 return *m_codeBlock; 214 } 215 CodeBlock& generatedBytecode() 216 { 217 ASSERT(m_codeBlock); 218 return *m_codeBlock; 219 } 220 221 bool usesEval() const { return body()->usesEval(); } 222 bool usesArguments() const { return body()->usesArguments(); } 223 size_t parameterCount() const { return body()->parameterCount(); } 224 UString paramString() const { return body()->paramString(); } 225 226 bool isHostFunction() const; 227 bool isGenerated() const 228 { 229 return m_codeBlock; 230 } 231 232 void recompile(ExecState* exec); 233 234 ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*); 235 236 void markAggregate(MarkStack& markStack); 237 238 private: 239 FunctionBodyNode* body() const { return static_cast<FunctionBodyNode*>(m_node.get()); } 240 241 void generateBytecode(ScopeChainNode*); 242 243 CodeBlock* m_codeBlock; 244 const Identifier& m_name; 245 246 #if ENABLE(JIT) 247 public: 248 JITCode& jitCode(ScopeChainNode* scopeChainNode) 249 { 250 if (!m_jitCode) 251 generateJITCode(scopeChainNode); 252 return m_jitCode; 253 } 254 255 static PassRefPtr<FunctionExecutable> createNativeThunk(ExecState* exec) 256 { 257 return adoptRef(new FunctionExecutable(exec)); 258 } 259 260 private: 261 FunctionExecutable(ExecState* exec); 262 void generateJITCode(ScopeChainNode*); 263 #endif 88 264 }; 89 265 -
trunk/JavaScriptCore/runtime/FunctionConstructor.cpp
r47304 r47412 94 94 JSGlobalObject* globalObject = exec->lexicalGlobalObject(); 95 95 ScopeChain scopeChain(globalObject, globalObject->globalData(), exec->globalThisValue()); 96 return new (exec) JSFunction(exec, functionName, body.get(), scopeChain.node());96 return new (exec) JSFunction(exec, adoptRef(new FunctionExecutable(functionName, body.get())), scopeChain.node()); 97 97 } 98 98 -
trunk/JavaScriptCore/runtime/FunctionPrototype.cpp
r47288 r47412 87 87 if (thisValue.inherits(&JSFunction::info)) { 88 88 JSFunction* function = asFunction(thisValue); 89 Function BodyNode* body = function->body();90 if (! body->isHostFunction()) {91 UString bodySourceString = body->toSourceString();92 insertSemicolonIfNeeded( bodySourceString);93 return jsString(exec, "function " + function->name(&exec->globalData()) + "(" + body->paramString() + ") " + bodySourceString);89 FunctionExecutable* executable = function->executable(); 90 if (!executable->isHostFunction()) { 91 UString sourceString = executable->source().toString(); 92 insertSemicolonIfNeeded(sourceString); 93 return jsString(exec, "function " + function->name(&exec->globalData()) + "(" + executable->paramString() + ") " + sourceString); 94 94 } 95 95 } -
trunk/JavaScriptCore/runtime/JSActivation.cpp
r47288 r47412 40 40 const ClassInfo JSActivation::info = { "JSActivation", 0, 0, 0 }; 41 41 42 JSActivation::JSActivation(CallFrame* callFrame, PassRefPtr<Function BodyNode> functionBody)43 : Base(callFrame->globalData().activationStructure, new JSActivationData(function Body, callFrame->registers()))42 JSActivation::JSActivation(CallFrame* callFrame, PassRefPtr<FunctionExecutable> functionExecutable) 43 : Base(callFrame->globalData().activationStructure, new JSActivationData(functionExecutable, callFrame->registers())) 44 44 { 45 45 } … … 58 58 return; 59 59 60 size_t numParametersMinusThis = d()->function Body->generatedBytecode().m_numParameters - 1;60 size_t numParametersMinusThis = d()->functionExecutable->generatedBytecode().m_numParameters - 1; 61 61 62 62 size_t count = numParametersMinusThis; 63 63 markStack.appendValues(registerArray, count); 64 64 65 size_t numVars = d()->function Body->generatedBytecode().m_numVars;65 size_t numVars = d()->functionExecutable->generatedBytecode().m_numVars; 66 66 67 67 // Skip the call frame, which sits between the parameters and vars. … … 137 137 bool JSActivation::isDynamicScope() const 138 138 { 139 return d()->function Body->usesEval();139 return d()->functionExecutable->usesEval(); 140 140 } 141 141 … … 144 144 JSActivation* activation = asActivation(slot.slotBase()); 145 145 146 if (activation->d()->function Body->usesArguments()) {146 if (activation->d()->functionExecutable->usesArguments()) { 147 147 PropertySlot slot; 148 148 activation->symbolTableGet(exec->propertyNames().arguments, slot); -
trunk/JavaScriptCore/runtime/JSActivation.h
r47022 r47412 44 44 typedef JSVariableObject Base; 45 45 public: 46 JSActivation(CallFrame*, PassRefPtr<Function BodyNode>);46 JSActivation(CallFrame*, PassRefPtr<FunctionExecutable>); 47 47 virtual ~JSActivation(); 48 48 … … 71 71 private: 72 72 struct JSActivationData : public JSVariableObjectData { 73 JSActivationData(PassRefPtr<Function BodyNode> functionBody, Register* registers)74 : JSVariableObjectData(&function Body->generatedBytecode().symbolTable(), registers)75 , function Body(functionBody)73 JSActivationData(PassRefPtr<FunctionExecutable> functionExecutable, Register* registers) 74 : JSVariableObjectData(&functionExecutable->generatedBytecode().symbolTable(), registers) 75 , functionExecutable(functionExecutable) 76 76 { 77 77 } 78 78 79 RefPtr<Function BodyNode> functionBody;79 RefPtr<FunctionExecutable> functionExecutable; 80 80 }; 81 81 -
trunk/JavaScriptCore/runtime/JSFunction.cpp
r47236 r47412 48 48 inline bool JSFunction::isHostFunction() const 49 49 { 50 return m_ body && m_body->isHostFunction();50 return m_executable && m_executable->isHostFunction(); 51 51 } 52 52 … … 65 65 : Base(&exec->globalData(), structure, name) 66 66 #if ENABLE(JIT) 67 , m_ body(FunctionBodyNode::createNativeThunk(&exec->globalData()))67 , m_executable(FunctionExecutable::createNativeThunk(exec)) 68 68 #endif 69 69 { … … 78 78 } 79 79 80 JSFunction::JSFunction(ExecState* exec, const Identifier& name, PassRefPtr<FunctionBodyNode> body, ScopeChainNode* scopeChainNode)81 : Base(&exec->globalData(), exec->lexicalGlobalObject()->functionStructure(), name)82 , m_ body(body)80 JSFunction::JSFunction(ExecState* exec, PassRefPtr<FunctionExecutable> executable, ScopeChainNode* scopeChainNode) 81 : Base(&exec->globalData(), exec->lexicalGlobalObject()->functionStructure(), executable->name()) 82 , m_executable(executable) 83 83 { 84 84 setScopeChain(scopeChainNode); … … 91 91 // this memory is freed and may be reused (potentially for another, different JSFunction). 92 92 #if ENABLE(JIT_OPTIMIZE_CALL) 93 if (m_ body && m_body->isGenerated())94 m_ body->generatedBytecode().unlinkCallers();93 if (m_executable && m_executable->isGenerated()) 94 m_executable->generatedBytecode().unlinkCallers(); 95 95 #endif 96 96 if (!isHostFunction()) … … 101 101 { 102 102 Base::markChildren(markStack); 103 m_ body->markAggregate(markStack);103 m_executable->markAggregate(markStack); 104 104 if (!isHostFunction()) 105 105 scopeChain().markAggregate(markStack); … … 112 112 return CallTypeHost; 113 113 } 114 callData.js.function Body = m_body.get();114 callData.js.functionExecutable = m_executable.get(); 115 115 callData.js.scopeChain = scopeChain().node(); 116 116 return CallTypeJS; … … 120 120 { 121 121 ASSERT(!isHostFunction()); 122 return exec->interpreter()->execute(m_ body.get(), exec, this, thisValue.toThisObject(exec), args, scopeChain().node(), exec->exceptionSlot());122 return exec->interpreter()->execute(m_executable.get(), exec, this, thisValue.toThisObject(exec), args, scopeChain().node(), exec->exceptionSlot()); 123 123 } 124 124 … … 141 141 JSFunction* thisObj = asFunction(slot.slotBase()); 142 142 ASSERT(!thisObj->isHostFunction()); 143 return jsNumber(exec, thisObj->m_ body->parameterCount());143 return jsNumber(exec, thisObj->m_executable->parameterCount()); 144 144 } 145 145 … … 205 205 if (isHostFunction()) 206 206 return ConstructTypeNone; 207 constructData.js.function Body = m_body.get();207 constructData.js.functionExecutable = m_executable.get(); 208 208 constructData.js.scopeChain = scopeChain().node(); 209 209 return ConstructTypeJS; … … 221 221 JSObject* thisObj = new (exec) JSObject(structure); 222 222 223 JSValue result = exec->interpreter()->execute(m_ body.get(), exec, this, thisObj, args, scopeChain().node(), exec->exceptionSlot());223 JSValue result = exec->interpreter()->execute(m_executable.get(), exec, this, thisObj, args, scopeChain().node(), exec->exceptionSlot()); 224 224 if (exec->hadException() || !result.isObject()) 225 225 return thisObj; … … 227 227 } 228 228 229 void JSFunction::setBody(PassRefPtr<FunctionBodyNode> body)230 {231 m_body = body;232 }233 234 229 } // namespace JSC -
trunk/JavaScriptCore/runtime/JSFunction.h
r47236 r47412 25 25 #define JSFunction_h 26 26 27 #include "Executable.h" 27 28 #include "InternalFunction.h" 28 29 29 30 namespace JSC { 30 31 31 class FunctionBodyNode;32 32 class FunctionPrototype; 33 33 class JSActivation; … … 42 42 public: 43 43 JSFunction(ExecState*, PassRefPtr<Structure>, int length, const Identifier&, NativeFunction); 44 JSFunction(ExecState*, const Identifier&, PassRefPtr<FunctionBodyNode>, ScopeChainNode*);44 JSFunction(ExecState*, PassRefPtr<FunctionExecutable>, ScopeChainNode*); 45 45 virtual ~JSFunction(); 46 46 … … 51 51 ScopeChain& scope() { return scopeChain(); } 52 52 53 void setBody(PassRefPtr<FunctionBodyNode>); 54 FunctionBodyNode* body() const { return m_body.get(); } 53 FunctionExecutable* executable() const { return m_executable.get(); } 55 54 56 55 static JS_EXPORTDATA const ClassInfo info; … … 87 86 static JSValue lengthGetter(ExecState*, const Identifier&, const PropertySlot&); 88 87 89 RefPtr<Function BodyNode> m_body;88 RefPtr<FunctionExecutable> m_executable; 90 89 ScopeChain& scopeChain() 91 90 { … … 123 122 } 124 123 124 inline JSFunction* FunctionExecutable::make(ExecState* exec, ScopeChainNode* scopeChain) 125 { 126 return new (exec) JSFunction(exec, this, scopeChain); 127 } 128 125 129 } // namespace JSC 126 130 -
trunk/JavaScriptCore/runtime/JSGlobalData.cpp
r47304 r47412 145 145 , head(0) 146 146 , dynamicGlobalObject(0) 147 , scopeNodeBeingReparsed(0)147 , functionCodeBlockBeingReparsed(0) 148 148 , firstStringifierToMark(0) 149 149 , markStack(vptrSet.jsArrayVPtr) … … 238 238 initializingLazyNumericCompareFunction = true; 239 239 RefPtr<FunctionBodyNode> functionBody = parser->parseFunctionFromGlobalCode(exec, 0, makeSource(UString("(function (v1, v2) { return v1 - v2; })")), 0, 0); 240 lazyNumericCompareFunction = functionBody->bytecode(exec->scopeChain()).instructions(); 240 FunctionExecutable function(functionBody->ident(), functionBody.get()); 241 lazyNumericCompareFunction = function.bytecode(exec->scopeChain()).instructions(); 241 242 initializingLazyNumericCompareFunction = false; 242 243 } -
trunk/JavaScriptCore/runtime/JSGlobalData.h
r47022 r47412 46 46 namespace JSC { 47 47 48 class CodeBlock; 48 49 class CommonIdentifiers; 49 class FunctionBodyNode;50 50 class IdentifierTable; 51 51 class Interpreter; … … 54 54 class Lexer; 55 55 class Parser; 56 class ScopeNode;57 56 class Stringifier; 58 57 class Structure; … … 146 145 HashSet<JSObject*> arrayVisitedElements; 147 146 148 ScopeNode* scopeNodeBeingReparsed;147 CodeBlock* functionCodeBlockBeingReparsed; 149 148 Stringifier* firstStringifierToMark; 150 149
Note:
See TracChangeset
for help on using the changeset viewer.