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