Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(509)

Side by Side Diff: src/ia32/code-stubs-ia32.cc

Issue 6824078: Move most of the incremental marking write barrier to generated code. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/code-stubs-ia32.h ('k') | src/ia32/codegen-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 13 matching lines...) Expand all
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #if defined(V8_TARGET_ARCH_IA32) 30 #if defined(V8_TARGET_ARCH_IA32)
31 31
32 #include "code-stubs.h" 32 #include "code-stubs.h"
33 #include "bootstrapper.h" 33 #include "bootstrapper.h"
34 #include "isolate.h"
34 #include "jsregexp.h" 35 #include "jsregexp.h"
35 #include "isolate.h" 36 #include "macro-assembler-ia32-inl.h"
36 #include "regexp-macro-assembler.h" 37 #include "regexp-macro-assembler.h"
37 38
38 namespace v8 { 39 namespace v8 {
39 namespace internal { 40 namespace internal {
40 41
41 #define __ ACCESS_MASM(masm) 42 #define __ ACCESS_MASM(masm)
42 43
43 void ToNumberStub::Generate(MacroAssembler* masm) { 44 void ToNumberStub::Generate(MacroAssembler* masm) {
44 // The ToNumber stub takes one argument in eax. 45 // The ToNumber stub takes one argument in eax.
45 NearLabel check_heap_number, call_builtin; 46 NearLabel check_heap_number, call_builtin;
(...skipping 4002 matching lines...) Expand 10 before | Expand all | Expand 10 after
4048 // ebx: last_match_info backing store (FixedArray) 4049 // ebx: last_match_info backing store (FixedArray)
4049 // edx: number of capture registers 4050 // edx: number of capture registers
4050 // Store the capture count. 4051 // Store the capture count.
4051 __ SmiTag(edx); // Number of capture registers to smi. 4052 __ SmiTag(edx); // Number of capture registers to smi.
4052 __ mov(FieldOperand(ebx, RegExpImpl::kLastCaptureCountOffset), edx); 4053 __ mov(FieldOperand(ebx, RegExpImpl::kLastCaptureCountOffset), edx);
4053 __ SmiUntag(edx); // Number of capture registers back from smi. 4054 __ SmiUntag(edx); // Number of capture registers back from smi.
4054 // Store last subject and last input. 4055 // Store last subject and last input.
4055 __ mov(eax, Operand(esp, kSubjectOffset)); 4056 __ mov(eax, Operand(esp, kSubjectOffset));
4056 __ mov(FieldOperand(ebx, RegExpImpl::kLastSubjectOffset), eax); 4057 __ mov(FieldOperand(ebx, RegExpImpl::kLastSubjectOffset), eax);
4057 __ mov(ecx, ebx); 4058 __ mov(ecx, ebx);
4058 __ RecordWrite(ecx, 4059 __ RecordWriteField(ecx,
4059 RegExpImpl::kLastSubjectOffset, 4060 RegExpImpl::kLastSubjectOffset,
4060 eax, 4061 eax,
4061 edi, 4062 edi,
4062 kDontSaveFPRegs); 4063 kDontSaveFPRegs);
4063 __ mov(eax, Operand(esp, kSubjectOffset)); 4064 __ mov(eax, Operand(esp, kSubjectOffset));
4064 __ mov(FieldOperand(ebx, RegExpImpl::kLastInputOffset), eax); 4065 __ mov(FieldOperand(ebx, RegExpImpl::kLastInputOffset), eax);
4065 __ mov(ecx, ebx); 4066 __ mov(ecx, ebx);
4066 __ RecordWrite(ecx, RegExpImpl::kLastInputOffset, eax, edi, kDontSaveFPRegs); 4067 __ RecordWriteField(ecx,
4068 RegExpImpl::kLastInputOffset,
4069 eax,
4070 edi,
4071 kDontSaveFPRegs);
4067 4072
4068 // Get the static offsets vector filled by the native regexp code. 4073 // Get the static offsets vector filled by the native regexp code.
4069 ExternalReference address_of_static_offsets_vector = 4074 ExternalReference address_of_static_offsets_vector =
4070 ExternalReference::address_of_static_offsets_vector(); 4075 ExternalReference::address_of_static_offsets_vector();
4071 __ mov(ecx, Immediate(address_of_static_offsets_vector)); 4076 __ mov(ecx, Immediate(address_of_static_offsets_vector));
4072 4077
4073 // ebx: last_match_info backing store (FixedArray) 4078 // ebx: last_match_info backing store (FixedArray)
4074 // ecx: offsets vector 4079 // ecx: offsets vector
4075 // edx: number of capture registers 4080 // edx: number of capture registers
4076 NearLabel next_capture, done; 4081 NearLabel next_capture, done;
(...skipping 2409 matching lines...) Expand 10 before | Expand all | Expand 10 after
6486 __ pop(ecx); 6491 __ pop(ecx);
6487 __ pop(eax); 6492 __ pop(eax);
6488 __ pop(edx); 6493 __ pop(edx);
6489 __ push(ecx); 6494 __ push(ecx);
6490 6495
6491 // Do a tail call to the rewritten stub. 6496 // Do a tail call to the rewritten stub.
6492 __ jmp(Operand(edi)); 6497 __ jmp(Operand(edi));
6493 } 6498 }
6494 6499
6495 6500
6501 // Takes the input in 3 registers: address_ value_ and object_. A pointer to
6502 // the value has just been written into the object, now this stub makes sure
6503 // we keep the GC informed. The word in the object where the value has been
6504 // written is in the address register.
6496 void RecordWriteStub::Generate(MacroAssembler* masm) { 6505 void RecordWriteStub::Generate(MacroAssembler* masm) {
6497 NearLabel skip_incremental_part; 6506 NearLabel skip_non_incremental_part;
6498 __ jmp(&skip_incremental_part); 6507 __ jmp(&skip_non_incremental_part);
6499 6508 if (HEAP->incremental_marking()->IsStopped()) {
6500 // TODO(gc) ISOLATES MERGE 6509 ASSERT(masm->get_opcode(-2) == kSkipNonIncrementalPartInstruction);
6501 // TODO(gc) possible bug, figure out what happens if GC is triggered
6502 // (incremental marking starts) during allocation of code object for this
6503 // stub. Looks like this stub will not be patched.
6504 if (!HEAP->incremental_marking()->IsStopped()) {
6505 ASSERT(masm->get_opcode(-2) == kSkipIncrementalPartInstruction);
6506 masm->set_opcode(-2, kTwoByteNopInstruction); 6510 masm->set_opcode(-2, kTwoByteNopInstruction);
6507 } 6511 }
6508 6512
6509 // If we are also emitting the remembered set code in this stub then we have 6513 if (FLAG_debug_code) {
6510 // the object we are writing into in the 'object' register and the slot in 6514 NearLabel ok, bad;
6511 // the 'address' register. We insert a primitive test here to ensure that 6515 __ cmp(value_, Operand(address_, 0));
6512 // this is the case. Otherwise the 'address' register is merely a scratch 6516 __ j(equal, &ok);
6513 // register. 6517 __ bind(&bad);
6514 if (FLAG_debug_code && emit_remembered_set_ == EMIT_REMEMBERED_SET) {
6515 NearLabel ok;
6516 __ cmp(address_, Operand(object_));
6517 __ j(above_equal, &ok);
6518 __ int3(); 6518 __ int3();
6519 __ bind(&ok); 6519 __ bind(&ok);
6520 } 6520
6521 6521 __ test(object_, Immediate(kSmiTagMask));
6522 __ IncrementalMarkingRecordWriteHelper(object_, value_, address_); 6522 __ j(zero, &bad);
6523 6523 __ test(address_, Immediate(kSmiTagMask));
6524 __ bind(&skip_incremental_part); 6524 __ j(not_zero, &bad);
6525 __ test(value_, Immediate(kSmiTagMask));
6526 __ j(zero, &bad);
6527 }
6525 6528
6526 if (emit_remembered_set_ == EMIT_REMEMBERED_SET) { 6529 if (emit_remembered_set_ == EMIT_REMEMBERED_SET) {
6527 Register scratch = value_; 6530 NearLabel skip;
6528 NearLabel done; 6531 __ InNewSpace(address_, value_, equal, &skip);
6529 __ InNewSpace(object_, scratch, equal, &done); 6532 __ HasScanOnScavenge(object_, value_, &skip);
6530 __ RememberedSetHelper(object_, address_, scratch, save_fp_regs_mode_); 6533 __ RememberedSetHelper(address_, value_, save_fp_regs_mode_);
6531 __ bind(&done); 6534 __ bind(&skip);
6532 } 6535 }
6536 __ ret(0);
6537
6538 __ bind(&skip_non_incremental_part);
6539
6540 GenerateIncremental(masm);
6541 }
6542
6543
6544 void RecordWriteStub::GenerateIncremental(MacroAssembler* masm) {
6545 regs_.Save(masm);
6546
6547 Label value_in_old_space;
6548
6549 __ InNewSpace(value_, regs_.scratch0(), not_equal, &value_in_old_space);
6550 // After this point the value_ register may have been overwritten since it is
6551 // also one of the scratch registers.
6552
6553 GenerateIncrementalValueIsInNewSpace(masm);
6554
6555 __ bind(&value_in_old_space);
6556 GenerateIncrementalValueIsInOldSpace(masm);
6557
6558 __ bind(&slow_);
6559 // Inform the incremental marker, but don't bother with the remembered set.
6560 regs_.SaveCallerSaveRegisters(masm, save_fp_regs_mode_);
6561 // TODO(gc) we are assuming that xmm registers are not modified by
6562 // the C function we are calling.
6563 __ PrepareCallCFunction(2, regs_.scratch0());
6564 __ mov(Operand(esp, 0 * kPointerSize), regs_.object());
6565 __ mov(regs_.scratch0(), Operand(regs_.address(), 0));
6566 __ mov(Operand(esp, 1 * kPointerSize), regs_.scratch0()); // Value.
6567 // TODO(gc): Create a fast version of this C function that does not duplicate
6568 // the checks done in the stub.
6569 __ CallCFunction(
6570 ExternalReference::incremental_marking_record_write_function(), 2);
6571 regs_.RestoreCallerSaveRegisters(masm, save_fp_regs_mode_);
6572 regs_.Restore(masm);
6573 __ ret(0);
6574 }
6575
6576
6577 void RecordWriteStub::GenerateIncrementalValueIsInNewSpace(
6578 MacroAssembler* masm) {
6579 Label both_in_new_space;
6580 Label value_in_new_space_object_is_black_no_remembered_set;
6581
6582 // The value is in new space. Check the object.
6583 __ InNewSpace(regs_.object(), regs_.scratch0(), equal, &both_in_new_space);
6584
6585 // Value is in new space, object is in old space. Could we be lucky and find
6586 // the scan_on_scavenge flag on the object's page?
6587 if (emit_remembered_set_ == EMIT_REMEMBERED_SET) {
6588 Label scan_on_scavenge;
6589 __ HasScanOnScavenge(regs_.object(), regs_.scratch0(), &scan_on_scavenge);
6590 GenerateIncrementalValueIsInNewSpaceObjectIsInOldSpaceRememberedSet(masm);
6591 __ bind(&scan_on_scavenge);
6592 }
6593 // This function will also bind the label.
6594 GenerateIncrementalValueIsInNewSpaceObjectIsInOldSpaceNoRememberedSet(
6595 masm, &value_in_new_space_object_is_black_no_remembered_set);
6596
6597 __ bind(&both_in_new_space);
6598 __ InNewSpaceIsBlack(regs_.object(),
6599 regs_.scratch0(),
6600 regs_.scratch1(),
6601 &value_in_new_space_object_is_black_no_remembered_set);
6602 regs_.Restore(masm);
6603 __ ret(0);
6604 }
6605
6606
6607 void RecordWriteStub::
6608 GenerateIncrementalValueIsInNewSpaceObjectIsInOldSpaceRememberedSet(
6609 MacroAssembler* masm) {
6610 NearLabel object_is_black, must_inform_both;
6611 Label must_inform_both_far;
6612
6613 __ jmp(&must_inform_both_far);
6614
6615 // Lets look at the colour of the object: If it is not black we don't have to
6616 // inform the incremental marker.
6617 __ InOldSpaceIsBlack(regs_.object(),
6618 regs_.scratch0(),
6619 regs_.scratch1(),
6620 &object_is_black);
6621 regs_.Restore(masm);
6622 __ RememberedSetHelper(address_, value_, save_fp_regs_mode_);
6623 __ ret(0);
6624
6625 __ bind(&object_is_black);
6626
6627 __ mov(regs_.scratch0(), Operand(regs_.address(), 0));
6628 __ push(regs_.object());
6629 __ EnsureNotWhite(regs_.scratch0(), // The value.
6630 regs_.scratch1(), // Scratch.
6631 regs_.object(), // Scratch.
6632 &must_inform_both,
6633 true); // In new space.
6634 __ pop(regs_.object());
6635 regs_.Restore(masm);
6636 __ RememberedSetHelper(address_, value_, save_fp_regs_mode_);
6637 __ ret(0);
6638
6639 __ bind(&must_inform_both);
6640 // Both the incremental marker and the the remembered set have to be informed.
6641 __ pop(regs_.object());
6642 __ bind(&must_inform_both_far);
6643 regs_.SaveCallerSaveRegisters(masm, save_fp_regs_mode_);
6644 // TODO(gc) we are assuming that xmm registers are not modified by
6645 // the C function we are calling.
6646 __ PrepareCallCFunction(2, regs_.scratch0());
6647 __ mov(Operand(esp, 0 * kPointerSize), regs_.object());
6648 __ mov(regs_.scratch0(), Operand(regs_.address(), 0));
6649 __ mov(Operand(esp, 1 * kPointerSize), regs_.scratch0()); // Value.
6650 __ CallCFunction(
6651 ExternalReference::incremental_marking_record_write_function(), 2);
6652 regs_.RestoreCallerSaveRegisters(masm, save_fp_regs_mode_);
6653 regs_.Restore(masm);
6654 __ RememberedSetHelper(address_, value_, save_fp_regs_mode_);
6655 __ ret(0);
6656 }
6657
6658
6659 void RecordWriteStub::
6660 GenerateIncrementalValueIsInNewSpaceObjectIsInOldSpaceNoRememberedSet(
6661 MacroAssembler* masm,
6662 Label* value_in_new_space_object_is_black_no_remembered_set) {
6663 NearLabel object_is_black, inform_incremental_marker;
6664
6665 __ jmp(&slow_);
6666
6667 __ InOldSpaceIsBlack(regs_.object(),
6668 regs_.scratch0(),
6669 regs_.scratch1(),
6670 &object_is_black);
6671 regs_.Restore(masm);
6672 __ ret(0);
6673
6674 __ bind(&object_is_black);
6675 __ bind(value_in_new_space_object_is_black_no_remembered_set);
6676
6677 // Reload the value from the word in the object.
6678 __ mov(regs_.scratch0(), Operand(regs_.address(), 0));
6679
6680 // We need one more scratch register in this case. Use the object register.
6681 __ push(regs_.object());
6682
6683 // Make sure the value is not white. If we can't do that, jump to the label.
6684 __ EnsureNotWhite(regs_.scratch0(), // The value.
6685 regs_.scratch1(), // Scratch.
6686 regs_.object(), // Scratch.
6687 &inform_incremental_marker,
6688 true); // In new space.
6689 __ pop(regs_.object());
6690 regs_.Restore(masm);
6691 __ ret(0);
6692
6693 __ bind(&inform_incremental_marker);
6694 __ pop(regs_.object());
6695
6696 __ jmp(&slow_);
6697 }
6698
6699
6700 void RecordWriteStub::GenerateIncrementalValueIsInOldSpace(
6701 MacroAssembler* masm) {
6702 NearLabel value_is_white;
6703 Label value_in_old_space_and_white_object_in_new_space;
6704 // If the value is in old space then the remembered set doesn't care. We may
6705 // be able to avoid logging anything if the incremental marker doesn't care
6706 // either.
6707 __ mov(regs_.scratch0(), Operand(regs_.address(), 0));
6708 __ push(regs_.object());
6709 __ EnsureNotWhite(regs_.scratch0(), // The value.
6710 regs_.scratch1(), // Scratch.
6711 regs_.object(), // Scratch.
6712 &value_is_white,
6713 false); // In old space.
6714 __ pop(regs_.object());
6715 regs_.Restore(masm);
6716 __ ret(0);
6717
6718 // The value is in old space and white. We have to find out which space the
6719 // object is in in order to find its colour.
6720 __ bind(&value_is_white);
6721 __ pop(regs_.object());
6722 __ InNewSpace(regs_.object(),
6723 regs_.scratch0(),
6724 equal,
6725 &value_in_old_space_and_white_object_in_new_space);
6726
6727 // Both in old space, value is white and can't be marked.
6728 __ InOldSpaceIsBlack(regs_.object(),
6729 regs_.scratch0(),
6730 regs_.scratch1(),
6731 &slow_);
6732 regs_.Restore(masm);
6733 __ ret(0);
6734
6735 // Object in new space, value in old space and white and can't be marked.
6736 __ bind(&value_in_old_space_and_white_object_in_new_space);
6737 __ InNewSpaceIsBlack(regs_.object(),
6738 regs_.scratch0(),
6739 regs_.scratch1(),
6740 &slow_);
6741 regs_.Restore(masm);
6533 __ ret(0); 6742 __ ret(0);
6534 } 6743 }
6535 6744
6536 6745
6537 #undef __ 6746 #undef __
6538 6747
6539 } } // namespace v8::internal 6748 } } // namespace v8::internal
6540 6749
6541 #endif // V8_TARGET_ARCH_IA32 6750 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.h ('k') | src/ia32/codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698