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

Side by Side Diff: src/bootstrapper.cc

Issue 1267493006: Remove JSFunctionResultCache. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 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
« no previous file with comments | « src/bailout-reason.h ('k') | src/contexts.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/base/utils/random-number-generator.h" 9 #include "src/base/utils/random-number-generator.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 const char* name, 234 const char* name,
235 ElementsKind elements_kind); 235 ElementsKind elements_kind);
236 bool InstallNatives(ContextType context_type); 236 bool InstallNatives(ContextType context_type);
237 237
238 void InstallTypedArray(const char* name, ElementsKind elements_kind, 238 void InstallTypedArray(const char* name, ElementsKind elements_kind,
239 Handle<JSFunction>* fun); 239 Handle<JSFunction>* fun);
240 bool InstallExperimentalNatives(); 240 bool InstallExperimentalNatives();
241 bool InstallExtraNatives(); 241 bool InstallExtraNatives();
242 void InstallBuiltinFunctionIds(); 242 void InstallBuiltinFunctionIds();
243 void InstallExperimentalBuiltinFunctionIds(); 243 void InstallExperimentalBuiltinFunctionIds();
244 void InstallJSFunctionResultCaches();
245 void InitializeNormalizedMapCaches(); 244 void InitializeNormalizedMapCaches();
246 245
247 enum ExtensionTraversalState { 246 enum ExtensionTraversalState {
248 UNVISITED, VISITED, INSTALLED 247 UNVISITED, VISITED, INSTALLED
249 }; 248 };
250 249
251 class ExtensionStates { 250 class ExtensionStates {
252 public: 251 public:
253 ExtensionStates(); 252 ExtensionStates();
254 ExtensionTraversalState get_state(RegisteredExtension* extension); 253 ExtensionTraversalState get_state(RegisteredExtension* extension);
(...skipping 2436 matching lines...) Expand 10 before | Expand all | Expand 10 after
2691 ResolveBuiltinIdHolder(native_context(), builtin.holder_expr); 2690 ResolveBuiltinIdHolder(native_context(), builtin.holder_expr);
2692 InstallBuiltinFunctionId(holder, builtin.fun_name, builtin.id); 2691 InstallBuiltinFunctionId(holder, builtin.fun_name, builtin.id);
2693 } 2692 }
2694 } 2693 }
2695 } 2694 }
2696 2695
2697 2696
2698 #undef INSTALL_BUILTIN_ID 2697 #undef INSTALL_BUILTIN_ID
2699 2698
2700 2699
2701 // Do not forget to update macros.py with named constant
2702 // of cache id.
2703 #define JSFUNCTION_RESULT_CACHE_LIST(F) \
2704 F(16, native_context()->regexp_function())
2705
2706
2707 static FixedArray* CreateCache(int size, Handle<JSFunction> factory_function) {
2708 Factory* factory = factory_function->GetIsolate()->factory();
2709 // Caches are supposed to live for a long time, allocate in old space.
2710 int array_size = JSFunctionResultCache::kEntriesIndex + 2 * size;
2711 // Cannot use cast as object is not fully initialized yet.
2712 JSFunctionResultCache* cache = reinterpret_cast<JSFunctionResultCache*>(
2713 *factory->NewFixedArrayWithHoles(array_size, TENURED));
2714 cache->set(JSFunctionResultCache::kFactoryIndex, *factory_function);
2715 cache->MakeZeroSize();
2716 return cache;
2717 }
2718
2719
2720 void Genesis::InstallJSFunctionResultCaches() {
2721 const int kNumberOfCaches = 0 +
2722 #define F(size, func) + 1
2723 JSFUNCTION_RESULT_CACHE_LIST(F)
2724 #undef F
2725 ;
2726
2727 Handle<FixedArray> caches =
2728 factory()->NewFixedArray(kNumberOfCaches, TENURED);
2729
2730 int index = 0;
2731
2732 #define F(size, func) do { \
2733 FixedArray* cache = CreateCache((size), Handle<JSFunction>(func)); \
2734 caches->set(index++, cache); \
2735 } while (false)
2736
2737 JSFUNCTION_RESULT_CACHE_LIST(F);
2738
2739 #undef F
2740
2741 native_context()->set_jsfunction_result_caches(*caches);
2742 }
2743
2744
2745 void Genesis::InitializeNormalizedMapCaches() { 2700 void Genesis::InitializeNormalizedMapCaches() {
2746 Handle<NormalizedMapCache> cache = NormalizedMapCache::New(isolate()); 2701 Handle<NormalizedMapCache> cache = NormalizedMapCache::New(isolate());
2747 native_context()->set_normalized_map_cache(*cache); 2702 native_context()->set_normalized_map_cache(*cache);
2748 } 2703 }
2749 2704
2750 2705
2751 bool Bootstrapper::InstallExtensions(Handle<Context> native_context, 2706 bool Bootstrapper::InstallExtensions(Handle<Context> native_context,
2752 v8::ExtensionConfiguration* extensions) { 2707 v8::ExtensionConfiguration* extensions) {
2753 BootstrapperActive active(this); 2708 BootstrapperActive active(this);
2754 SaveContext saved_context(isolate_); 2709 SaveContext saved_context(isolate_);
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
3245 } else { 3200 } else {
3246 // We get here if there was no context snapshot. 3201 // We get here if there was no context snapshot.
3247 CreateRoots(); 3202 CreateRoots();
3248 Handle<JSFunction> empty_function = CreateEmptyFunction(isolate); 3203 Handle<JSFunction> empty_function = CreateEmptyFunction(isolate);
3249 CreateStrictModeFunctionMaps(empty_function); 3204 CreateStrictModeFunctionMaps(empty_function);
3250 CreateStrongModeFunctionMaps(empty_function); 3205 CreateStrongModeFunctionMaps(empty_function);
3251 Handle<GlobalObject> global_object = 3206 Handle<GlobalObject> global_object =
3252 CreateNewGlobals(global_proxy_template, global_proxy); 3207 CreateNewGlobals(global_proxy_template, global_proxy);
3253 HookUpGlobalProxy(global_object, global_proxy); 3208 HookUpGlobalProxy(global_object, global_proxy);
3254 InitializeGlobal(global_object, empty_function, context_type); 3209 InitializeGlobal(global_object, empty_function, context_type);
3255 InstallJSFunctionResultCaches();
3256 InitializeNormalizedMapCaches(); 3210 InitializeNormalizedMapCaches();
3257 3211
3258 if (!InstallNatives(context_type)) return; 3212 if (!InstallNatives(context_type)) return;
3259 3213
3260 MakeFunctionInstancePrototypeWritable(); 3214 MakeFunctionInstancePrototypeWritable();
3261 3215
3262 if (context_type == FULL_CONTEXT) { 3216 if (context_type == FULL_CONTEXT) {
3263 if (!ConfigureGlobalObjects(global_proxy_template)) return; 3217 if (!ConfigureGlobalObjects(global_proxy_template)) return;
3264 } 3218 }
3265 isolate->counters()->contexts_created_from_scratch()->Increment(); 3219 isolate->counters()->contexts_created_from_scratch()->Increment();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3307 } 3261 }
3308 3262
3309 3263
3310 // Called when the top-level V8 mutex is destroyed. 3264 // Called when the top-level V8 mutex is destroyed.
3311 void Bootstrapper::FreeThreadResources() { 3265 void Bootstrapper::FreeThreadResources() {
3312 DCHECK(!IsActive()); 3266 DCHECK(!IsActive());
3313 } 3267 }
3314 3268
3315 } // namespace internal 3269 } // namespace internal
3316 } // namespace v8 3270 } // namespace v8
OLDNEW
« no previous file with comments | « src/bailout-reason.h ('k') | src/contexts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698