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/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/extensions/externalize-string-extension.h" | 10 #include "src/extensions/externalize-string-extension.h" |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), | 476 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), |
477 prototype, ro_attribs); | 477 prototype, ro_attribs); |
478 map->AppendDescriptor(&d); | 478 map->AppendDescriptor(&d); |
479 } | 479 } |
480 } | 480 } |
481 | 481 |
482 | 482 |
483 Handle<Map> Genesis::CreateSloppyFunctionMap(FunctionMode function_mode) { | 483 Handle<Map> Genesis::CreateSloppyFunctionMap(FunctionMode function_mode) { |
484 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); | 484 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); |
485 SetFunctionInstanceDescriptor(map, function_mode); | 485 SetFunctionInstanceDescriptor(map, function_mode); |
486 if (IsFunctionModeWithPrototype(function_mode)) map->set_is_constructor(); | 486 map->set_is_constructor(IsFunctionModeWithPrototype(function_mode)); |
487 map->set_is_callable(); | 487 map->set_is_callable(); |
488 return map; | 488 return map; |
489 } | 489 } |
490 | 490 |
491 | 491 |
492 Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) { | 492 Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) { |
493 // Allocate the map for function instances. Maps are allocated first and their | 493 // Allocate the map for function instances. Maps are allocated first and their |
494 // prototypes patched later, once empty function is created. | 494 // prototypes patched later, once empty function is created. |
495 | 495 |
496 // Functions with this map will not have a 'prototype' property, and | 496 // Functions with this map will not have a 'prototype' property, and |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 Builtins::kRestrictedStrictArgumentsPropertiesThrower); | 708 Builtins::kRestrictedStrictArgumentsPropertiesThrower); |
709 } | 709 } |
710 return strict_poison_function_; | 710 return strict_poison_function_; |
711 } | 711 } |
712 | 712 |
713 | 713 |
714 Handle<Map> Genesis::CreateStrictFunctionMap( | 714 Handle<Map> Genesis::CreateStrictFunctionMap( |
715 FunctionMode function_mode, Handle<JSFunction> empty_function) { | 715 FunctionMode function_mode, Handle<JSFunction> empty_function) { |
716 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); | 716 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); |
717 SetStrictFunctionInstanceDescriptor(map, function_mode); | 717 SetStrictFunctionInstanceDescriptor(map, function_mode); |
718 if (IsFunctionModeWithPrototype(function_mode)) map->set_is_constructor(); | 718 map->set_is_constructor(IsFunctionModeWithPrototype(function_mode)); |
719 map->set_is_callable(); | 719 map->set_is_callable(); |
720 Map::SetPrototype(map, empty_function); | 720 Map::SetPrototype(map, empty_function); |
721 return map; | 721 return map; |
722 } | 722 } |
723 | 723 |
724 | 724 |
725 Handle<Map> Genesis::CreateStrongFunctionMap( | 725 Handle<Map> Genesis::CreateStrongFunctionMap( |
726 Handle<JSFunction> empty_function, bool is_constructor) { | 726 Handle<JSFunction> empty_function, bool is_constructor) { |
727 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); | 727 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); |
728 SetStrongFunctionInstanceDescriptor(map); | 728 SetStrongFunctionInstanceDescriptor(map); |
729 if (is_constructor) map->set_is_constructor(); | 729 map->set_is_constructor(is_constructor); |
730 Map::SetPrototype(map, empty_function); | 730 Map::SetPrototype(map, empty_function); |
731 map->set_is_callable(); | 731 map->set_is_callable(); |
732 map->set_is_extensible(is_constructor); | 732 map->set_is_extensible(is_constructor); |
733 map->set_is_strong(); | 733 map->set_is_strong(); |
734 return map; | 734 return map; |
735 } | 735 } |
736 | 736 |
737 | 737 |
738 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) { | 738 void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) { |
739 // Allocate map for the prototype-less strict mode instances. | 739 // Allocate map for the prototype-less strict mode instances. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); | 782 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); |
783 | 783 |
784 // Create maps for generator functions and their prototypes. Store those | 784 // Create maps for generator functions and their prototypes. Store those |
785 // maps in the native context. The "prototype" property descriptor is | 785 // maps in the native context. The "prototype" property descriptor is |
786 // writable, non-enumerable, and non-configurable (as per ES6 draft | 786 // writable, non-enumerable, and non-configurable (as per ES6 draft |
787 // 04-14-15, section 25.2.4.3). | 787 // 04-14-15, section 25.2.4.3). |
788 Handle<Map> strict_function_map(strict_function_map_writable_prototype_); | 788 Handle<Map> strict_function_map(strict_function_map_writable_prototype_); |
789 // Generator functions do not have "caller" or "arguments" accessors. | 789 // Generator functions do not have "caller" or "arguments" accessors. |
790 Handle<Map> sloppy_generator_function_map = | 790 Handle<Map> sloppy_generator_function_map = |
791 Map::Copy(strict_function_map, "SloppyGeneratorFunction"); | 791 Map::Copy(strict_function_map, "SloppyGeneratorFunction"); |
| 792 sloppy_generator_function_map->set_is_constructor(false); |
792 Map::SetPrototype(sloppy_generator_function_map, | 793 Map::SetPrototype(sloppy_generator_function_map, |
793 generator_function_prototype); | 794 generator_function_prototype); |
794 native_context()->set_sloppy_generator_function_map( | 795 native_context()->set_sloppy_generator_function_map( |
795 *sloppy_generator_function_map); | 796 *sloppy_generator_function_map); |
796 | 797 |
797 Handle<Map> strict_generator_function_map = | 798 Handle<Map> strict_generator_function_map = |
798 Map::Copy(strict_function_map, "StrictGeneratorFunction"); | 799 Map::Copy(strict_function_map, "StrictGeneratorFunction"); |
| 800 strict_generator_function_map->set_is_constructor(false); |
799 Map::SetPrototype(strict_generator_function_map, | 801 Map::SetPrototype(strict_generator_function_map, |
800 generator_function_prototype); | 802 generator_function_prototype); |
801 native_context()->set_strict_generator_function_map( | 803 native_context()->set_strict_generator_function_map( |
802 *strict_generator_function_map); | 804 *strict_generator_function_map); |
803 | 805 |
804 Handle<Map> strong_function_map(native_context()->strong_function_map()); | 806 Handle<Map> strong_function_map(native_context()->strong_function_map()); |
805 Handle<Map> strong_generator_function_map = | 807 Handle<Map> strong_generator_function_map = |
806 Map::Copy(strong_function_map, "StrongGeneratorFunction"); | 808 Map::Copy(strong_function_map, "StrongGeneratorFunction"); |
| 809 strong_generator_function_map->set_is_constructor(false); |
807 Map::SetPrototype(strong_generator_function_map, | 810 Map::SetPrototype(strong_generator_function_map, |
808 generator_function_prototype); | 811 generator_function_prototype); |
809 native_context()->set_strong_generator_function_map( | 812 native_context()->set_strong_generator_function_map( |
810 *strong_generator_function_map); | 813 *strong_generator_function_map); |
811 | 814 |
812 Handle<JSFunction> object_function(native_context()->object_function()); | 815 Handle<JSFunction> object_function(native_context()->object_function()); |
813 Handle<Map> generator_object_prototype_map = Map::Create(isolate(), 0); | 816 Handle<Map> generator_object_prototype_map = Map::Create(isolate(), 0); |
814 Map::SetPrototype(generator_object_prototype_map, generator_object_prototype); | 817 Map::SetPrototype(generator_object_prototype_map, generator_object_prototype); |
815 native_context()->set_generator_object_prototype_map( | 818 native_context()->set_generator_object_prototype_map( |
816 *generator_object_prototype_map); | 819 *generator_object_prototype_map); |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1619 { // name | 1622 { // name |
1620 DataDescriptor d(factory->name_string(), JSBoundFunction::kNameIndex, | 1623 DataDescriptor d(factory->name_string(), JSBoundFunction::kNameIndex, |
1621 roc_attribs, Representation::Tagged()); | 1624 roc_attribs, Representation::Tagged()); |
1622 map->AppendDescriptor(&d); | 1625 map->AppendDescriptor(&d); |
1623 } | 1626 } |
1624 | 1627 |
1625 map->SetInObjectProperties(2); | 1628 map->SetInObjectProperties(2); |
1626 native_context()->set_bound_function_without_constructor_map(*map); | 1629 native_context()->set_bound_function_without_constructor_map(*map); |
1627 | 1630 |
1628 map = Map::Copy(map, "IsConstructor"); | 1631 map = Map::Copy(map, "IsConstructor"); |
1629 map->set_is_constructor(); | 1632 map->set_is_constructor(true); |
1630 native_context()->set_bound_function_with_constructor_map(*map); | 1633 native_context()->set_bound_function_with_constructor_map(*map); |
1631 } | 1634 } |
1632 | 1635 |
1633 { // --- sloppy arguments map | 1636 { // --- sloppy arguments map |
1634 // Make sure we can recognize argument objects at runtime. | 1637 // Make sure we can recognize argument objects at runtime. |
1635 // This is done by introducing an anonymous function with | 1638 // This is done by introducing an anonymous function with |
1636 // class_name equals 'Arguments'. | 1639 // class_name equals 'Arguments'. |
1637 Handle<String> arguments_string = factory->Arguments_string(); | 1640 Handle<String> arguments_string = factory->Arguments_string(); |
1638 Handle<Code> code = isolate->builtins()->Illegal(); | 1641 Handle<Code> code = isolate->builtins()->Illegal(); |
1639 Handle<JSFunction> function = factory->NewFunctionWithoutPrototype( | 1642 Handle<JSFunction> function = factory->NewFunctionWithoutPrototype( |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2446 } | 2449 } |
2447 | 2450 |
2448 | 2451 |
2449 void Genesis::InstallJSProxyMaps() { | 2452 void Genesis::InstallJSProxyMaps() { |
2450 // Allocate the different maps for all Proxy types. | 2453 // Allocate the different maps for all Proxy types. |
2451 // Next to the default proxy, we need maps indicating callable and | 2454 // Next to the default proxy, we need maps indicating callable and |
2452 // constructable proxies. | 2455 // constructable proxies. |
2453 | 2456 |
2454 Handle<Map> proxy_function_map = | 2457 Handle<Map> proxy_function_map = |
2455 Map::Copy(isolate()->sloppy_function_without_prototype_map(), "Proxy"); | 2458 Map::Copy(isolate()->sloppy_function_without_prototype_map(), "Proxy"); |
2456 proxy_function_map->set_is_constructor(); | 2459 proxy_function_map->set_is_constructor(true); |
2457 native_context()->set_proxy_function_map(*proxy_function_map); | 2460 native_context()->set_proxy_function_map(*proxy_function_map); |
2458 | 2461 |
2459 Handle<Map> proxy_map = | 2462 Handle<Map> proxy_map = |
2460 factory()->NewMap(JS_PROXY_TYPE, JSProxy::kSize, FAST_ELEMENTS); | 2463 factory()->NewMap(JS_PROXY_TYPE, JSProxy::kSize, FAST_ELEMENTS); |
2461 native_context()->set_proxy_map(*proxy_map); | 2464 native_context()->set_proxy_map(*proxy_map); |
2462 | 2465 |
2463 Handle<Map> proxy_callable_map = Map::Copy(proxy_map, "callable Proxy"); | 2466 Handle<Map> proxy_callable_map = Map::Copy(proxy_map, "callable Proxy"); |
2464 proxy_callable_map->set_is_callable(); | 2467 proxy_callable_map->set_is_callable(); |
2465 native_context()->set_proxy_callable_map(*proxy_callable_map); | 2468 native_context()->set_proxy_callable_map(*proxy_callable_map); |
2466 proxy_callable_map->SetConstructor(native_context()->function_function()); | 2469 proxy_callable_map->SetConstructor(native_context()->function_function()); |
2467 | 2470 |
2468 Handle<Map> proxy_constructor_map = | 2471 Handle<Map> proxy_constructor_map = |
2469 Map::Copy(proxy_callable_map, "constructor Proxy"); | 2472 Map::Copy(proxy_callable_map, "constructor Proxy"); |
2470 proxy_constructor_map->set_is_constructor(); | 2473 proxy_constructor_map->set_is_constructor(true); |
2471 native_context()->set_proxy_constructor_map(*proxy_constructor_map); | 2474 native_context()->set_proxy_constructor_map(*proxy_constructor_map); |
2472 } | 2475 } |
2473 | 2476 |
2474 | 2477 |
2475 void Genesis::InitializeGlobal_harmony_proxies() { | 2478 void Genesis::InitializeGlobal_harmony_proxies() { |
2476 if (!FLAG_harmony_proxies) return; | 2479 if (!FLAG_harmony_proxies) return; |
2477 Handle<JSGlobalObject> global( | 2480 Handle<JSGlobalObject> global( |
2478 JSGlobalObject::cast(native_context()->global_object())); | 2481 JSGlobalObject::cast(native_context()->global_object())); |
2479 Isolate* isolate = global->GetIsolate(); | 2482 Isolate* isolate = global->GetIsolate(); |
2480 Factory* factory = isolate->factory(); | 2483 Factory* factory = isolate->factory(); |
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3519 } | 3522 } |
3520 | 3523 |
3521 | 3524 |
3522 // Called when the top-level V8 mutex is destroyed. | 3525 // Called when the top-level V8 mutex is destroyed. |
3523 void Bootstrapper::FreeThreadResources() { | 3526 void Bootstrapper::FreeThreadResources() { |
3524 DCHECK(!IsActive()); | 3527 DCHECK(!IsActive()); |
3525 } | 3528 } |
3526 | 3529 |
3527 } // namespace internal | 3530 } // namespace internal |
3528 } // namespace v8 | 3531 } // namespace v8 |
OLD | NEW |