| 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 (rmode_ == RUNTIME_ENTRY || IsCodeTarget(rmode_)) { | 54 if (IsRuntimeEntry(rmode_) || 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_) || rmode_ == RUNTIME_ENTRY); | 86 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); |
| 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_) || rmode_ == RUNTIME_ENTRY | 92 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) |
| 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_) || rmode_ == RUNTIME_ENTRY); | 106 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); |
| 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 |
| 152 Handle<JSGlobalPropertyCell> RelocInfo::target_cell_handle() { | 165 Handle<JSGlobalPropertyCell> RelocInfo::target_cell_handle() { |
| 153 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); | 166 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); |
| 154 Address address = Memory::Address_at(pc_); | 167 Address address = Memory::Address_at(pc_); |
| 155 return Handle<JSGlobalPropertyCell>( | 168 return Handle<JSGlobalPropertyCell>( |
| 156 reinterpret_cast<JSGlobalPropertyCell**>(address)); | 169 reinterpret_cast<JSGlobalPropertyCell**>(address)); |
| 157 } | 170 } |
| 158 | 171 |
| 159 | 172 |
| 160 JSGlobalPropertyCell* RelocInfo::target_cell() { | 173 JSGlobalPropertyCell* RelocInfo::target_cell() { |
| 161 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); | 174 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 visitor->VisitCodeAgeSequence(this); | 268 visitor->VisitCodeAgeSequence(this); |
| 256 #ifdef ENABLE_DEBUGGER_SUPPORT | 269 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 257 // TODO(isolates): Get a cached isolate below. | 270 // TODO(isolates): Get a cached isolate below. |
| 258 } else if (((RelocInfo::IsJSReturn(mode) && | 271 } else if (((RelocInfo::IsJSReturn(mode) && |
| 259 IsPatchedReturnSequence()) || | 272 IsPatchedReturnSequence()) || |
| 260 (RelocInfo::IsDebugBreakSlot(mode) && | 273 (RelocInfo::IsDebugBreakSlot(mode) && |
| 261 IsPatchedDebugBreakSlotSequence())) && | 274 IsPatchedDebugBreakSlotSequence())) && |
| 262 Isolate::Current()->debug()->has_break_points()) { | 275 Isolate::Current()->debug()->has_break_points()) { |
| 263 visitor->VisitDebugTarget(this); | 276 visitor->VisitDebugTarget(this); |
| 264 #endif | 277 #endif |
| 265 } else if (mode == RelocInfo::RUNTIME_ENTRY) { | 278 } else if (IsRuntimeEntry(mode)) { |
| 266 visitor->VisitRuntimeEntry(this); | 279 visitor->VisitRuntimeEntry(this); |
| 267 } | 280 } |
| 268 } | 281 } |
| 269 | 282 |
| 270 | 283 |
| 271 template<typename StaticVisitor> | 284 template<typename StaticVisitor> |
| 272 void RelocInfo::Visit(Heap* heap) { | 285 void RelocInfo::Visit(Heap* heap) { |
| 273 RelocInfo::Mode mode = rmode(); | 286 RelocInfo::Mode mode = rmode(); |
| 274 if (mode == RelocInfo::EMBEDDED_OBJECT) { | 287 if (mode == RelocInfo::EMBEDDED_OBJECT) { |
| 275 StaticVisitor::VisitEmbeddedPointer(heap, this); | 288 StaticVisitor::VisitEmbeddedPointer(heap, this); |
| 276 CPU::FlushICache(pc_, sizeof(Address)); | 289 CPU::FlushICache(pc_, sizeof(Address)); |
| 277 } else if (RelocInfo::IsCodeTarget(mode)) { | 290 } else if (RelocInfo::IsCodeTarget(mode)) { |
| 278 StaticVisitor::VisitCodeTarget(heap, this); | 291 StaticVisitor::VisitCodeTarget(heap, this); |
| 279 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { | 292 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { |
| 280 StaticVisitor::VisitGlobalPropertyCell(heap, this); | 293 StaticVisitor::VisitGlobalPropertyCell(heap, this); |
| 281 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { | 294 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { |
| 282 StaticVisitor::VisitExternalReference(this); | 295 StaticVisitor::VisitExternalReference(this); |
| 283 CPU::FlushICache(pc_, sizeof(Address)); | 296 CPU::FlushICache(pc_, sizeof(Address)); |
| 284 } else if (RelocInfo::IsCodeAgeSequence(mode)) { | 297 } else if (RelocInfo::IsCodeAgeSequence(mode)) { |
| 285 StaticVisitor::VisitCodeAgeSequence(heap, this); | 298 StaticVisitor::VisitCodeAgeSequence(heap, this); |
| 286 #ifdef ENABLE_DEBUGGER_SUPPORT | 299 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 287 } else if (heap->isolate()->debug()->has_break_points() && | 300 } else if (heap->isolate()->debug()->has_break_points() && |
| 288 ((RelocInfo::IsJSReturn(mode) && | 301 ((RelocInfo::IsJSReturn(mode) && |
| 289 IsPatchedReturnSequence()) || | 302 IsPatchedReturnSequence()) || |
| 290 (RelocInfo::IsDebugBreakSlot(mode) && | 303 (RelocInfo::IsDebugBreakSlot(mode) && |
| 291 IsPatchedDebugBreakSlotSequence()))) { | 304 IsPatchedDebugBreakSlotSequence()))) { |
| 292 StaticVisitor::VisitDebugTarget(heap, this); | 305 StaticVisitor::VisitDebugTarget(heap, this); |
| 293 #endif | 306 #endif |
| 294 } else if (mode == RelocInfo::RUNTIME_ENTRY) { | 307 } else if (IsRuntimeEntry(mode)) { |
| 295 StaticVisitor::VisitRuntimeEntry(this); | 308 StaticVisitor::VisitRuntimeEntry(this); |
| 296 } | 309 } |
| 297 } | 310 } |
| 298 | 311 |
| 299 | 312 |
| 300 | 313 |
| 301 Immediate::Immediate(int x) { | 314 Immediate::Immediate(int x) { |
| 302 x_ = x; | 315 x_ = x; |
| 303 rmode_ = RelocInfo::NONE32; | 316 rmode_ = RelocInfo::NONE32; |
| 304 } | 317 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 | 507 |
| 495 Operand::Operand(int32_t disp, RelocInfo::Mode rmode) { | 508 Operand::Operand(int32_t disp, RelocInfo::Mode rmode) { |
| 496 // [disp/r] | 509 // [disp/r] |
| 497 set_modrm(0, ebp); | 510 set_modrm(0, ebp); |
| 498 set_dispr(disp, rmode); | 511 set_dispr(disp, rmode); |
| 499 } | 512 } |
| 500 | 513 |
| 501 } } // namespace v8::internal | 514 } } // namespace v8::internal |
| 502 | 515 |
| 503 #endif // V8_IA32_ASSEMBLER_IA32_INL_H_ | 516 #endif // V8_IA32_ASSEMBLER_IA32_INL_H_ |
| OLD | NEW |