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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/contexts.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/allocation-site-scopes.h" 8 #include "src/allocation-site-scopes.h"
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 4423 matching lines...) Expand 10 before | Expand all | Expand 10 after
4434 4434
4435 Handle<NormalizedMapCache> NormalizedMapCache::New(Isolate* isolate) { 4435 Handle<NormalizedMapCache> NormalizedMapCache::New(Isolate* isolate) {
4436 Handle<FixedArray> array( 4436 Handle<FixedArray> array(
4437 isolate->factory()->NewFixedArray(kEntries, TENURED)); 4437 isolate->factory()->NewFixedArray(kEntries, TENURED));
4438 return Handle<NormalizedMapCache>::cast(array); 4438 return Handle<NormalizedMapCache>::cast(array);
4439 } 4439 }
4440 4440
4441 4441
4442 MaybeHandle<Map> NormalizedMapCache::Get(Handle<Map> fast_map, 4442 MaybeHandle<Map> NormalizedMapCache::Get(Handle<Map> fast_map,
4443 PropertyNormalizationMode mode) { 4443 PropertyNormalizationMode mode) {
4444 // Only use the cache once it is initialized.
4445 if (!IsNormalizedMapCache(this)) return MaybeHandle<Map>();
4446 DisallowHeapAllocation no_gc; 4444 DisallowHeapAllocation no_gc;
4447 Object* value = FixedArray::get(GetIndex(fast_map)); 4445 Object* value = FixedArray::get(GetIndex(fast_map));
4448 if (!value->IsMap() || 4446 if (!value->IsMap() ||
4449 !Map::cast(value)->EquivalentToForNormalization(*fast_map, mode)) { 4447 !Map::cast(value)->EquivalentToForNormalization(*fast_map, mode)) {
4450 return MaybeHandle<Map>(); 4448 return MaybeHandle<Map>();
4451 } 4449 }
4452 return handle(Map::cast(value)); 4450 return handle(Map::cast(value));
4453 } 4451 }
4454 4452
4455 4453
4456 void NormalizedMapCache::Set(Handle<Map> fast_map, 4454 void NormalizedMapCache::Set(Handle<Map> fast_map,
4457 Handle<Map> normalized_map) { 4455 Handle<Map> normalized_map) {
4458 // Only use the cache once it is initialized.
4459 if (!IsNormalizedMapCache(this)) return;
4460 DisallowHeapAllocation no_gc; 4456 DisallowHeapAllocation no_gc;
4461 DCHECK(normalized_map->is_dictionary_map()); 4457 DCHECK(normalized_map->is_dictionary_map());
4462 FixedArray::set(GetIndex(fast_map), *normalized_map); 4458 FixedArray::set(GetIndex(fast_map), *normalized_map);
4463 } 4459 }
4464 4460
4465 4461
4466 void NormalizedMapCache::Clear() { 4462 void NormalizedMapCache::Clear() {
4467 int entries = length(); 4463 int entries = length();
4468 for (int i = 0; i != entries; i++) { 4464 for (int i = 0; i != entries; i++) {
4469 set_undefined(i); 4465 set_undefined(i);
(...skipping 2503 matching lines...) Expand 10 before | Expand all | Expand 10 after
6973 result->set_bit_field3(new_bit_field3); 6969 result->set_bit_field3(new_bit_field3);
6974 return result; 6970 return result;
6975 } 6971 }
6976 6972
6977 6973
6978 Handle<Map> Map::Normalize(Handle<Map> fast_map, 6974 Handle<Map> Map::Normalize(Handle<Map> fast_map,
6979 PropertyNormalizationMode mode) { 6975 PropertyNormalizationMode mode) {
6980 DCHECK(!fast_map->is_dictionary_map()); 6976 DCHECK(!fast_map->is_dictionary_map());
6981 6977
6982 Isolate* isolate = fast_map->GetIsolate(); 6978 Isolate* isolate = fast_map->GetIsolate();
6983 Handle<NormalizedMapCache> cache( 6979 Handle<Object> maybe_cache(isolate->native_context()->normalized_map_cache(),
6984 isolate->context()->native_context()->normalized_map_cache()); 6980 isolate);
6981 bool use_cache = !maybe_cache->IsUndefined();
6982 Handle<NormalizedMapCache> cache;
6983 if (use_cache) cache = Handle<NormalizedMapCache>::cast(maybe_cache);
6985 6984
6986 Handle<Map> new_map; 6985 Handle<Map> new_map;
6987 if (cache->Get(fast_map, mode).ToHandle(&new_map)) { 6986 if (use_cache && cache->Get(fast_map, mode).ToHandle(&new_map)) {
6988 #ifdef VERIFY_HEAP 6987 #ifdef VERIFY_HEAP
6989 if (FLAG_verify_heap) new_map->DictionaryMapVerify(); 6988 if (FLAG_verify_heap) new_map->DictionaryMapVerify();
6990 #endif 6989 #endif
6991 #ifdef ENABLE_SLOW_DCHECKS 6990 #ifdef ENABLE_SLOW_DCHECKS
6992 if (FLAG_enable_slow_asserts) { 6991 if (FLAG_enable_slow_asserts) {
6993 // The cached map should match newly created normalized map bit-by-bit, 6992 // The cached map should match newly created normalized map bit-by-bit,
6994 // except for the code cache, which can contain some ics which can be 6993 // except for the code cache, which can contain some ics which can be
6995 // applied to the shared map. 6994 // applied to the shared map.
6996 Handle<Map> fresh = Map::CopyNormalized(fast_map, mode); 6995 Handle<Map> fresh = Map::CopyNormalized(fast_map, mode);
6997 6996
6998 DCHECK(memcmp(fresh->address(), 6997 DCHECK(memcmp(fresh->address(),
6999 new_map->address(), 6998 new_map->address(),
7000 Map::kCodeCacheOffset) == 0); 6999 Map::kCodeCacheOffset) == 0);
7001 STATIC_ASSERT(Map::kDependentCodeOffset == 7000 STATIC_ASSERT(Map::kDependentCodeOffset ==
7002 Map::kCodeCacheOffset + kPointerSize); 7001 Map::kCodeCacheOffset + kPointerSize);
7003 int offset = Map::kDependentCodeOffset + kPointerSize; 7002 int offset = Map::kDependentCodeOffset + kPointerSize;
7004 DCHECK(memcmp(fresh->address() + offset, 7003 DCHECK(memcmp(fresh->address() + offset,
7005 new_map->address() + offset, 7004 new_map->address() + offset,
7006 Map::kSize - offset) == 0); 7005 Map::kSize - offset) == 0);
7007 } 7006 }
7008 #endif 7007 #endif
7009 } else { 7008 } else {
7010 new_map = Map::CopyNormalized(fast_map, mode); 7009 new_map = Map::CopyNormalized(fast_map, mode);
7011 cache->Set(fast_map, new_map); 7010 if (use_cache) {
7012 isolate->counters()->normalized_maps()->Increment(); 7011 cache->Set(fast_map, new_map);
7012 isolate->counters()->normalized_maps()->Increment();
7013 }
7013 } 7014 }
7014 fast_map->NotifyLeafMapLayoutChange(); 7015 fast_map->NotifyLeafMapLayoutChange();
7015 return new_map; 7016 return new_map;
7016 } 7017 }
7017 7018
7018 7019
7019 Handle<Map> Map::CopyNormalized(Handle<Map> map, 7020 Handle<Map> Map::CopyNormalized(Handle<Map> map,
7020 PropertyNormalizationMode mode) { 7021 PropertyNormalizationMode mode) {
7021 int new_instance_size = map->instance_size(); 7022 int new_instance_size = map->instance_size();
7022 if (mode == CLEAR_INOBJECT_PROPERTIES) { 7023 if (mode == CLEAR_INOBJECT_PROPERTIES) {
(...skipping 9896 matching lines...) Expand 10 before | Expand all | Expand 10 after
16919 #define ERROR_MESSAGES_TEXTS(C, T) T, 16920 #define ERROR_MESSAGES_TEXTS(C, T) T,
16920 static const char* error_messages_[] = { 16921 static const char* error_messages_[] = {
16921 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16922 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16922 }; 16923 };
16923 #undef ERROR_MESSAGES_TEXTS 16924 #undef ERROR_MESSAGES_TEXTS
16924 return error_messages_[reason]; 16925 return error_messages_[reason];
16925 } 16926 }
16926 16927
16927 16928
16928 } } // namespace v8::internal 16929 } } // namespace v8::internal
OLDNEW
« 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