OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_X64_ASSEMBLER_X64_INL_H_ | 5 #ifndef V8_X64_ASSEMBLER_X64_INL_H_ |
6 #define V8_X64_ASSEMBLER_X64_INL_H_ | 6 #define V8_X64_ASSEMBLER_X64_INL_H_ |
7 | 7 |
8 #include "x64/assembler-x64.h" | 8 #include "x64/assembler-x64.h" |
9 | 9 |
10 #include "cpu.h" | 10 #include "cpu.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 186 |
187 | 187 |
188 Address Assembler::target_address_at(Address pc, | 188 Address Assembler::target_address_at(Address pc, |
189 ConstantPoolArray* constant_pool) { | 189 ConstantPoolArray* constant_pool) { |
190 return Memory::int32_at(pc) + pc + 4; | 190 return Memory::int32_at(pc) + pc + 4; |
191 } | 191 } |
192 | 192 |
193 | 193 |
194 void Assembler::set_target_address_at(Address pc, | 194 void Assembler::set_target_address_at(Address pc, |
195 ConstantPoolArray* constant_pool, | 195 ConstantPoolArray* constant_pool, |
196 Address target) { | 196 Address target, |
| 197 ICacheFlushMode icache_flush_mode) { |
197 Memory::int32_at(pc) = static_cast<int32_t>(target - pc - 4); | 198 Memory::int32_at(pc) = static_cast<int32_t>(target - pc - 4); |
198 CPU::FlushICache(pc, sizeof(int32_t)); | 199 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { |
| 200 CPU::FlushICache(pc, sizeof(int32_t)); |
| 201 } |
199 } | 202 } |
200 | 203 |
201 | 204 |
202 Address Assembler::target_address_from_return_address(Address pc) { | 205 Address Assembler::target_address_from_return_address(Address pc) { |
203 return pc - kCallTargetAddressOffset; | 206 return pc - kCallTargetAddressOffset; |
204 } | 207 } |
205 | 208 |
206 | 209 |
207 Handle<Object> Assembler::code_target_object_handle_at(Address pc) { | 210 Handle<Object> Assembler::code_target_object_handle_at(Address pc) { |
208 return code_targets_[Memory::int32_at(pc)]; | 211 return code_targets_[Memory::int32_at(pc)]; |
209 } | 212 } |
210 | 213 |
211 | 214 |
212 Address Assembler::runtime_entry_at(Address pc) { | 215 Address Assembler::runtime_entry_at(Address pc) { |
213 ASSERT(isolate()->code_range()->exists()); | 216 ASSERT(isolate()->code_range()->exists()); |
214 return Memory::int32_at(pc) + isolate()->code_range()->start(); | 217 return Memory::int32_at(pc) + isolate()->code_range()->start(); |
215 } | 218 } |
216 | 219 |
217 // ----------------------------------------------------------------------------- | 220 // ----------------------------------------------------------------------------- |
218 // Implementation of RelocInfo | 221 // Implementation of RelocInfo |
219 | 222 |
220 // The modes possibly affected by apply must be in kApplyMask. | 223 // The modes possibly affected by apply must be in kApplyMask. |
221 void RelocInfo::apply(intptr_t delta) { | 224 void RelocInfo::apply(intptr_t delta, ICacheFlushMode icache_flush_mode) { |
| 225 bool flush_icache = icache_flush_mode != SKIP_ICACHE_FLUSH; |
222 if (IsInternalReference(rmode_)) { | 226 if (IsInternalReference(rmode_)) { |
223 // absolute code pointer inside code object moves with the code object. | 227 // absolute code pointer inside code object moves with the code object. |
224 Memory::Address_at(pc_) += static_cast<int32_t>(delta); | 228 Memory::Address_at(pc_) += static_cast<int32_t>(delta); |
225 CPU::FlushICache(pc_, sizeof(Address)); | 229 if (flush_icache) CPU::FlushICache(pc_, sizeof(Address)); |
226 } else if (IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)) { | 230 } else if (IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)) { |
227 Memory::int32_at(pc_) -= static_cast<int32_t>(delta); | 231 Memory::int32_at(pc_) -= static_cast<int32_t>(delta); |
228 CPU::FlushICache(pc_, sizeof(int32_t)); | 232 if (flush_icache) CPU::FlushICache(pc_, sizeof(int32_t)); |
229 } else if (rmode_ == CODE_AGE_SEQUENCE) { | 233 } else if (rmode_ == CODE_AGE_SEQUENCE) { |
230 if (*pc_ == kCallOpcode) { | 234 if (*pc_ == kCallOpcode) { |
231 int32_t* p = reinterpret_cast<int32_t*>(pc_ + 1); | 235 int32_t* p = reinterpret_cast<int32_t*>(pc_ + 1); |
232 *p -= static_cast<int32_t>(delta); // Relocate entry. | 236 *p -= static_cast<int32_t>(delta); // Relocate entry. |
233 CPU::FlushICache(p, sizeof(uint32_t)); | 237 if (flush_icache) CPU::FlushICache(p, sizeof(uint32_t)); |
234 } | 238 } |
235 } | 239 } |
236 } | 240 } |
237 | 241 |
238 | 242 |
239 Address RelocInfo::target_address() { | 243 Address RelocInfo::target_address() { |
240 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); | 244 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); |
241 return Assembler::target_address_at(pc_, host_); | 245 return Assembler::target_address_at(pc_, host_); |
242 } | 246 } |
243 | 247 |
(...skipping 14 matching lines...) Expand all Loading... |
258 | 262 |
259 int RelocInfo::target_address_size() { | 263 int RelocInfo::target_address_size() { |
260 if (IsCodedSpecially()) { | 264 if (IsCodedSpecially()) { |
261 return Assembler::kSpecialTargetSize; | 265 return Assembler::kSpecialTargetSize; |
262 } else { | 266 } else { |
263 return kPointerSize; | 267 return kPointerSize; |
264 } | 268 } |
265 } | 269 } |
266 | 270 |
267 | 271 |
268 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) { | 272 void RelocInfo::set_target_address(Address target, |
| 273 WriteBarrierMode write_barrier_mode, |
| 274 ICacheFlushMode icache_flush_mode) { |
269 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); | 275 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); |
270 Assembler::set_target_address_at(pc_, host_, target); | 276 Assembler::set_target_address_at(pc_, host_, target, icache_flush_mode); |
271 if (mode == UPDATE_WRITE_BARRIER && host() != NULL && IsCodeTarget(rmode_)) { | 277 if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL && |
| 278 IsCodeTarget(rmode_)) { |
272 Object* target_code = Code::GetCodeFromTargetAddress(target); | 279 Object* target_code = Code::GetCodeFromTargetAddress(target); |
273 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( | 280 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( |
274 host(), this, HeapObject::cast(target_code)); | 281 host(), this, HeapObject::cast(target_code)); |
275 } | 282 } |
276 } | 283 } |
277 | 284 |
278 | 285 |
279 Object* RelocInfo::target_object() { | 286 Object* RelocInfo::target_object() { |
280 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 287 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
281 return Memory::Object_at(pc_); | 288 return Memory::Object_at(pc_); |
282 } | 289 } |
283 | 290 |
284 | 291 |
285 Handle<Object> RelocInfo::target_object_handle(Assembler* origin) { | 292 Handle<Object> RelocInfo::target_object_handle(Assembler* origin) { |
286 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 293 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
287 if (rmode_ == EMBEDDED_OBJECT) { | 294 if (rmode_ == EMBEDDED_OBJECT) { |
288 return Memory::Object_Handle_at(pc_); | 295 return Memory::Object_Handle_at(pc_); |
289 } else { | 296 } else { |
290 return origin->code_target_object_handle_at(pc_); | 297 return origin->code_target_object_handle_at(pc_); |
291 } | 298 } |
292 } | 299 } |
293 | 300 |
294 | 301 |
295 Address RelocInfo::target_reference() { | 302 Address RelocInfo::target_reference() { |
296 ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE); | 303 ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE); |
297 return Memory::Address_at(pc_); | 304 return Memory::Address_at(pc_); |
298 } | 305 } |
299 | 306 |
300 | 307 |
301 void RelocInfo::set_target_object(Object* target, WriteBarrierMode mode) { | 308 void RelocInfo::set_target_object(Object* target, |
| 309 WriteBarrierMode write_barrier_mode, |
| 310 ICacheFlushMode icache_flush_mode) { |
302 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 311 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
303 ASSERT(!target->IsConsString()); | 312 ASSERT(!target->IsConsString()); |
304 Memory::Object_at(pc_) = target; | 313 Memory::Object_at(pc_) = target; |
305 CPU::FlushICache(pc_, sizeof(Address)); | 314 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { |
306 if (mode == UPDATE_WRITE_BARRIER && | 315 CPU::FlushICache(pc_, sizeof(Address)); |
| 316 } |
| 317 if (write_barrier_mode == UPDATE_WRITE_BARRIER && |
307 host() != NULL && | 318 host() != NULL && |
308 target->IsHeapObject()) { | 319 target->IsHeapObject()) { |
309 host()->GetHeap()->incremental_marking()->RecordWrite( | 320 host()->GetHeap()->incremental_marking()->RecordWrite( |
310 host(), &Memory::Object_at(pc_), HeapObject::cast(target)); | 321 host(), &Memory::Object_at(pc_), HeapObject::cast(target)); |
311 } | 322 } |
312 } | 323 } |
313 | 324 |
314 | 325 |
315 Address RelocInfo::target_runtime_entry(Assembler* origin) { | 326 Address RelocInfo::target_runtime_entry(Assembler* origin) { |
316 ASSERT(IsRuntimeEntry(rmode_)); | 327 ASSERT(IsRuntimeEntry(rmode_)); |
317 return origin->runtime_entry_at(pc_); | 328 return origin->runtime_entry_at(pc_); |
318 } | 329 } |
319 | 330 |
320 | 331 |
321 void RelocInfo::set_target_runtime_entry(Address target, | 332 void RelocInfo::set_target_runtime_entry(Address target, |
322 WriteBarrierMode mode) { | 333 WriteBarrierMode write_barrier_mode, |
| 334 ICacheFlushMode icache_flush_mode) { |
323 ASSERT(IsRuntimeEntry(rmode_)); | 335 ASSERT(IsRuntimeEntry(rmode_)); |
324 if (target_address() != target) set_target_address(target, mode); | 336 if (target_address() != target) { |
| 337 set_target_address(target, write_barrier_mode, icache_flush_mode); |
| 338 } |
325 } | 339 } |
326 | 340 |
327 | 341 |
328 Handle<Cell> RelocInfo::target_cell_handle() { | 342 Handle<Cell> RelocInfo::target_cell_handle() { |
329 ASSERT(rmode_ == RelocInfo::CELL); | 343 ASSERT(rmode_ == RelocInfo::CELL); |
330 Address address = Memory::Address_at(pc_); | 344 Address address = Memory::Address_at(pc_); |
331 return Handle<Cell>(reinterpret_cast<Cell**>(address)); | 345 return Handle<Cell>(reinterpret_cast<Cell**>(address)); |
332 } | 346 } |
333 | 347 |
334 | 348 |
335 Cell* RelocInfo::target_cell() { | 349 Cell* RelocInfo::target_cell() { |
336 ASSERT(rmode_ == RelocInfo::CELL); | 350 ASSERT(rmode_ == RelocInfo::CELL); |
337 return Cell::FromValueAddress(Memory::Address_at(pc_)); | 351 return Cell::FromValueAddress(Memory::Address_at(pc_)); |
338 } | 352 } |
339 | 353 |
340 | 354 |
341 void RelocInfo::set_target_cell(Cell* cell, WriteBarrierMode mode) { | 355 void RelocInfo::set_target_cell(Cell* cell, |
| 356 WriteBarrierMode write_barrier_mode, |
| 357 ICacheFlushMode icache_flush_mode) { |
342 ASSERT(rmode_ == RelocInfo::CELL); | 358 ASSERT(rmode_ == RelocInfo::CELL); |
343 Address address = cell->address() + Cell::kValueOffset; | 359 Address address = cell->address() + Cell::kValueOffset; |
344 Memory::Address_at(pc_) = address; | 360 Memory::Address_at(pc_) = address; |
345 CPU::FlushICache(pc_, sizeof(Address)); | 361 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { |
346 if (mode == UPDATE_WRITE_BARRIER && | 362 CPU::FlushICache(pc_, sizeof(Address)); |
| 363 } |
| 364 if (write_barrier_mode == UPDATE_WRITE_BARRIER && |
347 host() != NULL) { | 365 host() != NULL) { |
348 // TODO(1550) We are passing NULL as a slot because cell can never be on | 366 // TODO(1550) We are passing NULL as a slot because cell can never be on |
349 // evacuation candidate. | 367 // evacuation candidate. |
350 host()->GetHeap()->incremental_marking()->RecordWrite( | 368 host()->GetHeap()->incremental_marking()->RecordWrite( |
351 host(), NULL, cell); | 369 host(), NULL, cell); |
352 } | 370 } |
353 } | 371 } |
354 | 372 |
355 | 373 |
356 void RelocInfo::WipeOut() { | 374 void RelocInfo::WipeOut() { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 | 408 |
391 | 409 |
392 Code* RelocInfo::code_age_stub() { | 410 Code* RelocInfo::code_age_stub() { |
393 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); | 411 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); |
394 ASSERT(*pc_ == kCallOpcode); | 412 ASSERT(*pc_ == kCallOpcode); |
395 return Code::GetCodeFromTargetAddress( | 413 return Code::GetCodeFromTargetAddress( |
396 Assembler::target_address_at(pc_ + 1, host_)); | 414 Assembler::target_address_at(pc_ + 1, host_)); |
397 } | 415 } |
398 | 416 |
399 | 417 |
400 void RelocInfo::set_code_age_stub(Code* stub) { | 418 void RelocInfo::set_code_age_stub(Code* stub, |
| 419 ICacheFlushMode icache_flush_mode) { |
401 ASSERT(*pc_ == kCallOpcode); | 420 ASSERT(*pc_ == kCallOpcode); |
402 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); | 421 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); |
403 Assembler::set_target_address_at(pc_ + 1, host_, stub->instruction_start()); | 422 Assembler::set_target_address_at(pc_ + 1, host_, stub->instruction_start(), |
| 423 icache_flush_mode); |
404 } | 424 } |
405 | 425 |
406 | 426 |
407 Address RelocInfo::call_address() { | 427 Address RelocInfo::call_address() { |
408 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || | 428 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || |
409 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); | 429 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); |
410 return Memory::Address_at( | 430 return Memory::Address_at( |
411 pc_ + Assembler::kRealPatchReturnSequenceAddressOffset); | 431 pc_ + Assembler::kRealPatchReturnSequenceAddressOffset); |
412 } | 432 } |
413 | 433 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 ASSERT(len_ == 1 || len_ == 2); | 552 ASSERT(len_ == 1 || len_ == 2); |
533 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); | 553 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); |
534 *p = disp; | 554 *p = disp; |
535 len_ += sizeof(int32_t); | 555 len_ += sizeof(int32_t); |
536 } | 556 } |
537 | 557 |
538 | 558 |
539 } } // namespace v8::internal | 559 } } // namespace v8::internal |
540 | 560 |
541 #endif // V8_X64_ASSEMBLER_X64_INL_H_ | 561 #endif // V8_X64_ASSEMBLER_X64_INL_H_ |
OLD | NEW |