OLD | NEW |
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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 prototype, ro_attribs); | 460 prototype, ro_attribs); |
461 map->AppendDescriptor(&d); | 461 map->AppendDescriptor(&d); |
462 } | 462 } |
463 } | 463 } |
464 | 464 |
465 | 465 |
466 Handle<Map> Genesis::CreateSloppyFunctionMap(FunctionMode function_mode) { | 466 Handle<Map> Genesis::CreateSloppyFunctionMap(FunctionMode function_mode) { |
467 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); | 467 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); |
468 SetFunctionInstanceDescriptor(map, function_mode); | 468 SetFunctionInstanceDescriptor(map, function_mode); |
469 map->set_function_with_prototype(IsFunctionModeWithPrototype(function_mode)); | 469 map->set_function_with_prototype(IsFunctionModeWithPrototype(function_mode)); |
| 470 map->set_is_callable(); |
470 return map; | 471 return map; |
471 } | 472 } |
472 | 473 |
473 | 474 |
474 Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) { | 475 Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) { |
475 // Allocate the map for function instances. Maps are allocated first and their | 476 // Allocate the map for function instances. Maps are allocated first and their |
476 // prototypes patched later, once empty function is created. | 477 // prototypes patched later, once empty function is created. |
477 | 478 |
478 // Functions with this map will not have a 'prototype' property, and | 479 // Functions with this map will not have a 'prototype' property, and |
479 // can not be used as constructors. | 480 // can not be used as constructors. |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 } | 700 } |
700 return strict_poison_function_; | 701 return strict_poison_function_; |
701 } | 702 } |
702 | 703 |
703 | 704 |
704 Handle<Map> Genesis::CreateStrictFunctionMap( | 705 Handle<Map> Genesis::CreateStrictFunctionMap( |
705 FunctionMode function_mode, Handle<JSFunction> empty_function) { | 706 FunctionMode function_mode, Handle<JSFunction> empty_function) { |
706 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); | 707 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); |
707 SetStrictFunctionInstanceDescriptor(map, function_mode); | 708 SetStrictFunctionInstanceDescriptor(map, function_mode); |
708 map->set_function_with_prototype(IsFunctionModeWithPrototype(function_mode)); | 709 map->set_function_with_prototype(IsFunctionModeWithPrototype(function_mode)); |
| 710 map->set_is_callable(); |
709 Map::SetPrototype(map, empty_function); | 711 Map::SetPrototype(map, empty_function); |
710 return map; | 712 return map; |
711 } | 713 } |
712 | 714 |
713 | 715 |
714 Handle<Map> Genesis::CreateStrongFunctionMap( | 716 Handle<Map> Genesis::CreateStrongFunctionMap( |
715 Handle<JSFunction> empty_function, bool is_constructor) { | 717 Handle<JSFunction> empty_function, bool is_constructor) { |
716 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); | 718 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); |
717 SetStrongFunctionInstanceDescriptor(map); | 719 SetStrongFunctionInstanceDescriptor(map); |
718 map->set_function_with_prototype(is_constructor); | 720 map->set_function_with_prototype(is_constructor); |
719 Map::SetPrototype(map, empty_function); | 721 Map::SetPrototype(map, empty_function); |
| 722 map->set_is_callable(); |
720 map->set_is_extensible(is_constructor); | 723 map->set_is_extensible(is_constructor); |
721 map->set_is_strong(); | 724 map->set_is_strong(); |
722 return map; | 725 return map; |
723 } | 726 } |
724 | 727 |
725 | 728 |
726 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) { | 729 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) { |
727 // Allocate map for the prototype-less strict mode instances. | 730 // Allocate map for the prototype-less strict mode instances. |
728 Handle<Map> strict_function_without_prototype_map = | 731 Handle<Map> strict_function_without_prototype_map = |
729 CreateStrictFunctionMap(FUNCTION_WITHOUT_PROTOTYPE, empty); | 732 CreateStrictFunctionMap(FUNCTION_WITHOUT_PROTOTYPE, empty); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 native_context()->set_script_context_table(*script_context_table); | 1019 native_context()->set_script_context_table(*script_context_table); |
1017 InstallGlobalThisBinding(); | 1020 InstallGlobalThisBinding(); |
1018 | 1021 |
1019 Handle<String> object_name = factory->Object_string(); | 1022 Handle<String> object_name = factory->Object_string(); |
1020 JSObject::AddProperty( | 1023 JSObject::AddProperty( |
1021 global_object, object_name, isolate->object_function(), DONT_ENUM); | 1024 global_object, object_name, isolate->object_function(), DONT_ENUM); |
1022 | 1025 |
1023 Handle<JSObject> global(native_context()->global_object()); | 1026 Handle<JSObject> global(native_context()->global_object()); |
1024 | 1027 |
1025 // Install global Function object | 1028 // Install global Function object |
1026 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, | 1029 Handle<JSFunction> function_function = |
1027 empty_function, Builtins::kIllegal); | 1030 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, |
| 1031 empty_function, Builtins::kIllegal); |
| 1032 function_function->initial_map()->set_is_callable(); |
1028 | 1033 |
1029 { // --- A r r a y --- | 1034 { // --- A r r a y --- |
1030 Handle<JSFunction> array_function = | 1035 Handle<JSFunction> array_function = |
1031 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, | 1036 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, |
1032 isolate->initial_object_prototype(), | 1037 isolate->initial_object_prototype(), |
1033 Builtins::kArrayCode); | 1038 Builtins::kArrayCode); |
1034 array_function->shared()->DontAdaptArguments(); | 1039 array_function->shared()->DontAdaptArguments(); |
1035 array_function->shared()->set_function_data(Smi::FromInt(kArrayCode)); | 1040 array_function->shared()->set_function_data(Smi::FromInt(kArrayCode)); |
1036 | 1041 |
1037 // This seems a bit hackish, but we need to make sure Array.length | 1042 // This seems a bit hackish, but we need to make sure Array.length |
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2243 generator_function_prototype, | 2248 generator_function_prototype, |
2244 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY)); | 2249 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY)); |
2245 | 2250 |
2246 JSObject::AddProperty( | 2251 JSObject::AddProperty( |
2247 generator_function_prototype, | 2252 generator_function_prototype, |
2248 factory()->InternalizeUtf8String("prototype"), | 2253 factory()->InternalizeUtf8String("prototype"), |
2249 generator_object_prototype, | 2254 generator_object_prototype, |
2250 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); | 2255 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); |
2251 | 2256 |
2252 static const bool kUseStrictFunctionMap = true; | 2257 static const bool kUseStrictFunctionMap = true; |
2253 InstallFunction(builtins, "GeneratorFunction", JS_FUNCTION_TYPE, | 2258 Handle<JSFunction> generator_function_function = |
2254 JSFunction::kSize, generator_function_prototype, | 2259 InstallFunction(builtins, "GeneratorFunction", JS_FUNCTION_TYPE, |
2255 Builtins::kIllegal, kUseStrictFunctionMap); | 2260 JSFunction::kSize, generator_function_prototype, |
| 2261 Builtins::kIllegal, kUseStrictFunctionMap); |
| 2262 generator_function_function->initial_map()->set_is_callable(); |
2256 | 2263 |
2257 // Create maps for generator functions and their prototypes. Store those | 2264 // Create maps for generator functions and their prototypes. Store those |
2258 // maps in the native context. The "prototype" property descriptor is | 2265 // maps in the native context. The "prototype" property descriptor is |
2259 // writable, non-enumerable, and non-configurable (as per ES6 draft | 2266 // writable, non-enumerable, and non-configurable (as per ES6 draft |
2260 // 04-14-15, section 25.2.4.3). | 2267 // 04-14-15, section 25.2.4.3). |
2261 Handle<Map> strict_function_map(strict_function_map_writable_prototype_); | 2268 Handle<Map> strict_function_map(strict_function_map_writable_prototype_); |
2262 // Generator functions do not have "caller" or "arguments" accessors. | 2269 // Generator functions do not have "caller" or "arguments" accessors. |
2263 Handle<Map> sloppy_generator_function_map = | 2270 Handle<Map> sloppy_generator_function_map = |
2264 Map::Copy(strict_function_map, "SloppyGeneratorFunction"); | 2271 Map::Copy(strict_function_map, "SloppyGeneratorFunction"); |
2265 Map::SetPrototype(sloppy_generator_function_map, | 2272 Map::SetPrototype(sloppy_generator_function_map, |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3181 } | 3188 } |
3182 | 3189 |
3183 | 3190 |
3184 // Called when the top-level V8 mutex is destroyed. | 3191 // Called when the top-level V8 mutex is destroyed. |
3185 void Bootstrapper::FreeThreadResources() { | 3192 void Bootstrapper::FreeThreadResources() { |
3186 DCHECK(!IsActive()); | 3193 DCHECK(!IsActive()); |
3187 } | 3194 } |
3188 | 3195 |
3189 } // namespace internal | 3196 } // namespace internal |
3190 } // namespace v8 | 3197 } // namespace v8 |
OLD | NEW |