OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "v8memory.h" | 35 #include "v8memory.h" |
36 | 36 |
37 namespace v8 { | 37 namespace v8 { |
38 namespace internal { | 38 namespace internal { |
39 | 39 |
40 | 40 |
41 // ----------------------------------------------------------------------------- | 41 // ----------------------------------------------------------------------------- |
42 // Implementation of Assembler | 42 // Implementation of Assembler |
43 | 43 |
44 | 44 |
| 45 static const byte kCallOpcode = 0xE8; |
| 46 |
| 47 |
45 void Assembler::emitl(uint32_t x) { | 48 void Assembler::emitl(uint32_t x) { |
46 Memory::uint32_at(pc_) = x; | 49 Memory::uint32_at(pc_) = x; |
47 pc_ += sizeof(uint32_t); | 50 pc_ += sizeof(uint32_t); |
48 } | 51 } |
49 | 52 |
50 | 53 |
51 void Assembler::emitq(uint64_t x, RelocInfo::Mode rmode) { | 54 void Assembler::emitq(uint64_t x, RelocInfo::Mode rmode) { |
52 Memory::uint64_at(pc_) = x; | 55 Memory::uint64_at(pc_) = x; |
53 if (rmode != RelocInfo::NONE) { | 56 if (rmode != RelocInfo::NONE) { |
54 RecordRelocInfo(rmode, x); | 57 RecordRelocInfo(rmode, x); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 213 |
211 // The modes possibly affected by apply must be in kApplyMask. | 214 // The modes possibly affected by apply must be in kApplyMask. |
212 void RelocInfo::apply(intptr_t delta) { | 215 void RelocInfo::apply(intptr_t delta) { |
213 if (IsInternalReference(rmode_)) { | 216 if (IsInternalReference(rmode_)) { |
214 // absolute code pointer inside code object moves with the code object. | 217 // absolute code pointer inside code object moves with the code object. |
215 Memory::Address_at(pc_) += static_cast<int32_t>(delta); | 218 Memory::Address_at(pc_) += static_cast<int32_t>(delta); |
216 CPU::FlushICache(pc_, sizeof(Address)); | 219 CPU::FlushICache(pc_, sizeof(Address)); |
217 } else if (IsCodeTarget(rmode_)) { | 220 } else if (IsCodeTarget(rmode_)) { |
218 Memory::int32_at(pc_) -= static_cast<int32_t>(delta); | 221 Memory::int32_at(pc_) -= static_cast<int32_t>(delta); |
219 CPU::FlushICache(pc_, sizeof(int32_t)); | 222 CPU::FlushICache(pc_, sizeof(int32_t)); |
| 223 } else if (rmode_ == CODE_AGE_SEQUENCE) { |
| 224 if (*pc_ == kCallOpcode) { |
| 225 int32_t* p = reinterpret_cast<int32_t*>(pc_ + 1); |
| 226 *p -= delta; // Relocate entry. |
| 227 CPU::FlushICache(p, sizeof(uint32_t)); |
| 228 } |
220 } | 229 } |
221 } | 230 } |
222 | 231 |
223 | 232 |
224 Address RelocInfo::target_address() { | 233 Address RelocInfo::target_address() { |
225 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); | 234 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); |
226 if (IsCodeTarget(rmode_)) { | 235 if (IsCodeTarget(rmode_)) { |
227 return Assembler::target_address_at(pc_); | 236 return Assembler::target_address_at(pc_); |
228 } else { | 237 } else { |
229 return Memory::Address_at(pc_); | 238 return Memory::Address_at(pc_); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 return false; | 357 return false; |
349 #endif | 358 #endif |
350 } | 359 } |
351 | 360 |
352 | 361 |
353 bool RelocInfo::IsPatchedDebugBreakSlotSequence() { | 362 bool RelocInfo::IsPatchedDebugBreakSlotSequence() { |
354 return !Assembler::IsNop(pc()); | 363 return !Assembler::IsNop(pc()); |
355 } | 364 } |
356 | 365 |
357 | 366 |
| 367 Code* RelocInfo::code_age_stub() { |
| 368 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); |
| 369 ASSERT(*pc_ == kCallOpcode); |
| 370 return Code::GetCodeFromTargetAddress( |
| 371 Assembler::target_address_at(pc_ + 1)); |
| 372 } |
| 373 |
| 374 |
| 375 void RelocInfo::set_code_age_stub(Code* stub) { |
| 376 ASSERT(*pc_ == kCallOpcode); |
| 377 ASSERT(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); |
| 378 Assembler::set_target_address_at(pc_ + 1, stub->instruction_start()); |
| 379 } |
| 380 |
| 381 |
358 Address RelocInfo::call_address() { | 382 Address RelocInfo::call_address() { |
359 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || | 383 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || |
360 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); | 384 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); |
361 return Memory::Address_at( | 385 return Memory::Address_at( |
362 pc_ + Assembler::kRealPatchReturnSequenceAddressOffset); | 386 pc_ + Assembler::kRealPatchReturnSequenceAddressOffset); |
363 } | 387 } |
364 | 388 |
365 | 389 |
366 void RelocInfo::set_call_address(Address target) { | 390 void RelocInfo::set_call_address(Address target) { |
367 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || | 391 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 if (mode == RelocInfo::EMBEDDED_OBJECT) { | 425 if (mode == RelocInfo::EMBEDDED_OBJECT) { |
402 visitor->VisitEmbeddedPointer(this); | 426 visitor->VisitEmbeddedPointer(this); |
403 CPU::FlushICache(pc_, sizeof(Address)); | 427 CPU::FlushICache(pc_, sizeof(Address)); |
404 } else if (RelocInfo::IsCodeTarget(mode)) { | 428 } else if (RelocInfo::IsCodeTarget(mode)) { |
405 visitor->VisitCodeTarget(this); | 429 visitor->VisitCodeTarget(this); |
406 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { | 430 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { |
407 visitor->VisitGlobalPropertyCell(this); | 431 visitor->VisitGlobalPropertyCell(this); |
408 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { | 432 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { |
409 visitor->VisitExternalReference(this); | 433 visitor->VisitExternalReference(this); |
410 CPU::FlushICache(pc_, sizeof(Address)); | 434 CPU::FlushICache(pc_, sizeof(Address)); |
| 435 } else if (RelocInfo::IsCodeAgeSequence(mode)) { |
| 436 visitor->VisitCodeAgeSequence(this); |
411 #ifdef ENABLE_DEBUGGER_SUPPORT | 437 #ifdef ENABLE_DEBUGGER_SUPPORT |
412 // TODO(isolates): Get a cached isolate below. | 438 // TODO(isolates): Get a cached isolate below. |
413 } else if (((RelocInfo::IsJSReturn(mode) && | 439 } else if (((RelocInfo::IsJSReturn(mode) && |
414 IsPatchedReturnSequence()) || | 440 IsPatchedReturnSequence()) || |
415 (RelocInfo::IsDebugBreakSlot(mode) && | 441 (RelocInfo::IsDebugBreakSlot(mode) && |
416 IsPatchedDebugBreakSlotSequence())) && | 442 IsPatchedDebugBreakSlotSequence())) && |
417 Isolate::Current()->debug()->has_break_points()) { | 443 Isolate::Current()->debug()->has_break_points()) { |
418 visitor->VisitDebugTarget(this); | 444 visitor->VisitDebugTarget(this); |
419 #endif | 445 #endif |
420 } else if (mode == RelocInfo::RUNTIME_ENTRY) { | 446 } else if (mode == RelocInfo::RUNTIME_ENTRY) { |
421 visitor->VisitRuntimeEntry(this); | 447 visitor->VisitRuntimeEntry(this); |
422 } | 448 } |
423 } | 449 } |
424 | 450 |
425 | 451 |
426 template<typename StaticVisitor> | 452 template<typename StaticVisitor> |
427 void RelocInfo::Visit(Heap* heap) { | 453 void RelocInfo::Visit(Heap* heap) { |
428 RelocInfo::Mode mode = rmode(); | 454 RelocInfo::Mode mode = rmode(); |
429 if (mode == RelocInfo::EMBEDDED_OBJECT) { | 455 if (mode == RelocInfo::EMBEDDED_OBJECT) { |
430 StaticVisitor::VisitEmbeddedPointer(heap, this); | 456 StaticVisitor::VisitEmbeddedPointer(heap, this); |
431 CPU::FlushICache(pc_, sizeof(Address)); | 457 CPU::FlushICache(pc_, sizeof(Address)); |
432 } else if (RelocInfo::IsCodeTarget(mode)) { | 458 } else if (RelocInfo::IsCodeTarget(mode)) { |
433 StaticVisitor::VisitCodeTarget(heap, this); | 459 StaticVisitor::VisitCodeTarget(heap, this); |
434 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { | 460 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) { |
435 StaticVisitor::VisitGlobalPropertyCell(heap, this); | 461 StaticVisitor::VisitGlobalPropertyCell(heap, this); |
436 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { | 462 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { |
437 StaticVisitor::VisitExternalReference(this); | 463 StaticVisitor::VisitExternalReference(this); |
438 CPU::FlushICache(pc_, sizeof(Address)); | 464 CPU::FlushICache(pc_, sizeof(Address)); |
| 465 } else if (RelocInfo::IsCodeAgeSequence(mode)) { |
| 466 StaticVisitor::VisitCodeAgeSequence(heap, this); |
439 #ifdef ENABLE_DEBUGGER_SUPPORT | 467 #ifdef ENABLE_DEBUGGER_SUPPORT |
440 } else if (heap->isolate()->debug()->has_break_points() && | 468 } else if (heap->isolate()->debug()->has_break_points() && |
441 ((RelocInfo::IsJSReturn(mode) && | 469 ((RelocInfo::IsJSReturn(mode) && |
442 IsPatchedReturnSequence()) || | 470 IsPatchedReturnSequence()) || |
443 (RelocInfo::IsDebugBreakSlot(mode) && | 471 (RelocInfo::IsDebugBreakSlot(mode) && |
444 IsPatchedDebugBreakSlotSequence()))) { | 472 IsPatchedDebugBreakSlotSequence()))) { |
445 StaticVisitor::VisitDebugTarget(heap, this); | 473 StaticVisitor::VisitDebugTarget(heap, this); |
446 #endif | 474 #endif |
447 } else if (mode == RelocInfo::RUNTIME_ENTRY) { | 475 } else if (mode == RelocInfo::RUNTIME_ENTRY) { |
448 StaticVisitor::VisitRuntimeEntry(this); | 476 StaticVisitor::VisitRuntimeEntry(this); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 ASSERT(len_ == 1 || len_ == 2); | 512 ASSERT(len_ == 1 || len_ == 2); |
485 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); | 513 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); |
486 *p = disp; | 514 *p = disp; |
487 len_ += sizeof(int32_t); | 515 len_ += sizeof(int32_t); |
488 } | 516 } |
489 | 517 |
490 | 518 |
491 } } // namespace v8::internal | 519 } } // namespace v8::internal |
492 | 520 |
493 #endif // V8_X64_ASSEMBLER_X64_INL_H_ | 521 #endif // V8_X64_ASSEMBLER_X64_INL_H_ |
OLD | NEW |