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 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_object_literals) | 1658 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_object_literals) |
1659 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_regexps) | 1659 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_regexps) |
1660 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_arrow_functions) | 1660 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_arrow_functions) |
1661 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_tostring) | 1661 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_tostring) |
1662 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy) | 1662 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy) |
1663 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode) | 1663 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode) |
1664 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode_regexps) | 1664 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode_regexps) |
1665 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_computed_property_names) | 1665 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_computed_property_names) |
1666 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_rest_parameters) | 1666 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_rest_parameters) |
1667 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_reflect) | 1667 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_reflect) |
| 1668 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spreadcalls) |
1668 | 1669 |
1669 | 1670 |
1670 void Genesis::InstallNativeFunctions_harmony_proxies() { | 1671 void Genesis::InstallNativeFunctions_harmony_proxies() { |
1671 if (FLAG_harmony_proxies) { | 1672 if (FLAG_harmony_proxies) { |
1672 INSTALL_NATIVE(JSFunction, "DerivedHasTrap", derived_has_trap); | 1673 INSTALL_NATIVE(JSFunction, "DerivedHasTrap", derived_has_trap); |
1673 INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap); | 1674 INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap); |
1674 INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap); | 1675 INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap); |
1675 INSTALL_NATIVE(JSFunction, "ProxyEnumerate", proxy_enumerate); | 1676 INSTALL_NATIVE(JSFunction, "ProxyEnumerate", proxy_enumerate); |
1676 } | 1677 } |
1677 } | 1678 } |
1678 | 1679 |
1679 #undef INSTALL_NATIVE | 1680 #undef INSTALL_NATIVE |
1680 | 1681 |
1681 #define EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(id) \ | 1682 #define EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(id) \ |
1682 void Genesis::InitializeGlobal_##id() {} | 1683 void Genesis::InitializeGlobal_##id() {} |
1683 | 1684 |
1684 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_modules) | 1685 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_modules) |
1685 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrays) | 1686 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrays) |
1686 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_array_includes) | 1687 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_array_includes) |
1687 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_classes) | 1688 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_classes) |
1688 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object_literals) | 1689 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object_literals) |
1689 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrow_functions) | 1690 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrow_functions) |
1690 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tostring) | 1691 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tostring) |
1691 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies) | 1692 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies) |
1692 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy) | 1693 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy) |
1693 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode) | 1694 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode) |
1694 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_computed_property_names) | 1695 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_computed_property_names) |
1695 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_rest_parameters) | 1696 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_rest_parameters) |
| 1697 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_spreadcalls) |
1696 | 1698 |
1697 void Genesis::InitializeGlobal_harmony_regexps() { | 1699 void Genesis::InitializeGlobal_harmony_regexps() { |
1698 Handle<JSObject> builtins(native_context()->builtins()); | 1700 Handle<JSObject> builtins(native_context()->builtins()); |
1699 | 1701 |
1700 Handle<HeapObject> flag(FLAG_harmony_regexps ? heap()->true_value() | 1702 Handle<HeapObject> flag(FLAG_harmony_regexps ? heap()->true_value() |
1701 : heap()->false_value()); | 1703 : heap()->false_value()); |
1702 Runtime::SetObjectProperty(isolate(), builtins, | 1704 Runtime::SetObjectProperty(isolate(), builtins, |
1703 factory()->harmony_regexps_string(), flag, | 1705 factory()->harmony_regexps_string(), flag, |
1704 STRICT).Assert(); | 1706 STRICT).Assert(); |
1705 } | 1707 } |
1706 | 1708 |
1707 | 1709 |
1708 void Genesis::InitializeGlobal_harmony_unicode_regexps() { | 1710 void Genesis::InitializeGlobal_harmony_unicode_regexps() { |
1709 Handle<JSObject> builtins(native_context()->builtins()); | 1711 Handle<JSObject> builtins(native_context()->builtins()); |
1710 | 1712 |
1711 Handle<HeapObject> flag(FLAG_harmony_unicode_regexps ? heap()->true_value() | 1713 Handle<HeapObject> flag(FLAG_harmony_unicode_regexps ? heap()->true_value() |
1712 : heap()->false_value()); | 1714 : heap()->false_value()); |
1713 Runtime::SetObjectProperty(isolate(), builtins, | 1715 Runtime::SetObjectProperty(isolate(), builtins, |
1714 factory()->harmony_unicode_regexps_string(), flag, | 1716 factory()->harmony_unicode_regexps_string(), flag, |
1715 STRICT).Assert(); | 1717 STRICT).Assert(); |
1716 } | 1718 } |
1717 | 1719 |
1718 | 1720 |
1719 void Genesis::InitializeGlobal_harmony_reflect() { | 1721 void Genesis::InitializeGlobal_harmony_reflect() { |
1720 if (!FLAG_harmony_reflect) return; | |
1721 Handle<JSObject> builtins(native_context()->builtins()); | 1722 Handle<JSObject> builtins(native_context()->builtins()); |
1722 // Install references to functions of the Reflect object | 1723 // Install references to functions of the Reflect object |
1723 { | 1724 if (FLAG_harmony_reflect || FLAG_harmony_spreadcalls) { |
1724 Handle<JSFunction> apply = | 1725 Handle<JSFunction> apply = |
1725 InstallFunction(builtins, "ReflectApply", JS_OBJECT_TYPE, | 1726 InstallFunction(builtins, "ReflectApply", JS_OBJECT_TYPE, |
1726 JSObject::kHeaderSize, MaybeHandle<JSObject>(), | 1727 JSObject::kHeaderSize, MaybeHandle<JSObject>(), |
1727 Builtins::kReflectApply); | 1728 Builtins::kReflectApply); |
1728 Handle<JSFunction> construct = | 1729 Handle<JSFunction> construct = |
1729 InstallFunction(builtins, "ReflectConstruct", JS_OBJECT_TYPE, | 1730 InstallFunction(builtins, "ReflectConstruct", JS_OBJECT_TYPE, |
1730 JSObject::kHeaderSize, MaybeHandle<JSObject>(), | 1731 JSObject::kHeaderSize, MaybeHandle<JSObject>(), |
1731 Builtins::kReflectConstruct); | 1732 Builtins::kReflectConstruct); |
1732 if (FLAG_vector_ics) { | 1733 if (FLAG_vector_ics) { |
1733 // Apply embeds an IC, so we need a type vector of size 1 in the shared | 1734 // Apply embeds an IC, so we need a type vector of size 1 in the shared |
1734 // function info. | 1735 // function info. |
1735 FeedbackVectorSpec spec(0, Code::CALL_IC); | 1736 FeedbackVectorSpec spec(0, Code::CALL_IC); |
1736 Handle<TypeFeedbackVector> feedback_vector = | 1737 Handle<TypeFeedbackVector> feedback_vector = |
1737 factory()->NewTypeFeedbackVector(&spec); | 1738 factory()->NewTypeFeedbackVector(&spec); |
1738 apply->shared()->set_feedback_vector(*feedback_vector); | 1739 apply->shared()->set_feedback_vector(*feedback_vector); |
1739 | 1740 |
1740 feedback_vector = factory()->NewTypeFeedbackVector(&spec); | 1741 feedback_vector = factory()->NewTypeFeedbackVector(&spec); |
1741 construct->shared()->set_feedback_vector(*feedback_vector); | 1742 construct->shared()->set_feedback_vector(*feedback_vector); |
1742 } | 1743 } |
1743 | 1744 |
1744 apply->shared()->set_internal_formal_parameter_count(3); | 1745 apply->shared()->set_internal_formal_parameter_count(3); |
1745 apply->shared()->set_length(3); | 1746 apply->shared()->set_length(3); |
1746 | 1747 |
1747 construct->shared()->set_internal_formal_parameter_count(3); | 1748 construct->shared()->set_internal_formal_parameter_count(3); |
1748 construct->shared()->set_length(2); | 1749 construct->shared()->set_length(2); |
1749 } | 1750 } |
1750 | 1751 |
| 1752 if (!FLAG_harmony_reflect) return; |
1751 Handle<JSGlobalObject> global(JSGlobalObject::cast( | 1753 Handle<JSGlobalObject> global(JSGlobalObject::cast( |
1752 native_context()->global_object())); | 1754 native_context()->global_object())); |
1753 Handle<String> reflect_string = | 1755 Handle<String> reflect_string = |
1754 factory()->NewStringFromStaticChars("Reflect"); | 1756 factory()->NewStringFromStaticChars("Reflect"); |
1755 Handle<Object> reflect = | 1757 Handle<Object> reflect = |
1756 factory()->NewJSObject(isolate()->object_function(), TENURED); | 1758 factory()->NewJSObject(isolate()->object_function(), TENURED); |
1757 JSObject::AddProperty(global, reflect_string, reflect, DONT_ENUM); | 1759 JSObject::AddProperty(global, reflect_string, reflect, DONT_ENUM); |
1758 } | 1760 } |
1759 | 1761 |
1760 | 1762 |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2310 static const char* harmony_arrow_functions_natives[] = {NULL}; | 2312 static const char* harmony_arrow_functions_natives[] = {NULL}; |
2311 static const char* harmony_tostring_natives[] = {"native harmony-tostring.js", | 2313 static const char* harmony_tostring_natives[] = {"native harmony-tostring.js", |
2312 NULL}; | 2314 NULL}; |
2313 static const char* harmony_sloppy_natives[] = {NULL}; | 2315 static const char* harmony_sloppy_natives[] = {NULL}; |
2314 static const char* harmony_unicode_natives[] = {NULL}; | 2316 static const char* harmony_unicode_natives[] = {NULL}; |
2315 static const char* harmony_unicode_regexps_natives[] = {NULL}; | 2317 static const char* harmony_unicode_regexps_natives[] = {NULL}; |
2316 static const char* harmony_computed_property_names_natives[] = {NULL}; | 2318 static const char* harmony_computed_property_names_natives[] = {NULL}; |
2317 static const char* harmony_rest_parameters_natives[] = {NULL}; | 2319 static const char* harmony_rest_parameters_natives[] = {NULL}; |
2318 static const char* harmony_reflect_natives[] = {"native harmony-reflect.js", | 2320 static const char* harmony_reflect_natives[] = {"native harmony-reflect.js", |
2319 NULL}; | 2321 NULL}; |
| 2322 static const char* harmony_spreadcalls_natives[] = { |
| 2323 "native harmony-spread.js", NULL}; |
2320 | 2324 |
2321 for (int i = ExperimentalNatives::GetDebuggerCount(); | 2325 for (int i = ExperimentalNatives::GetDebuggerCount(); |
2322 i < ExperimentalNatives::GetBuiltinsCount(); i++) { | 2326 i < ExperimentalNatives::GetBuiltinsCount(); i++) { |
2323 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \ | 2327 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \ |
2324 if (FLAG_##id) { \ | 2328 if (FLAG_##id) { \ |
2325 for (size_t j = 0; id##_natives[j] != NULL; j++) { \ | 2329 for (size_t j = 0; id##_natives[j] != NULL; j++) { \ |
2326 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \ | 2330 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \ |
2327 if (strncmp(script_name.start(), id##_natives[j], \ | 2331 if (strncmp(script_name.start(), id##_natives[j], \ |
2328 script_name.length()) == 0) { \ | 2332 script_name.length()) == 0) { \ |
2329 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \ | 2333 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \ |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2952 return from + sizeof(NestingCounterType); | 2956 return from + sizeof(NestingCounterType); |
2953 } | 2957 } |
2954 | 2958 |
2955 | 2959 |
2956 // Called when the top-level V8 mutex is destroyed. | 2960 // Called when the top-level V8 mutex is destroyed. |
2957 void Bootstrapper::FreeThreadResources() { | 2961 void Bootstrapper::FreeThreadResources() { |
2958 DCHECK(!IsActive()); | 2962 DCHECK(!IsActive()); |
2959 } | 2963 } |
2960 | 2964 |
2961 } } // namespace v8::internal | 2965 } } // namespace v8::internal |
OLD | NEW |