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 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/base/division-by-constant.h" | 8 #include "src/base/division-by-constant.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 IncrementCounter(isolate()->counters()->write_barriers_dynamic(), 1); | 500 IncrementCounter(isolate()->counters()->write_barriers_dynamic(), 1); |
501 | 501 |
502 // Clobber clobbered registers when running with the debug-code flag | 502 // Clobber clobbered registers when running with the debug-code flag |
503 // turned on to provoke errors. | 503 // turned on to provoke errors. |
504 if (emit_debug_code()) { | 504 if (emit_debug_code()) { |
505 Move(address, kZapValue, Assembler::RelocInfoNone()); | 505 Move(address, kZapValue, Assembler::RelocInfoNone()); |
506 Move(value, kZapValue, Assembler::RelocInfoNone()); | 506 Move(value, kZapValue, Assembler::RelocInfoNone()); |
507 } | 507 } |
508 } | 508 } |
509 | 509 |
| 510 void MacroAssembler::RecordWriteCodeEntryField(Register js_function, |
| 511 Register code_entry, |
| 512 Register scratch) { |
| 513 const int offset = JSFunction::kCodeEntryOffset; |
| 514 |
| 515 // The input registers are fixed to make calling the C write barrier function |
| 516 // easier. |
| 517 DCHECK(js_function.is(rdi)); |
| 518 DCHECK(code_entry.is(rcx)); |
| 519 DCHECK(scratch.is(rax)); |
| 520 |
| 521 // Since a code entry (value) is always in old space, we don't need to update |
| 522 // remembered set. If incremental marking is off, there is nothing for us to |
| 523 // do. |
| 524 if (!FLAG_incremental_marking) return; |
| 525 |
| 526 AssertNotSmi(js_function); |
| 527 |
| 528 if (emit_debug_code()) { |
| 529 Label ok; |
| 530 leap(scratch, FieldOperand(js_function, offset)); |
| 531 cmpp(code_entry, Operand(scratch, 0)); |
| 532 j(equal, &ok, Label::kNear); |
| 533 int3(); |
| 534 bind(&ok); |
| 535 } |
| 536 |
| 537 // First, check if a write barrier is even needed. The tests below |
| 538 // catch stores of Smis and stores into young gen. |
| 539 Label done; |
| 540 |
| 541 CheckPageFlag(code_entry, scratch, |
| 542 MemoryChunk::kPointersToHereAreInterestingMask, zero, &done, |
| 543 Label::kNear); |
| 544 CheckPageFlag(js_function, scratch, |
| 545 MemoryChunk::kPointersFromHereAreInterestingMask, zero, &done, |
| 546 Label::kNear); |
| 547 |
| 548 // Save input registers. |
| 549 Push(js_function); |
| 550 Push(code_entry); |
| 551 |
| 552 const Register dst = scratch; |
| 553 leap(dst, FieldOperand(js_function, offset)); |
| 554 |
| 555 // Save caller-saved registers. |
| 556 PushCallerSaved(kDontSaveFPRegs, js_function, code_entry); |
| 557 |
| 558 int argument_count = 3; |
| 559 PrepareCallCFunction(argument_count); |
| 560 |
| 561 // Load the argument registers. |
| 562 if (arg_reg_1.is(rcx)) { |
| 563 // Windows calling convention. |
| 564 DCHECK(arg_reg_2.is(rdx) && arg_reg_3.is(r8)); |
| 565 |
| 566 movp(arg_reg_1, js_function); // rcx gets rdi. |
| 567 movp(arg_reg_2, dst); // rdx gets rax. |
| 568 } else { |
| 569 // AMD64 calling convention. |
| 570 DCHECK(arg_reg_1.is(rdi) && arg_reg_2.is(rsi) && arg_reg_3.is(rdx)); |
| 571 |
| 572 // rdi is already loaded with js_function. |
| 573 movp(arg_reg_2, dst); // rsi gets rax. |
| 574 } |
| 575 Move(arg_reg_3, ExternalReference::isolate_address(isolate())); |
| 576 |
| 577 { |
| 578 AllowExternalCallThatCantCauseGC scope(this); |
| 579 CallCFunction( |
| 580 ExternalReference::incremental_marking_record_write_code_entry_function( |
| 581 isolate()), |
| 582 argument_count); |
| 583 } |
| 584 |
| 585 // Restore caller-saved registers. |
| 586 PopCallerSaved(kDontSaveFPRegs, js_function, code_entry); |
| 587 |
| 588 // Restore input registers. |
| 589 Pop(code_entry); |
| 590 Pop(js_function); |
| 591 |
| 592 bind(&done); |
| 593 } |
510 | 594 |
511 void MacroAssembler::Assert(Condition cc, BailoutReason reason) { | 595 void MacroAssembler::Assert(Condition cc, BailoutReason reason) { |
512 if (emit_debug_code()) Check(cc, reason); | 596 if (emit_debug_code()) Check(cc, reason); |
513 } | 597 } |
514 | 598 |
515 | 599 |
516 void MacroAssembler::AssertFastElements(Register elements) { | 600 void MacroAssembler::AssertFastElements(Register elements) { |
517 if (emit_debug_code()) { | 601 if (emit_debug_code()) { |
518 Label ok; | 602 Label ok; |
519 CompareRoot(FieldOperand(elements, HeapObject::kMapOffset), | 603 CompareRoot(FieldOperand(elements, HeapObject::kMapOffset), |
(...skipping 4991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5511 movl(rax, dividend); | 5595 movl(rax, dividend); |
5512 shrl(rax, Immediate(31)); | 5596 shrl(rax, Immediate(31)); |
5513 addl(rdx, rax); | 5597 addl(rdx, rax); |
5514 } | 5598 } |
5515 | 5599 |
5516 | 5600 |
5517 } // namespace internal | 5601 } // namespace internal |
5518 } // namespace v8 | 5602 } // namespace v8 |
5519 | 5603 |
5520 #endif // V8_TARGET_ARCH_X64 | 5604 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |