Changeset 41089 in webkit for trunk/JavaScriptCore/assembler/AbstractMacroAssembler.h
- Timestamp:
- Feb 19, 2009, 2:51:40 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/assembler/AbstractMacroAssembler.h
r40879 r41089 266 266 friend class AbstractMacroAssembler; 267 267 public: 268 enum Flags { 269 None = 0x0, 270 Linkable = 0x1, 271 Near = 0x2, 272 LinkableNear = 0x3, 273 }; 274 268 275 Call() 269 { 270 } 271 272 Call(JmpSrc jmp, bool isRelative) 276 : m_flags(None) 277 { 278 } 279 280 Call(JmpSrc jmp, Flags flags) 273 281 : m_jmp(jmp) 274 #ifndef NDEBUG 275 , isRelative(isRelative) 276 #endif 277 { 278 #ifdef NDEBUG 279 #pragma unused(isRelative) 280 #endif 281 } 282 283 void link(AbstractMacroAssembler<AssemblerType>* masm) 284 { 285 ASSERT(isRelative); 286 masm->m_assembler.link(m_jmp, masm->m_assembler.label()); 287 } 288 289 void linkTo(Label label, AbstractMacroAssembler<AssemblerType>* masm) 290 { 291 ASSERT(isRelative); 292 masm->m_assembler.link(m_jmp, label.m_label); 282 , m_flags(flags) 283 { 284 } 285 286 bool isFlagSet(Flags flag) 287 { 288 return m_flags & flag; 289 } 290 291 static Call fromTailJump(Jump jump) 292 { 293 return Call(jump.m_jmp, Linkable); 293 294 } 294 295 295 296 private: 296 297 JmpSrc m_jmp; 297 #ifndef NDEBUG 298 bool isRelative; 299 #endif 298 Flags m_flags; 300 299 }; 301 300 … … 310 309 template<class AssemblerType_T> 311 310 friend class AbstractMacroAssembler; 311 friend class Call; 312 312 public: 313 313 Jump() … … 322 322 void link(AbstractMacroAssembler<AssemblerType>* masm) 323 323 { 324 masm->m_assembler.link (m_jmp, masm->m_assembler.label());324 masm->m_assembler.linkJump(m_jmp, masm->m_assembler.label()); 325 325 } 326 326 327 327 void linkTo(Label label, AbstractMacroAssembler<AssemblerType>* masm) 328 328 { 329 masm->m_assembler.link (m_jmp, label.m_label);329 masm->m_assembler.linkJump(m_jmp, label.m_label); 330 330 } 331 331 … … 461 461 void relink(CodeLocationLabel destination) 462 462 { 463 AssemblerType::patch BranchOffset(reinterpret_cast<intptr_t>(this->m_location), destination.m_location);463 AssemblerType::patchJump(reinterpret_cast<intptr_t>(this->m_location), destination.m_location); 464 464 } 465 465 … … 485 485 void relink(FunctionSig* function) 486 486 { 487 AssemblerType::patch BranchOffset(reinterpret_cast<intptr_t>(this->m_location), reinterpret_cast<void*>(function));487 AssemblerType::patchMacroAssemblerCall(reinterpret_cast<intptr_t>(this->m_location), reinterpret_cast<void*>(function)); 488 488 } 489 489 … … 502 502 }; 503 503 504 // CodeLocationNearCall: 505 // 506 // A point in the JIT code at which there is a call instruction with near linkage. 507 class CodeLocationNearCall : public CodeLocationCommon { 508 friend class CodeLocationCommon; 509 friend class PatchBuffer; 510 public: 511 CodeLocationNearCall() 512 { 513 } 514 515 template<typename FunctionSig> 516 void relink(FunctionSig* function) 517 { 518 AssemblerType::patchCall(reinterpret_cast<intptr_t>(this->m_location), reinterpret_cast<void*>(function)); 519 } 520 521 // This methods returns the value that will be set as the return address 522 // within a function that has been called from this call instruction. 523 void* calleeReturnAddressValue() 524 { 525 return this->m_location; 526 } 527 528 private: 529 explicit CodeLocationNearCall(void* location) 530 : CodeLocationCommon(location) 531 { 532 } 533 }; 534 504 535 // CodeLocationDataLabel32: 505 536 // … … 561 592 void relinkCallerToFunction(FunctionSig* newCalleeFunction) 562 593 { 563 AssemblerType::patchBranchOffset(reinterpret_cast<intptr_t>(this->m_location), reinterpret_cast<void*>(newCalleeFunction)); 594 AssemblerType::patchMacroAssemblerCall(reinterpret_cast<intptr_t>(this->m_location), reinterpret_cast<void*>(newCalleeFunction)); 595 } 596 597 template<typename FunctionSig> 598 void relinkNearCallerToFunction(FunctionSig* newCalleeFunction) 599 { 600 AssemblerType::patchCall(reinterpret_cast<intptr_t>(this->m_location), reinterpret_cast<void*>(newCalleeFunction)); 564 601 } 565 602 … … 616 653 void link(Call call, FunctionSig* function) 617 654 { 618 AssemblerType::link(m_code, call.m_jmp, reinterpret_cast<void*>(function)); 655 ASSERT(call.isFlagSet(Call::Linkable)); 656 #if PLATFORM(X86_64) 657 if (call.isFlagSet(Call::Near)) { 658 AssemblerType::linkCall(m_code, call.m_jmp, reinterpret_cast<void*>(function)); 659 } else { 660 intptr_t callLocation = reinterpret_cast<intptr_t>(AssemblerType::getRelocatedAddress(m_code, call.m_jmp)); 661 AssemblerType::patchMacroAssemblerCall(callLocation, reinterpret_cast<void*>(function)); 662 } 663 #else 664 AssemblerType::linkCall(m_code, call.m_jmp, reinterpret_cast<void*>(function)); 665 #endif 619 666 } 620 667 … … 622 669 void linkTailRecursive(Jump jump, FunctionSig* function) 623 670 { 624 AssemblerType::link (m_code, jump.m_jmp, reinterpret_cast<void*>(function));671 AssemblerType::linkJump(m_code, jump.m_jmp, reinterpret_cast<void*>(function)); 625 672 } 626 673 … … 628 675 void linkTailRecursive(JumpList list, FunctionSig* function) 629 676 { 677 for (unsigned i = 0; i < list.m_jumps.size(); ++i) { 678 AssemblerType::linkJump(m_code, list.m_jumps[i].m_jmp, reinterpret_cast<void*>(function)); 679 } 680 } 681 682 void link(Jump jump, CodeLocationLabel label) 683 { 684 AssemblerType::linkJump(m_code, jump.m_jmp, label.m_location); 685 } 686 687 void link(JumpList list, CodeLocationLabel label) 688 { 630 689 for (unsigned i = 0; i < list.m_jumps.size(); ++i) 631 AssemblerType::link(m_code, list.m_jumps[i].m_jmp, reinterpret_cast<void*>(function)); 632 } 633 634 void link(Jump jump, CodeLocationLabel label) 635 { 636 AssemblerType::link(m_code, jump.m_jmp, label.m_location); 637 } 638 639 void link(JumpList list, CodeLocationLabel label) 640 { 641 for (unsigned i = 0; i < list.m_jumps.size(); ++i) 642 AssemblerType::link(m_code, list.m_jumps[i].m_jmp, label.m_location); 690 AssemblerType::linkJump(m_code, list.m_jumps[i].m_jmp, label.m_location); 643 691 } 644 692 … … 652 700 CodeLocationCall locationOf(Call call) 653 701 { 654 ASSERT(call.isRelative); 702 ASSERT(call.isFlagSet(Call::Linkable)); 703 ASSERT(!call.isFlagSet(Call::Near)); 655 704 return CodeLocationCall(AssemblerType::getRelocatedAddress(m_code, call.m_jmp)); 705 } 706 707 CodeLocationNearCall locationOfNearCall(Call call) 708 { 709 ASSERT(call.isFlagSet(Call::Linkable)); 710 ASSERT(call.isFlagSet(Call::Near)); 711 return CodeLocationNearCall(AssemblerType::getRelocatedAddress(m_code, call.m_jmp)); 656 712 } 657 713 … … 732 788 733 789 ptrdiff_t differenceBetween(DataLabelPtr from, Jump to) 790 { 791 return AssemblerType::getDifferenceBetweenLabels(from.m_label, to.m_jmp); 792 } 793 794 ptrdiff_t differenceBetween(DataLabelPtr from, Call to) 734 795 { 735 796 return AssemblerType::getDifferenceBetweenLabels(from.m_label, to.m_jmp);
Note:
See TracChangeset
for help on using the changeset viewer.