| 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 } else if (Debug::has_break_points() && | 207 } else if (Debug::has_break_points() && |
| 200 ((RelocInfo::IsJSReturn(mode) && | 208 ((RelocInfo::IsJSReturn(mode) && |
| 201 IsPatchedReturnSequence()) || | 209 IsPatchedReturnSequence()) || |
| 202 (RelocInfo::IsDebugBreakSlot(mode) && | 210 (RelocInfo::IsDebugBreakSlot(mode) && |
| 203 IsPatchedDebugBreakSlotSequence()))) { | 211 IsPatchedDebugBreakSlotSequence()))) { |
| 204 visitor->VisitDebugTarget(this); | 212 visitor->VisitDebugTarget(this); |
| 205 #endif | 213 #endif |
| 206 } else if (mode == RelocInfo::RUNTIME_ENTRY) { | 214 } else if (mode == RelocInfo::RUNTIME_ENTRY) { |
| 207 visitor->VisitRuntimeEntry(this); | 215 visitor->VisitRuntimeEntry(this); |
| 208 } | 216 } |
| 209 } | 217 } |
| 210 | 218 |
| 211 | 219 |
| 212 template<typename StaticVisitor> | 220 template<typename StaticVisitor> |
| 213 void RelocInfo::Visit() { | 221 void RelocInfo::Visit() { |
| 214 RelocInfo::Mode mode = rmode(); | 222 RelocInfo::Mode mode = rmode(); |
| 215 if (mode == RelocInfo::EMBEDDED_OBJECT) { | 223 if (mode == RelocInfo::EMBEDDED_OBJECT) { |
| 216 StaticVisitor::VisitPointer(target_object_address()); | 224 StaticVisitor::VisitPointer(target_object_address()); |
| 225 CPU::FlushICache(pc_, sizeof(Address)); |
| 217 } else if (RelocInfo::IsCodeTarget(mode)) { | 226 } else if (RelocInfo::IsCodeTarget(mode)) { |
| 218 StaticVisitor::VisitCodeTarget(this); | 227 StaticVisitor::VisitCodeTarget(this); |
| 219 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { | 228 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { |
| 220 StaticVisitor::VisitGlobalPropertyCell(this); | 229 StaticVisitor::VisitGlobalPropertyCell(this); |
| 221 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { | 230 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { |
| 222 StaticVisitor::VisitExternalReference(target_reference_address()); | 231 StaticVisitor::VisitExternalReference(target_reference_address()); |
| 232 CPU::FlushICache(pc_, sizeof(Address)); |
| 223 #ifdef ENABLE_DEBUGGER_SUPPORT | 233 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 224 } else if (Debug::has_break_points() && | 234 } else if (Debug::has_break_points() && |
| 225 ((RelocInfo::IsJSReturn(mode) && | 235 ((RelocInfo::IsJSReturn(mode) && |
| 226 IsPatchedReturnSequence()) || | 236 IsPatchedReturnSequence()) || |
| 227 (RelocInfo::IsDebugBreakSlot(mode) && | 237 (RelocInfo::IsDebugBreakSlot(mode) && |
| 228 IsPatchedDebugBreakSlotSequence()))) { | 238 IsPatchedDebugBreakSlotSequence()))) { |
| 229 StaticVisitor::VisitDebugTarget(this); | 239 StaticVisitor::VisitDebugTarget(this); |
| 230 #endif | 240 #endif |
| 231 } else if (mode == RelocInfo::RUNTIME_ENTRY) { | 241 } else if (mode == RelocInfo::RUNTIME_ENTRY) { |
| 232 StaticVisitor::VisitRuntimeEntry(this); | 242 StaticVisitor::VisitRuntimeEntry(this); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 | 420 |
| 411 Operand::Operand(int32_t disp, RelocInfo::Mode rmode) { | 421 Operand::Operand(int32_t disp, RelocInfo::Mode rmode) { |
| 412 // [disp/r] | 422 // [disp/r] |
| 413 set_modrm(0, ebp); | 423 set_modrm(0, ebp); |
| 414 set_dispr(disp, rmode); | 424 set_dispr(disp, rmode); |
| 415 } | 425 } |
| 416 | 426 |
| 417 } } // namespace v8::internal | 427 } } // namespace v8::internal |
| 418 | 428 |
| 419 #endif // V8_IA32_ASSEMBLER_IA32_INL_H_ | 429 #endif // V8_IA32_ASSEMBLER_IA32_INL_H_ |
| OLD | NEW |