| 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 are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 namespace v8 { | 45 namespace v8 { |
| 46 namespace internal { | 46 namespace internal { |
| 47 | 47 |
| 48 | 48 |
| 49 static const byte kCallOpcode = 0xE8; | 49 static const byte kCallOpcode = 0xE8; |
| 50 | 50 |
| 51 | 51 |
| 52 // The modes possibly affected by apply must be in kApplyMask. | 52 // The modes possibly affected by apply must be in kApplyMask. |
| 53 void RelocInfo::apply(intptr_t delta) { | 53 void RelocInfo::apply(intptr_t delta) { |
| 54 if (IsRuntimeEntry(rmode_) || IsCodeTarget(rmode_)) { | 54 if (rmode_ == RUNTIME_ENTRY || IsCodeTarget(rmode_)) { |
| 55 int32_t* p = reinterpret_cast<int32_t*>(pc_); | 55 int32_t* p = reinterpret_cast<int32_t*>(pc_); |
| 56 *p -= delta; // Relocate entry. | 56 *p -= delta; // Relocate entry. |
| 57 CPU::FlushICache(p, sizeof(uint32_t)); | 57 CPU::FlushICache(p, sizeof(uint32_t)); |
| 58 } else if (rmode_ == CODE_AGE_SEQUENCE) { | 58 } else if (rmode_ == CODE_AGE_SEQUENCE) { |
| 59 if (*pc_ == kCallOpcode) { | 59 if (*pc_ == kCallOpcode) { |
| 60 int32_t* p = reinterpret_cast<int32_t*>(pc_ + 1); | 60 int32_t* p = reinterpret_cast<int32_t*>(pc_ + 1); |
| 61 *p -= delta; // Relocate entry. | 61 *p -= delta; // Relocate entry. |
| 62 CPU::FlushICache(p, sizeof(uint32_t)); | 62 CPU::FlushICache(p, sizeof(uint32_t)); |
| 63 } | 63 } |
| 64 } else if (rmode_ == JS_RETURN && IsPatchedReturnSequence()) { | 64 } else if (rmode_ == JS_RETURN && IsPatchedReturnSequence()) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 76 } else if (IsInternalReference(rmode_)) { | 76 } else if (IsInternalReference(rmode_)) { |
| 77 // absolute code pointer inside code object moves with the code object. | 77 // absolute code pointer inside code object moves with the code object. |
| 78 int32_t* p = reinterpret_cast<int32_t*>(pc_); | 78 int32_t* p = reinterpret_cast<int32_t*>(pc_); |
| 79 *p += delta; // Relocate entry. | 79 *p += delta; // Relocate entry. |
| 80 CPU::FlushICache(p, sizeof(uint32_t)); | 80 CPU::FlushICache(p, sizeof(uint32_t)); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 | 83 |
| 84 | 84 |
| 85 Address RelocInfo::target_address() { | 85 Address RelocInfo::target_address() { |
| 86 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); | 86 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); |
| 87 return Assembler::target_address_at(pc_); | 87 return Assembler::target_address_at(pc_); |
| 88 } | 88 } |
| 89 | 89 |
| 90 | 90 |
| 91 Address RelocInfo::target_address_address() { | 91 Address RelocInfo::target_address_address() { |
| 92 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) | 92 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY |
| 93 || rmode_ == EMBEDDED_OBJECT | 93 || rmode_ == EMBEDDED_OBJECT |
| 94 || rmode_ == EXTERNAL_REFERENCE); | 94 || rmode_ == EXTERNAL_REFERENCE); |
| 95 return reinterpret_cast<Address>(pc_); | 95 return reinterpret_cast<Address>(pc_); |
| 96 } | 96 } |
| 97 | 97 |
| 98 | 98 |
| 99 int RelocInfo::target_address_size() { | 99 int RelocInfo::target_address_size() { |
| 100 return Assembler::kSpecialTargetSize; | 100 return Assembler::kSpecialTargetSize; |
| 101 } | 101 } |
| 102 | 102 |
| 103 | 103 |
| 104 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) { | 104 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) { |
| 105 Assembler::set_target_address_at(pc_, target); | 105 Assembler::set_target_address_at(pc_, target); |
| 106 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); | 106 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); |
| 107 if (mode == UPDATE_WRITE_BARRIER && host() != NULL && IsCodeTarget(rmode_)) { | 107 if (mode == UPDATE_WRITE_BARRIER && host() != NULL && IsCodeTarget(rmode_)) { |
| 108 Object* target_code = Code::GetCodeFromTargetAddress(target); | 108 Object* target_code = Code::GetCodeFromTargetAddress(target); |
| 109 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( | 109 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( |
| 110 host(), this, HeapObject::cast(target_code)); | 110 host(), this, HeapObject::cast(target_code)); |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 | 114 |
| 115 Object* RelocInfo::target_object() { | 115 Object* RelocInfo::target_object() { |
| 116 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 116 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 | 145 |
| 146 Address* RelocInfo::target_reference_address() { | 146 Address* RelocInfo::target_reference_address() { |
| 147 ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE); | 147 ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE); |
| 148 return reinterpret_cast<Address*>(pc_); | 148 return reinterpret_cast<Address*>(pc_); |
| 149 } | 149 } |
| 150 | 150 |
| 151 | 151 |
| 152 Address RelocInfo::target_runtime_entry(Assembler* origin) { | |
| 153 ASSERT(IsRuntimeEntry(rmode_)); | |
| 154 return reinterpret_cast<Address>(*reinterpret_cast<int32_t*>(pc_)); | |
| 155 } | |
| 156 | |
| 157 | |
| 158 void RelocInfo::set_target_runtime_entry(Address target, | |
| 159 WriteBarrierMode mode) { | |
| 160 ASSERT(IsRuntimeEntry(rmode_)); | |
| 161 if (target_address() != target) set_target_address(target, mode); | |
| 162 } | |
| 163 | |
| 164 | |
| 165 Handle<JSGlobalPropertyCell> RelocInfo::target_cell_handle() { | 152 Handle<JSGlobalPropertyCell> RelocInfo::target_cell_handle() { |
| 166 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); | 153 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); |
| 167 Address address = Memory::Address_at(pc_); | 154 Address address = Memory::Address_at(pc_); |
| 168 return Handle<JSGlobalPropertyCell>( | 155 return Handle<JSGlobalPropertyCell>( |
| 169 reinterpret_cast<JSGlobalPropertyCell**>(address)); | 156 reinterpret_cast<JSGlobalPropertyCell**>(address)); |
| 170 } | 157 } |
| 171 | 158 |
| 172 | 159 |
| 173 JSGlobalPropertyCell* RelocInfo::target_cell() { | 160 JSGlobalPropertyCell* RelocInfo::target_cell() { |
| 174 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); | 161 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 visitor->VisitCodeAgeSequence(this); | 255 visitor->VisitCodeAgeSequence(this); |
| 269 #ifdef ENABLE_DEBUGGER_SUPPORT | 256 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 270 // TODO(isolates): Get a cached isolate below. | 257 // TODO(isolates): Get a cached isolate below. |
| 271 } else if (((RelocInfo::IsJSReturn(mode) && | 258 } else if (((RelocInfo::IsJSReturn(mode) && |
| 272 IsPatchedReturnSequence()) || | 259 IsPatchedReturnSequence()) || |
| 273 (RelocInfo::IsDebugBreakSlot(mode) && | 260 (RelocInfo::IsDebugBreakSlot(mode) && |
| 274 IsPatchedDebugBreakSlotSequence())) && | 261 IsPatchedDebugBreakSlotSequence())) && |
| 275 Isolate::Current()->debug()->has_break_points()) { | 262 Isolate::Current()->debug()->has_break_points()) { |
| 276 visitor->VisitDebugTarget(this); | 263 visitor->VisitDebugTarget(this); |
| 277 #endif | 264 #endif |
| 278 } else if (IsRuntimeEntry(mode)) { | 265 } else if (mode == RelocInfo::RUNTIME_ENTRY) { |
| 279 visitor->VisitRuntimeEntry(this); | 266 visitor->VisitRuntimeEntry(this); |
| 280 } | 267 } |
| 281 } | 268 } |
| 282 | 269 |
| 283 | 270 |
| 284 template<typename StaticVisitor> | 271 template<typename StaticVisitor> |
| 285 void RelocInfo::Visit(Heap* heap) { | 272 void RelocInfo::Visit(Heap* heap) { |
| 286 RelocInfo::Mode mode = rmode(); | 273 RelocInfo::Mode mode = rmode(); |
| 287 if (mode == RelocInfo::EMBEDDED_OBJECT) { | 274 if (mode == RelocInfo::EMBEDDED_OBJECT) { |
| 288 StaticVisitor::VisitEmbeddedPointer(heap, this); | 275 StaticVisitor::VisitEmbeddedPointer(heap, this); |
| 289 CPU::FlushICache(pc_, sizeof(Address)); | 276 CPU::FlushICache(pc_, sizeof(Address)); |
| 290 } else if (RelocInfo::IsCodeTarget(mode)) { | 277 } else if (RelocInfo::IsCodeTarget(mode)) { |
| 291 StaticVisitor::VisitCodeTarget(heap, this); | 278 StaticVisitor::VisitCodeTarget(heap, this); |
| 292 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { | 279 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { |
| 293 StaticVisitor::VisitGlobalPropertyCell(heap, this); | 280 StaticVisitor::VisitGlobalPropertyCell(heap, this); |
| 294 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { | 281 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { |
| 295 StaticVisitor::VisitExternalReference(this); | 282 StaticVisitor::VisitExternalReference(this); |
| 296 CPU::FlushICache(pc_, sizeof(Address)); | 283 CPU::FlushICache(pc_, sizeof(Address)); |
| 297 } else if (RelocInfo::IsCodeAgeSequence(mode)) { | 284 } else if (RelocInfo::IsCodeAgeSequence(mode)) { |
| 298 StaticVisitor::VisitCodeAgeSequence(heap, this); | 285 StaticVisitor::VisitCodeAgeSequence(heap, this); |
| 299 #ifdef ENABLE_DEBUGGER_SUPPORT | 286 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 300 } else if (heap->isolate()->debug()->has_break_points() && | 287 } else if (heap->isolate()->debug()->has_break_points() && |
| 301 ((RelocInfo::IsJSReturn(mode) && | 288 ((RelocInfo::IsJSReturn(mode) && |
| 302 IsPatchedReturnSequence()) || | 289 IsPatchedReturnSequence()) || |
| 303 (RelocInfo::IsDebugBreakSlot(mode) && | 290 (RelocInfo::IsDebugBreakSlot(mode) && |
| 304 IsPatchedDebugBreakSlotSequence()))) { | 291 IsPatchedDebugBreakSlotSequence()))) { |
| 305 StaticVisitor::VisitDebugTarget(heap, this); | 292 StaticVisitor::VisitDebugTarget(heap, this); |
| 306 #endif | 293 #endif |
| 307 } else if (IsRuntimeEntry(mode)) { | 294 } else if (mode == RelocInfo::RUNTIME_ENTRY) { |
| 308 StaticVisitor::VisitRuntimeEntry(this); | 295 StaticVisitor::VisitRuntimeEntry(this); |
| 309 } | 296 } |
| 310 } | 297 } |
| 311 | 298 |
| 312 | 299 |
| 313 | 300 |
| 314 Immediate::Immediate(int x) { | 301 Immediate::Immediate(int x) { |
| 315 x_ = x; | 302 x_ = x; |
| 316 rmode_ = RelocInfo::NONE32; | 303 rmode_ = RelocInfo::NONE32; |
| 317 } | 304 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 | 494 |
| 508 Operand::Operand(int32_t disp, RelocInfo::Mode rmode) { | 495 Operand::Operand(int32_t disp, RelocInfo::Mode rmode) { |
| 509 // [disp/r] | 496 // [disp/r] |
| 510 set_modrm(0, ebp); | 497 set_modrm(0, ebp); |
| 511 set_dispr(disp, rmode); | 498 set_dispr(disp, rmode); |
| 512 } | 499 } |
| 513 | 500 |
| 514 } } // namespace v8::internal | 501 } } // namespace v8::internal |
| 515 | 502 |
| 516 #endif // V8_IA32_ASSEMBLER_IA32_INL_H_ | 503 #endif // V8_IA32_ASSEMBLER_IA32_INL_H_ |
| OLD | NEW |