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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 if (mode == UPDATE_WRITE_BARRIER && host() != NULL && IsCodeTarget(rmode_)) { | 119 if (mode == UPDATE_WRITE_BARRIER && host() != NULL && IsCodeTarget(rmode_)) { |
120 Object* target_code = Code::GetCodeFromTargetAddress(target); | 120 Object* target_code = Code::GetCodeFromTargetAddress(target); |
121 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( | 121 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( |
122 host(), this, HeapObject::cast(target_code)); | 122 host(), this, HeapObject::cast(target_code)); |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
126 | 126 |
127 Object* RelocInfo::target_object() { | 127 Object* RelocInfo::target_object() { |
128 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 128 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
129 return reinterpret_cast<Object*>(Assembler::target_pointer_at(pc_)); | 129 return reinterpret_cast<Object*>(Assembler::target_address_at(pc_)); |
130 } | 130 } |
131 | 131 |
132 | 132 |
133 Handle<Object> RelocInfo::target_object_handle(Assembler* origin) { | 133 Handle<Object> RelocInfo::target_object_handle(Assembler* origin) { |
134 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 134 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
135 return Handle<Object>(reinterpret_cast<Object**>( | 135 return Handle<Object>(reinterpret_cast<Object**>( |
136 Assembler::target_pointer_at(pc_))); | 136 Assembler::target_address_at(pc_))); |
137 } | 137 } |
138 | 138 |
139 | 139 |
140 void RelocInfo::set_target_object(Object* target, WriteBarrierMode mode) { | 140 void RelocInfo::set_target_object(Object* target, WriteBarrierMode mode) { |
141 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 141 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
142 ASSERT(!target->IsConsString()); | 142 ASSERT(!target->IsConsString()); |
143 Assembler::set_target_pointer_at(pc_, reinterpret_cast<Address>(target)); | 143 Assembler::set_target_address_at(pc_, reinterpret_cast<Address>(target)); |
144 if (mode == UPDATE_WRITE_BARRIER && | 144 if (mode == UPDATE_WRITE_BARRIER && |
145 host() != NULL && | 145 host() != NULL && |
146 target->IsHeapObject()) { | 146 target->IsHeapObject()) { |
147 host()->GetHeap()->incremental_marking()->RecordWrite( | 147 host()->GetHeap()->incremental_marking()->RecordWrite( |
148 host(), &Memory::Object_at(pc_), HeapObject::cast(target)); | 148 host(), &Memory::Object_at(pc_), HeapObject::cast(target)); |
149 } | 149 } |
150 } | 150 } |
151 | 151 |
152 | 152 |
153 Address RelocInfo::target_reference() { | 153 Address RelocInfo::target_reference() { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); | 256 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); |
257 return reinterpret_cast<Object**>(pc_ + 2 * Assembler::kInstrSize); | 257 return reinterpret_cast<Object**>(pc_ + 2 * Assembler::kInstrSize); |
258 } | 258 } |
259 | 259 |
260 | 260 |
261 void RelocInfo::WipeOut() { | 261 void RelocInfo::WipeOut() { |
262 ASSERT(IsEmbeddedObject(rmode_) || | 262 ASSERT(IsEmbeddedObject(rmode_) || |
263 IsCodeTarget(rmode_) || | 263 IsCodeTarget(rmode_) || |
264 IsRuntimeEntry(rmode_) || | 264 IsRuntimeEntry(rmode_) || |
265 IsExternalReference(rmode_)); | 265 IsExternalReference(rmode_)); |
266 Assembler::set_target_pointer_at(pc_, NULL); | 266 Assembler::set_target_address_at(pc_, NULL); |
267 } | 267 } |
268 | 268 |
269 | 269 |
270 bool RelocInfo::IsPatchedReturnSequence() { | 270 bool RelocInfo::IsPatchedReturnSequence() { |
271 Instr current_instr = Assembler::instr_at(pc_); | 271 Instr current_instr = Assembler::instr_at(pc_); |
272 Instr next_instr = Assembler::instr_at(pc_ + Assembler::kInstrSize); | 272 Instr next_instr = Assembler::instr_at(pc_ + Assembler::kInstrSize); |
273 // A patched return sequence is: | 273 // A patched return sequence is: |
274 // ldr ip, [pc, #0] | 274 // ldr ip, [pc, #0] |
275 // blx ip | 275 // blx ip |
276 return ((current_instr & kLdrPCMask) == kLdrPCPattern) | 276 return ((current_instr & kLdrPCMask) == kLdrPCPattern) |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 pc_ += kInstrSize; | 390 pc_ += kInstrSize; |
391 } | 391 } |
392 | 392 |
393 | 393 |
394 Address Assembler::target_pointer_address_at(Address pc) { | 394 Address Assembler::target_pointer_address_at(Address pc) { |
395 Instr instr = Memory::int32_at(pc); | 395 Instr instr = Memory::int32_at(pc); |
396 return pc + GetLdrRegisterImmediateOffset(instr) + kPcLoadDelta; | 396 return pc + GetLdrRegisterImmediateOffset(instr) + kPcLoadDelta; |
397 } | 397 } |
398 | 398 |
399 | 399 |
400 Address Assembler::target_pointer_at(Address pc) { | 400 Address Assembler::target_address_at(Address pc) { |
401 if (IsMovW(Memory::int32_at(pc))) { | 401 if (IsMovW(Memory::int32_at(pc))) { |
402 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize))); | 402 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize))); |
403 Instruction* instr = Instruction::At(pc); | 403 Instruction* instr = Instruction::At(pc); |
404 Instruction* next_instr = Instruction::At(pc + kInstrSize); | 404 Instruction* next_instr = Instruction::At(pc + kInstrSize); |
405 return reinterpret_cast<Address>( | 405 return reinterpret_cast<Address>( |
406 (next_instr->ImmedMovwMovtValue() << 16) | | 406 (next_instr->ImmedMovwMovtValue() << 16) | |
407 instr->ImmedMovwMovtValue()); | 407 instr->ImmedMovwMovtValue()); |
408 } | 408 } |
409 ASSERT(IsLdrPcImmediateOffset(Memory::int32_at(pc))); | 409 ASSERT(IsLdrPcImmediateOffset(Memory::int32_at(pc))); |
410 return Memory::Address_at(target_pointer_address_at(pc)); | 410 return Memory::Address_at(target_pointer_address_at(pc)); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 Memory::Address_at(constant_pool_entry) = target; | 457 Memory::Address_at(constant_pool_entry) = target; |
458 } | 458 } |
459 | 459 |
460 | 460 |
461 static Instr EncodeMovwImmediate(uint32_t immediate) { | 461 static Instr EncodeMovwImmediate(uint32_t immediate) { |
462 ASSERT(immediate < 0x10000); | 462 ASSERT(immediate < 0x10000); |
463 return ((immediate & 0xf000) << 4) | (immediate & 0xfff); | 463 return ((immediate & 0xf000) << 4) | (immediate & 0xfff); |
464 } | 464 } |
465 | 465 |
466 | 466 |
467 void Assembler::set_target_pointer_at(Address pc, Address target) { | 467 void Assembler::set_target_address_at(Address pc, Address target) { |
468 if (IsMovW(Memory::int32_at(pc))) { | 468 if (IsMovW(Memory::int32_at(pc))) { |
469 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize))); | 469 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize))); |
470 uint32_t* instr_ptr = reinterpret_cast<uint32_t*>(pc); | 470 uint32_t* instr_ptr = reinterpret_cast<uint32_t*>(pc); |
471 uint32_t immediate = reinterpret_cast<uint32_t>(target); | 471 uint32_t immediate = reinterpret_cast<uint32_t>(target); |
472 uint32_t intermediate = instr_ptr[0]; | 472 uint32_t intermediate = instr_ptr[0]; |
473 intermediate &= ~EncodeMovwImmediate(0xFFFF); | 473 intermediate &= ~EncodeMovwImmediate(0xFFFF); |
474 intermediate |= EncodeMovwImmediate(immediate & 0xFFFF); | 474 intermediate |= EncodeMovwImmediate(immediate & 0xFFFF); |
475 instr_ptr[0] = intermediate; | 475 instr_ptr[0] = intermediate; |
476 intermediate = instr_ptr[1]; | 476 intermediate = instr_ptr[1]; |
477 intermediate &= ~EncodeMovwImmediate(0xFFFF); | 477 intermediate &= ~EncodeMovwImmediate(0xFFFF); |
(...skipping 10 matching lines...) Expand all Loading... |
488 // CPU::FlushICache(pc, sizeof(target)); | 488 // CPU::FlushICache(pc, sizeof(target)); |
489 // However, on ARM, no instruction is actually patched in the case | 489 // However, on ARM, no instruction is actually patched in the case |
490 // of embedded constants of the form: | 490 // of embedded constants of the form: |
491 // ldr ip, [pc, #...] | 491 // ldr ip, [pc, #...] |
492 // since the instruction accessing this address in the constant pool remains | 492 // since the instruction accessing this address in the constant pool remains |
493 // unchanged. | 493 // unchanged. |
494 } | 494 } |
495 } | 495 } |
496 | 496 |
497 | 497 |
498 Address Assembler::target_address_at(Address pc) { | |
499 return target_pointer_at(pc); | |
500 } | |
501 | |
502 | |
503 void Assembler::set_target_address_at(Address pc, Address target) { | |
504 set_target_pointer_at(pc, target); | |
505 } | |
506 | |
507 | |
508 } } // namespace v8::internal | 498 } } // namespace v8::internal |
509 | 499 |
510 #endif // V8_ARM_ASSEMBLER_ARM_INL_H_ | 500 #endif // V8_ARM_ASSEMBLER_ARM_INL_H_ |
OLD | NEW |