Changeset 127810 in webkit for trunk/Source/JavaScriptCore/runtime
- Timestamp:
- Sep 6, 2012, 6:42:53 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore/runtime
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/Executable.cpp
r127774 r127810 134 134 const ClassInfo FunctionExecutable::s_info = { "FunctionExecutable", &ScriptExecutable::s_info, 0, 0, CREATE_METHOD_TABLE(FunctionExecutable) }; 135 135 136 FunctionExecutable::FunctionExecutable(JSGlobalData& globalData, const Identifier& name, const Identifier& inferredName, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, bool inStrictContext)137 : ScriptExecutable(globalData.functionExecutableStructure.get(), globalData, source, inStrictContext)136 FunctionExecutable::FunctionExecutable(JSGlobalData& globalData, FunctionBodyNode* node) 137 : ScriptExecutable(globalData.functionExecutableStructure.get(), globalData, node->source(), node->isStrictMode()) 138 138 , m_numCapturedVariables(0) 139 , m_forceUsesArguments(forceUsesArguments) 140 , m_parameters(parameters) 141 , m_name(name) 142 , m_inferredName(inferredName.isNull() ? globalData.propertyNames->emptyIdentifier : inferredName) 143 { 144 } 145 146 FunctionExecutable::FunctionExecutable(ExecState* exec, const Identifier& name, const Identifier& inferredName, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, bool inStrictContext) 147 : ScriptExecutable(exec->globalData().functionExecutableStructure.get(), exec, source, inStrictContext) 148 , m_numCapturedVariables(0) 149 , m_forceUsesArguments(forceUsesArguments) 150 , m_parameters(parameters) 151 , m_name(name) 152 , m_inferredName(inferredName.isNull() ? exec->globalData().propertyNames->emptyIdentifier : inferredName) 153 { 139 , m_forceUsesArguments(node->usesArguments()) 140 , m_parameters(node->parameters()) 141 , m_name(node->ident()) 142 , m_inferredName(node->inferredName().isNull() ? globalData.propertyNames->emptyIdentifier : node->inferredName()) 143 , m_functionNameIsInScopeToggle(node->functionNameIsInScopeToggle()) 144 { 145 m_firstLine = node->lineNo(); 146 m_lastLine = node->lastLine(); 154 147 } 155 148 … … 211 204 if (!lexicalGlobalObject->evalEnabled()) 212 205 return throwError(exec, createEvalError(exec, ASCIILiteral("Eval is disabled"))); 213 RefPtr<EvalNode> evalNode = parse<EvalNode>(globalData, lexicalGlobalObject, m_source, 0, isStrictMode() ? JSParseStrict : JSParseNormal, EvalNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, lexicalGlobalObject->debugger(), exec, &exception);206 RefPtr<EvalNode> evalNode = parse<EvalNode>(globalData, lexicalGlobalObject, m_source, 0, Identifier(), isStrictMode() ? JSParseStrict : JSParseNormal, EvalNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, lexicalGlobalObject->debugger(), exec, &exception); 214 207 if (!evalNode) { 215 208 ASSERT(exception); … … 294 287 JSGlobalData* globalData = &exec->globalData(); 295 288 JSGlobalObject* lexicalGlobalObject = exec->lexicalGlobalObject(); 296 RefPtr<ProgramNode> programNode = parse<ProgramNode>(globalData, lexicalGlobalObject, m_source, 0, JSParseNormal, ProgramNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, lexicalGlobalObject->debugger(), exec, &exception);289 RefPtr<ProgramNode> programNode = parse<ProgramNode>(globalData, lexicalGlobalObject, m_source, 0, Identifier(), JSParseNormal, ProgramNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, lexicalGlobalObject->debugger(), exec, &exception); 297 290 if (programNode) 298 291 return 0; … … 336 329 m_programCodeBlock = newCodeBlock.release(); 337 330 } else { 338 RefPtr<ProgramNode> programNode = parse<ProgramNode>(globalData, lexicalGlobalObject, m_source, 0, isStrictMode() ? JSParseStrict : JSParseNormal, ProgramNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, lexicalGlobalObject->debugger(), exec, &exception);331 RefPtr<ProgramNode> programNode = parse<ProgramNode>(globalData, lexicalGlobalObject, m_source, 0, Identifier(), isStrictMode() ? JSParseStrict : JSParseNormal, ProgramNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, lexicalGlobalObject->debugger(), exec, &exception); 339 332 if (!programNode) { 340 333 ASSERT(exception); … … 479 472 JSGlobalData* globalData = scope->globalData(); 480 473 JSGlobalObject* globalObject = scope->globalObject(); 481 RefPtr<FunctionBodyNode> body = parse<FunctionBodyNode>(globalData, globalObject, m_source, m_parameters.get(), isStrictMode() ? JSParseStrict : JSParseNormal, FunctionBodyNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, 0, 0, &exception); 474 RefPtr<FunctionBodyNode> body = parse<FunctionBodyNode>( 475 globalData, 476 globalObject, 477 m_source, 478 m_parameters.get(), 479 name(), 480 isStrictMode() ? JSParseStrict : JSParseNormal, 481 FunctionBodyNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, 482 0, 483 0, 484 &exception 485 ); 482 486 483 487 if (!body) { … … 487 491 if (m_forceUsesArguments) 488 492 body->setUsesArguments(); 489 body->finishParsing(m_parameters, m_name );493 body->finishParsing(m_parameters, m_name, m_functionNameIsInScopeToggle); 490 494 recordParse(body->features(), body->hasCapturedVariables(), body->lineNo(), body->lastLine()); 491 495 … … 648 652 } 649 653 650 FunctionExecutable* FunctionExecutable::fromGlobalCode(const Identifier& functionName, ExecState* exec, Debugger* debugger, const SourceCode& source, JSObject** exception)654 FunctionExecutable* FunctionExecutable::fromGlobalCode(const Identifier& name, ExecState* exec, Debugger* debugger, const SourceCode& source, JSObject** exception) 651 655 { 652 656 JSGlobalObject* lexicalGlobalObject = exec->lexicalGlobalObject(); 653 RefPtr<ProgramNode> program = parse<ProgramNode>(&exec->globalData(), lexicalGlobalObject, source, 0, JSParseNormal, ProgramNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, debugger, exec, exception);657 RefPtr<ProgramNode> program = parse<ProgramNode>(&exec->globalData(), lexicalGlobalObject, source, 0, Identifier(), JSParseNormal, ProgramNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, debugger, exec, exception); 654 658 if (!program) { 655 659 ASSERT(*exception); … … 657 661 } 658 662 659 // Uses of this function that would not result in a single function expression are invalid.663 // This function assumes an input string that would result in a single anonymous function expression. 660 664 StatementNode* exprStatement = program->singleStatement(); 661 665 ASSERT(exprStatement); … … 666 670 FunctionBodyNode* body = static_cast<FuncExprNode*>(funcExpr)->body(); 667 671 ASSERT(body); 668 669 return FunctionExecutable::create(exec->globalData(), functionName, functionName, body->source(), body->usesArguments(), body->parameters(), body->isStrictMode(), body->lineNo(), body->lastLine()); 672 ASSERT(body->ident().isNull()); 673 674 FunctionExecutable* functionExecutable = FunctionExecutable::create(exec->globalData(), body); 675 functionExecutable->m_nameValue.set(exec->globalData(), functionExecutable, jsString(&exec->globalData(), name.ustring())); 676 return functionExecutable; 670 677 } 671 678 -
trunk/Source/JavaScriptCore/runtime/Executable.h
r127774 r127810 540 540 typedef ScriptExecutable Base; 541 541 542 static FunctionExecutable* create( ExecState* exec, const Identifier& name, const Identifier& inferredName, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, bool isInStrictContext, int firstLine, int lastLine)543 { 544 FunctionExecutable* executable = new (NotNull, allocateCell<FunctionExecutable>( *exec->heap())) FunctionExecutable(exec, name, inferredName, source, forceUsesArguments, parameters, isInStrictContext);545 executable->finishCreation( exec->globalData(), name, firstLine, lastLine);542 static FunctionExecutable* create(JSGlobalData& globalData, FunctionBodyNode* node) 543 { 544 FunctionExecutable* executable = new (NotNull, allocateCell<FunctionExecutable>(globalData.heap)) FunctionExecutable(globalData, node); 545 executable->finishCreation(globalData); 546 546 return executable; 547 547 } 548 549 static FunctionExecutable* create(JSGlobalData& globalData, const Identifier& name, const Identifier& inferredName, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, bool isInStrictContext, int firstLine, int lastLine) 550 { 551 FunctionExecutable* executable = new (NotNull, allocateCell<FunctionExecutable>(globalData.heap)) FunctionExecutable(globalData, name, inferredName, source, forceUsesArguments, parameters, isInStrictContext); 552 executable->finishCreation(globalData, name, firstLine, lastLine); 553 return executable; 554 } 548 static FunctionExecutable* fromGlobalCode(const Identifier& name, ExecState*, Debugger*, const SourceCode&, JSObject** exception); 555 549 556 550 static void destroy(JSCell*); 557 551 558 JSFunction* make(ExecState* exec, JSScope* scope)559 {560 return JSFunction::create(exec, this, scope);561 }562 563 552 // Returns either call or construct bytecode. This can be appropriate 564 553 // for answering questions that that don't vary between call and construct -- … … 709 698 void clearCodeIfNotCompiling(); 710 699 static void visitChildren(JSCell*, SlotVisitor&); 711 static FunctionExecutable* fromGlobalCode(const Identifier&, ExecState*, Debugger*, const SourceCode&, JSObject** exception);712 700 static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue proto) 713 701 { … … 722 710 723 711 protected: 724 void finishCreation(JSGlobalData& globalData , const Identifier& name, int firstLine, int lastLine)712 void finishCreation(JSGlobalData& globalData) 725 713 { 726 714 Base::finishCreation(globalData); 727 m_firstLine = firstLine; 728 m_lastLine = lastLine; 729 m_nameValue.set(globalData, this, jsString(&globalData, name.ustring())); 715 m_nameValue.set(globalData, this, jsString(&globalData, name().ustring())); 730 716 } 731 717 732 718 private: 733 FunctionExecutable(JSGlobalData&, const Identifier& name, const Identifier& inferredName, const SourceCode&, bool forceUsesArguments, FunctionParameters*, bool); 734 FunctionExecutable(ExecState*, const Identifier& name, const Identifier& inferredName, const SourceCode&, bool forceUsesArguments, FunctionParameters*, bool); 719 FunctionExecutable(JSGlobalData&, FunctionBodyNode*); 735 720 736 721 JSObject* compileForCallInternal(ExecState*, JSScope*, JITCode::JITType, unsigned bytecodeIndex = UINT_MAX); … … 765 750 Identifier m_name; 766 751 Identifier m_inferredName; 752 FunctionNameIsInScopeToggle m_functionNameIsInScopeToggle; 767 753 WriteBarrier<JSString> m_nameValue; 768 754 WriteBarrier<SharedSymbolTable> m_symbolTable; -
trunk/Source/JavaScriptCore/runtime/JSNameScope.h
r127774 r127810 39 39 static JSNameScope* create(ExecState* exec, const Identifier& identifier, JSValue value, unsigned attributes) 40 40 { 41 JSNameScope* scopeObject = new (NotNull, allocateCell<JSNameScope>(*exec->heap())) JSNameScope(exec); 41 JSNameScope* scopeObject = new (NotNull, allocateCell<JSNameScope>(*exec->heap())) JSNameScope(exec, exec->scope()); 42 scopeObject->finishCreation(exec, identifier, value, attributes); 43 return scopeObject; 44 } 45 46 static JSNameScope* create(ExecState* exec, const Identifier& identifier, JSValue value, unsigned attributes, JSScope* next) 47 { 48 JSNameScope* scopeObject = new (NotNull, allocateCell<JSNameScope>(*exec->heap())) JSNameScope(exec, next); 42 49 scopeObject->finishCreation(exec, identifier, value, attributes); 43 50 return scopeObject; … … 65 72 66 73 private: 67 JSNameScope(ExecState* exec )74 JSNameScope(ExecState* exec, JSScope* next) 68 75 : Base( 69 76 exec->globalData(), 70 77 exec->lexicalGlobalObject()->nameScopeStructure(), 71 78 reinterpret_cast<Register*>(&m_registerStore + 1), 72 exec->scope()79 next 73 80 ) 74 81 {
Note:
See TracChangeset
for help on using the changeset viewer.