Changeset 34372 in webkit for trunk/JavaScriptCore/VM/CodeGenerator.h
- Timestamp:
- Jun 4, 2008, 10:36:55 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/VM/CodeGenerator.h
r34319 r34372 38 38 #include "Machine.h" 39 39 #include "RegisterID.h" 40 #include "SegmentedVector.h" 40 41 #include "SymbolTable.h" 41 #include "SegmentedVector.h"42 42 #include "debugger.h" 43 43 #include "nodes.h" … … 64 64 RegisterID* retAddrDst; 65 65 }; 66 66 67 67 struct ControlFlowContext { 68 68 bool isFinallyBlock; 69 69 FinallyContext finallyContext; 70 70 }; 71 71 72 72 class CodeGenerator { 73 73 public: 74 74 typedef DeclarationStacks::VarStack VarStack; 75 75 typedef DeclarationStacks::FunctionStack FunctionStack; 76 76 77 77 static void setDumpsGeneratedCode(bool dumpsGeneratedCode); 78 78 79 79 CodeGenerator(ProgramNode*, const Debugger*, const ScopeChain&, SymbolTable*, CodeBlock*, VarStack&, FunctionStack&, bool canCreateGlobals); 80 80 CodeGenerator(FunctionBodyNode*, const Debugger*, const ScopeChain&, SymbolTable*, CodeBlock*); … … 96 96 97 97 // Searches the scope chain in an attempt to statically locate the requested 98 // property. Returns false if for any reason the property cannot be safely 98 // property. Returns false if for any reason the property cannot be safely 99 99 // optimised at all. Otherwise it will return the index and depth of the 100 // VariableObject that defines the property. If the property cannot be found 100 // VariableObject that defines the property. If the property cannot be found 101 101 // statically, depth will contain the depth of the scope chain where dynamic 102 102 // lookup must begin. … … 133 133 134 134 // Returns the place to write the final output of an operation. 135 RegisterID* finalDestination(RegisterID* originalDst, RegisterID* tempDst = 0) 136 { 135 RegisterID* finalDestination(RegisterID* originalDst, RegisterID* tempDst = 0) 136 { 137 137 if (originalDst) 138 138 return originalDst; 139 139 if (tempDst && tempDst->isTemporary()) 140 140 return tempDst; 141 return newTemporary(); 142 } 143 144 RegisterID* destinationForAssignResult(RegisterID* dst) { 145 if (dst && m_codeBlock->needsFullScopeChain) 141 return newTemporary(); 142 } 143 144 RegisterID* destinationForAssignResult(RegisterID* dst) 145 { 146 if (dst && m_codeBlock->needsFullScopeChain) 146 147 return dst->isTemporary() ? dst : newTemporary(); 147 148 return 0; … … 151 152 RegisterID* moveToDestinationIfNeeded(RegisterID* dst, RegisterID* src) { return (dst && dst != src) ? emitMove(dst, src) : src; } 152 153 153 154 154 PassRefPtr<LabelID> newLabel(); 155 155 156 156 // The emitNode functions are just syntactic sugar for calling 157 157 // Node::emitCode. They're the only functions that accept a NULL register. 158 RegisterID* emitNode(RegisterID* dst, Node* n) { 158 RegisterID* emitNode(RegisterID* dst, Node* n) 159 { 159 160 // Node::emitCode assumes that dst, if provided, is either a local or a referenced temporary. 160 161 ASSERT(!dst || !dst->isTemporary() || dst->refCount()); … … 183 184 return dst; 184 185 } 185 186 186 187 return PassRefPtr<RegisterID>(emitNode(n)); 187 188 } … … 190 191 RegisterID* emitLoad(RegisterID* dst, double); 191 192 RegisterID* emitLoad(RegisterID* dst, JSValue*); 192 193 193 194 RegisterID* emitNewObject(RegisterID* dst); 194 195 RegisterID* emitNewArray(RegisterID* dst); … … 266 267 PassRefPtr<LabelID> emitJumpSubroutine(RegisterID* retAddrDst, LabelID*); 267 268 void emitSubroutineReturn(RegisterID* retAddrSrc); 268 269 269 270 RegisterID* emitGetPropertyNames(RegisterID* dst, RegisterID* base); 270 271 RegisterID* emitNextPropertyName(RegisterID* dst, RegisterID* iter, LabelID* target); … … 273 274 void emitThrow(RegisterID*); 274 275 RegisterID* emitNewError(RegisterID* dst, ErrorType type, JSValue* message); 275 276 276 277 RegisterID* emitPushScope(RegisterID* scope); 277 278 void emitPopScope(); 278 279 279 280 void emitDebugHook(DebugHookID, int firstLine, int lastLine); 280 281 281 282 int scopeDepth() { return m_dynamicScopeDepth + m_finallyDepth; } 282 283 283 284 void pushFinallyContext(LabelID* target, RegisterID* returnAddrDst); 284 285 void popFinallyContext(); … … 290 291 JumpContext* jumpContextForBreak(const Identifier&); 291 292 292 293 293 CodeType codeType() const { return m_codeType; } 294 294 295 private: 295 296 PassRefPtr<LabelID> emitComplexJumpScopes(LabelID* target, ControlFlowContext* topScope, ControlFlowContext* bottomScope); … … 300 301 301 302 typedef HashMap<JSValue*, unsigned, DefaultHash<JSValue*>::Hash, JSValueHashTraits> JSValueMap; 302 303 303 304 struct IdentifierMapIndexHashTraits { 304 305 typedef int TraitType; … … 316 317 // Maps a register index in the symbol table to a RegisterID index in m_locals. 317 318 int localsIndex(int registerIndex) { return -registerIndex - 1; } 318 319 319 320 // Returns the RegisterID corresponding to ident. 320 321 RegisterID* addVar(const Identifier& ident, bool isConstant) … … 335 336 unsigned addConstant(JSValue*); 336 337 unsigned addRegExp(RegExp* r); 337 338 338 339 Vector<Instruction>& instructions() { return m_codeBlock->instructions; } 339 340 SymbolTable& symbolTable() { return *m_symbolTable; } 340 341 Vector<HandlerInfo>& exceptionHandlers() { return m_codeBlock->exceptionHandlers; } 341 342 342 343 bool shouldOptimizeLocals() { return (m_codeType != EvalCode) && !m_dynamicScopeDepth; } 343 344 bool canOptimizeNonLocals() { return (m_codeType == FunctionCode) && !m_dynamicScopeDepth && !m_codeBlock->usesEval; } 344 345 345 346 bool m_shouldEmitDebugHooks; 346 347 347 348 const ScopeChain* m_scopeChain; 348 349 SymbolTable* m_symbolTable; 349 350 350 351 ScopeNode* m_scopeNode; 351 352 CodeBlock* m_codeBlock; 352 353 353 354 HashSet<RefPtr<UString::Rep>, IdentifierRepHash> m_functions; 354 355 RegisterID m_thisRegister; … … 359 360 int m_dynamicScopeDepth; 360 361 CodeType m_codeType; 361 362 362 363 Vector<JumpContext> m_jumpContextStack; 363 364 int m_continueDepth; … … 373 374 CommonIdentifiers* m_propertyNames; 374 375 375 #ifndef NDEBUG 376 #ifndef NDEBUG 376 377 static bool s_dumpsGeneratedCode; 377 378 #endif
Note:
See TracChangeset
for help on using the changeset viewer.