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

Side by Side Diff: src/bootstrapper.cc

Issue 1145213005: [strong] cache strong object literal maps (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix map comparison 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
« no previous file with comments | « include/v8.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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 map->set_is_prototype_map(true); 524 map->set_is_prototype_map(true);
525 object_function_prototype->set_map(*map); 525 object_function_prototype->set_map(*map);
526 526
527 native_context()->set_initial_object_prototype(*object_function_prototype); 527 native_context()->set_initial_object_prototype(*object_function_prototype);
528 // For bootstrapping set the array prototype to be the same as the object 528 // For bootstrapping set the array prototype to be the same as the object
529 // prototype, otherwise the missing initial_array_prototype will cause 529 // prototype, otherwise the missing initial_array_prototype will cause
530 // assertions during startup. 530 // assertions during startup.
531 native_context()->set_initial_array_prototype(*object_function_prototype); 531 native_context()->set_initial_array_prototype(*object_function_prototype);
532 Accessors::FunctionSetPrototype(object_fun, object_function_prototype) 532 Accessors::FunctionSetPrototype(object_fun, object_function_prototype)
533 .Assert(); 533 .Assert();
534
535 // Allocate initial strong object map.
536 Handle<Map> strong_object_map =
537 Map::Copy(object_function_map, "EmptyStrongObject");
538 strong_object_map->set_is_strong();
539 native_context()->set_js_object_strong_map(*strong_object_map);
534 } 540 }
535 541
536 // Allocate the empty function as the prototype for function - ES6 19.2.3 542 // Allocate the empty function as the prototype for function - ES6 19.2.3
537 Handle<Code> code(isolate->builtins()->builtin(Builtins::kEmptyFunction)); 543 Handle<Code> code(isolate->builtins()->builtin(Builtins::kEmptyFunction));
538 Handle<JSFunction> empty_function = 544 Handle<JSFunction> empty_function =
539 factory->NewFunctionWithoutPrototype(factory->empty_string(), code); 545 factory->NewFunctionWithoutPrototype(factory->empty_string(), code);
540 546
541 // Allocate the function map first and then patch the prototype later 547 // Allocate the function map first and then patch the prototype later
542 Handle<Map> empty_function_map = 548 Handle<Map> empty_function_map =
543 CreateSloppyFunctionMap(FUNCTION_WITHOUT_PROTOTYPE); 549 CreateSloppyFunctionMap(FUNCTION_WITHOUT_PROTOTYPE);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 } 705 }
700 706
701 707
702 Handle<Map> Genesis::CreateStrongFunctionMap( 708 Handle<Map> Genesis::CreateStrongFunctionMap(
703 Handle<JSFunction> empty_function, bool is_constructor) { 709 Handle<JSFunction> empty_function, bool is_constructor) {
704 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); 710 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize);
705 SetStrongFunctionInstanceDescriptor(map); 711 SetStrongFunctionInstanceDescriptor(map);
706 map->set_function_with_prototype(is_constructor); 712 map->set_function_with_prototype(is_constructor);
707 Map::SetPrototype(map, empty_function); 713 Map::SetPrototype(map, empty_function);
708 map->set_is_extensible(is_constructor); 714 map->set_is_extensible(is_constructor);
709 map->set_is_strong(true); 715 map->set_is_strong();
710 return map; 716 return map;
711 } 717 }
712 718
713 719
714 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) { 720 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) {
715 // Allocate map for the prototype-less strict mode instances. 721 // Allocate map for the prototype-less strict mode instances.
716 Handle<Map> strict_function_without_prototype_map = 722 Handle<Map> strict_function_without_prototype_map =
717 CreateStrictFunctionMap(FUNCTION_WITHOUT_PROTOTYPE, empty); 723 CreateStrictFunctionMap(FUNCTION_WITHOUT_PROTOTYPE, empty);
718 native_context()->set_strict_function_without_prototype_map( 724 native_context()->set_strict_function_without_prototype_map(
719 *strict_function_without_prototype_map); 725 *strict_function_without_prototype_map);
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 native_context()->set_array_function(*array_function); 1019 native_context()->set_array_function(*array_function);
1014 1020
1015 // Cache the array maps, needed by ArrayConstructorStub 1021 // Cache the array maps, needed by ArrayConstructorStub
1016 CacheInitialJSArrayMaps(native_context(), initial_map); 1022 CacheInitialJSArrayMaps(native_context(), initial_map);
1017 ArrayConstructorStub array_constructor_stub(isolate); 1023 ArrayConstructorStub array_constructor_stub(isolate);
1018 Handle<Code> code = array_constructor_stub.GetCode(); 1024 Handle<Code> code = array_constructor_stub.GetCode();
1019 array_function->shared()->set_construct_stub(*code); 1025 array_function->shared()->set_construct_stub(*code);
1020 1026
1021 Handle<Map> initial_strong_map = 1027 Handle<Map> initial_strong_map =
1022 Map::Copy(initial_map, "SetInstancePrototype"); 1028 Map::Copy(initial_map, "SetInstancePrototype");
1023 initial_strong_map->set_is_strong(true); 1029 initial_strong_map->set_is_strong();
1024 CacheInitialJSArrayMaps(native_context(), initial_strong_map); 1030 CacheInitialJSArrayMaps(native_context(), initial_strong_map);
1025 } 1031 }
1026 1032
1027 { // --- N u m b e r --- 1033 { // --- N u m b e r ---
1028 Handle<JSFunction> number_fun = 1034 Handle<JSFunction> number_fun =
1029 InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize, 1035 InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize,
1030 isolate->initial_object_prototype(), 1036 isolate->initial_object_prototype(),
1031 Builtins::kIllegal); 1037 Builtins::kIllegal);
1032 native_context()->set_number_function(*number_fun); 1038 native_context()->set_number_function(*number_fun);
1033 } 1039 }
(...skipping 2011 matching lines...) Expand 10 before | Expand all | Expand 10 after
3045 return from + sizeof(NestingCounterType); 3051 return from + sizeof(NestingCounterType);
3046 } 3052 }
3047 3053
3048 3054
3049 // Called when the top-level V8 mutex is destroyed. 3055 // Called when the top-level V8 mutex is destroyed.
3050 void Bootstrapper::FreeThreadResources() { 3056 void Bootstrapper::FreeThreadResources() {
3051 DCHECK(!IsActive()); 3057 DCHECK(!IsActive());
3052 } 3058 }
3053 3059
3054 } } // namespace v8::internal 3060 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/contexts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698