Changeset 39070 in webkit for trunk/JavaScriptCore/bytecode/CodeBlock.h
- Timestamp:
- Dec 6, 2008, 2:01:05 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/bytecode/CodeBlock.h
r39038 r39070 216 216 }; 217 217 218 struct CodeBlock { 218 class CodeBlock { 219 friend class JIT; 220 public: 219 221 CodeBlock(ScopeNode* ownerNode, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset) 220 : ownerNode(ownerNode)221 , globalData(0)222 #if ENABLE(JIT)223 , ctiCode(0)224 #endif 225 , numCalleeRegisters(0)226 , numConstants(0)227 , numVars(0)228 , numParameters(0) 229 , needsFullScopeChain(ownerNode->needsActivation())230 , usesEval(ownerNode->usesEval())231 , codeType(codeType)232 , source(sourceProvider)233 , sourceOffset(sourceOffset)234 { 235 ASSERT( source);222 : m_numCalleeRegisters(0) 223 , m_numConstants(0) 224 , m_numVars(0) 225 , m_numParameters(0) 226 , m_ownerNode(ownerNode) 227 , m_globalData(0) 228 #if ENABLE(JIT) 229 , m_jitCode(0) 230 #endif 231 , m_needsFullScopeChain(ownerNode->needsActivation()) 232 , m_usesEval(ownerNode->usesEval()) 233 , m_codeType(codeType) 234 , m_source(sourceProvider) 235 , m_sourceOffset(sourceOffset) 236 { 237 ASSERT(m_source); 236 238 } 237 239 … … 245 247 { 246 248 caller->callee = this; 247 caller->position = linkedCallerList.size();248 linkedCallerList.append(caller);249 caller->position = m_linkedCallerList.size(); 250 m_linkedCallerList.append(caller); 249 251 } 250 252 … … 252 254 { 253 255 unsigned pos = caller->position; 254 unsigned lastPos = linkedCallerList.size() - 1;256 unsigned lastPos = m_linkedCallerList.size() - 1; 255 257 256 258 if (pos != lastPos) { 257 linkedCallerList[pos] =linkedCallerList[lastPos];258 linkedCallerList[pos]->position = pos;259 m_linkedCallerList[pos] = m_linkedCallerList[lastPos]; 260 m_linkedCallerList[pos]->position = pos; 259 261 } 260 linkedCallerList.shrink(lastPos);262 m_linkedCallerList.shrink(lastPos); 261 263 } 262 264 263 265 inline bool isKnownNotImmediate(int index) 264 266 { 265 if (index == thisRegister)267 if (index == m_thisRegister) 266 268 return true; 267 269 … … 274 276 ALWAYS_INLINE bool isConstantRegisterIndex(int index) 275 277 { 276 return index >= numVars && index < numVars +numConstants;278 return index >= m_numVars && index < m_numVars + m_numConstants; 277 279 } 278 280 279 281 ALWAYS_INLINE JSValue* getConstant(int index) 280 282 { 281 return constantRegisters[index -numVars].getJSValue();283 return m_constantRegisters[index - m_numVars].getJSValue(); 282 284 } 283 285 284 286 ALWAYS_INLINE bool isTemporaryRegisterIndex(int index) 285 287 { 286 return index >= numVars +numConstants;288 return index >= m_numVars + m_numConstants; 287 289 } 288 290 … … 303 305 StructureStubInfo& getStubInfo(void* returnAddress) 304 306 { 305 return *(binaryChop<StructureStubInfo, void*, getStructureStubInfoReturnLocation>( propertyAccessInstructions.begin(),propertyAccessInstructions.size(), returnAddress));307 return *(binaryChop<StructureStubInfo, void*, getStructureStubInfoReturnLocation>(m_propertyAccessInstructions.begin(), m_propertyAccessInstructions.size(), returnAddress)); 306 308 } 307 309 308 310 CallLinkInfo& getCallLinkInfo(void* returnAddress) 309 311 { 310 return *(binaryChop<CallLinkInfo, void*, getCallLinkInfoReturnLocation>(callLinkInfos.begin(), callLinkInfos.size(), returnAddress)); 311 } 312 313 void shrinkToFit(); 312 return *(binaryChop<CallLinkInfo, void*, getCallLinkInfoReturnLocation>(m_callLinkInfos.begin(), m_callLinkInfos.size(), returnAddress)); 313 } 314 315 316 Vector<Instruction>& instructions() { return m_instructions; } 317 #if ENABLE(JIT) 318 void setJITCode(void* jitCode) { m_jitCode = jitCode; } 319 void* jitCode() { return m_jitCode; } 320 #endif 321 322 ScopeNode* ownerNode() const { return m_ownerNode; } 323 324 void setGlobalData(JSGlobalData* globalData) { m_globalData = globalData; } 325 326 void setThisRegister(int thisRegister) { m_thisRegister = thisRegister; } 327 int thisRegister() const { return m_thisRegister; } 328 329 void setNeedsFullScopeChain(bool needsFullScopeChain) { m_needsFullScopeChain = needsFullScopeChain; } 330 bool needsFullScopeChain() const { return m_needsFullScopeChain; } 331 void setUsesEval(bool usesEval) { m_usesEval = usesEval; } 332 bool usesEval() const { return m_usesEval; } 333 void setUsesArguments(bool usesArguments) { m_usesArguments = usesArguments; } 334 bool usesArguments() const { return m_usesArguments; } 335 336 CodeType codeType() const { return m_codeType; } 337 338 SourceProvider* source() const { return m_source.get(); } 339 unsigned sourceOffset() const { return m_sourceOffset; } 340 341 void addGlobalResolveInstruction(unsigned globalResolveInstructions) { m_globalResolveInstructions.append(globalResolveInstructions); } 342 343 size_t numberOfPropertyAccessInstructions() const { return m_propertyAccessInstructions.size(); } 344 void addPropertyAccessInstruction(unsigned propertyAccessInstructions) { m_propertyAccessInstructions.append(StructureStubInfo(propertyAccessInstructions)); } 345 StructureStubInfo& propertyAccessInstruction(int index) { return m_propertyAccessInstructions[index]; } 346 347 size_t numberOfCallLinkInfos() const { return m_callLinkInfos.size(); } 348 void addCallLinkInfo() { m_callLinkInfos.append(CallLinkInfo()); } 349 CallLinkInfo& callLinkInfo(int index) { return m_callLinkInfos[index]; } 350 351 size_t numberOfJumpTargets() const { return m_jumpTargets.size(); } 352 void addJumpTarget(unsigned jumpTarget) { m_jumpTargets.append(jumpTarget); } 353 unsigned jumpTarget(int index) const { return m_jumpTargets[index]; } 354 unsigned lastJumpTarget() const { return m_jumpTargets.last(); } 355 356 size_t numberOfExceptionHandlers() const { return m_exceptionHandlers.size(); } 357 void addExceptionHandler(const HandlerInfo& hanler) { return m_exceptionHandlers.append(hanler); } 358 HandlerInfo& exceptionHandler(int index) { return m_exceptionHandlers[index]; } 359 360 void addExpressionInfo(const ExpressionRangeInfo& expressionInfo) { return m_expressionInfo.append(expressionInfo); } 361 362 size_t numberOfLineInfos() const { return m_lineInfo.size(); } 363 void addLineInfo(const LineInfo& lineInfo) { return m_lineInfo.append(lineInfo); } 364 LineInfo& lastLineInfo() { return m_lineInfo.last(); } 365 366 #if ENABLE(JIT) 367 HashMap<void*, unsigned>& jitReturnAddressVPCMap() { return m_jitReturnAddressVPCMap; } 368 #endif 369 370 // Constant Pool 371 372 size_t numberOfIdentifiers() const { return m_identifiers.size(); } 373 void addIdentifier(const Identifier& i) { return m_identifiers.append(i); } 374 Identifier& identifier(int index) { return m_identifiers[index]; } 375 376 size_t numberOfConstantRegisters() const { return m_constantRegisters.size(); } 377 void addConstantRegister(const Register& r) { return m_constantRegisters.append(r); } 378 Register& constantRegister(int index) { return m_constantRegisters[index]; } 379 380 unsigned addFunction(FuncDeclNode* n) { unsigned size = m_functions.size(); m_functions.append(n); return size; } 381 FuncDeclNode* function(int index) const { return m_functions[index].get(); } 382 383 unsigned addFunctionExpression(FuncExprNode* n) { unsigned size = m_functionExpressions.size(); m_functionExpressions.append(n); return size; } 384 FuncExprNode* functionExpression(int index) const { return m_functionExpressions[index].get(); } 385 386 unsigned addUnexpectedConstant(JSValue* v) { unsigned size = m_unexpectedConstants.size(); m_unexpectedConstants.append(v); return size; } 387 JSValue* unexpectedConstant(int index) const { return m_unexpectedConstants[index]; } 388 389 unsigned addRegExp(RegExp* r) { unsigned size = m_regexps.size(); m_regexps.append(r); return size; } 390 RegExp* regexp(int index) const { return m_regexps[index].get(); } 391 392 // Jump Tables 314 393 315 394 size_t numberOfImmediateSwitchJumpTables() const { return m_immediateSwitchJumpTables.size(); } … … 325 404 StringJumpTable& stringSwitchJumpTable(int tableIndex) { return m_stringSwitchJumpTables[tableIndex]; } 326 405 327 ScopeNode* ownerNode; 328 JSGlobalData* globalData; 329 #if ENABLE(JIT) 330 void* ctiCode; 331 #endif 332 333 int numCalleeRegisters; 334 406 407 SymbolTable& symbolTable() { return m_symbolTable; } 408 EvalCodeCache& evalCodeCache() { return m_evalCodeCache; } 409 410 void shrinkToFit(); 411 412 // FIXME: Make these remaining members private. 413 414 int m_numCalleeRegisters; 335 415 // NOTE: numConstants holds the number of constant registers allocated 336 416 // by the code generator, not the number of constant registers used. 337 417 // (Duplicate constants are uniqued during code generation, and spare 338 418 // constant registers may be allocated.) 339 int numConstants; 340 int numVars; 341 int numParameters; 342 int thisRegister; 343 bool needsFullScopeChain; 344 bool usesEval; 345 bool usesArguments; 346 CodeType codeType; 347 RefPtr<SourceProvider> source; 348 unsigned sourceOffset; 349 350 Vector<Instruction> instructions; 351 Vector<unsigned> globalResolveInstructions; 352 Vector<StructureStubInfo> propertyAccessInstructions; 353 Vector<CallLinkInfo> callLinkInfos; 354 Vector<CallLinkInfo*> linkedCallerList; 355 356 // Constant pool 357 Vector<Identifier> identifiers; 358 Vector<RefPtr<FuncDeclNode> > functions; 359 Vector<RefPtr<FuncExprNode> > functionExpressions; 360 Vector<Register> constantRegisters; 361 Vector<JSValue*> unexpectedConstants; 362 Vector<RefPtr<RegExp> > regexps; 363 Vector<HandlerInfo> exceptionHandlers; 364 Vector<ExpressionRangeInfo> expressionInfo; 365 Vector<LineInfo> lineInfo; 366 367 #if ENABLE(JIT) 368 HashMap<void*, unsigned> ctiReturnAddressVPCMap; 369 #endif 370 371 Vector<unsigned> jumpTargets; 372 373 EvalCodeCache evalCodeCache; 374 375 SymbolTable symbolTable; 419 int m_numConstants; 420 int m_numVars; 421 int m_numParameters; 422 376 423 private: 377 424 #if !defined(NDEBUG) || ENABLE(OPCODE_SAMPLING) … … 379 426 #endif 380 427 428 ScopeNode* m_ownerNode; 429 JSGlobalData* m_globalData; 430 431 Vector<Instruction> m_instructions; 432 #if ENABLE(JIT) 433 void* m_jitCode; 434 #endif 435 436 int m_thisRegister; 437 438 bool m_needsFullScopeChain; 439 bool m_usesEval; 440 bool m_usesArguments; 441 442 CodeType m_codeType; 443 444 RefPtr<SourceProvider> m_source; 445 unsigned m_sourceOffset; 446 447 Vector<unsigned> m_globalResolveInstructions; 448 Vector<StructureStubInfo> m_propertyAccessInstructions; 449 Vector<CallLinkInfo> m_callLinkInfos; 450 Vector<CallLinkInfo*> m_linkedCallerList; 451 452 Vector<unsigned> m_jumpTargets; 453 454 Vector<HandlerInfo> m_exceptionHandlers; 455 Vector<ExpressionRangeInfo> m_expressionInfo; 456 Vector<LineInfo> m_lineInfo; 457 458 #if ENABLE(JIT) 459 HashMap<void*, unsigned> m_jitReturnAddressVPCMap; 460 #endif 461 462 // Constant Pool 463 Vector<Identifier> m_identifiers; 464 Vector<Register> m_constantRegisters; 465 Vector<RefPtr<FuncDeclNode> > m_functions; 466 Vector<RefPtr<FuncExprNode> > m_functionExpressions; 467 Vector<JSValue*> m_unexpectedConstants; 468 Vector<RefPtr<RegExp> > m_regexps; 469 470 // Jump Tables 381 471 Vector<SimpleJumpTable> m_immediateSwitchJumpTables; 382 472 Vector<SimpleJumpTable> m_characterSwitchJumpTables; 383 473 Vector<StringJumpTable> m_stringSwitchJumpTables; 474 475 SymbolTable m_symbolTable; 476 477 EvalCodeCache m_evalCodeCache; 384 478 }; 385 479 … … 387 481 // responsible for marking it. 388 482 389 struct ProgramCodeBlock : public CodeBlock { 483 class ProgramCodeBlock : public CodeBlock { 484 public: 390 485 ProgramCodeBlock(ScopeNode* ownerNode, CodeType codeType, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider) 391 486 : CodeBlock(ownerNode, codeType, sourceProvider, 0) 392 , globalObject(globalObject)393 { 394 globalObject->codeBlocks().add(this);487 , m_globalObject(globalObject) 488 { 489 m_globalObject->codeBlocks().add(this); 395 490 } 396 491 397 492 ~ProgramCodeBlock() 398 493 { 399 if (globalObject) 400 globalObject->codeBlocks().remove(this); 401 } 402 403 JSGlobalObject* globalObject; // For program and eval nodes, the global object that marks the constant pool. 404 }; 405 406 struct EvalCodeBlock : public ProgramCodeBlock { 494 if (m_globalObject) 495 m_globalObject->codeBlocks().remove(this); 496 } 497 498 void clearGlobalObject() { m_globalObject = 0; } 499 500 private: 501 JSGlobalObject* m_globalObject; // For program and eval nodes, the global object that marks the constant pool. 502 }; 503 504 class EvalCodeBlock : public ProgramCodeBlock { 505 public: 407 506 EvalCodeBlock(ScopeNode* ownerNode, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider) 408 507 : ProgramCodeBlock(ownerNode, EvalCode, globalObject, sourceProvider)
Note:
See TracChangeset
for help on using the changeset viewer.