Chromium Code Reviews

Side by Side Diff: src/bootstrapper.cc

Issue 913073003: [es6] implement Reflect.apply() & Reflect.construct() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « BUILD.gn ('k') | src/builtins.h » ('j') | src/runtime.js » ('J')
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/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 1646 matching lines...)
1657 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_regexps) 1657 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_regexps)
1658 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_arrow_functions) 1658 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_arrow_functions)
1659 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_numeric_literals) 1659 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_numeric_literals)
1660 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_tostring) 1660 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_tostring)
1661 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_templates) 1661 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_templates)
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 1668
1668 1669
1669 void Genesis::InstallNativeFunctions_harmony_proxies() { 1670 void Genesis::InstallNativeFunctions_harmony_proxies() {
1670 if (FLAG_harmony_proxies) { 1671 if (FLAG_harmony_proxies) {
1671 INSTALL_NATIVE(JSFunction, "DerivedHasTrap", derived_has_trap); 1672 INSTALL_NATIVE(JSFunction, "DerivedHasTrap", derived_has_trap);
1672 INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap); 1673 INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap);
1673 INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap); 1674 INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap);
1674 INSTALL_NATIVE(JSFunction, "ProxyEnumerate", proxy_enumerate); 1675 INSTALL_NATIVE(JSFunction, "ProxyEnumerate", proxy_enumerate);
1675 } 1676 }
1676 } 1677 }
(...skipping 12 matching lines...)
1689 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object_literals) 1690 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object_literals)
1690 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrow_functions) 1691 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrow_functions)
1691 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_numeric_literals) 1692 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_numeric_literals)
1692 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tostring) 1693 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tostring)
1693 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies) 1694 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies)
1694 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_templates) 1695 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_templates)
1695 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy) 1696 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy)
1696 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode) 1697 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode)
1697 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_computed_property_names) 1698 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_computed_property_names)
1698 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_rest_parameters) 1699 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_rest_parameters)
1700 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_reflect)
1699 1701
1700 void Genesis::InitializeGlobal_harmony_regexps() { 1702 void Genesis::InitializeGlobal_harmony_regexps() {
1701 Handle<JSObject> builtins(native_context()->builtins()); 1703 Handle<JSObject> builtins(native_context()->builtins());
1702 1704
1703 Handle<HeapObject> flag(FLAG_harmony_regexps ? heap()->true_value() 1705 Handle<HeapObject> flag(FLAG_harmony_regexps ? heap()->true_value()
1704 : heap()->false_value()); 1706 : heap()->false_value());
1705 PropertyAttributes attributes = 1707 PropertyAttributes attributes =
1706 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); 1708 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY);
1707 Runtime::DefineObjectProperty(builtins, factory()->harmony_regexps_string(), 1709 Runtime::DefineObjectProperty(builtins, factory()->harmony_regexps_string(),
1708 flag, attributes).Assert(); 1710 flag, attributes).Assert();
(...skipping 370 matching lines...)
2079 native_context()->set_strong_generator_function_map( 2081 native_context()->set_strong_generator_function_map(
2080 *strong_generator_function_map); 2082 *strong_generator_function_map);
2081 2083
2082 Handle<JSFunction> object_function(native_context()->object_function()); 2084 Handle<JSFunction> object_function(native_context()->object_function());
2083 Handle<Map> generator_object_prototype_map = Map::Create(isolate(), 0); 2085 Handle<Map> generator_object_prototype_map = Map::Create(isolate(), 0);
2084 generator_object_prototype_map->SetPrototype(generator_object_prototype); 2086 generator_object_prototype_map->SetPrototype(generator_object_prototype);
2085 native_context()->set_generator_object_prototype_map( 2087 native_context()->set_generator_object_prototype_map(
2086 *generator_object_prototype_map); 2088 *generator_object_prototype_map);
2087 } 2089 }
2088 2090
2091 // Install references to functions of the Reflect object
2092 {
2093 Handle<JSFunction> apply =
2094 InstallFunction(builtins, "ReflectApply", JS_OBJECT_TYPE,
2095 JSObject::kHeaderSize, MaybeHandle<JSObject>(),
2096 Builtins::kReflectApply);
2097 Handle<JSFunction> construct =
2098 InstallFunction(builtins, "ReflectConstruct", JS_OBJECT_TYPE,
2099 JSObject::kHeaderSize, MaybeHandle<JSObject>(),
2100 Builtins::kReflectConstruct);
2101 if (FLAG_vector_ics) {
2102 // Apply embeds an IC, so we need a type vector of size 1 in the shared
2103 // function info.
2104 FeedbackVectorSpec spec(0, 1);
2105 spec.SetKind(0, Code::CALL_IC);
2106 Handle<TypeFeedbackVector> feedback_vector =
2107 factory()->NewTypeFeedbackVector(spec);
2108 apply->shared()->set_feedback_vector(*feedback_vector);
2109
2110 feedback_vector = factory()->NewTypeFeedbackVector(spec);
2111 construct->shared()->set_feedback_vector(*feedback_vector);
2112 }
2113
2114 apply->shared()->set_internal_formal_parameter_count(3);
2115 apply->shared()->set_length(3);
2116
2117 construct->shared()->set_internal_formal_parameter_count(3);
2118 construct->shared()->set_length(2);
2119 }
2120
2089 if (FLAG_disable_native_files) { 2121 if (FLAG_disable_native_files) {
2090 PrintF("Warning: Running without installed natives!\n"); 2122 PrintF("Warning: Running without installed natives!\n");
2091 return true; 2123 return true;
2092 } 2124 }
2093 2125
2094 // Install public symbols. 2126 // Install public symbols.
2095 { 2127 {
2096 static const PropertyAttributes attributes = 2128 static const PropertyAttributes attributes =
2097 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); 2129 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
2098 #define INSTALL_PUBLIC_SYMBOL(name, varname, description) \ 2130 #define INSTALL_PUBLIC_SYMBOL(name, varname, description) \
(...skipping 180 matching lines...)
2279 static const char* harmony_numeric_literals_natives[] = {NULL}; 2311 static const char* harmony_numeric_literals_natives[] = {NULL};
2280 static const char* harmony_tostring_natives[] = {"native harmony-tostring.js", 2312 static const char* harmony_tostring_natives[] = {"native harmony-tostring.js",
2281 NULL}; 2313 NULL};
2282 static const char* harmony_templates_natives[] = { 2314 static const char* harmony_templates_natives[] = {
2283 "native harmony-templates.js", NULL}; 2315 "native harmony-templates.js", NULL};
2284 static const char* harmony_sloppy_natives[] = {NULL}; 2316 static const char* harmony_sloppy_natives[] = {NULL};
2285 static const char* harmony_unicode_natives[] = {NULL}; 2317 static const char* harmony_unicode_natives[] = {NULL};
2286 static const char* harmony_unicode_regexps_natives[] = {NULL}; 2318 static const char* harmony_unicode_regexps_natives[] = {NULL};
2287 static const char* harmony_computed_property_names_natives[] = {NULL}; 2319 static const char* harmony_computed_property_names_natives[] = {NULL};
2288 static const char* harmony_rest_parameters_natives[] = {NULL}; 2320 static const char* harmony_rest_parameters_natives[] = {NULL};
2321 static const char* harmony_reflect_natives[] = {"native harmony-reflect.js",
2322 NULL};
2289 2323
2290 for (int i = ExperimentalNatives::GetDebuggerCount(); 2324 for (int i = ExperimentalNatives::GetDebuggerCount();
2291 i < ExperimentalNatives::GetBuiltinsCount(); i++) { 2325 i < ExperimentalNatives::GetBuiltinsCount(); i++) {
2292 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \ 2326 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \
2293 if (FLAG_##id) { \ 2327 if (FLAG_##id) { \
2294 for (size_t j = 0; id##_natives[j] != NULL; j++) { \ 2328 for (size_t j = 0; id##_natives[j] != NULL; j++) { \
2295 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \ 2329 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \
2296 if (strncmp(script_name.start(), id##_natives[j], \ 2330 if (strncmp(script_name.start(), id##_natives[j], \
2297 script_name.length()) == 0) { \ 2331 script_name.length()) == 0) { \
2298 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \ 2332 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \
(...skipping 585 matching lines...)
2884 InstallJSFunctionResultCaches(); 2918 InstallJSFunctionResultCaches();
2885 InitializeNormalizedMapCaches(); 2919 InitializeNormalizedMapCaches();
2886 if (!InstallNatives()) return; 2920 if (!InstallNatives()) return;
2887 2921
2888 MakeFunctionInstancePrototypeWritable(); 2922 MakeFunctionInstancePrototypeWritable();
2889 2923
2890 if (!ConfigureGlobalObjects(global_proxy_template)) return; 2924 if (!ConfigureGlobalObjects(global_proxy_template)) return;
2891 isolate->counters()->contexts_created_from_scratch()->Increment(); 2925 isolate->counters()->contexts_created_from_scratch()->Increment();
2892 } 2926 }
2893 2927
2928 if (FLAG_harmony_reflect) {
2929 // TODO(caitp): this should not be here, there's got to be a better way.
2930 // Shouldn't InitializeExperimentalGlobal() happen before
arv (Not doing code reviews) 2015/03/04 09:45:01 Dmitry fixed this I believe.
caitp (gmail) 2015/03/04 13:24:14 Fix hasn't landed yet, but yes it will be changed
2931 // InitializeExperimentalNatives()?
2932 Handle<JSGlobalObject> global(JSGlobalObject::cast(
2933 native_context()->global_object()));
2934 Handle<String> reflect_string =
2935 factory()->NewStringFromStaticChars("Reflect");
2936 Handle<Object> reflect =
2937 factory()->NewJSObject(isolate->object_function(), TENURED);
2938 JSObject::AddProperty(global, reflect_string, reflect, DONT_ENUM);
2939 }
2940
2894 // Install experimental natives. 2941 // Install experimental natives.
2895 if (!InstallExperimentalNatives()) return; 2942 if (!InstallExperimentalNatives()) return;
2896 InitializeExperimentalGlobal(); 2943 InitializeExperimentalGlobal();
2897 2944
2898 // The serializer cannot serialize typed arrays. Reset those typed arrays 2945 // The serializer cannot serialize typed arrays. Reset those typed arrays
2899 // for each new context. 2946 // for each new context.
2900 InitializeBuiltinTypedArrays(); 2947 InitializeBuiltinTypedArrays();
2901 2948
2902 result_ = native_context(); 2949 result_ = native_context();
2903 } 2950 }
(...skipping 21 matching lines...)
2925 return from + sizeof(NestingCounterType); 2972 return from + sizeof(NestingCounterType);
2926 } 2973 }
2927 2974
2928 2975
2929 // Called when the top-level V8 mutex is destroyed. 2976 // Called when the top-level V8 mutex is destroyed.
2930 void Bootstrapper::FreeThreadResources() { 2977 void Bootstrapper::FreeThreadResources() {
2931 DCHECK(!IsActive()); 2978 DCHECK(!IsActive());
2932 } 2979 }
2933 2980
2934 } } // namespace v8::internal 2981 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | src/builtins.h » ('j') | src/runtime.js » ('J')

Powered by Google App Engine