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

Unified Diff: src/objects.cc

Issue 457333003: Change the type of the cache so we can check whether it is there (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 months 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
« no previous file with comments | « src/contexts.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index cf9f65dcf6ccb5496cb91d0cb5bcd86e46b974b9..aa9984000086e372087aeb1adc52613d5fcff29b 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -4441,8 +4441,6 @@ Handle<NormalizedMapCache> NormalizedMapCache::New(Isolate* isolate) {
MaybeHandle<Map> NormalizedMapCache::Get(Handle<Map> fast_map,
PropertyNormalizationMode mode) {
- // Only use the cache once it is initialized.
- if (!IsNormalizedMapCache(this)) return MaybeHandle<Map>();
DisallowHeapAllocation no_gc;
Object* value = FixedArray::get(GetIndex(fast_map));
if (!value->IsMap() ||
@@ -4455,8 +4453,6 @@ MaybeHandle<Map> NormalizedMapCache::Get(Handle<Map> fast_map,
void NormalizedMapCache::Set(Handle<Map> fast_map,
Handle<Map> normalized_map) {
- // Only use the cache once it is initialized.
- if (!IsNormalizedMapCache(this)) return;
DisallowHeapAllocation no_gc;
DCHECK(normalized_map->is_dictionary_map());
FixedArray::set(GetIndex(fast_map), *normalized_map);
@@ -6980,11 +6976,14 @@ Handle<Map> Map::Normalize(Handle<Map> fast_map,
DCHECK(!fast_map->is_dictionary_map());
Isolate* isolate = fast_map->GetIsolate();
- Handle<NormalizedMapCache> cache(
- isolate->context()->native_context()->normalized_map_cache());
+ Handle<Object> maybe_cache(isolate->native_context()->normalized_map_cache(),
+ isolate);
+ bool use_cache = !maybe_cache->IsUndefined();
+ Handle<NormalizedMapCache> cache;
+ if (use_cache) cache = Handle<NormalizedMapCache>::cast(maybe_cache);
Handle<Map> new_map;
- if (cache->Get(fast_map, mode).ToHandle(&new_map)) {
+ if (use_cache && cache->Get(fast_map, mode).ToHandle(&new_map)) {
#ifdef VERIFY_HEAP
if (FLAG_verify_heap) new_map->DictionaryMapVerify();
#endif
@@ -7008,8 +7007,10 @@ Handle<Map> Map::Normalize(Handle<Map> fast_map,
#endif
} else {
new_map = Map::CopyNormalized(fast_map, mode);
- cache->Set(fast_map, new_map);
- isolate->counters()->normalized_maps()->Increment();
+ if (use_cache) {
+ cache->Set(fast_map, new_map);
+ isolate->counters()->normalized_maps()->Increment();
+ }
}
fast_map->NotifyLeafMapLayoutChange();
return new_map;
« no previous file with comments | « src/contexts.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698