Changeset 32290 in webkit
- Timestamp:
- Apr 21, 2008 12:39:36 AM (16 years ago)
- Location:
- branches/squirrelfish/JavaScriptCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/squirrelfish/JavaScriptCore/ChangeLog
r32289 r32290 1 2008-04-21 Cameron Zwarich <cwzwarich@uwaterloo.ca> 2 3 Reviewed by Maciej. 4 5 Add support for variable declarations in eval code. 6 7 * VM/CodeBlock.h: 8 (KJS::EvalCodeBlock::EvalCodeBlock): 9 * VM/CodeGenerator.cpp: 10 (KJS::CodeGenerator::CodeGenerator): 11 * VM/CodeGenerator.h: 12 * VM/Machine.cpp: 13 (KJS::Machine::execute): 14 * VM/Machine.h: 15 * kjs/function.cpp: 16 (KJS::globalFuncEval): 17 * kjs/nodes.cpp: 18 (KJS::EvalNode::generateCode): 19 * kjs/nodes.h: 20 (KJS::EvalNode::): 21 1 22 2008-04-20 Oliver Hunt <oliver@apple.com> 2 23 -
branches/squirrelfish/JavaScriptCore/VM/CodeBlock.h
r32281 r32290 116 116 }; 117 117 118 struct EvalCodeBlock : public ProgramCodeBlock { 119 EvalCodeBlock(const UString& sourceURL_, bool usesEval_, bool needsClosure_, JSGlobalObject* globalObject_) 120 : ProgramCodeBlock(sourceURL_, usesEval_, needsClosure_, globalObject_) 121 { 122 } 123 124 Vector<Identifier> declaredVariables; 125 }; 126 118 127 } // namespace KJS 119 128 -
branches/squirrelfish/JavaScriptCore/VM/CodeGenerator.cpp
r32289 r32290 241 241 } 242 242 243 CodeGenerator::CodeGenerator(EvalNode* evalNode, const ScopeChain& scopeChain, SymbolTable* symbolTable, CodeBlock* codeBlock)243 CodeGenerator::CodeGenerator(EvalNode* evalNode, const ScopeChain& scopeChain, SymbolTable* symbolTable, EvalCodeBlock* codeBlock, VarStack& varStack) 244 244 : m_scopeChain(&scopeChain) 245 245 , m_symbolTable(symbolTable) … … 254 254 { 255 255 addVar(m_propertyNames->thisIdentifier); 256 257 for (size_t i = 0; i < varStack.size(); ++i) 258 codeBlock->declaredVariables.append(varStack[i].first); 256 259 } 257 260 -
branches/squirrelfish/JavaScriptCore/VM/CodeGenerator.h
r32289 r32290 74 74 CodeGenerator(ProgramNode*, const ScopeChain&, SymbolTable*, CodeBlock*, VarStack&, FunctionStack&); 75 75 CodeGenerator(FunctionBodyNode*, const ScopeChain&, SymbolTable*, CodeBlock*, VarStack&, FunctionStack&, Vector<Identifier>& parameters); 76 CodeGenerator(EvalNode*, const ScopeChain&, SymbolTable*, CodeBlock*);76 CodeGenerator(EvalNode*, const ScopeChain&, SymbolTable*, EvalCodeBlock*, VarStack&); 77 77 78 78 const CommonIdentifiers& propertyNames() const { return *m_propertyNames; } -
branches/squirrelfish/JavaScriptCore/VM/Machine.cpp
r32286 r32290 577 577 } 578 578 579 JSValue* Machine::execute(EvalNode* evalNode, ExecState* exec, JSObject* thisObj, RegisterFile* registerFile, int registerOffset, ScopeChainNode* scopeChain, JSValue** exception) 580 { 581 CodeBlock* codeBlock = &evalNode->code(scopeChain); 582 579 JSValue* Machine::execute(EvalNode* evalNode, ExecState* exec, JSObject* thisObj, RegisterFile* registerFile, int registerOffset, ScopeChainNode* scopeChain, JSValue** exception, JSObject* variableObject) 580 { 581 EvalCodeBlock* codeBlock = &evalNode->code(scopeChain); 582 583 if (!variableObject) { 584 ScopeChainNode* node; 585 586 for (node = scopeChain; !node->object->isActivationObject() && node->next; node = node->next) { } 587 variableObject = node->object; 588 } 589 590 for (Vector<Identifier>::const_iterator iter = codeBlock->declaredVariables.begin(); iter != codeBlock->declaredVariables.end(); ++iter) { 591 Identifier ident = *iter; 592 593 if (!variableObject->hasProperty(exec, ident)) 594 variableObject->put(exec, ident, jsUndefined()); 595 } 596 583 597 size_t oldSize = registerFile->size(); 584 598 size_t newSize = registerOffset + codeBlock->numVars + codeBlock->numTemporaries; … … 594 608 } 595 609 596 JSValue* Machine::execute(EvalNode* evalNode, ExecState* exec, JSObject* thisObj, RegisterFileStack* registerFileStack, ScopeChainNode* scopeChain, JSValue** exception )610 JSValue* Machine::execute(EvalNode* evalNode, ExecState* exec, JSObject* thisObj, RegisterFileStack* registerFileStack, ScopeChainNode* scopeChain, JSValue** exception, JSObject* variableObject) 597 611 { 598 612 RegisterFile* registerFile = registerFileStack->current(); 599 CodeBlock* codeBlock = &evalNode->code(scopeChain); 600 601 size_t oldSize = registerFile->size(); 602 size_t newSize = oldSize + codeBlock->numVars + codeBlock->numTemporaries; 603 registerFile->grow(newSize); 604 Register* r = (*registerFile->basePointer()) + oldSize + codeBlock->numVars; 605 606 r[ProgramCodeThisRegister].u.jsValue = thisObj; 607 JSValue* result = privateExecute(Normal, exec, registerFile, r, scopeChain, codeBlock, exception); 608 609 registerFile->shrink(oldSize); 610 611 return result; 613 return Machine::execute(evalNode, exec, thisObj, registerFile, registerFile->size(), scopeChain, exception, variableObject); 612 614 } 613 615 -
branches/squirrelfish/JavaScriptCore/VM/Machine.h
r32194 r32290 81 81 JSValue* execute(ProgramNode*, ExecState*, JSObject* thisObj, RegisterFileStack*, ScopeChain*, JSValue** exception); 82 82 JSValue* execute(FunctionBodyNode*, const List& args, JSObject* thisObj, ExecState*, RegisterFileStack*, ScopeChain*, JSValue** exception); 83 JSValue* execute(EvalNode*, ExecState*, JSObject* thisObj, RegisterFile*, int registerOffset, ScopeChainNode*, JSValue** exception );84 JSValue* execute(EvalNode*, ExecState*, JSObject* thisObj, RegisterFileStack*, ScopeChainNode*, JSValue** exception );83 JSValue* execute(EvalNode*, ExecState*, JSObject* thisObj, RegisterFile*, int registerOffset, ScopeChainNode*, JSValue** exception, JSObject* variableObject = 0); 84 JSValue* execute(EvalNode*, ExecState*, JSObject* thisObj, RegisterFileStack*, ScopeChainNode*, JSValue** exception, JSObject* variableObject); 85 85 86 86 private: -
branches/squirrelfish/JavaScriptCore/kjs/function.cpp
r32289 r32290 724 724 725 725 JSValue* exception = 0; 726 JSValue* value = machine().execute(evalNode.get(), &newExec, thisObj, &newExec.dynamicGlobalObject()->registerFileStack(), scopeChain.node(), &exception );726 JSValue* value = machine().execute(evalNode.get(), &newExec, thisObj, &newExec.dynamicGlobalObject()->registerFileStack(), scopeChain.node(), &exception, globalObject); 727 727 728 728 #if JAVASCRIPT_PROFILING -
branches/squirrelfish/JavaScriptCore/kjs/nodes.cpp
r32289 r32290 5677 5677 ASSERT(globalObject->isGlobalObject()); 5678 5678 5679 m_code.set(new ProgramCodeBlock(sourceURL(), usesEval(), needsClosure(), globalObject));5679 m_code.set(new EvalCodeBlock(sourceURL(), usesEval(), needsClosure(), globalObject)); 5680 5680 5681 CodeGenerator generator(this, scopeChain, new SymbolTable(), m_code.get() );5681 CodeGenerator generator(this, scopeChain, new SymbolTable(), m_code.get(), m_varStack); 5682 5682 generator.generate(); 5683 5683 -
branches/squirrelfish/JavaScriptCore/kjs/nodes.h
r32289 r32290 51 51 class FuncDeclNode; 52 52 class Node; 53 class EvalCodeBlock; 53 54 class ProgramCodeBlock; 54 55 class PropertyListNode; … … 2987 2988 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2988 2989 2989 ProgramCodeBlock& code(ScopeChainNode* scopeChain) KJS_FAST_CALL2990 EvalCodeBlock& code(ScopeChainNode* scopeChain) KJS_FAST_CALL 2990 2991 { 2991 2992 if (!m_code) … … 3001 3002 virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL; 3002 3003 3003 OwnPtr< ProgramCodeBlock> m_code;3004 OwnPtr<EvalCodeBlock> m_code; 3004 3005 }; 3005 3006
Note: See TracChangeset
for help on using the changeset viewer.