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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
Index: src/ia32/code-stubs-ia32.cc
===================================================================
--- src/ia32/code-stubs-ia32.cc (revision 7619)
+++ src/ia32/code-stubs-ia32.cc (working copy)
@@ -32,6 +32,7 @@
#include "code-stubs.h"
#include "bootstrapper.h"
#include "jsregexp.h"
+#include "macro-assembler-ia32-inl.h"
#include "regexp-macro-assembler.h"
namespace v8 {
@@ -4045,15 +4046,19 @@
__ mov(eax, Operand(esp, kSubjectOffset));
__ mov(FieldOperand(ebx, RegExpImpl::kLastSubjectOffset), eax);
__ mov(ecx, ebx);
- __ RecordWrite(ecx,
- RegExpImpl::kLastSubjectOffset,
- eax,
- edi,
- kDontSaveFPRegs);
+ __ RecordWriteField(ecx,
+ RegExpImpl::kLastSubjectOffset,
+ eax,
+ edi,
+ kDontSaveFPRegs);
__ mov(eax, Operand(esp, kSubjectOffset));
__ mov(FieldOperand(ebx, RegExpImpl::kLastInputOffset), eax);
__ mov(ecx, ebx);
- __ RecordWrite(ecx, RegExpImpl::kLastInputOffset, eax, edi, kDontSaveFPRegs);
+ __ RecordWriteField(ecx,
+ RegExpImpl::kLastInputOffset,
+ eax,
+ edi,
+ kDontSaveFPRegs);
// Get the static offsets vector filled by the native regexp code.
ExternalReference address_of_static_offsets_vector =
@@ -6475,42 +6480,244 @@
}
+// Takes the input in 3 registers: address_ value_ and object_. A pointer to
+// the value has just been written into the object, now this stub makes sure
+// we keep the GC informed. The word in the object where the value has been
+// written is in the address register.
void RecordWriteStub::Generate(MacroAssembler* masm) {
- NearLabel skip_incremental_part;
- __ jmp(&skip_incremental_part);
- if (!IncrementalMarking::IsStopped()) {
- ASSERT(masm->get_opcode(-2) == kSkipIncrementalPartInstruction);
+ NearLabel skip_non_incremental_part;
+ __ jmp(&skip_non_incremental_part);
+ if (IncrementalMarking::IsStopped()) {
+ ASSERT(masm->get_opcode(-2) == kSkipNonIncrementalPartInstruction);
masm->set_opcode(-2, kTwoByteNopInstruction);
}
- // If we are also emitting the remembered set code in this stub then we have
- // the object we are writing into in the 'object' register and the slot in
- // the 'address' register. We insert a primitive test here to ensure that
- // this is the case. Otherwise the 'address' register is merely a scratch
- // register.
- if (FLAG_debug_code && emit_remembered_set_ == EMIT_REMEMBERED_SET) {
+ if (emit_remembered_set_ == EMIT_REMEMBERED_SET) {
+ NearLabel skip;
+ __ InNewSpace(address_, value_, equal, &skip);
+ __ HasScanOnScavenge(object_, value_, &skip);
+ __ RememberedSetHelper(address_, value_, save_fp_regs_mode_);
+ __ bind(&skip);
+ }
+ __ ret(0);
+
+ __ bind(&skip_non_incremental_part);
+
+ GenerateIncremental(masm);
+}
+
+
+void RecordWriteStub::GenerateIncremental(MacroAssembler* masm) {
+ RegisterAllocation regs(masm,
+ object_, // An input reg.
+ address_, // An input reg.
+ value_); // One scratch reg.
+ regs_ = &regs;
+ if (FLAG_debug_code) {
NearLabel ok;
- __ cmp(address_, Operand(object_));
- __ j(above_equal, &ok);
+ __ cmp(value_, Operand(address_, 0));
+ __ j(equal, &ok);
__ int3();
__ bind(&ok);
}
- __ IncrementalMarkingRecordWriteHelper(object_, value_, address_);
+ regs.Save();
- __ bind(&skip_incremental_part);
+ Label increment_marker_slow_case;
+ slow_ = &increment_marker_slow_case;
+ Label value_in_old_space;
+ __ InNewSpace(value_, regs.scratch0(), not_equal, &value_in_old_space);
+ // After this point the value_ register may have been overwritten since it is
+ // also one of the scratch registers.
+
+ GenerateIncrementalValueIsInNewSpace(masm);
+
+ __ bind(&value_in_old_space);
+ GenerateIncrementalValueIsInOldSpace(masm);
+
+ __ bind(slow_);
+ // Inform the incremental marker, but don't bother with the remembered set.
+ regs.SaveCallerSaveRegisters();
+ // TODO(gc) we are assuming that xmm registers are not modified by
+ // the C function we are calling.
+ __ PrepareCallCFunction(2, regs.scratch0());
+ __ mov(Operand(esp, 0 * kPointerSize), regs.object());
+ __ mov(regs.scratch0(), Operand(regs.address(), 0));
+ __ mov(Operand(esp, 1 * kPointerSize), regs.scratch0()); // Value.
+ // TODO(gc): Create a fast version of this C function that does not duplicate
+ // the checks done in the stub.
+ __ CallCFunction(
+ ExternalReference::incremental_marking_record_write_function(), 2);
+ regs.RestoreCallerSaveRegisters();
+ regs.Restore();
+ __ ret(0);
+}
+
+
+void RecordWriteStub::GenerateIncrementalValueIsInNewSpace(
+ MacroAssembler* masm) {
+ Label both_in_new_space;
+ Label value_in_new_space_object_is_black_no_remembered_set;
+
+ // The value is in new space. Check the object.
+ __ InNewSpace(regs_->object(), regs_->scratch0(), equal, &both_in_new_space);
+
+ // Value is in new space, object is in old space. Could we be lucky and find
+ // the scan_on_scavenge flag on the object's page?
if (emit_remembered_set_ == EMIT_REMEMBERED_SET) {
- Register scratch = value_;
- NearLabel done;
- __ InNewSpace(object_, scratch, equal, &done);
- __ RememberedSetHelper(object_, address_, scratch, save_fp_regs_mode_);
- __ bind(&done);
+ Label scan_on_scavenge;
+ __ HasScanOnScavenge(object_, value_, &scan_on_scavenge);
+ GenerateIncrementalValueIsInNewSpaceObjectIsInOldSpaceRememberedSet(masm);
+ __ bind(&scan_on_scavenge);
}
+ // This function will also bind the label.
+ GenerateIncrementalValueIsInNewSpaceObjectIsInOldSpaceNoRememberedSet(
+ masm, &value_in_new_space_object_is_black_no_remembered_set);
+
+ __ bind(&both_in_new_space);
+ __ InNewSpaceIsBlack(regs_->object(),
+ regs_->scratch0(),
+ regs_->scratch1(),
+ &value_in_new_space_object_is_black_no_remembered_set);
+ regs_->Restore();
__ ret(0);
}
+void RecordWriteStub::
+ GenerateIncrementalValueIsInNewSpaceObjectIsInOldSpaceRememberedSet(
+ MacroAssembler* masm) {
+ NearLabel object_is_black, must_inform_both;
+
+ // Lets look at the colour of the object: If it is not black we don't have to
+ // inform the incremental marker.
+ __ InOldSpaceIsBlack(regs_->object(),
+ regs_->scratch0(),
+ regs_->scratch1(),
+ &object_is_black);
+ regs_->Restore();
+ __ RememberedSetHelper(address_, value_, save_fp_regs_mode_);
+ __ ret(0);
+
+ __ bind(&object_is_black);
+
+ __ mov(regs_->scratch0(), Operand(regs_->address(), 0));
+ __ push(regs_->object());
+ __ EnsureNotWhite(regs_->scratch0(), // The value.
+ regs_->scratch1(), // Scratch.
+ regs_->object(), // Scratch.
+ &must_inform_both,
+ true); // In new space.
+ __ pop(regs_->object());
+ regs_->Restore();
+ __ RememberedSetHelper(address_, value_, save_fp_regs_mode_);
+ __ ret(0);
+
+ __ bind(&must_inform_both);
+ // Both the incremental marker and the the remembered set have to be informed.
+ __ pop(regs_->object());
+ regs_->SaveCallerSaveRegisters();
+ // TODO(gc) we are assuming that xmm registers are not modified by
+ // the C function we are calling.
+ __ PrepareCallCFunction(2, regs_->scratch0());
+ __ mov(Operand(esp, 0 * kPointerSize), regs_->object());
+ __ mov(regs_->scratch0(), Operand(regs_->address(), 0));
+ __ mov(Operand(esp, 1 * kPointerSize), regs_->scratch0()); // Value.
+ __ CallCFunction(
+ ExternalReference::incremental_marking_record_write_function(), 2);
+ regs_->RestoreCallerSaveRegisters();
+ regs_->Restore();
+ __ RememberedSetHelper(address_, value_, save_fp_regs_mode_);
+ __ ret(0);
+}
+
+
+void RecordWriteStub::
+ GenerateIncrementalValueIsInNewSpaceObjectIsInOldSpaceNoRememberedSet(
+ MacroAssembler* masm,
+ Label* value_in_new_space_object_is_black_no_remembered_set) {
+ NearLabel object_is_black, inform_incremental_marker;
+
+ __ InOldSpaceIsBlack(regs_->object(),
+ regs_->scratch0(),
+ regs_->scratch1(),
+ &object_is_black);
+ regs_->Restore();
+ __ ret(0);
+
+ __ bind(&object_is_black);
+ __ bind(value_in_new_space_object_is_black_no_remembered_set);
+
+ // Reload the value from the word in the object.
+ __ mov(regs_->scratch0(), Operand(regs_->address(), 0));
+
+ // We need one more scratch register in this case. Use the object register.
+ __ push(regs_->object());
+
+ // Make sure the value is not white. If we can't do that, jump to the label.
+ __ EnsureNotWhite(regs_->scratch0(), // The value.
+ regs_->scratch1(), // Scratch.
+ regs_->object(), // Scratch.
+ &inform_incremental_marker,
+ true); // In new space.
+ __ pop(regs_->object());
+ regs_->Restore();
+ __ ret(0);
+
+ __ bind(&inform_incremental_marker);
+ __ pop(regs_->object());
+
+ __ jmp(slow_);
+}
+
+
+void RecordWriteStub::GenerateIncrementalValueIsInOldSpace(
+ MacroAssembler* masm) {
+ NearLabel value_is_white;
+ Label value_in_old_space_and_white_object_in_new_space;
+ // If the value is in old space then the remembered set doesn't care. We may
+ // be able to avoid logging anything if the incremental marker doesn't care
+ // either.
+ __ mov(regs_->scratch0(), Operand(regs_->address(), 0));
+ __ push(regs_->object());
+ __ EnsureNotWhite(regs_->scratch0(), // The value.
+ regs_->scratch1(), // Scratch.
+ regs_->object(), // Scratch.
+ &value_is_white,
+ false); // In old space.
+ __ pop(regs_->object());
+ regs_->Restore();
+ __ ret(0);
+
+ // The value is in old space and white. We have to find out which space the
+ // object is in in order to find its colour.
+ __ bind(&value_is_white);
+ __ pop(regs_->object());
+ __ InNewSpace(regs_->object(),
+ regs_->scratch0(),
+ equal,
+ &value_in_old_space_and_white_object_in_new_space);
+
+ // Both in old space, value is white and can't be marked.
+ __ InOldSpaceIsBlack(regs_->object(),
+ regs_->scratch0(),
+ regs_->scratch1(),
+ slow_);
+ regs_->Restore();
+ __ ret(0);
+
+ // Object in new space, value in old space and white and can't be marked.
+ __ bind(&value_in_old_space_and_white_object_in_new_space);
+ __ InNewSpaceIsBlack(regs_->object(),
+ regs_->scratch0(),
+ regs_->scratch1(),
+ slow_);
+ regs_->Restore();
+ __ ret(0);
+}
+
+
#undef __
} } // namespace v8::internal

Powered by Google App Engine
This is Rietveld 408576698