Reviewers: Michael Starzinger,
Message:
The marking bits should never be accessed outside the GC unless we now for
sure
that it is valid to do so. Marking right now implements access to the mark
bits
using public accessors. Instead of checking the marking state before
accessing
the marking bits, we could also make the public accessors in Marking
private and
make Marking friends with the classes that need fast marking bits access.
New
public accessors in Marking could check the marking state before accessing
the
marking bits. WDYT? Would you prefer that over the current, explicit
solution?
Description:
Access marking bits from the runtime only when incremental marking is in
MARKING
state.
BUG=
Please review this at https://codereview.chromium.org/203523009/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+21, -11 lines):
M src/objects-inl.h
M src/objects.cc
M src/runtime.cc
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index
8b4baf3de48622429faa435de51166e4cecc95fe..b6bd4e329e4a609822cca4a25f8a30ffdc45a23a
100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -2744,7 +2744,8 @@ void DescriptorArray::SwapSortedKeys(int first, int
second) {
DescriptorArray::WhitenessWitness::WhitenessWitness(FixedArray* array)
: marking_(array->GetHeap()->incremental_marking()) {
marking_->EnterNoMarkingScope();
- ASSERT(Marking::Color(array) == Marking::WHITE_OBJECT);
+ ASSERT(!marking_->IsMarking() ||
+ Marking::Color(array) == Marking::WHITE_OBJECT);
}
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
cb8489f6d29f47dcb9ac75b6d985e9bd6a538da0..3961f31c07d53b382ef00cff787c2673d4f9d46c
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -1301,7 +1301,8 @@ bool
String::MakeExternal(v8::String::ExternalStringResource* resource) {
// Fill the remainder of the string with dead wood.
int new_size = this->Size(); // Byte size of the external String object.
heap->CreateFillerObjectAt(this->address() + new_size, size - new_size);
- if (Marking::IsBlack(Marking::MarkBitFrom(this))) {
+ if (heap->incremental_marking()->IsMarking() &&
+ Marking::IsBlack(Marking::MarkBitFrom(this))) {
MemoryChunk::IncrementLiveBytesFromMutator(this->address(),
new_size - size);
}
@@ -1360,7 +1361,8 @@ bool
String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) {
// Fill the remainder of the string with dead wood.
int new_size = this->Size(); // Byte size of the external String object.
heap->CreateFillerObjectAt(this->address() + new_size, size - new_size);
- if (Marking::IsBlack(Marking::MarkBitFrom(this))) {
+ if (heap->incremental_marking()->IsMarking() &&
+ Marking::IsBlack(Marking::MarkBitFrom(this))) {
MemoryChunk::IncrementLiveBytesFromMutator(this->address(),
new_size - size);
}
@@ -2301,7 +2303,8 @@ static void RightTrimFixedArray(Heap* heap,
FixedArray* elms, int to_trim) {
elms->set_length(len - to_trim);
// Maintain marking consistency for IncrementalMarking.
- if (Marking::IsBlack(Marking::MarkBitFrom(elms))) {
+ if (heap->incremental_marking()->IsMarking() &&
+ Marking::IsBlack(Marking::MarkBitFrom(elms))) {
if (trim_mode == FROM_GC) {
MemoryChunk::IncrementLiveBytesFromGC(elms->address(), -size_delta);
} else {
@@ -4643,9 +4646,11 @@ void JSObject::NormalizeProperties(Handle<JSObject>
object,
int new_instance_size = new_map->instance_size();
int instance_size_delta = map->instance_size() - new_instance_size;
ASSERT(instance_size_delta >= 0);
- isolate->heap()->CreateFillerObjectAt(object->address() +
new_instance_size,
- instance_size_delta);
- if (Marking::IsBlack(Marking::MarkBitFrom(*object))) {
+ Heap* heap = isolate->heap();
+ heap->CreateFillerObjectAt(object->address() + new_instance_size,
+ instance_size_delta);
+ if (heap->incremental_marking()->IsMarking() &&
+ Marking::IsBlack(Marking::MarkBitFrom(*object))) {
MemoryChunk::IncrementLiveBytesFromMutator(object->address(),
-instance_size_delta);
}
@@ -9217,7 +9222,8 @@ Handle<String> SeqString::Truncate(Handle<SeqString>
string, int new_length) {
// that are a multiple of pointer size.
heap->CreateFillerObjectAt(start_of_string + new_size, delta);
}
- if (Marking::IsBlack(Marking::MarkBitFrom(start_of_string))) {
+ if (heap->incremental_marking()->IsMarking() &&
+ Marking::IsBlack(Marking::MarkBitFrom(start_of_string))) {
MemoryChunk::IncrementLiveBytesFromMutator(start_of_string, -delta);
}
@@ -10371,7 +10377,8 @@ void Code::Relocate(intptr_t delta) {
void Code::CopyFrom(const CodeDesc& desc) {
- ASSERT(Marking::Color(this) == Marking::WHITE_OBJECT);
+ ASSERT(!GetHeap()->incremental_marking()->IsMarking() ||
+ Marking::Color(this) == Marking::WHITE_OBJECT);
// copy code
CopyBytes(instruction_start(), desc.buffer,
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
916c99371938da6f63eea6eea42525cc1afd0c00..e2c61556dabf10123291b8a436c4a76e7b16aa23
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -4125,8 +4125,10 @@ MUST_USE_RESULT static MaybeObject*
StringReplaceGlobalRegExpWithEmptyString(
if (delta == 0) return *answer;
Address end_of_string = answer->address() + string_size;
- isolate->heap()->CreateFillerObjectAt(end_of_string, delta);
- if (Marking::IsBlack(Marking::MarkBitFrom(*answer))) {
+ Heap* heap = isolate->heap();
+ heap->CreateFillerObjectAt(end_of_string, delta);
+ if (heap->incremental_marking()->IsMarking() &&
+ Marking::IsBlack(Marking::MarkBitFrom(*answer))) {
MemoryChunk::IncrementLiveBytesFromMutator(answer->address(), -delta);
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.