Commit ec534af3 authored by sandholm@chromium.org's avatar sandholm@chromium.org

Ensure strings are never externalized as a side-effect of doing a GC.

Review URL: http://codereview.chromium.org/7105016

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8142 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6d7d3b8d
......@@ -4264,6 +4264,9 @@ bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) {
if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
return false;
}
if (isolate->heap()->IsInGCPostProcessing()) {
return false;
}
bool result = obj->MakeExternal(resource);
if (result && !obj->IsSymbol()) {
isolate->heap()->external_string_table()->AddString(*obj);
......@@ -4296,6 +4299,9 @@ bool v8::String::MakeExternal(
if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
return false;
}
if (isolate->heap()->IsInGCPostProcessing()) {
return false;
}
bool result = obj->MakeExternal(resource);
if (result && !obj->IsSymbol()) {
isolate->heap()->external_string_table()->AddString(*obj);
......
......@@ -107,6 +107,7 @@ Heap::Heap()
cell_space_(NULL),
lo_space_(NULL),
gc_state_(NOT_IN_GC),
gc_post_processing_depth_(0),
mc_count_(0),
ms_count_(0),
gc_count_(0),
......@@ -794,11 +795,13 @@ bool Heap::PerformGarbageCollection(GarbageCollector collector,
isolate_->counters()->objs_since_last_young()->Set(0);
gc_post_processing_depth_++;
{ DisableAssertNoAllocation allow_allocation;
GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL);
next_gc_likely_to_collect_more =
isolate_->global_handles()->PostGarbageCollectionProcessing(collector);
}
gc_post_processing_depth_--;
// Update relocatables.
Relocatable::PostGarbageCollectionProcessing();
......
......@@ -1054,6 +1054,8 @@ class Heap {
enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT };
inline HeapState gc_state() { return gc_state_; }
inline bool IsInGCPostProcessing() { return gc_post_processing_depth_ > 0; }
#ifdef DEBUG
bool IsAllocationAllowed() { return allocation_allowed_; }
inline bool allow_allocation(bool enable);
......@@ -1277,6 +1279,7 @@ class Heap {
CellSpace* cell_space_;
LargeObjectSpace* lo_space_;
HeapState gc_state_;
int gc_post_processing_depth_;
// Returns the size of object residing in non new spaces.
intptr_t PromotedSpaceSize();
......
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