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

Side by Side Diff: src/heap/heap.cc

Issue 1142493002: Use a private own symbol instead of a hidden property for hash codes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/api.h" 8 #include "src/api.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 3054 matching lines...) Expand 10 before | Expand all | Expand 10 after
3065 3065
3066 set_polymorphic_code_cache(PolymorphicCodeCache::cast( 3066 set_polymorphic_code_cache(PolymorphicCodeCache::cast(
3067 *factory->NewStruct(POLYMORPHIC_CODE_CACHE_TYPE))); 3067 *factory->NewStruct(POLYMORPHIC_CODE_CACHE_TYPE)));
3068 3068
3069 set_instanceof_cache_function(Smi::FromInt(0)); 3069 set_instanceof_cache_function(Smi::FromInt(0));
3070 set_instanceof_cache_map(Smi::FromInt(0)); 3070 set_instanceof_cache_map(Smi::FromInt(0));
3071 set_instanceof_cache_answer(Smi::FromInt(0)); 3071 set_instanceof_cache_answer(Smi::FromInt(0));
3072 3072
3073 { 3073 {
3074 HandleScope scope(isolate()); 3074 HandleScope scope(isolate());
3075 #define SYMBOL_INIT(name) \ 3075 #define SYMBOL_INIT(name) \
3076 Handle<Symbol> name = factory->NewPrivateOwnSymbol(); \ 3076 { \
3077 roots_[k##name##RootIndex] = *name; 3077 Handle<String> name##d = factory->NewStringFromStaticChars(#name); \
3078 Handle<Object> symbol(isolate()->factory()->NewPrivateOwnSymbol(name##d)); \
3079 roots_[k##name##RootIndex] = *symbol; \
3080 }
3078 PRIVATE_SYMBOL_LIST(SYMBOL_INIT) 3081 PRIVATE_SYMBOL_LIST(SYMBOL_INIT)
3079 #undef SYMBOL_INIT 3082 #undef SYMBOL_INIT
3080 } 3083 }
3081 3084
3082 { 3085 {
3083 HandleScope scope(isolate()); 3086 HandleScope scope(isolate());
3084 #define SYMBOL_INIT(name, varname, description) \ 3087 #define SYMBOL_INIT(name, varname, description) \
3085 Handle<Symbol> name = factory->NewSymbol(); \ 3088 Handle<Symbol> name = factory->NewSymbol(); \
3086 Handle<String> name##d = factory->NewStringFromStaticChars(#description); \ 3089 Handle<String> name##d = factory->NewStringFromStaticChars(#description); \
3087 name->set_name(*name##d); \ 3090 name->set_name(*name##d); \
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
3180 isolate_->context_slot_cache()->Clear(); 3183 isolate_->context_slot_cache()->Clear();
3181 3184
3182 // Initialize descriptor cache. 3185 // Initialize descriptor cache.
3183 isolate_->descriptor_lookup_cache()->Clear(); 3186 isolate_->descriptor_lookup_cache()->Clear();
3184 3187
3185 // Initialize compilation cache. 3188 // Initialize compilation cache.
3186 isolate_->compilation_cache()->Clear(); 3189 isolate_->compilation_cache()->Clear();
3187 } 3190 }
3188 3191
3189 3192
3193 void Heap::AddPrivateGlobalSymbols(Handle<Object> private_intern_table) {
3194 #define ADD_SYMBOL_TO_PRIVATE_INTERN_TABLE(name_arg) \
3195 { \
3196 Handle<Symbol> symbol(Symbol::cast(roots_[k##name_arg##RootIndex])); \
3197 Handle<String> name_arg##d(String::cast(symbol->name())); \
3198 JSObject::SetProperty(Handle<JSObject>::cast(private_intern_table), \
3199 name_arg##d, symbol, STRICT).Assert(); \
3200 }
3201 PRIVATE_SYMBOL_LIST(ADD_SYMBOL_TO_PRIVATE_INTERN_TABLE)
3202 #undef ADD_SYMBOL_TO_PRIVATE_INTERN_TABLE
3203 }
3204
3205
3190 bool Heap::RootCanBeWrittenAfterInitialization(Heap::RootListIndex root_index) { 3206 bool Heap::RootCanBeWrittenAfterInitialization(Heap::RootListIndex root_index) {
3191 switch (root_index) { 3207 switch (root_index) {
3192 case kStoreBufferTopRootIndex: 3208 case kStoreBufferTopRootIndex:
3193 case kNumberStringCacheRootIndex: 3209 case kNumberStringCacheRootIndex:
3194 case kInstanceofCacheFunctionRootIndex: 3210 case kInstanceofCacheFunctionRootIndex:
3195 case kInstanceofCacheMapRootIndex: 3211 case kInstanceofCacheMapRootIndex:
3196 case kInstanceofCacheAnswerRootIndex: 3212 case kInstanceofCacheAnswerRootIndex:
3197 case kCodeStubsRootIndex: 3213 case kCodeStubsRootIndex:
3198 case kNonMonomorphicCacheRootIndex: 3214 case kNonMonomorphicCacheRootIndex:
3199 case kPolymorphicCodeCacheRootIndex: 3215 case kPolymorphicCodeCacheRootIndex:
(...skipping 3329 matching lines...) Expand 10 before | Expand all | Expand 10 after
6529 } 6545 }
6530 delete list; 6546 delete list;
6531 } else { 6547 } else {
6532 prev = list; 6548 prev = list;
6533 } 6549 }
6534 list = next; 6550 list = next;
6535 } 6551 }
6536 } 6552 }
6537 } 6553 }
6538 } // namespace v8::internal 6554 } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698