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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 Address RelocInfo::constant_pool_entry_address() { | 94 Address RelocInfo::constant_pool_entry_address() { |
95 UNREACHABLE(); | 95 UNREACHABLE(); |
96 return NULL; | 96 return NULL; |
97 } | 97 } |
98 | 98 |
99 | 99 |
100 int RelocInfo::target_address_size() { | 100 int RelocInfo::target_address_size() { |
101 return Assembler::kSpecialTargetSize; | 101 return Assembler::kSpecialTargetSize; |
102 } | 102 } |
103 | 103 |
104 | 104 HeapObject* RelocInfo::target_object() { |
105 Object* RelocInfo::target_object() { | |
106 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 105 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
107 return Memory::Object_at(pc_); | 106 return HeapObject::cast(Memory::Object_at(pc_)); |
108 } | 107 } |
109 | 108 |
110 | 109 Handle<HeapObject> RelocInfo::target_object_handle(Assembler* origin) { |
111 Handle<Object> RelocInfo::target_object_handle(Assembler* origin) { | |
112 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 110 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
113 return Memory::Object_Handle_at(pc_); | 111 return Handle<HeapObject>::cast(Memory::Object_Handle_at(pc_)); |
114 } | 112 } |
115 | 113 |
116 | 114 void RelocInfo::set_target_object(HeapObject* target, |
117 void RelocInfo::set_target_object(Object* target, | |
118 WriteBarrierMode write_barrier_mode, | 115 WriteBarrierMode write_barrier_mode, |
119 ICacheFlushMode icache_flush_mode) { | 116 ICacheFlushMode icache_flush_mode) { |
120 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 117 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
121 Memory::Object_at(pc_) = target; | 118 Memory::Object_at(pc_) = target; |
122 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { | 119 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { |
123 Assembler::FlushICache(isolate_, pc_, sizeof(Address)); | 120 Assembler::FlushICache(target->GetIsolate(), pc_, sizeof(Address)); |
124 } | 121 } |
125 if (write_barrier_mode == UPDATE_WRITE_BARRIER && | 122 if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != nullptr) { |
126 host() != NULL && | |
127 target->IsHeapObject()) { | |
128 host()->GetHeap()->RecordWriteIntoCode(host(), this, target); | 123 host()->GetHeap()->RecordWriteIntoCode(host(), this, target); |
129 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( | 124 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(host(), this, |
130 host(), this, HeapObject::cast(target)); | 125 target); |
131 } | 126 } |
132 } | 127 } |
133 | 128 |
134 | 129 |
135 Address RelocInfo::target_external_reference() { | 130 Address RelocInfo::target_external_reference() { |
136 DCHECK(rmode_ == RelocInfo::EXTERNAL_REFERENCE); | 131 DCHECK(rmode_ == RelocInfo::EXTERNAL_REFERENCE); |
137 return Memory::Address_at(pc_); | 132 return Memory::Address_at(pc_); |
138 } | 133 } |
139 | 134 |
140 | 135 |
141 Address RelocInfo::target_internal_reference() { | 136 Address RelocInfo::target_internal_reference() { |
142 DCHECK(rmode_ == INTERNAL_REFERENCE); | 137 DCHECK(rmode_ == INTERNAL_REFERENCE); |
143 return Memory::Address_at(pc_); | 138 return Memory::Address_at(pc_); |
144 } | 139 } |
145 | 140 |
146 | 141 |
147 Address RelocInfo::target_internal_reference_address() { | 142 Address RelocInfo::target_internal_reference_address() { |
148 DCHECK(rmode_ == INTERNAL_REFERENCE); | 143 DCHECK(rmode_ == INTERNAL_REFERENCE); |
149 return reinterpret_cast<Address>(pc_); | 144 return reinterpret_cast<Address>(pc_); |
150 } | 145 } |
151 | 146 |
152 | 147 |
153 Address RelocInfo::target_runtime_entry(Assembler* origin) { | 148 Address RelocInfo::target_runtime_entry(Assembler* origin) { |
154 DCHECK(IsRuntimeEntry(rmode_)); | 149 DCHECK(IsRuntimeEntry(rmode_)); |
155 return reinterpret_cast<Address>(*reinterpret_cast<int32_t*>(pc_)); | 150 return reinterpret_cast<Address>(*reinterpret_cast<int32_t*>(pc_)); |
156 } | 151 } |
157 | 152 |
158 | 153 void RelocInfo::set_target_runtime_entry(Isolate* isolate, Address target, |
159 void RelocInfo::set_target_runtime_entry(Address target, | |
160 WriteBarrierMode write_barrier_mode, | 154 WriteBarrierMode write_barrier_mode, |
161 ICacheFlushMode icache_flush_mode) { | 155 ICacheFlushMode icache_flush_mode) { |
162 DCHECK(IsRuntimeEntry(rmode_)); | 156 DCHECK(IsRuntimeEntry(rmode_)); |
163 if (target_address() != target) { | 157 if (target_address() != target) { |
164 set_target_address(target, write_barrier_mode, icache_flush_mode); | 158 set_target_address(isolate, target, write_barrier_mode, icache_flush_mode); |
165 } | 159 } |
166 } | 160 } |
167 | 161 |
168 | 162 |
169 Handle<Cell> RelocInfo::target_cell_handle() { | 163 Handle<Cell> RelocInfo::target_cell_handle() { |
170 DCHECK(rmode_ == RelocInfo::CELL); | 164 DCHECK(rmode_ == RelocInfo::CELL); |
171 Address address = Memory::Address_at(pc_); | 165 Address address = Memory::Address_at(pc_); |
172 return Handle<Cell>(reinterpret_cast<Cell**>(address)); | 166 return Handle<Cell>(reinterpret_cast<Cell**>(address)); |
173 } | 167 } |
174 | 168 |
175 | 169 |
176 Cell* RelocInfo::target_cell() { | 170 Cell* RelocInfo::target_cell() { |
177 DCHECK(rmode_ == RelocInfo::CELL); | 171 DCHECK(rmode_ == RelocInfo::CELL); |
178 return Cell::FromValueAddress(Memory::Address_at(pc_)); | 172 return Cell::FromValueAddress(Memory::Address_at(pc_)); |
179 } | 173 } |
180 | 174 |
181 | 175 |
182 void RelocInfo::set_target_cell(Cell* cell, | 176 void RelocInfo::set_target_cell(Cell* cell, |
183 WriteBarrierMode write_barrier_mode, | 177 WriteBarrierMode write_barrier_mode, |
184 ICacheFlushMode icache_flush_mode) { | 178 ICacheFlushMode icache_flush_mode) { |
185 DCHECK(cell->IsCell()); | 179 DCHECK(cell->IsCell()); |
186 DCHECK(rmode_ == RelocInfo::CELL); | 180 DCHECK(rmode_ == RelocInfo::CELL); |
187 Address address = cell->address() + Cell::kValueOffset; | 181 Address address = cell->address() + Cell::kValueOffset; |
188 Memory::Address_at(pc_) = address; | 182 Memory::Address_at(pc_) = address; |
189 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { | 183 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { |
190 Assembler::FlushICache(isolate_, pc_, sizeof(Address)); | 184 Assembler::FlushICache(cell->GetIsolate(), pc_, sizeof(Address)); |
191 } | 185 } |
192 if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL) { | 186 if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL) { |
193 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(host(), this, | 187 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(host(), this, |
194 cell); | 188 cell); |
195 } | 189 } |
196 } | 190 } |
197 | 191 |
198 | 192 Handle<Code> RelocInfo::code_age_stub_handle(Assembler* origin) { |
199 Handle<Object> RelocInfo::code_age_stub_handle(Assembler* origin) { | |
200 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); | 193 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); |
201 DCHECK(*pc_ == kCallOpcode); | 194 DCHECK(*pc_ == kCallOpcode); |
202 return Memory::Object_Handle_at(pc_ + 1); | 195 return Handle<Code>::cast(Memory::Object_Handle_at(pc_ + 1)); |
203 } | 196 } |
204 | 197 |
205 | 198 |
206 Code* RelocInfo::code_age_stub() { | 199 Code* RelocInfo::code_age_stub() { |
207 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); | 200 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); |
208 DCHECK(*pc_ == kCallOpcode); | 201 DCHECK(*pc_ == kCallOpcode); |
209 return Code::GetCodeFromTargetAddress( | 202 return Code::GetCodeFromTargetAddress( |
210 Assembler::target_address_at(pc_ + 1, host_)); | 203 Assembler::target_address_at(pc_ + 1, host_)); |
211 } | 204 } |
212 | 205 |
213 | 206 |
214 void RelocInfo::set_code_age_stub(Code* stub, | 207 void RelocInfo::set_code_age_stub(Code* stub, |
215 ICacheFlushMode icache_flush_mode) { | 208 ICacheFlushMode icache_flush_mode) { |
216 DCHECK(*pc_ == kCallOpcode); | 209 DCHECK(*pc_ == kCallOpcode); |
217 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); | 210 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); |
218 Assembler::set_target_address_at( | 211 Assembler::set_target_address_at(stub->GetIsolate(), pc_ + 1, host_, |
219 isolate_, pc_ + 1, host_, stub->instruction_start(), icache_flush_mode); | 212 stub->instruction_start(), |
| 213 icache_flush_mode); |
220 } | 214 } |
221 | 215 |
222 | 216 |
223 Address RelocInfo::debug_call_address() { | 217 Address RelocInfo::debug_call_address() { |
224 DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()); | 218 DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()); |
225 Address location = pc_ + Assembler::kPatchDebugBreakSlotAddressOffset; | 219 Address location = pc_ + Assembler::kPatchDebugBreakSlotAddressOffset; |
226 return Assembler::target_address_at(location, host_); | 220 return Assembler::target_address_at(location, host_); |
227 } | 221 } |
228 | 222 |
229 | 223 void RelocInfo::set_debug_call_address(Isolate* isolate, Address target) { |
230 void RelocInfo::set_debug_call_address(Address target) { | |
231 DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()); | 224 DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()); |
232 Address location = pc_ + Assembler::kPatchDebugBreakSlotAddressOffset; | 225 Address location = pc_ + Assembler::kPatchDebugBreakSlotAddressOffset; |
233 Assembler::set_target_address_at(isolate_, location, host_, target); | 226 Assembler::set_target_address_at(isolate, location, host_, target); |
234 if (host() != NULL) { | 227 if (host() != NULL) { |
235 Code* target_code = Code::GetCodeFromTargetAddress(target); | 228 Code* target_code = Code::GetCodeFromTargetAddress(target); |
236 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(host(), this, | 229 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(host(), this, |
237 target_code); | 230 target_code); |
238 } | 231 } |
239 } | 232 } |
240 | 233 |
241 | 234 void RelocInfo::WipeOut(Isolate* isolate) { |
242 void RelocInfo::WipeOut() { | |
243 if (IsEmbeddedObject(rmode_) || IsExternalReference(rmode_) || | 235 if (IsEmbeddedObject(rmode_) || IsExternalReference(rmode_) || |
244 IsInternalReference(rmode_)) { | 236 IsInternalReference(rmode_)) { |
245 Memory::Address_at(pc_) = NULL; | 237 Memory::Address_at(pc_) = NULL; |
246 } else if (IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)) { | 238 } else if (IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)) { |
247 // Effectively write zero into the relocation. | 239 // Effectively write zero into the relocation. |
248 Assembler::set_target_address_at(isolate_, pc_, host_, | 240 Assembler::set_target_address_at(isolate, pc_, host_, |
249 pc_ + sizeof(int32_t)); | 241 pc_ + sizeof(int32_t)); |
250 } else { | 242 } else { |
251 UNREACHABLE(); | 243 UNREACHABLE(); |
252 } | 244 } |
253 } | 245 } |
254 | 246 |
255 template <typename ObjectVisitor> | 247 template <typename ObjectVisitor> |
256 void RelocInfo::Visit(Isolate* isolate, ObjectVisitor* visitor) { | 248 void RelocInfo::Visit(Isolate* isolate, ObjectVisitor* visitor) { |
257 RelocInfo::Mode mode = rmode(); | 249 RelocInfo::Mode mode = rmode(); |
258 if (mode == RelocInfo::EMBEDDED_OBJECT) { | 250 if (mode == RelocInfo::EMBEDDED_OBJECT) { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 | 425 |
434 | 426 |
435 Address Assembler::target_address_at(Address pc, Address constant_pool) { | 427 Address Assembler::target_address_at(Address pc, Address constant_pool) { |
436 return pc + sizeof(int32_t) + *reinterpret_cast<int32_t*>(pc); | 428 return pc + sizeof(int32_t) + *reinterpret_cast<int32_t*>(pc); |
437 } | 429 } |
438 | 430 |
439 | 431 |
440 void Assembler::set_target_address_at(Isolate* isolate, Address pc, | 432 void Assembler::set_target_address_at(Isolate* isolate, Address pc, |
441 Address constant_pool, Address target, | 433 Address constant_pool, Address target, |
442 ICacheFlushMode icache_flush_mode) { | 434 ICacheFlushMode icache_flush_mode) { |
| 435 DCHECK_IMPLIES(isolate == nullptr, icache_flush_mode == SKIP_ICACHE_FLUSH); |
443 int32_t* p = reinterpret_cast<int32_t*>(pc); | 436 int32_t* p = reinterpret_cast<int32_t*>(pc); |
444 *p = target - (pc + sizeof(int32_t)); | 437 *p = target - (pc + sizeof(int32_t)); |
445 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { | 438 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { |
446 Assembler::FlushICache(isolate, p, sizeof(int32_t)); | 439 Assembler::FlushICache(isolate, p, sizeof(int32_t)); |
447 } | 440 } |
448 } | 441 } |
449 | 442 |
450 Address Assembler::target_address_at(Address pc, Code* code) { | 443 Address Assembler::target_address_at(Address pc, Code* code) { |
451 Address constant_pool = code ? code->constant_pool() : NULL; | 444 Address constant_pool = code ? code->constant_pool() : NULL; |
452 return target_address_at(pc, constant_pool); | 445 return target_address_at(pc, constant_pool); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 | 538 |
546 Operand::Operand(Immediate imm) { | 539 Operand::Operand(Immediate imm) { |
547 // [disp/r] | 540 // [disp/r] |
548 set_modrm(0, ebp); | 541 set_modrm(0, ebp); |
549 set_dispr(imm.x_, imm.rmode_); | 542 set_dispr(imm.x_, imm.rmode_); |
550 } | 543 } |
551 } // namespace internal | 544 } // namespace internal |
552 } // namespace v8 | 545 } // namespace v8 |
553 | 546 |
554 #endif // V8_X87_ASSEMBLER_X87_INL_H_ | 547 #endif // V8_X87_ASSEMBLER_X87_INL_H_ |
OLD | NEW |