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 Address RelocInfo::constant_pool_entry_address() { | 116 Address RelocInfo::constant_pool_entry_address() { |
117 ASSERT(IsInConstantPool()); | 117 ASSERT(IsInConstantPool()); |
118 ASSERT(Assembler::IsLdrPcImmediateOffset(Memory::int32_at(pc_))); | 118 ASSERT(Assembler::IsLdrPcImmediateOffset(Memory::int32_at(pc_))); |
119 return Assembler::target_pointer_address_at(pc_); | 119 return Assembler::target_pointer_address_at(pc_); |
120 } | 120 } |
121 | 121 |
122 | 122 |
123 int RelocInfo::target_address_size() { | 123 int RelocInfo::target_address_size() { |
124 return kPointerSize; | 124 return kPointerSize; |
125 } | 125 } |
126 | 126 |
127 | 127 |
128 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) { | 128 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) { |
129 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); | 129 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); |
130 Assembler::set_target_address_at(pc_, target); | 130 Assembler::set_target_address_at(pc_, host_, target); |
131 if (mode == UPDATE_WRITE_BARRIER && host() != NULL && IsCodeTarget(rmode_)) { | 131 if (mode == UPDATE_WRITE_BARRIER && host() != NULL && IsCodeTarget(rmode_)) { |
132 Object* target_code = Code::GetCodeFromTargetAddress(target); | 132 Object* target_code = Code::GetCodeFromTargetAddress(target); |
133 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( | 133 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( |
134 host(), this, HeapObject::cast(target_code)); | 134 host(), this, HeapObject::cast(target_code)); |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 | 138 |
139 Object* RelocInfo::target_object() { | 139 Object* RelocInfo::target_object() { |
140 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 140 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
141 return reinterpret_cast<Object*>(Assembler::target_address_at(pc_)); | 141 return reinterpret_cast<Object*>(Assembler::target_address_at(pc_, host_)); |
142 } | 142 } |
143 | 143 |
144 | 144 |
145 Handle<Object> RelocInfo::target_object_handle(Assembler* origin) { | 145 Handle<Object> RelocInfo::target_object_handle(Assembler* origin) { |
146 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 146 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
147 return Handle<Object>(reinterpret_cast<Object**>( | 147 return Handle<Object>(reinterpret_cast<Object**>( |
148 Assembler::target_address_at(pc_))); | 148 Assembler::target_address_at(pc_, host_))); |
149 } | 149 } |
150 | 150 |
151 | 151 |
152 void RelocInfo::set_target_object(Object* target, WriteBarrierMode mode) { | 152 void RelocInfo::set_target_object(Object* target, WriteBarrierMode mode) { |
153 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 153 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
154 ASSERT(!target->IsConsString()); | 154 ASSERT(!target->IsConsString()); |
155 Assembler::set_target_address_at(pc_, reinterpret_cast<Address>(target)); | 155 Assembler::set_target_address_at(pc_, host_, |
| 156 reinterpret_cast<Address>(target)); |
156 if (mode == UPDATE_WRITE_BARRIER && | 157 if (mode == UPDATE_WRITE_BARRIER && |
157 host() != NULL && | 158 host() != NULL && |
158 target->IsHeapObject()) { | 159 target->IsHeapObject()) { |
159 host()->GetHeap()->incremental_marking()->RecordWrite( | 160 host()->GetHeap()->incremental_marking()->RecordWrite( |
160 host(), &Memory::Object_at(pc_), HeapObject::cast(target)); | 161 host(), &Memory::Object_at(pc_), HeapObject::cast(target)); |
161 } | 162 } |
162 } | 163 } |
163 | 164 |
164 | 165 |
165 Address RelocInfo::target_reference() { | 166 Address RelocInfo::target_reference() { |
166 ASSERT(rmode_ == EXTERNAL_REFERENCE); | 167 ASSERT(rmode_ == EXTERNAL_REFERENCE); |
167 return Assembler::target_address_at(pc_); | 168 return Assembler::target_address_at(pc_, host_); |
168 } | 169 } |
169 | 170 |
170 | 171 |
171 Address RelocInfo::target_runtime_entry(Assembler* origin) { | 172 Address RelocInfo::target_runtime_entry(Assembler* origin) { |
172 ASSERT(IsRuntimeEntry(rmode_)); | 173 ASSERT(IsRuntimeEntry(rmode_)); |
173 return target_address(); | 174 return target_address(); |
174 } | 175 } |
175 | 176 |
176 | 177 |
177 void RelocInfo::set_target_runtime_entry(Address target, | 178 void RelocInfo::set_target_runtime_entry(Address target, |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); | 269 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); |
269 return reinterpret_cast<Object**>(pc_ + 2 * Assembler::kInstrSize); | 270 return reinterpret_cast<Object**>(pc_ + 2 * Assembler::kInstrSize); |
270 } | 271 } |
271 | 272 |
272 | 273 |
273 void RelocInfo::WipeOut() { | 274 void RelocInfo::WipeOut() { |
274 ASSERT(IsEmbeddedObject(rmode_) || | 275 ASSERT(IsEmbeddedObject(rmode_) || |
275 IsCodeTarget(rmode_) || | 276 IsCodeTarget(rmode_) || |
276 IsRuntimeEntry(rmode_) || | 277 IsRuntimeEntry(rmode_) || |
277 IsExternalReference(rmode_)); | 278 IsExternalReference(rmode_)); |
278 Assembler::set_target_address_at(pc_, NULL); | 279 Assembler::set_target_address_at(pc_, host_, NULL); |
279 } | 280 } |
280 | 281 |
281 | 282 |
282 bool RelocInfo::IsPatchedReturnSequence() { | 283 bool RelocInfo::IsPatchedReturnSequence() { |
283 Instr current_instr = Assembler::instr_at(pc_); | 284 Instr current_instr = Assembler::instr_at(pc_); |
284 Instr next_instr = Assembler::instr_at(pc_ + Assembler::kInstrSize); | 285 Instr next_instr = Assembler::instr_at(pc_ + Assembler::kInstrSize); |
285 // A patched return sequence is: | 286 // A patched return sequence is: |
286 // ldr ip, [pc, #0] | 287 // ldr ip, [pc, #0] |
287 // blx ip | 288 // blx ip |
288 return ((current_instr & kLdrPCMask) == kLdrPCPattern) | 289 return ((current_instr & kLdrPCMask) == kLdrPCPattern) |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 pc_ += kInstrSize; | 403 pc_ += kInstrSize; |
403 } | 404 } |
404 | 405 |
405 | 406 |
406 Address Assembler::target_pointer_address_at(Address pc) { | 407 Address Assembler::target_pointer_address_at(Address pc) { |
407 Instr instr = Memory::int32_at(pc); | 408 Instr instr = Memory::int32_at(pc); |
408 return pc + GetLdrRegisterImmediateOffset(instr) + kPcLoadDelta; | 409 return pc + GetLdrRegisterImmediateOffset(instr) + kPcLoadDelta; |
409 } | 410 } |
410 | 411 |
411 | 412 |
412 Address Assembler::target_address_at(Address pc) { | 413 Address Assembler::target_address_at(Address pc, |
| 414 ConstantPoolArray* constant_pool) { |
413 if (IsMovW(Memory::int32_at(pc))) { | 415 if (IsMovW(Memory::int32_at(pc))) { |
414 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize))); | 416 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize))); |
415 Instruction* instr = Instruction::At(pc); | 417 Instruction* instr = Instruction::At(pc); |
416 Instruction* next_instr = Instruction::At(pc + kInstrSize); | 418 Instruction* next_instr = Instruction::At(pc + kInstrSize); |
417 return reinterpret_cast<Address>( | 419 return reinterpret_cast<Address>( |
418 (next_instr->ImmedMovwMovtValue() << 16) | | 420 (next_instr->ImmedMovwMovtValue() << 16) | |
419 instr->ImmedMovwMovtValue()); | 421 instr->ImmedMovwMovtValue()); |
420 } | 422 } |
421 ASSERT(IsLdrPcImmediateOffset(Memory::int32_at(pc))); | 423 ASSERT(IsLdrPcImmediateOffset(Memory::int32_at(pc))); |
422 return Memory::Address_at(target_pointer_address_at(pc)); | 424 return Memory::Address_at(target_pointer_address_at(pc)); |
(...skipping 29 matching lines...) Expand all Loading... |
452 return pc + kInstrSize * 2; | 454 return pc + kInstrSize * 2; |
453 } else { | 455 } else { |
454 ASSERT(IsMovW(Memory::int32_at(pc))); | 456 ASSERT(IsMovW(Memory::int32_at(pc))); |
455 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize))); | 457 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize))); |
456 return pc + kInstrSize * 3; | 458 return pc + kInstrSize * 3; |
457 } | 459 } |
458 } | 460 } |
459 | 461 |
460 | 462 |
461 void Assembler::deserialization_set_special_target_at( | 463 void Assembler::deserialization_set_special_target_at( |
462 Address constant_pool_entry, Address target) { | 464 Address constant_pool_entry, Code* code, Address target) { |
463 Memory::Address_at(constant_pool_entry) = target; | 465 Memory::Address_at(constant_pool_entry) = target; |
464 } | 466 } |
465 | 467 |
466 | 468 |
467 static Instr EncodeMovwImmediate(uint32_t immediate) { | 469 static Instr EncodeMovwImmediate(uint32_t immediate) { |
468 ASSERT(immediate < 0x10000); | 470 ASSERT(immediate < 0x10000); |
469 return ((immediate & 0xf000) << 4) | (immediate & 0xfff); | 471 return ((immediate & 0xf000) << 4) | (immediate & 0xfff); |
470 } | 472 } |
471 | 473 |
472 | 474 |
473 void Assembler::set_target_address_at(Address pc, Address target) { | 475 void Assembler::set_target_address_at(Address pc, |
| 476 ConstantPoolArray* constant_pool, |
| 477 Address target) { |
474 if (IsMovW(Memory::int32_at(pc))) { | 478 if (IsMovW(Memory::int32_at(pc))) { |
475 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize))); | 479 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize))); |
476 uint32_t* instr_ptr = reinterpret_cast<uint32_t*>(pc); | 480 uint32_t* instr_ptr = reinterpret_cast<uint32_t*>(pc); |
477 uint32_t immediate = reinterpret_cast<uint32_t>(target); | 481 uint32_t immediate = reinterpret_cast<uint32_t>(target); |
478 uint32_t intermediate = instr_ptr[0]; | 482 uint32_t intermediate = instr_ptr[0]; |
479 intermediate &= ~EncodeMovwImmediate(0xFFFF); | 483 intermediate &= ~EncodeMovwImmediate(0xFFFF); |
480 intermediate |= EncodeMovwImmediate(immediate & 0xFFFF); | 484 intermediate |= EncodeMovwImmediate(immediate & 0xFFFF); |
481 instr_ptr[0] = intermediate; | 485 instr_ptr[0] = intermediate; |
482 intermediate = instr_ptr[1]; | 486 intermediate = instr_ptr[1]; |
483 intermediate &= ~EncodeMovwImmediate(0xFFFF); | 487 intermediate &= ~EncodeMovwImmediate(0xFFFF); |
(...skipping 13 matching lines...) Expand all Loading... |
497 // ldr ip, [pc, #...] | 501 // ldr ip, [pc, #...] |
498 // since the instruction accessing this address in the constant pool remains | 502 // since the instruction accessing this address in the constant pool remains |
499 // unchanged. | 503 // unchanged. |
500 } | 504 } |
501 } | 505 } |
502 | 506 |
503 | 507 |
504 } } // namespace v8::internal | 508 } } // namespace v8::internal |
505 | 509 |
506 #endif // V8_ARM_ASSEMBLER_ARM_INL_H_ | 510 #endif // V8_ARM_ASSEMBLER_ARM_INL_H_ |
OLD | NEW |