Revision: 10243
Author: [email protected]
Date: Tue Dec 13 06:20:03 2011
Log: Guard against undefined fields in global context.
BUG=v8:1860
TEST=
[email protected]
Review URL: http://codereview.chromium.org/8917014
http://code.google.com/p/v8/source/detail?r=10243
Modified:
/branches/bleeding_edge/src/assembler.cc
/branches/bleeding_edge/src/assembler.h
/branches/bleeding_edge/src/deoptimizer.cc
/branches/bleeding_edge/src/heap.cc
/branches/bleeding_edge/src/incremental-marking.cc
=======================================
--- /branches/bleeding_edge/src/assembler.cc Wed Dec 7 08:15:18 2011
+++ /branches/bleeding_edge/src/assembler.cc Tue Dec 13 06:20:03 2011
@@ -815,11 +815,6 @@
return ExternalReference(
Redirect(isolate, FUNCTION_ADDR(Deoptimizer::ComputeOutputFrames)));
}
-
-
-ExternalReference ExternalReference::global_contexts_list(Isolate*
isolate) {
- return
ExternalReference(isolate->heap()->global_contexts_list_address());
-}
ExternalReference ExternalReference::keyed_lookup_cache_keys(Isolate*
isolate) {
=======================================
--- /branches/bleeding_edge/src/assembler.h Tue Nov 29 02:56:11 2011
+++ /branches/bleeding_edge/src/assembler.h Tue Dec 13 06:20:03 2011
@@ -590,7 +590,6 @@
// Deoptimization support.
static ExternalReference new_deoptimizer_function(Isolate* isolate);
static ExternalReference compute_output_frames_function(Isolate*
isolate);
- static ExternalReference global_contexts_list(Isolate* isolate);
// Static data in the keyed lookup cache.
static ExternalReference keyed_lookup_cache_keys(Isolate* isolate);
=======================================
--- /branches/bleeding_edge/src/deoptimizer.cc Wed Nov 16 00:44:30 2011
+++ /branches/bleeding_edge/src/deoptimizer.cc Tue Dec 13 06:20:03 2011
@@ -264,11 +264,16 @@
AssertNoAllocation no_allocation;
// Run through the list of all global contexts and deoptimize.
- Object* global = Isolate::Current()->heap()->global_contexts_list();
- while (!global->IsUndefined()) {
-
VisitAllOptimizedFunctionsForGlobalObject(Context::cast(global)->global(),
- visitor);
- global = Context::cast(global)->get(Context::NEXT_CONTEXT_LINK);
+ Object* context = Isolate::Current()->heap()->global_contexts_list();
+ while (!context->IsUndefined()) {
+ // GC can happen when the context is not fully initialized,
+ // so the global field of the context can be undefined.
+ Object* global = Context::cast(context)->get(Context::GLOBAL_INDEX);
+ if (!global->IsUndefined()) {
+ VisitAllOptimizedFunctionsForGlobalObject(JSObject::cast(global),
+ visitor);
+ }
+ context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK);
}
}
=======================================
--- /branches/bleeding_edge/src/heap.cc Fri Dec 9 01:26:14 2011
+++ /branches/bleeding_edge/src/heap.cc Tue Dec 13 06:20:03 2011
@@ -642,13 +642,17 @@
Object* context = global_contexts_list_;
while (!context->IsUndefined()) {
- // Get the caches for this context:
- FixedArray* caches =
- Context::cast(context)->jsfunction_result_caches();
- // Clear the caches:
- int length = caches->length();
- for (int i = 0; i < length; i++) {
- JSFunctionResultCache::cast(caches->get(i))->Clear();
+ // Get the caches for this context. GC can happen when the context
+ // is not fully initialized, so the caches can be undefined.
+ Object* caches_or_undefined =
+
Context::cast(context)->get(Context::JSFUNCTION_RESULT_CACHES_INDEX);
+ if (!caches_or_undefined->IsUndefined()) {
+ FixedArray* caches = FixedArray::cast(caches_or_undefined);
+ // Clear the caches:
+ int length = caches->length();
+ for (int i = 0; i < length; i++) {
+ JSFunctionResultCache::cast(caches->get(i))->Clear();
+ }
}
// Get the next context:
context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK);
@@ -665,7 +669,13 @@
Object* context = global_contexts_list_;
while (!context->IsUndefined()) {
- Context::cast(context)->normalized_map_cache()->Clear();
+ // GC can happen when the context is not fully initialized,
+ // so the cache can be undefined.
+ Object* cache =
+ Context::cast(context)->get(Context::NORMALIZED_MAP_CACHE_INDEX);
+ if (!cache->IsUndefined()) {
+ NormalizedMapCache::cast(cache)->Clear();
+ }
context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK);
}
}
=======================================
--- /branches/bleeding_edge/src/incremental-marking.cc Wed Nov 30 09:53:26
2011
+++ /branches/bleeding_edge/src/incremental-marking.cc Tue Dec 13 06:20:03
2011
@@ -677,11 +677,16 @@
Object* context = heap_->global_contexts_list();
while (!context->IsUndefined()) {
- NormalizedMapCache* cache =
Context::cast(context)->normalized_map_cache();
- MarkBit mark_bit = Marking::MarkBitFrom(cache);
- if (Marking::IsGrey(mark_bit)) {
- Marking::GreyToBlack(mark_bit);
- MemoryChunk::IncrementLiveBytes(cache->address(), cache->Size());
+ // GC can happen when the context is not fully initialized,
+ // so the cache can be undefined.
+ HeapObject* cache = HeapObject::cast(
+ Context::cast(context)->get(Context::NORMALIZED_MAP_CACHE_INDEX));
+ if (!cache->IsUndefined()) {
+ MarkBit mark_bit = Marking::MarkBitFrom(cache);
+ if (Marking::IsGrey(mark_bit)) {
+ Marking::GreyToBlack(mark_bit);
+ MemoryChunk::IncrementLiveBytes(cache->address(), cache->Size());
+ }
}
context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK);
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev