Revert r11556 and r11558 to allow roll.

R=yangguo@chromium.org

Review URL: https://chromiumcodereview.appspot.com/10383182

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11564 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 1016c4a2
// Copyright 2012 the V8 project authors. All rights reserved. // Copyright 2011 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
...@@ -118,29 +118,13 @@ void IncrementalMarking::BlackToGreyAndUnshift(HeapObject* obj, ...@@ -118,29 +118,13 @@ void IncrementalMarking::BlackToGreyAndUnshift(HeapObject* obj,
void IncrementalMarking::WhiteToGreyAndPush(HeapObject* obj, MarkBit mark_bit) { void IncrementalMarking::WhiteToGreyAndPush(HeapObject* obj, MarkBit mark_bit) {
Marking::WhiteToGrey(mark_bit); WhiteToGrey(obj, mark_bit);
marking_deque_.PushGrey(obj); marking_deque_.PushGrey(obj);
} }
bool IncrementalMarking::MarkObjectAndPush(HeapObject* obj) { void IncrementalMarking::WhiteToGrey(HeapObject* obj, MarkBit mark_bit) {
MarkBit mark_bit = Marking::MarkBitFrom(obj); Marking::WhiteToGrey(mark_bit);
if (!mark_bit.Get()) {
WhiteToGreyAndPush(obj, mark_bit);
return true;
}
return false;
}
bool IncrementalMarking::MarkObjectWithoutPush(HeapObject* obj) {
MarkBit mark_bit = Marking::MarkBitFrom(obj);
if (!mark_bit.Get()) {
mark_bit.Set();
MemoryChunk::IncrementLiveBytesFromGC(obj->address(), obj->Size());
return true;
}
return false;
} }
......
// Copyright 2012 the V8 project authors. All rights reserved. // Copyright 2011 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
...@@ -42,7 +42,6 @@ IncrementalMarking::IncrementalMarking(Heap* heap) ...@@ -42,7 +42,6 @@ IncrementalMarking::IncrementalMarking(Heap* heap)
state_(STOPPED), state_(STOPPED),
marking_deque_memory_(NULL), marking_deque_memory_(NULL),
marking_deque_memory_committed_(false), marking_deque_memory_committed_(false),
marker_(this, heap->mark_compact_collector()),
steps_count_(0), steps_count_(0),
steps_took_(0), steps_took_(0),
longest_step_(0.0), longest_step_(0.0),
...@@ -664,22 +663,6 @@ void IncrementalMarking::Hurry() { ...@@ -664,22 +663,6 @@ void IncrementalMarking::Hurry() {
} else if (map == global_context_map) { } else if (map == global_context_map) {
// Global contexts have weak fields. // Global contexts have weak fields.
VisitGlobalContext(Context::cast(obj), &marking_visitor); VisitGlobalContext(Context::cast(obj), &marking_visitor);
} else if (map->instance_type() == MAP_TYPE) {
Map* map = Map::cast(obj);
heap_->ClearCacheOnMap(map);
// When map collection is enabled we have to mark through map's
// transitions and back pointers in a special way to make these links
// weak. Only maps for subclasses of JSReceiver can have transitions.
STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE);
if (FLAG_collect_maps &&
map->instance_type() >= FIRST_JS_RECEIVER_TYPE) {
marker_.MarkMapContents(map);
} else {
marking_visitor.VisitPointers(
HeapObject::RawField(map, Map::kPointerFieldsBeginOffset),
HeapObject::RawField(map, Map::kPointerFieldsEndOffset));
}
} else { } else {
obj->Iterate(&marking_visitor); obj->Iterate(&marking_visitor);
} }
...@@ -824,6 +807,12 @@ void IncrementalMarking::Step(intptr_t allocated_bytes, ...@@ -824,6 +807,12 @@ void IncrementalMarking::Step(intptr_t allocated_bytes,
Map* map = obj->map(); Map* map = obj->map();
if (map == filler_map) continue; if (map == filler_map) continue;
if (obj->IsMap()) {
Map* map = Map::cast(obj);
heap_->ClearCacheOnMap(map);
}
int size = obj->SizeFromMap(map); int size = obj->SizeFromMap(map);
bytes_to_process -= size; bytes_to_process -= size;
MarkBit map_mark_bit = Marking::MarkBitFrom(map); MarkBit map_mark_bit = Marking::MarkBitFrom(map);
...@@ -841,22 +830,6 @@ void IncrementalMarking::Step(intptr_t allocated_bytes, ...@@ -841,22 +830,6 @@ void IncrementalMarking::Step(intptr_t allocated_bytes,
MarkObjectGreyDoNotEnqueue(ctx->normalized_map_cache()); MarkObjectGreyDoNotEnqueue(ctx->normalized_map_cache());
VisitGlobalContext(ctx, &marking_visitor); VisitGlobalContext(ctx, &marking_visitor);
} else if (map->instance_type() == MAP_TYPE) {
Map* map = Map::cast(obj);
heap_->ClearCacheOnMap(map);
// When map collection is enabled we have to mark through map's
// transitions and back pointers in a special way to make these links
// weak. Only maps for subclasses of JSReceiver can have transitions.
STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE);
if (FLAG_collect_maps &&
map->instance_type() >= FIRST_JS_RECEIVER_TYPE) {
marker_.MarkMapContents(map);
} else {
marking_visitor.VisitPointers(
HeapObject::RawField(map, Map::kPointerFieldsBeginOffset),
HeapObject::RawField(map, Map::kPointerFieldsEndOffset));
}
} else if (map->instance_type() == JS_FUNCTION_TYPE) { } else if (map->instance_type() == JS_FUNCTION_TYPE) {
marking_visitor.VisitPointers( marking_visitor.VisitPointers(
HeapObject::RawField(obj, JSFunction::kPropertiesOffset), HeapObject::RawField(obj, JSFunction::kPropertiesOffset),
......
// Copyright 2012 the V8 project authors. All rights reserved. // Copyright 2011 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
...@@ -154,6 +154,8 @@ class IncrementalMarking { ...@@ -154,6 +154,8 @@ class IncrementalMarking {
inline void WhiteToGreyAndPush(HeapObject* obj, MarkBit mark_bit); inline void WhiteToGreyAndPush(HeapObject* obj, MarkBit mark_bit);
inline void WhiteToGrey(HeapObject* obj, MarkBit mark_bit);
// Does white->black or keeps gray or black color. Returns true if converting // Does white->black or keeps gray or black color. Returns true if converting
// white to black. // white to black.
inline bool MarkBlackOrKeepGrey(MarkBit mark_bit) { inline bool MarkBlackOrKeepGrey(MarkBit mark_bit) {
...@@ -167,16 +169,6 @@ class IncrementalMarking { ...@@ -167,16 +169,6 @@ class IncrementalMarking {
return true; return true;
} }
// Marks the object grey and pushes it on the marking stack.
// Returns true if object needed marking and false otherwise.
// This is for incremental marking only.
INLINE(bool MarkObjectAndPush(HeapObject* obj));
// Marks the object black without pushing it on the marking stack.
// Returns true if object needed marking and false otherwise.
// This is for incremental marking only.
INLINE(bool MarkObjectWithoutPush(HeapObject* obj));
inline int steps_count() { inline int steps_count() {
return steps_count_; return steps_count_;
} }
...@@ -268,7 +260,6 @@ class IncrementalMarking { ...@@ -268,7 +260,6 @@ class IncrementalMarking {
VirtualMemory* marking_deque_memory_; VirtualMemory* marking_deque_memory_;
bool marking_deque_memory_committed_; bool marking_deque_memory_committed_;
MarkingDeque marking_deque_; MarkingDeque marking_deque_;
Marker<IncrementalMarking> marker_;
int steps_count_; int steps_count_;
double steps_took_; double steps_took_;
......
// Copyright 2012 the V8 project authors. All rights reserved. // Copyright 2011 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
...@@ -52,15 +52,6 @@ void MarkCompactCollector::SetFlags(int flags) { ...@@ -52,15 +52,6 @@ void MarkCompactCollector::SetFlags(int flags) {
} }
bool MarkCompactCollector::MarkObjectAndPush(HeapObject* obj) {
if (MarkObjectWithoutPush(obj)) {
marking_deque_.PushBlack(obj);
return true;
}
return false;
}
void MarkCompactCollector::MarkObject(HeapObject* obj, MarkBit mark_bit) { void MarkCompactCollector::MarkObject(HeapObject* obj, MarkBit mark_bit) {
ASSERT(Marking::MarkBitFrom(obj) == mark_bit); ASSERT(Marking::MarkBitFrom(obj) == mark_bit);
if (!mark_bit.Get()) { if (!mark_bit.Get()) {
...@@ -71,13 +62,16 @@ void MarkCompactCollector::MarkObject(HeapObject* obj, MarkBit mark_bit) { ...@@ -71,13 +62,16 @@ void MarkCompactCollector::MarkObject(HeapObject* obj, MarkBit mark_bit) {
} }
bool MarkCompactCollector::MarkObjectWithoutPush(HeapObject* obj) { bool MarkCompactCollector::MarkObjectWithoutPush(HeapObject* object) {
MarkBit mark_bit = Marking::MarkBitFrom(obj); MarkBit mark = Marking::MarkBitFrom(object);
if (!mark_bit.Get()) { bool old_mark = mark.Get();
SetMark(obj, mark_bit); if (!old_mark) SetMark(object, mark);
return true; return old_mark;
} }
return false;
void MarkCompactCollector::MarkObjectAndPush(HeapObject* object) {
if (!MarkObjectWithoutPush(object)) marking_deque_.PushBlack(object);
} }
......
This diff is collapsed.
...@@ -42,7 +42,6 @@ typedef bool (*IsAliveFunction)(HeapObject* obj, int* size, int* offset); ...@@ -42,7 +42,6 @@ typedef bool (*IsAliveFunction)(HeapObject* obj, int* size, int* offset);
// Forward declarations. // Forward declarations.
class CodeFlusher; class CodeFlusher;
class GCTracer; class GCTracer;
class MarkCompactCollector;
class MarkingVisitor; class MarkingVisitor;
class RootMarkingVisitor; class RootMarkingVisitor;
...@@ -167,6 +166,7 @@ class Marking { ...@@ -167,6 +166,7 @@ class Marking {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Marking deque for tracing live objects. // Marking deque for tracing live objects.
class MarkingDeque { class MarkingDeque {
public: public:
MarkingDeque() MarkingDeque()
...@@ -383,34 +383,6 @@ class SlotsBuffer { ...@@ -383,34 +383,6 @@ class SlotsBuffer {
}; };
// -------------------------------------------------------------------------
// Marker shared between incremental and non-incremental marking
template<class BaseMarker> class Marker {
public:
Marker(BaseMarker* base_marker, MarkCompactCollector* mark_compact_collector)
: base_marker_(base_marker),
mark_compact_collector_(mark_compact_collector) {}
// Mark pointers in a Map and its DescriptorArray together, possibly
// treating transitions or back pointers weak.
void MarkMapContents(Map* map);
void MarkDescriptorArray(DescriptorArray* descriptors);
void MarkAccessorPairSlot(AccessorPair* accessors, int offset);
private:
BaseMarker* base_marker() {
return base_marker_;
}
MarkCompactCollector* mark_compact_collector() {
return mark_compact_collector_;
}
BaseMarker* base_marker_;
MarkCompactCollector* mark_compact_collector_;
};
// Defined in isolate.h. // Defined in isolate.h.
class ThreadLocalTop; class ThreadLocalTop;
...@@ -612,6 +584,8 @@ class MarkCompactCollector { ...@@ -612,6 +584,8 @@ class MarkCompactCollector {
bool was_marked_incrementally_; bool was_marked_incrementally_;
bool collect_maps_;
bool flush_monomorphic_ics_; bool flush_monomorphic_ics_;
// A pointer to the current stack-allocated GC tracer object during a full // A pointer to the current stack-allocated GC tracer object during a full
...@@ -634,13 +608,12 @@ class MarkCompactCollector { ...@@ -634,13 +608,12 @@ class MarkCompactCollector {
// //
// After: Live objects are marked and non-live objects are unmarked. // After: Live objects are marked and non-live objects are unmarked.
friend class RootMarkingVisitor; friend class RootMarkingVisitor;
friend class MarkingVisitor; friend class MarkingVisitor;
friend class StaticMarkingVisitor; friend class StaticMarkingVisitor;
friend class CodeMarkingVisitor; friend class CodeMarkingVisitor;
friend class SharedFunctionInfoMarkingVisitor; friend class SharedFunctionInfoMarkingVisitor;
friend class Marker<IncrementalMarking>;
friend class Marker<MarkCompactCollector>;
// Mark non-optimize code for functions inlined into the given optimized // Mark non-optimize code for functions inlined into the given optimized
// code. This will prevent it from being flushed. // code. This will prevent it from being flushed.
...@@ -658,25 +631,22 @@ class MarkCompactCollector { ...@@ -658,25 +631,22 @@ class MarkCompactCollector {
void AfterMarking(); void AfterMarking();
// Marks the object black and pushes it on the marking stack. // Marks the object black and pushes it on the marking stack.
// Returns true if object needed marking and false otherwise. // This is for non-incremental marking.
// This is for non-incremental marking only.
INLINE(bool MarkObjectAndPush(HeapObject* obj));
// Marks the object black and pushes it on the marking stack.
// This is for non-incremental marking only.
INLINE(void MarkObject(HeapObject* obj, MarkBit mark_bit)); INLINE(void MarkObject(HeapObject* obj, MarkBit mark_bit));
// Marks the object black without pushing it on the marking stack. INLINE(bool MarkObjectWithoutPush(HeapObject* object));
// Returns true if object needed marking and false otherwise. INLINE(void MarkObjectAndPush(HeapObject* value));
// This is for non-incremental marking only.
INLINE(bool MarkObjectWithoutPush(HeapObject* obj));
// Marks the object black assuming that it is not yet marked. // Marks the object black. This is for non-incremental marking.
// This is for non-incremental marking only.
INLINE(void SetMark(HeapObject* obj, MarkBit mark_bit)); INLINE(void SetMark(HeapObject* obj, MarkBit mark_bit));
void ProcessNewlyMarkedObject(HeapObject* obj); void ProcessNewlyMarkedObject(HeapObject* obj);
// Mark a Map and its DescriptorArray together, skipping transitions.
void MarkMapContents(Map* map);
void MarkAccessorPairSlot(HeapObject* accessors, int offset);
void MarkDescriptorArray(DescriptorArray* descriptors);
// Mark the heap roots and all objects reachable from them. // Mark the heap roots and all objects reachable from them.
void MarkRoots(RootMarkingVisitor* visitor); void MarkRoots(RootMarkingVisitor* visitor);
...@@ -779,7 +749,6 @@ class MarkCompactCollector { ...@@ -779,7 +749,6 @@ class MarkCompactCollector {
MarkingDeque marking_deque_; MarkingDeque marking_deque_;
CodeFlusher* code_flusher_; CodeFlusher* code_flusher_;
Object* encountered_weak_maps_; Object* encountered_weak_maps_;
Marker<MarkCompactCollector> marker_;
List<Page*> evacuation_candidates_; List<Page*> evacuation_candidates_;
List<Code*> invalidated_code_; List<Code*> invalidated_code_;
......
...@@ -1735,60 +1735,3 @@ TEST(OptimizedAllocationAlwaysInNewSpace) { ...@@ -1735,60 +1735,3 @@ TEST(OptimizedAllocationAlwaysInNewSpace) {
CHECK(HEAP->InNewSpace(*o)); CHECK(HEAP->InNewSpace(*o));
} }
static int CountMapTransitions(Map* map) {
int result = 0;
DescriptorArray* descs = map->instance_descriptors();
for (int i = 0; i < descs->number_of_descriptors(); i++) {
if (descs->IsTransitionOnly(i)) {
result++;
}
}
return result;
}
// Test that map transitions are cleared and maps are collected with
// incremental marking as well.
TEST(Regress1465) {
i::FLAG_allow_natives_syntax = true;
i::FLAG_trace_incremental_marking = true;
InitializeVM();
v8::HandleScope scope;
#define TRANSITION_COUNT 256
for (int i = 0; i < TRANSITION_COUNT; i++) {
EmbeddedVector<char, 64> buffer;
OS::SNPrintF(buffer, "var o = new Object; o.prop%d = %d;", i, i);
CompileRun(buffer.start());
}
CompileRun("var root = new Object;");
Handle<JSObject> root =
v8::Utils::OpenHandle(
*v8::Handle<v8::Object>::Cast(
v8::Context::GetCurrent()->Global()->Get(v8_str("root"))));
// Count number of live transitions before marking.
int transitions_before = CountMapTransitions(root->map());
CompileRun("%DebugPrint(root);");
CHECK_EQ(TRANSITION_COUNT, transitions_before);
// Go through all incremental marking steps in one swoop.
IncrementalMarking* marking = HEAP->incremental_marking();
CHECK(marking->IsStopped());
marking->Start();
CHECK(marking->IsMarking());
while (!marking->IsComplete()) {
marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
}
CHECK(marking->IsComplete());
HEAP->CollectAllGarbage(Heap::kNoGCFlags);
CHECK(marking->IsStopped());
// Count number of live transitions after marking. Note that one transition
// is left, because 'o' still holds an instance of one transition target.
int transitions_after = CountMapTransitions(root->map());
CompileRun("%DebugPrint(root);");
CHECK_EQ(1, transitions_after);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment