Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(880)

Unified Diff: src/heap.cc

Issue 8917014: Guard against undefined fields in global context. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix more global context accesses. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index bc7550ed9a63e3a8ff55a6ed815ea4b93d8b9f79..2a3439f306466c6850a98f49cb64b8ff3c1224f9 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -648,7 +648,10 @@ void Heap::ClearJSFunctionResultCaches() {
// Clear the caches:
int length = caches->length();
for (int i = 0; i < length; i++) {
- JSFunctionResultCache::cast(caches->get(i))->Clear();
+ Object* cache = caches->get(i);
+ if (!cache->IsUndefined()) {
+ JSFunctionResultCache::cast(cache)->Clear();
+ }
}
// Get the next context:
context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK);
@@ -665,7 +668,11 @@ void Heap::ClearNormalizedMapCaches() {
Object* context = global_contexts_list_;
while (!context->IsUndefined()) {
- Context::cast(context)->normalized_map_cache()->Clear();
+ int index = Context::NORMALIZED_MAP_CACHE_INDEX;
Vyacheslav Egorov (Chromium) 2011/12/13 12:26:20 I don't think we need separate variable just for i
ulan 2011/12/13 13:02:58 Done.
+ Object* cache = Context::cast(context)->get(index);
+ if (!cache->IsUndefined()) {
Vyacheslav Egorov (Chromium) 2011/12/13 12:26:20 please comment why we need to guard against partia
ulan 2011/12/13 13:02:58 Done.
+ NormalizedMapCache::cast(cache)->Clear();
+ }
context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK);
}
}

Powered by Google App Engine
This is Rietveld 408576698