| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 namespace v8 { | 43 namespace v8 { |
| 44 namespace internal { | 44 namespace internal { |
| 45 | 45 |
| 46 | 46 |
| 47 // The modes possibly affected by apply must be in kApplyMask. | 47 // The modes possibly affected by apply must be in kApplyMask. |
| 48 void RelocInfo::apply(intptr_t delta) { | 48 void RelocInfo::apply(intptr_t delta) { |
| 49 if (rmode_ == RUNTIME_ENTRY || IsCodeTarget(rmode_)) { | 49 if (rmode_ == RUNTIME_ENTRY || IsCodeTarget(rmode_)) { |
| 50 int32_t* p = reinterpret_cast<int32_t*>(pc_); | 50 int32_t* p = reinterpret_cast<int32_t*>(pc_); |
| 51 *p -= delta; // Relocate entry. | 51 *p -= delta; // Relocate entry. |
| 52 CPU::FlushICache(p, sizeof(uint32_t)); |
| 52 } else if (rmode_ == JS_RETURN && IsPatchedReturnSequence()) { | 53 } else if (rmode_ == JS_RETURN && IsPatchedReturnSequence()) { |
| 53 // Special handling of js_return when a break point is set (call | 54 // Special handling of js_return when a break point is set (call |
| 54 // instruction has been inserted). | 55 // instruction has been inserted). |
| 55 int32_t* p = reinterpret_cast<int32_t*>(pc_ + 1); | 56 int32_t* p = reinterpret_cast<int32_t*>(pc_ + 1); |
| 56 *p -= delta; // Relocate entry. | 57 *p -= delta; // Relocate entry. |
| 58 CPU::FlushICache(p, sizeof(uint32_t)); |
| 57 } else if (rmode_ == DEBUG_BREAK_SLOT && IsPatchedDebugBreakSlotSequence()) { | 59 } else if (rmode_ == DEBUG_BREAK_SLOT && IsPatchedDebugBreakSlotSequence()) { |
| 58 // Special handling of a debug break slot when a break point is set (call | 60 // Special handling of a debug break slot when a break point is set (call |
| 59 // instruction has been inserted). | 61 // instruction has been inserted). |
| 60 int32_t* p = reinterpret_cast<int32_t*>(pc_ + 1); | 62 int32_t* p = reinterpret_cast<int32_t*>(pc_ + 1); |
| 61 *p -= delta; // Relocate entry. | 63 *p -= delta; // Relocate entry. |
| 64 CPU::FlushICache(p, sizeof(uint32_t)); |
| 62 } else if (IsInternalReference(rmode_)) { | 65 } else if (IsInternalReference(rmode_)) { |
| 63 // absolute code pointer inside code object moves with the code object. | 66 // absolute code pointer inside code object moves with the code object. |
| 64 int32_t* p = reinterpret_cast<int32_t*>(pc_); | 67 int32_t* p = reinterpret_cast<int32_t*>(pc_); |
| 65 *p += delta; // Relocate entry. | 68 *p += delta; // Relocate entry. |
| 69 CPU::FlushICache(p, sizeof(uint32_t)); |
| 66 } | 70 } |
| 67 } | 71 } |
| 68 | 72 |
| 69 | 73 |
| 70 Address RelocInfo::target_address() { | 74 Address RelocInfo::target_address() { |
| 71 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); | 75 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); |
| 72 return Assembler::target_address_at(pc_); | 76 return Assembler::target_address_at(pc_); |
| 73 } | 77 } |
| 74 | 78 |
| 75 | 79 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 104 | 108 |
| 105 Object** RelocInfo::target_object_address() { | 109 Object** RelocInfo::target_object_address() { |
| 106 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 110 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
| 107 return &Memory::Object_at(pc_); | 111 return &Memory::Object_at(pc_); |
| 108 } | 112 } |
| 109 | 113 |
| 110 | 114 |
| 111 void RelocInfo::set_target_object(Object* target) { | 115 void RelocInfo::set_target_object(Object* target) { |
| 112 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 116 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
| 113 Memory::Object_at(pc_) = target; | 117 Memory::Object_at(pc_) = target; |
| 118 CPU::FlushICache(pc_, sizeof(Address)); |
| 114 } | 119 } |
| 115 | 120 |
| 116 | 121 |
| 117 Address* RelocInfo::target_reference_address() { | 122 Address* RelocInfo::target_reference_address() { |
| 118 ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE); | 123 ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE); |
| 119 return reinterpret_cast<Address*>(pc_); | 124 return reinterpret_cast<Address*>(pc_); |
| 120 } | 125 } |
| 121 | 126 |
| 122 | 127 |
| 123 Handle<JSGlobalPropertyCell> RelocInfo::target_cell_handle() { | 128 Handle<JSGlobalPropertyCell> RelocInfo::target_cell_handle() { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 134 Object* object = HeapObject::FromAddress( | 139 Object* object = HeapObject::FromAddress( |
| 135 address - JSGlobalPropertyCell::kValueOffset); | 140 address - JSGlobalPropertyCell::kValueOffset); |
| 136 return reinterpret_cast<JSGlobalPropertyCell*>(object); | 141 return reinterpret_cast<JSGlobalPropertyCell*>(object); |
| 137 } | 142 } |
| 138 | 143 |
| 139 | 144 |
| 140 void RelocInfo::set_target_cell(JSGlobalPropertyCell* cell) { | 145 void RelocInfo::set_target_cell(JSGlobalPropertyCell* cell) { |
| 141 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); | 146 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); |
| 142 Address address = cell->address() + JSGlobalPropertyCell::kValueOffset; | 147 Address address = cell->address() + JSGlobalPropertyCell::kValueOffset; |
| 143 Memory::Address_at(pc_) = address; | 148 Memory::Address_at(pc_) = address; |
| 149 CPU::FlushICache(pc_, sizeof(Address)); |
| 144 } | 150 } |
| 145 | 151 |
| 146 | 152 |
| 147 Address RelocInfo::call_address() { | 153 Address RelocInfo::call_address() { |
| 148 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || | 154 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || |
| 149 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); | 155 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); |
| 150 return Assembler::target_address_at(pc_ + 1); | 156 return Assembler::target_address_at(pc_ + 1); |
| 151 } | 157 } |
| 152 | 158 |
| 153 | 159 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 182 | 188 |
| 183 bool RelocInfo::IsPatchedDebugBreakSlotSequence() { | 189 bool RelocInfo::IsPatchedDebugBreakSlotSequence() { |
| 184 return !Assembler::IsNop(pc()); | 190 return !Assembler::IsNop(pc()); |
| 185 } | 191 } |
| 186 | 192 |
| 187 | 193 |
| 188 void RelocInfo::Visit(ObjectVisitor* visitor) { | 194 void RelocInfo::Visit(ObjectVisitor* visitor) { |
| 189 RelocInfo::Mode mode = rmode(); | 195 RelocInfo::Mode mode = rmode(); |
| 190 if (mode == RelocInfo::EMBEDDED_OBJECT) { | 196 if (mode == RelocInfo::EMBEDDED_OBJECT) { |
| 191 visitor->VisitPointer(target_object_address()); | 197 visitor->VisitPointer(target_object_address()); |
| 198 CPU::FlushICache(pc_, sizeof(Address)); |
| 192 } else if (RelocInfo::IsCodeTarget(mode)) { | 199 } else if (RelocInfo::IsCodeTarget(mode)) { |
| 193 visitor->VisitCodeTarget(this); | 200 visitor->VisitCodeTarget(this); |
| 194 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { | 201 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { |
| 195 visitor->VisitGlobalPropertyCell(this); | 202 visitor->VisitGlobalPropertyCell(this); |
| 196 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { | 203 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { |
| 197 visitor->VisitExternalReference(target_reference_address()); | 204 visitor->VisitExternalReference(target_reference_address()); |
| 205 CPU::FlushICache(pc_, sizeof(Address)); |
| 198 #ifdef ENABLE_DEBUGGER_SUPPORT | 206 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 199 // TODO(isolates): Get a cached isolate below. | 207 // TODO(isolates): Get a cached isolate below. |
| 200 } else if (((RelocInfo::IsJSReturn(mode) && | 208 } else if (((RelocInfo::IsJSReturn(mode) && |
| 201 IsPatchedReturnSequence()) || | 209 IsPatchedReturnSequence()) || |
| 202 (RelocInfo::IsDebugBreakSlot(mode) && | 210 (RelocInfo::IsDebugBreakSlot(mode) && |
| 203 IsPatchedDebugBreakSlotSequence())) && | 211 IsPatchedDebugBreakSlotSequence())) && |
| 204 Isolate::Current()->debug()->has_break_points()) { | 212 Isolate::Current()->debug()->has_break_points()) { |
| 205 visitor->VisitDebugTarget(this); | 213 visitor->VisitDebugTarget(this); |
| 206 #endif | 214 #endif |
| 207 } else if (mode == RelocInfo::RUNTIME_ENTRY) { | 215 } else if (mode == RelocInfo::RUNTIME_ENTRY) { |
| 208 visitor->VisitRuntimeEntry(this); | 216 visitor->VisitRuntimeEntry(this); |
| 209 } | 217 } |
| 210 } | 218 } |
| 211 | 219 |
| 212 | 220 |
| 213 template<typename StaticVisitor> | 221 template<typename StaticVisitor> |
| 214 void RelocInfo::Visit(Heap* heap) { | 222 void RelocInfo::Visit(Heap* heap) { |
| 215 RelocInfo::Mode mode = rmode(); | 223 RelocInfo::Mode mode = rmode(); |
| 216 if (mode == RelocInfo::EMBEDDED_OBJECT) { | 224 if (mode == RelocInfo::EMBEDDED_OBJECT) { |
| 217 StaticVisitor::VisitPointer(heap, target_object_address()); | 225 StaticVisitor::VisitPointer(heap, target_object_address()); |
| 226 CPU::FlushICache(pc_, sizeof(Address)); |
| 218 } else if (RelocInfo::IsCodeTarget(mode)) { | 227 } else if (RelocInfo::IsCodeTarget(mode)) { |
| 219 StaticVisitor::VisitCodeTarget(this); | 228 StaticVisitor::VisitCodeTarget(this); |
| 220 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { | 229 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { |
| 221 StaticVisitor::VisitGlobalPropertyCell(this); | 230 StaticVisitor::VisitGlobalPropertyCell(this); |
| 222 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { | 231 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { |
| 223 StaticVisitor::VisitExternalReference(target_reference_address()); | 232 StaticVisitor::VisitExternalReference(target_reference_address()); |
| 233 CPU::FlushICache(pc_, sizeof(Address)); |
| 224 #ifdef ENABLE_DEBUGGER_SUPPORT | 234 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 225 } else if (heap->isolate()->debug()->has_break_points() && | 235 } else if (heap->isolate()->debug()->has_break_points() && |
| 226 ((RelocInfo::IsJSReturn(mode) && | 236 ((RelocInfo::IsJSReturn(mode) && |
| 227 IsPatchedReturnSequence()) || | 237 IsPatchedReturnSequence()) || |
| 228 (RelocInfo::IsDebugBreakSlot(mode) && | 238 (RelocInfo::IsDebugBreakSlot(mode) && |
| 229 IsPatchedDebugBreakSlotSequence()))) { | 239 IsPatchedDebugBreakSlotSequence()))) { |
| 230 StaticVisitor::VisitDebugTarget(this); | 240 StaticVisitor::VisitDebugTarget(this); |
| 231 #endif | 241 #endif |
| 232 } else if (mode == RelocInfo::RUNTIME_ENTRY) { | 242 } else if (mode == RelocInfo::RUNTIME_ENTRY) { |
| 233 StaticVisitor::VisitRuntimeEntry(this); | 243 StaticVisitor::VisitRuntimeEntry(this); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 | 421 |
| 412 Operand::Operand(int32_t disp, RelocInfo::Mode rmode) { | 422 Operand::Operand(int32_t disp, RelocInfo::Mode rmode) { |
| 413 // [disp/r] | 423 // [disp/r] |
| 414 set_modrm(0, ebp); | 424 set_modrm(0, ebp); |
| 415 set_dispr(disp, rmode); | 425 set_dispr(disp, rmode); |
| 416 } | 426 } |
| 417 | 427 |
| 418 } } // namespace v8::internal | 428 } } // namespace v8::internal |
| 419 | 429 |
| 420 #endif // V8_IA32_ASSEMBLER_IA32_INL_H_ | 430 #endif // V8_IA32_ASSEMBLER_IA32_INL_H_ |
| OLD | NEW |