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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 prototype, ro_attribs); | 481 prototype, ro_attribs); |
482 map->AppendDescriptor(&d); | 482 map->AppendDescriptor(&d); |
483 } | 483 } |
484 } | 484 } |
485 | 485 |
486 | 486 |
487 Handle<Map> Genesis::CreateSloppyFunctionMap(FunctionMode function_mode) { | 487 Handle<Map> Genesis::CreateSloppyFunctionMap(FunctionMode function_mode) { |
488 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); | 488 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); |
489 SetFunctionInstanceDescriptor(map, function_mode); | 489 SetFunctionInstanceDescriptor(map, function_mode); |
490 map->set_function_with_prototype(IsFunctionModeWithPrototype(function_mode)); | 490 map->set_function_with_prototype(IsFunctionModeWithPrototype(function_mode)); |
| 491 map->set_is_callable(); |
491 return map; | 492 return map; |
492 } | 493 } |
493 | 494 |
494 | 495 |
495 Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) { | 496 Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) { |
496 // Allocate the map for function instances. Maps are allocated first and their | 497 // Allocate the map for function instances. Maps are allocated first and their |
497 // prototypes patched later, once empty function is created. | 498 // prototypes patched later, once empty function is created. |
498 | 499 |
499 // Functions with this map will not have a 'prototype' property, and | 500 // Functions with this map will not have a 'prototype' property, and |
500 // can not be used as constructors. | 501 // can not be used as constructors. |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 } | 721 } |
721 return strict_poison_function_; | 722 return strict_poison_function_; |
722 } | 723 } |
723 | 724 |
724 | 725 |
725 Handle<Map> Genesis::CreateStrictFunctionMap( | 726 Handle<Map> Genesis::CreateStrictFunctionMap( |
726 FunctionMode function_mode, Handle<JSFunction> empty_function) { | 727 FunctionMode function_mode, Handle<JSFunction> empty_function) { |
727 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); | 728 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); |
728 SetStrictFunctionInstanceDescriptor(map, function_mode); | 729 SetStrictFunctionInstanceDescriptor(map, function_mode); |
729 map->set_function_with_prototype(IsFunctionModeWithPrototype(function_mode)); | 730 map->set_function_with_prototype(IsFunctionModeWithPrototype(function_mode)); |
| 731 map->set_is_callable(); |
730 Map::SetPrototype(map, empty_function); | 732 Map::SetPrototype(map, empty_function); |
731 return map; | 733 return map; |
732 } | 734 } |
733 | 735 |
734 | 736 |
735 Handle<Map> Genesis::CreateStrongFunctionMap( | 737 Handle<Map> Genesis::CreateStrongFunctionMap( |
736 Handle<JSFunction> empty_function, bool is_constructor) { | 738 Handle<JSFunction> empty_function, bool is_constructor) { |
737 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); | 739 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); |
738 SetStrongFunctionInstanceDescriptor(map); | 740 SetStrongFunctionInstanceDescriptor(map); |
739 map->set_function_with_prototype(is_constructor); | 741 map->set_function_with_prototype(is_constructor); |
740 Map::SetPrototype(map, empty_function); | 742 Map::SetPrototype(map, empty_function); |
| 743 map->set_is_callable(); |
741 map->set_is_extensible(is_constructor); | 744 map->set_is_extensible(is_constructor); |
742 map->set_is_strong(); | 745 map->set_is_strong(); |
743 return map; | 746 return map; |
744 } | 747 } |
745 | 748 |
746 | 749 |
747 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) { | 750 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) { |
748 // Allocate map for the prototype-less strict mode instances. | 751 // Allocate map for the prototype-less strict mode instances. |
749 Handle<Map> strict_function_without_prototype_map = | 752 Handle<Map> strict_function_without_prototype_map = |
750 CreateStrictFunctionMap(FUNCTION_WITHOUT_PROTOTYPE, empty); | 753 CreateStrictFunctionMap(FUNCTION_WITHOUT_PROTOTYPE, empty); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 native_context()->set_script_context_table(*script_context_table); | 1040 native_context()->set_script_context_table(*script_context_table); |
1038 InstallGlobalThisBinding(); | 1041 InstallGlobalThisBinding(); |
1039 | 1042 |
1040 Handle<String> object_name = factory->Object_string(); | 1043 Handle<String> object_name = factory->Object_string(); |
1041 JSObject::AddProperty( | 1044 JSObject::AddProperty( |
1042 global_object, object_name, isolate->object_function(), DONT_ENUM); | 1045 global_object, object_name, isolate->object_function(), DONT_ENUM); |
1043 | 1046 |
1044 Handle<JSObject> global(native_context()->global_object()); | 1047 Handle<JSObject> global(native_context()->global_object()); |
1045 | 1048 |
1046 // Install global Function object | 1049 // Install global Function object |
1047 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, | 1050 Handle<JSFunction> function_function = |
1048 empty_function, Builtins::kIllegal); | 1051 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, |
| 1052 empty_function, Builtins::kIllegal); |
| 1053 function_function->initial_map()->set_is_callable(); |
1049 | 1054 |
1050 { // --- A r r a y --- | 1055 { // --- A r r a y --- |
1051 Handle<JSFunction> array_function = | 1056 Handle<JSFunction> array_function = |
1052 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, | 1057 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, |
1053 isolate->initial_object_prototype(), | 1058 isolate->initial_object_prototype(), |
1054 Builtins::kArrayCode); | 1059 Builtins::kArrayCode); |
1055 array_function->shared()->DontAdaptArguments(); | 1060 array_function->shared()->DontAdaptArguments(); |
1056 array_function->shared()->set_function_data(Smi::FromInt(kArrayCode)); | 1061 array_function->shared()->set_function_data(Smi::FromInt(kArrayCode)); |
1057 | 1062 |
1058 // This seems a bit hackish, but we need to make sure Array.length | 1063 // This seems a bit hackish, but we need to make sure Array.length |
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2235 generator_function_prototype, | 2240 generator_function_prototype, |
2236 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY)); | 2241 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY)); |
2237 | 2242 |
2238 JSObject::AddProperty( | 2243 JSObject::AddProperty( |
2239 generator_function_prototype, | 2244 generator_function_prototype, |
2240 factory()->InternalizeUtf8String("prototype"), | 2245 factory()->InternalizeUtf8String("prototype"), |
2241 generator_object_prototype, | 2246 generator_object_prototype, |
2242 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); | 2247 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); |
2243 | 2248 |
2244 static const bool kUseStrictFunctionMap = true; | 2249 static const bool kUseStrictFunctionMap = true; |
2245 InstallFunction(builtins, "GeneratorFunction", JS_FUNCTION_TYPE, | 2250 Handle<JSFunction> generator_function_function = |
2246 JSFunction::kSize, generator_function_prototype, | 2251 InstallFunction(builtins, "GeneratorFunction", JS_FUNCTION_TYPE, |
2247 Builtins::kIllegal, kUseStrictFunctionMap); | 2252 JSFunction::kSize, generator_function_prototype, |
| 2253 Builtins::kIllegal, kUseStrictFunctionMap); |
| 2254 generator_function_function->initial_map()->set_is_callable(); |
2248 | 2255 |
2249 // Create maps for generator functions and their prototypes. Store those | 2256 // Create maps for generator functions and their prototypes. Store those |
2250 // maps in the native context. The "prototype" property descriptor is | 2257 // maps in the native context. The "prototype" property descriptor is |
2251 // writable, non-enumerable, and non-configurable (as per ES6 draft | 2258 // writable, non-enumerable, and non-configurable (as per ES6 draft |
2252 // 04-14-15, section 25.2.4.3). | 2259 // 04-14-15, section 25.2.4.3). |
2253 Handle<Map> strict_function_map(strict_function_map_writable_prototype_); | 2260 Handle<Map> strict_function_map(strict_function_map_writable_prototype_); |
2254 // Generator functions do not have "caller" or "arguments" accessors. | 2261 // Generator functions do not have "caller" or "arguments" accessors. |
2255 Handle<Map> sloppy_generator_function_map = | 2262 Handle<Map> sloppy_generator_function_map = |
2256 Map::Copy(strict_function_map, "SloppyGeneratorFunction"); | 2263 Map::Copy(strict_function_map, "SloppyGeneratorFunction"); |
2257 Map::SetPrototype(sloppy_generator_function_map, | 2264 Map::SetPrototype(sloppy_generator_function_map, |
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3190 } | 3197 } |
3191 | 3198 |
3192 | 3199 |
3193 // Called when the top-level V8 mutex is destroyed. | 3200 // Called when the top-level V8 mutex is destroyed. |
3194 void Bootstrapper::FreeThreadResources() { | 3201 void Bootstrapper::FreeThreadResources() { |
3195 DCHECK(!IsActive()); | 3202 DCHECK(!IsActive()); |
3196 } | 3203 } |
3197 | 3204 |
3198 } // namespace internal | 3205 } // namespace internal |
3199 } // namespace v8 | 3206 } // namespace v8 |
OLD | NEW |