Revision: 8618
Author: [email protected]
Date: Tue Jul 12 04:15:04 2011
Log: Patch RecordWriteStub after adding it to the stub cache not
during generation.
This guarantees that stub's mode will match the state of incremental marker.
[email protected]
BUG=v8:1545
Review URL: http://codereview.chromium.org/7329049
http://code.google.com/p/v8/source/detail?r=8618
Modified:
/branches/experimental/gc/src/arm/code-stubs-arm.h
/branches/experimental/gc/src/code-stubs.cc
/branches/experimental/gc/src/code-stubs.h
/branches/experimental/gc/src/ia32/code-stubs-ia32.cc
/branches/experimental/gc/src/ia32/code-stubs-ia32.h
/branches/experimental/gc/src/incremental-marking.cc
/branches/experimental/gc/src/incremental-marking.h
/branches/experimental/gc/src/x64/code-stubs-x64.cc
/branches/experimental/gc/src/x64/code-stubs-x64.h
=======================================
--- /branches/experimental/gc/src/arm/code-stubs-arm.h Fri Jul 8 02:16:20
2011
+++ /branches/experimental/gc/src/arm/code-stubs-arm.h Tue Jul 12 04:15:04
2011
@@ -466,6 +466,10 @@
INCREMENTAL_COMPACTION
};
+ static Mode GetMode(Code* stub) {
+ return STORE_BUFFER_ONLY;
+ }
+
static void Patch(Code* stub, Mode mode) {
ASSERT(mode == STORE_BUFFER_ONLY);
}
@@ -560,6 +564,17 @@
RememberedSetActionBits::encode(remembered_set_action_) |
SaveFPRegsModeBits::encode(save_fp_regs_mode_);
}
+
+ bool MustBeInStubCache() {
+ // All stubs must be registered in the stub cache
+ // otherwise IncrementalMarker would not be able to find
+ // and patch it.
+ return true;
+ }
+
+ void Activate(Code* code) {
+ code->GetHeap()->incremental_marking()->ActivateGeneratedStub(code);
+ }
class ObjectBits: public BitField<int, 0, 4> {};
class ValueBits: public BitField<int, 4, 4> {};
=======================================
--- /branches/experimental/gc/src/code-stubs.cc Tue May 24 05:03:26 2011
+++ /branches/experimental/gc/src/code-stubs.cc Tue Jul 12 04:15:04 2011
@@ -120,8 +120,8 @@
GetKey(),
new_object);
heap->public_set_code_stubs(*dict);
-
code = *new_object;
+ Activate(code);
}
ASSERT(!NeedsImmovableCode() || heap->lo_space()->Contains(code));
@@ -160,7 +160,11 @@
heap->code_stubs()->AtNumberPut(GetKey(), code);
if (maybe_new_object->ToObject(&new_object)) {
heap->public_set_code_stubs(NumberDictionary::cast(new_object));
- }
+ } else if (MustBeInStubCache()) {
+ return maybe_new_object;
+ }
+
+ Activate(code);
}
return code;
=======================================
--- /branches/experimental/gc/src/code-stubs.h Wed May 25 07:05:16 2011
+++ /branches/experimental/gc/src/code-stubs.h Tue Jul 12 04:15:04 2011
@@ -167,6 +167,14 @@
// Finish the code object after it has been generated.
virtual void FinishCode(Code* code) { }
+
+ // Returns true if TryGetCode should fail if it failed
+ // to register newly generated stub in the stub cache.
+ virtual bool MustBeInStubCache() { return false; }
+
+ // Activate newly generated stub. Is called after
+ // registering stub in the stub cache.
+ virtual void Activate(Code* code) { }
// Returns information for computing the number key.
virtual Major MajorKey() = 0;
=======================================
--- /branches/experimental/gc/src/ia32/code-stubs-ia32.cc Fri Jul 8
08:50:03 2011
+++ /branches/experimental/gc/src/ia32/code-stubs-ia32.cc Tue Jul 12
04:15:04 2011
@@ -6258,18 +6258,10 @@
__ bind(&skip_to_incremental_compacting);
GenerateIncremental(masm, INCREMENTAL_COMPACTION);
- // TODO(1545) ensure that GC can't happen after stub was generated by
before
- // it was added to a stub cache.
- IncrementalMarking* marking =
masm->isolate()->heap()->incremental_marking();
- if (!marking->IsMarking() || marking->IsCompacting()) {
- ASSERT(masm->byte_at(0) == kTwoByteJumpInstruction);
- masm->set_byte_at(0, kTwoByteNopInstruction);
- }
-
- if (!marking->IsMarking()) {
- ASSERT(masm->byte_at(2) == kFiveByteJumpInstruction);
- masm->set_byte_at(2, kFiveByteNopInstruction);
- }
+ // Initial mode of the stub is expected to be STORE_BUFFER_ONLY.
+ // Will be checked in IncrementalMarking::ActivateGeneratedStub.
+ masm->set_byte_at(0, kTwoByteNopInstruction);
+ masm->set_byte_at(2, kFiveByteNopInstruction);
}
=======================================
--- /branches/experimental/gc/src/ia32/code-stubs-ia32.h Fri Jul 8
08:50:03 2011
+++ /branches/experimental/gc/src/ia32/code-stubs-ia32.h Tue Jul 12
04:15:04 2011
@@ -762,6 +762,17 @@
RememberedSetActionBits::encode(remembered_set_action_) |
SaveFPRegsModeBits::encode(save_fp_regs_mode_);
}
+
+ bool MustBeInStubCache() {
+ // All stubs must be registered in the stub cache
+ // otherwise IncrementalMarker would not be able to find
+ // and patch it.
+ return true;
+ }
+
+ void Activate(Code* code) {
+ code->GetHeap()->incremental_marking()->ActivateGeneratedStub(code);
+ }
class ObjectBits: public BitField<int, 0, 3> {};
class ValueBits: public BitField<int, 3, 3> {};
=======================================
--- /branches/experimental/gc/src/incremental-marking.cc Tue Jul 12
02:27:33 2011
+++ /branches/experimental/gc/src/incremental-marking.cc Tue Jul 12
04:15:04 2011
@@ -303,6 +303,22 @@
return FLAG_incremental_marking &&
heap_->PromotedSpaceSize() > kActivationThreshold;
}
+
+
+void IncrementalMarking::ActivateGeneratedStub(Code* stub) {
+ ASSERT(RecordWriteStub::GetMode(stub) ==
+ RecordWriteStub::STORE_BUFFER_ONLY);
+
+ if (!IsMarking()) {
+ // Initially stub is generated in STORE_BUFFER_ONLY mode thus
+ // we don't need to do anything if incremental marking is
+ // not active.
+ } else if (IsCompacting()) {
+ RecordWriteStub::Patch(stub, RecordWriteStub::INCREMENTAL_COMPACTION);
+ } else {
+ RecordWriteStub::Patch(stub, RecordWriteStub::INCREMENTAL);
+ }
+}
static void PatchIncrementalMarkingRecordWriteStubs(
=======================================
--- /branches/experimental/gc/src/incremental-marking.h Fri Jul 8 02:16:20
2011
+++ /branches/experimental/gc/src/incremental-marking.h Tue Jul 12 04:15:04
2011
@@ -161,6 +161,8 @@
MarkingDeque* marking_deque() { return &marking_deque_; }
bool IsCompacting() { return IsMarking() && is_compacting_; }
+
+ void ActivateGeneratedStub(Code* stub);
private:
void set_should_hurry(bool val) {
=======================================
--- /branches/experimental/gc/src/x64/code-stubs-x64.cc Fri Jul 8 02:16:20
2011
+++ /branches/experimental/gc/src/x64/code-stubs-x64.cc Tue Jul 12 04:15:04
2011
@@ -5182,18 +5182,10 @@
__ bind(&skip_to_incremental_compacting);
GenerateIncremental(masm, INCREMENTAL_COMPACTION);
- // TODO(1545) ensure that GC can't happen after stub was generated by
before
- // it was added to a stub cache.
- IncrementalMarking* marking =
masm->isolate()->heap()->incremental_marking();
- if (!marking->IsMarking() || marking->IsCompacting()) {
- ASSERT(masm->byte_at(0) == kTwoByteJumpInstruction);
- masm->set_byte_at(0, kTwoByteNopInstruction);
- }
-
- if (!marking->IsMarking()) {
- ASSERT(masm->byte_at(2) == kFiveByteJumpInstruction);
- masm->set_byte_at(2, kFiveByteNopInstruction);
- }
+ // Initial mode of the stub is expected to be STORE_BUFFER_ONLY.
+ // Will be checked in IncrementalMarking::ActivateGeneratedStub.
+ masm->set_byte_at(0, kTwoByteNopInstruction);
+ masm->set_byte_at(2, kFiveByteNopInstruction);
}
=======================================
--- /branches/experimental/gc/src/x64/code-stubs-x64.h Fri Jul 8 08:50:03
2011
+++ /branches/experimental/gc/src/x64/code-stubs-x64.h Tue Jul 12 04:15:04
2011
@@ -746,6 +746,17 @@
RememberedSetActionBits::encode(remembered_set_action_) |
SaveFPRegsModeBits::encode(save_fp_regs_mode_);
}
+
+ bool MustBeInStubCache() {
+ // All stubs must be registered in the stub cache
+ // otherwise IncrementalMarker would not be able to find
+ // and patch it.
+ return true;
+ }
+
+ void Activate(Code* code) {
+ code->GetHeap()->incremental_marking()->ActivateGeneratedStub(code);
+ }
class ObjectBits: public BitField<int, 0, 4> {};
class ValueBits: public BitField<int, 4, 4> {};
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev