OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
6 // are met: | 6 // are met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 int RelocInfo::target_address_size() { | 98 int RelocInfo::target_address_size() { |
99 return kPointerSize; | 99 return kPointerSize; |
100 } | 100 } |
101 | 101 |
102 | 102 |
103 void RelocInfo::set_target_address(Address target, | 103 void RelocInfo::set_target_address(Address target, |
104 WriteBarrierMode write_barrier_mode, | 104 WriteBarrierMode write_barrier_mode, |
105 ICacheFlushMode icache_flush_mode) { | 105 ICacheFlushMode icache_flush_mode) { |
106 DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); | 106 DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); |
107 Assembler::set_target_address_at(pc_, host_, target, icache_flush_mode); | 107 Assembler::set_target_address_at(isolate_, pc_, host_, target, |
| 108 icache_flush_mode); |
108 if (write_barrier_mode == UPDATE_WRITE_BARRIER && | 109 if (write_barrier_mode == UPDATE_WRITE_BARRIER && |
109 host() != NULL && IsCodeTarget(rmode_)) { | 110 host() != NULL && IsCodeTarget(rmode_)) { |
110 Object* target_code = Code::GetCodeFromTargetAddress(target); | 111 Object* target_code = Code::GetCodeFromTargetAddress(target); |
111 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( | 112 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( |
112 host(), this, HeapObject::cast(target_code)); | 113 host(), this, HeapObject::cast(target_code)); |
113 } | 114 } |
114 } | 115 } |
115 | 116 |
116 | 117 |
117 Object* RelocInfo::target_object() { | 118 Object* RelocInfo::target_object() { |
118 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 119 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
119 return reinterpret_cast<Object*>(Assembler::target_address_at(pc_, host_)); | 120 return reinterpret_cast<Object*>(Assembler::target_address_at(pc_, host_)); |
120 } | 121 } |
121 | 122 |
122 | 123 |
123 Handle<Object> RelocInfo::target_object_handle(Assembler* origin) { | 124 Handle<Object> RelocInfo::target_object_handle(Assembler* origin) { |
124 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 125 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
125 return Handle<Object>(reinterpret_cast<Object**>( | 126 return Handle<Object>(reinterpret_cast<Object**>( |
126 Assembler::target_address_at(pc_, host_))); | 127 Assembler::target_address_at(pc_, host_))); |
127 } | 128 } |
128 | 129 |
129 | 130 |
130 void RelocInfo::set_target_object(Object* target, | 131 void RelocInfo::set_target_object(Object* target, |
131 WriteBarrierMode write_barrier_mode, | 132 WriteBarrierMode write_barrier_mode, |
132 ICacheFlushMode icache_flush_mode) { | 133 ICacheFlushMode icache_flush_mode) { |
133 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 134 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
134 Assembler::set_target_address_at(pc_, host_, | 135 Assembler::set_target_address_at(isolate_, pc_, host_, |
135 reinterpret_cast<Address>(target), | 136 reinterpret_cast<Address>(target), |
136 icache_flush_mode); | 137 icache_flush_mode); |
137 if (write_barrier_mode == UPDATE_WRITE_BARRIER && | 138 if (write_barrier_mode == UPDATE_WRITE_BARRIER && |
138 host() != NULL && | 139 host() != NULL && |
139 target->IsHeapObject()) { | 140 target->IsHeapObject()) { |
140 host()->GetHeap()->incremental_marking()->RecordWrite( | 141 host()->GetHeap()->incremental_marking()->RecordWrite( |
141 host(), &Memory::Object_at(pc_), HeapObject::cast(target)); | 142 host(), &Memory::Object_at(pc_), HeapObject::cast(target)); |
142 } | 143 } |
143 } | 144 } |
144 | 145 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 } | 251 } |
251 | 252 |
252 | 253 |
253 void RelocInfo::WipeOut() { | 254 void RelocInfo::WipeOut() { |
254 DCHECK(IsEmbeddedObject(rmode_) || IsCodeTarget(rmode_) || | 255 DCHECK(IsEmbeddedObject(rmode_) || IsCodeTarget(rmode_) || |
255 IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) || | 256 IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) || |
256 IsInternalReference(rmode_)); | 257 IsInternalReference(rmode_)); |
257 if (IsInternalReference(rmode_)) { | 258 if (IsInternalReference(rmode_)) { |
258 Memory::Address_at(pc_) = NULL; | 259 Memory::Address_at(pc_) = NULL; |
259 } else { | 260 } else { |
260 Assembler::set_target_address_at(pc_, host_, NULL); | 261 Assembler::set_target_address_at(isolate_, pc_, host_, NULL); |
261 } | 262 } |
262 } | 263 } |
263 | 264 |
264 | 265 |
265 bool RelocInfo::IsPatchedReturnSequence() { | 266 bool RelocInfo::IsPatchedReturnSequence() { |
266 Instr current_instr = Assembler::instr_at(pc_); | 267 Instr current_instr = Assembler::instr_at(pc_); |
267 Instr next_instr = Assembler::instr_at(pc_ + Assembler::kInstrSize); | 268 Instr next_instr = Assembler::instr_at(pc_ + Assembler::kInstrSize); |
268 // A patched return sequence is: | 269 // A patched return sequence is: |
269 // ldr ip, [pc, #0] | 270 // ldr ip, [pc, #0] |
270 // blx ip | 271 // blx ip |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 } else { | 466 } else { |
466 // A mov / orr load immediate. | 467 // A mov / orr load immediate. |
467 return pc + kInstrSize * 5; | 468 return pc + kInstrSize * 5; |
468 } | 469 } |
469 } | 470 } |
470 } | 471 } |
471 } | 472 } |
472 | 473 |
473 | 474 |
474 void Assembler::deserialization_set_special_target_at( | 475 void Assembler::deserialization_set_special_target_at( |
475 Address constant_pool_entry, Code* code, Address target) { | 476 Isolate* isolate, Address constant_pool_entry, Code* code, Address target) { |
476 if (FLAG_enable_embedded_constant_pool) { | 477 if (FLAG_enable_embedded_constant_pool) { |
477 set_target_address_at(constant_pool_entry, code, target); | 478 set_target_address_at(isolate, constant_pool_entry, code, target); |
478 } else { | 479 } else { |
479 Memory::Address_at(constant_pool_entry) = target; | 480 Memory::Address_at(constant_pool_entry) = target; |
480 } | 481 } |
481 } | 482 } |
482 | 483 |
483 | 484 |
484 void Assembler::deserialization_set_target_internal_reference_at( | 485 void Assembler::deserialization_set_target_internal_reference_at( |
485 Address pc, Address target, RelocInfo::Mode mode) { | 486 Isolate* isolate, Address pc, Address target, RelocInfo::Mode mode) { |
486 Memory::Address_at(pc) = target; | 487 Memory::Address_at(pc) = target; |
487 } | 488 } |
488 | 489 |
489 | 490 |
490 bool Assembler::is_constant_pool_load(Address pc) { | 491 bool Assembler::is_constant_pool_load(Address pc) { |
491 if (CpuFeatures::IsSupported(ARMv7)) { | 492 if (CpuFeatures::IsSupported(ARMv7)) { |
492 return !Assembler::IsMovW(Memory::int32_at(pc)) || | 493 return !Assembler::IsMovW(Memory::int32_at(pc)) || |
493 (FLAG_enable_embedded_constant_pool && | 494 (FLAG_enable_embedded_constant_pool && |
494 Assembler::IsLdrPpRegOffset( | 495 Assembler::IsLdrPpRegOffset( |
495 Memory::int32_at(pc + 2 * Assembler::kInstrSize))); | 496 Memory::int32_at(pc + 2 * Assembler::kInstrSize))); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 Instr orr_instr_2 = instr_at(pc + 2 * kInstrSize); | 566 Instr orr_instr_2 = instr_at(pc + 2 * kInstrSize); |
566 Instr orr_instr_3 = instr_at(pc + 3 * kInstrSize); | 567 Instr orr_instr_3 = instr_at(pc + 3 * kInstrSize); |
567 Address ret = reinterpret_cast<Address>( | 568 Address ret = reinterpret_cast<Address>( |
568 DecodeShiftImm(mov_instr) | DecodeShiftImm(orr_instr_1) | | 569 DecodeShiftImm(mov_instr) | DecodeShiftImm(orr_instr_1) | |
569 DecodeShiftImm(orr_instr_2) | DecodeShiftImm(orr_instr_3)); | 570 DecodeShiftImm(orr_instr_2) | DecodeShiftImm(orr_instr_3)); |
570 return ret; | 571 return ret; |
571 } | 572 } |
572 } | 573 } |
573 | 574 |
574 | 575 |
575 void Assembler::set_target_address_at(Address pc, Address constant_pool, | 576 void Assembler::set_target_address_at(Isolate* isolate, Address pc, |
576 Address target, | 577 Address constant_pool, Address target, |
577 ICacheFlushMode icache_flush_mode) { | 578 ICacheFlushMode icache_flush_mode) { |
578 if (is_constant_pool_load(pc)) { | 579 if (is_constant_pool_load(pc)) { |
579 // This is a constant pool lookup. Update the entry in the constant pool. | 580 // This is a constant pool lookup. Update the entry in the constant pool. |
580 Memory::Address_at(constant_pool_entry_address(pc, constant_pool)) = target; | 581 Memory::Address_at(constant_pool_entry_address(pc, constant_pool)) = target; |
581 // Intuitively, we would think it is necessary to always flush the | 582 // Intuitively, we would think it is necessary to always flush the |
582 // instruction cache after patching a target address in the code as follows: | 583 // instruction cache after patching a target address in the code as follows: |
583 // Assembler::FlushICacheWithoutIsolate(pc, sizeof(target)); | 584 // Assembler::FlushICache(isolate, pc, sizeof(target)); |
584 // However, on ARM, no instruction is actually patched in the case | 585 // However, on ARM, no instruction is actually patched in the case |
585 // of embedded constants of the form: | 586 // of embedded constants of the form: |
586 // ldr ip, [pp, #...] | 587 // ldr ip, [pp, #...] |
587 // since the instruction accessing this address in the constant pool remains | 588 // since the instruction accessing this address in the constant pool remains |
588 // unchanged. | 589 // unchanged. |
589 } else if (CpuFeatures::IsSupported(ARMv7)) { | 590 } else if (CpuFeatures::IsSupported(ARMv7)) { |
590 // This is an movw / movt immediate load. Patch the immediate embedded in | 591 // This is an movw / movt immediate load. Patch the immediate embedded in |
591 // the instructions. | 592 // the instructions. |
592 DCHECK(IsMovW(Memory::int32_at(pc))); | 593 DCHECK(IsMovW(Memory::int32_at(pc))); |
593 DCHECK(IsMovT(Memory::int32_at(pc + kInstrSize))); | 594 DCHECK(IsMovT(Memory::int32_at(pc + kInstrSize))); |
594 uint32_t* instr_ptr = reinterpret_cast<uint32_t*>(pc); | 595 uint32_t* instr_ptr = reinterpret_cast<uint32_t*>(pc); |
595 uint32_t immediate = reinterpret_cast<uint32_t>(target); | 596 uint32_t immediate = reinterpret_cast<uint32_t>(target); |
596 instr_ptr[0] = PatchMovwImmediate(instr_ptr[0], immediate & 0xFFFF); | 597 instr_ptr[0] = PatchMovwImmediate(instr_ptr[0], immediate & 0xFFFF); |
597 instr_ptr[1] = PatchMovwImmediate(instr_ptr[1], immediate >> 16); | 598 instr_ptr[1] = PatchMovwImmediate(instr_ptr[1], immediate >> 16); |
598 DCHECK(IsMovW(Memory::int32_at(pc))); | 599 DCHECK(IsMovW(Memory::int32_at(pc))); |
599 DCHECK(IsMovT(Memory::int32_at(pc + kInstrSize))); | 600 DCHECK(IsMovT(Memory::int32_at(pc + kInstrSize))); |
600 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { | 601 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { |
601 Assembler::FlushICacheWithoutIsolate(pc, 2 * kInstrSize); | 602 Assembler::FlushICache(isolate, pc, 2 * kInstrSize); |
602 } | 603 } |
603 } else { | 604 } else { |
604 // This is an mov / orr immediate load. Patch the immediate embedded in | 605 // This is an mov / orr immediate load. Patch the immediate embedded in |
605 // the instructions. | 606 // the instructions. |
606 DCHECK(IsMovImmed(Memory::int32_at(pc)) && | 607 DCHECK(IsMovImmed(Memory::int32_at(pc)) && |
607 IsOrrImmed(Memory::int32_at(pc + kInstrSize)) && | 608 IsOrrImmed(Memory::int32_at(pc + kInstrSize)) && |
608 IsOrrImmed(Memory::int32_at(pc + 2 * kInstrSize)) && | 609 IsOrrImmed(Memory::int32_at(pc + 2 * kInstrSize)) && |
609 IsOrrImmed(Memory::int32_at(pc + 3 * kInstrSize))); | 610 IsOrrImmed(Memory::int32_at(pc + 3 * kInstrSize))); |
610 uint32_t* instr_ptr = reinterpret_cast<uint32_t*>(pc); | 611 uint32_t* instr_ptr = reinterpret_cast<uint32_t*>(pc); |
611 uint32_t immediate = reinterpret_cast<uint32_t>(target); | 612 uint32_t immediate = reinterpret_cast<uint32_t>(target); |
612 instr_ptr[0] = PatchShiftImm(instr_ptr[0], immediate & kImm8Mask); | 613 instr_ptr[0] = PatchShiftImm(instr_ptr[0], immediate & kImm8Mask); |
613 instr_ptr[1] = PatchShiftImm(instr_ptr[1], immediate & (kImm8Mask << 8)); | 614 instr_ptr[1] = PatchShiftImm(instr_ptr[1], immediate & (kImm8Mask << 8)); |
614 instr_ptr[2] = PatchShiftImm(instr_ptr[2], immediate & (kImm8Mask << 16)); | 615 instr_ptr[2] = PatchShiftImm(instr_ptr[2], immediate & (kImm8Mask << 16)); |
615 instr_ptr[3] = PatchShiftImm(instr_ptr[3], immediate & (kImm8Mask << 24)); | 616 instr_ptr[3] = PatchShiftImm(instr_ptr[3], immediate & (kImm8Mask << 24)); |
616 DCHECK(IsMovImmed(Memory::int32_at(pc)) && | 617 DCHECK(IsMovImmed(Memory::int32_at(pc)) && |
617 IsOrrImmed(Memory::int32_at(pc + kInstrSize)) && | 618 IsOrrImmed(Memory::int32_at(pc + kInstrSize)) && |
618 IsOrrImmed(Memory::int32_at(pc + 2 * kInstrSize)) && | 619 IsOrrImmed(Memory::int32_at(pc + 2 * kInstrSize)) && |
619 IsOrrImmed(Memory::int32_at(pc + 3 * kInstrSize))); | 620 IsOrrImmed(Memory::int32_at(pc + 3 * kInstrSize))); |
620 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { | 621 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { |
621 Assembler::FlushICacheWithoutIsolate(pc, 4 * kInstrSize); | 622 Assembler::FlushICache(isolate, pc, 4 * kInstrSize); |
622 } | 623 } |
623 } | 624 } |
624 } | 625 } |
625 | 626 |
626 | 627 |
627 } // namespace internal | 628 } // namespace internal |
628 } // namespace v8 | 629 } // namespace v8 |
629 | 630 |
630 #endif // V8_ARM_ASSEMBLER_ARM_INL_H_ | 631 #endif // V8_ARM_ASSEMBLER_ARM_INL_H_ |
OLD | NEW |