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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 int32_t* p = reinterpret_cast<int32_t*>(pc_); | 94 int32_t* p = reinterpret_cast<int32_t*>(pc_); |
95 *p += delta; // relocate entry | 95 *p += delta; // relocate entry |
96 } | 96 } |
97 // We do not use pc relative addressing on ARM, so there is | 97 // We do not use pc relative addressing on ARM, so there is |
98 // nothing else to do. | 98 // nothing else to do. |
99 } | 99 } |
100 | 100 |
101 | 101 |
102 Address RelocInfo::target_address() { | 102 Address RelocInfo::target_address() { |
103 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); | 103 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); |
104 return Assembler::target_address_at(pc_); | 104 return Assembler::target_address_at(pc_, host_); |
105 } | 105 } |
106 | 106 |
107 | 107 |
108 Address RelocInfo::target_address_address() { | 108 Address RelocInfo::target_address_address() { |
109 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) | 109 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) |
110 || rmode_ == EMBEDDED_OBJECT | 110 || rmode_ == EMBEDDED_OBJECT |
111 || rmode_ == EXTERNAL_REFERENCE); | 111 || rmode_ == EXTERNAL_REFERENCE); |
112 return Assembler::target_pointer_address_at(pc_); | 112 return Assembler::target_pointer_address_at(pc_); |
113 } | 113 } |
114 | 114 |
115 | 115 |
116 int RelocInfo::target_address_size() { | 116 int RelocInfo::target_address_size() { |
117 return kPointerSize; | 117 return kPointerSize; |
118 } | 118 } |
119 | 119 |
120 | 120 |
121 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) { | 121 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) { |
122 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); | 122 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); |
123 Assembler::set_target_address_at(pc_, target); | 123 Assembler::set_target_address_at(pc_, host_, target); |
124 if (mode == UPDATE_WRITE_BARRIER && host() != NULL && IsCodeTarget(rmode_)) { | 124 if (mode == UPDATE_WRITE_BARRIER && host() != NULL && IsCodeTarget(rmode_)) { |
125 Object* target_code = Code::GetCodeFromTargetAddress(target); | 125 Object* target_code = Code::GetCodeFromTargetAddress(target); |
126 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( | 126 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( |
127 host(), this, HeapObject::cast(target_code)); | 127 host(), this, HeapObject::cast(target_code)); |
128 } | 128 } |
129 } | 129 } |
130 | 130 |
131 | 131 |
132 Object* RelocInfo::target_object() { | 132 Object* RelocInfo::target_object() { |
133 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 133 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
134 return reinterpret_cast<Object*>(Assembler::target_address_at(pc_)); | 134 return reinterpret_cast<Object*>(Assembler::target_address_at(pc_, host_)); |
135 } | 135 } |
136 | 136 |
137 | 137 |
138 Handle<Object> RelocInfo::target_object_handle(Assembler* origin) { | 138 Handle<Object> RelocInfo::target_object_handle(Assembler* origin) { |
139 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 139 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
140 return Handle<Object>(reinterpret_cast<Object**>( | 140 return Handle<Object>(reinterpret_cast<Object**>( |
141 Assembler::target_address_at(pc_))); | 141 Assembler::target_address_at(pc_, host_))); |
142 } | 142 } |
143 | 143 |
144 | 144 |
145 void RelocInfo::set_target_object(Object* target, WriteBarrierMode mode) { | 145 void RelocInfo::set_target_object(Object* target, WriteBarrierMode mode) { |
146 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 146 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
147 ASSERT(!target->IsConsString()); | 147 ASSERT(!target->IsConsString()); |
148 Assembler::set_target_address_at(pc_, reinterpret_cast<Address>(target)); | 148 Assembler::set_target_address_at(pc_, host_, |
| 149 reinterpret_cast<Address>(target)); |
149 if (mode == UPDATE_WRITE_BARRIER && | 150 if (mode == UPDATE_WRITE_BARRIER && |
150 host() != NULL && | 151 host() != NULL && |
151 target->IsHeapObject()) { | 152 target->IsHeapObject()) { |
152 host()->GetHeap()->incremental_marking()->RecordWrite( | 153 host()->GetHeap()->incremental_marking()->RecordWrite( |
153 host(), &Memory::Object_at(pc_), HeapObject::cast(target)); | 154 host(), &Memory::Object_at(pc_), HeapObject::cast(target)); |
154 } | 155 } |
155 } | 156 } |
156 | 157 |
157 | 158 |
158 Address RelocInfo::target_reference() { | 159 Address RelocInfo::target_reference() { |
159 ASSERT(rmode_ == EXTERNAL_REFERENCE); | 160 ASSERT(rmode_ == EXTERNAL_REFERENCE); |
160 return Assembler::target_address_at(pc_); | 161 return Assembler::target_address_at(pc_, host_); |
161 } | 162 } |
162 | 163 |
163 | 164 |
164 Address RelocInfo::target_runtime_entry(Assembler* origin) { | 165 Address RelocInfo::target_runtime_entry(Assembler* origin) { |
165 ASSERT(IsRuntimeEntry(rmode_)); | 166 ASSERT(IsRuntimeEntry(rmode_)); |
166 return target_address(); | 167 return target_address(); |
167 } | 168 } |
168 | 169 |
169 | 170 |
170 void RelocInfo::set_target_runtime_entry(Address target, | 171 void RelocInfo::set_target_runtime_entry(Address target, |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); | 262 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); |
262 return reinterpret_cast<Object**>(pc_ + 2 * Assembler::kInstrSize); | 263 return reinterpret_cast<Object**>(pc_ + 2 * Assembler::kInstrSize); |
263 } | 264 } |
264 | 265 |
265 | 266 |
266 void RelocInfo::WipeOut() { | 267 void RelocInfo::WipeOut() { |
267 ASSERT(IsEmbeddedObject(rmode_) || | 268 ASSERT(IsEmbeddedObject(rmode_) || |
268 IsCodeTarget(rmode_) || | 269 IsCodeTarget(rmode_) || |
269 IsRuntimeEntry(rmode_) || | 270 IsRuntimeEntry(rmode_) || |
270 IsExternalReference(rmode_)); | 271 IsExternalReference(rmode_)); |
271 Assembler::set_target_address_at(pc_, NULL); | 272 Assembler::set_target_address_at(pc_, host_, NULL); |
272 } | 273 } |
273 | 274 |
274 | 275 |
275 bool RelocInfo::IsPatchedReturnSequence() { | 276 bool RelocInfo::IsPatchedReturnSequence() { |
276 Instr current_instr = Assembler::instr_at(pc_); | 277 Instr current_instr = Assembler::instr_at(pc_); |
277 Instr next_instr = Assembler::instr_at(pc_ + Assembler::kInstrSize); | 278 Instr next_instr = Assembler::instr_at(pc_ + Assembler::kInstrSize); |
278 // A patched return sequence is: | 279 // A patched return sequence is: |
279 // ldr ip, [pc, #0] | 280 // ldr ip, [pc, #0] |
280 // blx ip | 281 // blx ip |
281 return ((current_instr & kLdrPCMask) == kLdrPCPattern) | 282 return ((current_instr & kLdrPCMask) == kLdrPCPattern) |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 pc_ += kInstrSize; | 396 pc_ += kInstrSize; |
396 } | 397 } |
397 | 398 |
398 | 399 |
399 Address Assembler::target_pointer_address_at(Address pc) { | 400 Address Assembler::target_pointer_address_at(Address pc) { |
400 Instr instr = Memory::int32_at(pc); | 401 Instr instr = Memory::int32_at(pc); |
401 return pc + GetLdrRegisterImmediateOffset(instr) + kPcLoadDelta; | 402 return pc + GetLdrRegisterImmediateOffset(instr) + kPcLoadDelta; |
402 } | 403 } |
403 | 404 |
404 | 405 |
405 Address Assembler::target_address_at(Address pc) { | 406 Address Assembler::target_address_at(Address pc, |
| 407 ConstantPoolArray* constant_pool) { |
406 if (IsMovW(Memory::int32_at(pc))) { | 408 if (IsMovW(Memory::int32_at(pc))) { |
407 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize))); | 409 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize))); |
408 Instruction* instr = Instruction::At(pc); | 410 Instruction* instr = Instruction::At(pc); |
409 Instruction* next_instr = Instruction::At(pc + kInstrSize); | 411 Instruction* next_instr = Instruction::At(pc + kInstrSize); |
410 return reinterpret_cast<Address>( | 412 return reinterpret_cast<Address>( |
411 (next_instr->ImmedMovwMovtValue() << 16) | | 413 (next_instr->ImmedMovwMovtValue() << 16) | |
412 instr->ImmedMovwMovtValue()); | 414 instr->ImmedMovwMovtValue()); |
413 } | 415 } |
414 ASSERT(IsLdrPcImmediateOffset(Memory::int32_at(pc))); | 416 ASSERT(IsLdrPcImmediateOffset(Memory::int32_at(pc))); |
415 return Memory::Address_at(target_pointer_address_at(pc)); | 417 return Memory::Address_at(target_pointer_address_at(pc)); |
(...skipping 29 matching lines...) Expand all Loading... |
445 return pc + kInstrSize * 2; | 447 return pc + kInstrSize * 2; |
446 } else { | 448 } else { |
447 ASSERT(IsMovW(Memory::int32_at(pc))); | 449 ASSERT(IsMovW(Memory::int32_at(pc))); |
448 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize))); | 450 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize))); |
449 return pc + kInstrSize * 3; | 451 return pc + kInstrSize * 3; |
450 } | 452 } |
451 } | 453 } |
452 | 454 |
453 | 455 |
454 void Assembler::deserialization_set_special_target_at( | 456 void Assembler::deserialization_set_special_target_at( |
455 Address constant_pool_entry, Address target) { | 457 Address constant_pool_entry, Code* code, Address target) { |
456 Memory::Address_at(constant_pool_entry) = target; | 458 Memory::Address_at(constant_pool_entry) = target; |
457 } | 459 } |
458 | 460 |
459 | 461 |
460 static Instr EncodeMovwImmediate(uint32_t immediate) { | 462 static Instr EncodeMovwImmediate(uint32_t immediate) { |
461 ASSERT(immediate < 0x10000); | 463 ASSERT(immediate < 0x10000); |
462 return ((immediate & 0xf000) << 4) | (immediate & 0xfff); | 464 return ((immediate & 0xf000) << 4) | (immediate & 0xfff); |
463 } | 465 } |
464 | 466 |
465 | 467 |
466 void Assembler::set_target_address_at(Address pc, Address target) { | 468 void Assembler::set_target_address_at(Address pc, |
| 469 ConstantPoolArray* constant_pool, |
| 470 Address target) { |
467 if (IsMovW(Memory::int32_at(pc))) { | 471 if (IsMovW(Memory::int32_at(pc))) { |
468 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize))); | 472 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize))); |
469 uint32_t* instr_ptr = reinterpret_cast<uint32_t*>(pc); | 473 uint32_t* instr_ptr = reinterpret_cast<uint32_t*>(pc); |
470 uint32_t immediate = reinterpret_cast<uint32_t>(target); | 474 uint32_t immediate = reinterpret_cast<uint32_t>(target); |
471 uint32_t intermediate = instr_ptr[0]; | 475 uint32_t intermediate = instr_ptr[0]; |
472 intermediate &= ~EncodeMovwImmediate(0xFFFF); | 476 intermediate &= ~EncodeMovwImmediate(0xFFFF); |
473 intermediate |= EncodeMovwImmediate(immediate & 0xFFFF); | 477 intermediate |= EncodeMovwImmediate(immediate & 0xFFFF); |
474 instr_ptr[0] = intermediate; | 478 instr_ptr[0] = intermediate; |
475 intermediate = instr_ptr[1]; | 479 intermediate = instr_ptr[1]; |
476 intermediate &= ~EncodeMovwImmediate(0xFFFF); | 480 intermediate &= ~EncodeMovwImmediate(0xFFFF); |
(...skipping 13 matching lines...) Expand all Loading... |
490 // ldr ip, [pc, #...] | 494 // ldr ip, [pc, #...] |
491 // since the instruction accessing this address in the constant pool remains | 495 // since the instruction accessing this address in the constant pool remains |
492 // unchanged. | 496 // unchanged. |
493 } | 497 } |
494 } | 498 } |
495 | 499 |
496 | 500 |
497 } } // namespace v8::internal | 501 } } // namespace v8::internal |
498 | 502 |
499 #endif // V8_ARM_ASSEMBLER_ARM_INL_H_ | 503 #endif // V8_ARM_ASSEMBLER_ARM_INL_H_ |
OLD | NEW |