Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(589)

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: Rebase + use InitializeGlobal() instead of hack in bootstrapper Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/arm64/builtins-arm64.cc ('k') | src/builtins.h » ('j') | no next file with comments »
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 1649 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_regexps) 1660 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_regexps)
1661 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_arrow_functions) 1661 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_arrow_functions)
1662 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_numeric_literals) 1662 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_numeric_literals)
1663 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_tostring) 1663 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_tostring)
1664 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_templates) 1664 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_templates)
1665 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy) 1665 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy)
1666 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode) 1666 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode)
1667 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode_regexps) 1667 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode_regexps)
1668 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_computed_property_names) 1668 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_computed_property_names)
1669 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_rest_parameters) 1669 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_rest_parameters)
1670 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_reflect)
1670 1671
1671 1672
1672 void Genesis::InstallNativeFunctions_harmony_proxies() { 1673 void Genesis::InstallNativeFunctions_harmony_proxies() {
1673 if (FLAG_harmony_proxies) { 1674 if (FLAG_harmony_proxies) {
1674 INSTALL_NATIVE(JSFunction, "DerivedHasTrap", derived_has_trap); 1675 INSTALL_NATIVE(JSFunction, "DerivedHasTrap", derived_has_trap);
1675 INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap); 1676 INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap);
1676 INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap); 1677 INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap);
1677 INSTALL_NATIVE(JSFunction, "ProxyEnumerate", proxy_enumerate); 1678 INSTALL_NATIVE(JSFunction, "ProxyEnumerate", proxy_enumerate);
1678 } 1679 }
1679 } 1680 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 Handle<JSObject> builtins(native_context()->builtins()); 1715 Handle<JSObject> builtins(native_context()->builtins());
1715 1716
1716 Handle<HeapObject> flag(FLAG_harmony_unicode_regexps ? heap()->true_value() 1717 Handle<HeapObject> flag(FLAG_harmony_unicode_regexps ? heap()->true_value()
1717 : heap()->false_value()); 1718 : heap()->false_value());
1718 Runtime::SetObjectProperty(isolate(), builtins, 1719 Runtime::SetObjectProperty(isolate(), builtins,
1719 factory()->harmony_unicode_regexps_string(), flag, 1720 factory()->harmony_unicode_regexps_string(), flag,
1720 STRICT).Assert(); 1721 STRICT).Assert();
1721 } 1722 }
1722 1723
1723 1724
1725 void Genesis::InitializeGlobal_harmony_reflect() {
1726 Handle<JSGlobalObject> global(JSGlobalObject::cast(
Dmitry Lomov (no reviews) 2015/03/16 09:42:24 This has to be under if(FLAG_harmony_reflect)
caitp (gmail) 2015/03/16 13:08:01 Acknowledged.
1727 native_context()->global_object()));
1728 Handle<String> reflect_string =
1729 factory()->NewStringFromStaticChars("Reflect");
1730 Handle<Object> reflect =
1731 factory()->NewJSObject(isolate()->object_function(), TENURED);
1732 JSObject::AddProperty(global, reflect_string, reflect, DONT_ENUM);
1733 }
1734
1735
1724 Handle<JSFunction> Genesis::InstallInternalArray( 1736 Handle<JSFunction> Genesis::InstallInternalArray(
1725 Handle<JSBuiltinsObject> builtins, 1737 Handle<JSBuiltinsObject> builtins,
1726 const char* name, 1738 const char* name,
1727 ElementsKind elements_kind) { 1739 ElementsKind elements_kind) {
1728 // --- I n t e r n a l A r r a y --- 1740 // --- I n t e r n a l A r r a y ---
1729 // An array constructor on the builtins object that works like 1741 // An array constructor on the builtins object that works like
1730 // the public Array constructor, except that its prototype 1742 // the public Array constructor, except that its prototype
1731 // doesn't inherit from Object.prototype. 1743 // doesn't inherit from Object.prototype.
1732 // To be used only for internal work by builtins. Instances 1744 // To be used only for internal work by builtins. Instances
1733 // must not be leaked to user code. 1745 // must not be leaked to user code.
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
2078 native_context()->set_strong_generator_function_map( 2090 native_context()->set_strong_generator_function_map(
2079 *strong_generator_function_map); 2091 *strong_generator_function_map);
2080 2092
2081 Handle<JSFunction> object_function(native_context()->object_function()); 2093 Handle<JSFunction> object_function(native_context()->object_function());
2082 Handle<Map> generator_object_prototype_map = Map::Create(isolate(), 0); 2094 Handle<Map> generator_object_prototype_map = Map::Create(isolate(), 0);
2083 generator_object_prototype_map->SetPrototype(generator_object_prototype); 2095 generator_object_prototype_map->SetPrototype(generator_object_prototype);
2084 native_context()->set_generator_object_prototype_map( 2096 native_context()->set_generator_object_prototype_map(
2085 *generator_object_prototype_map); 2097 *generator_object_prototype_map);
2086 } 2098 }
2087 2099
2100 // Install references to functions of the Reflect object
Dmitry Lomov (no reviews) 2015/03/16 09:42:24 This should be under FLAG_harmony_reflect. Move it
caitp (gmail) 2015/03/16 13:08:01 I want these functions to be exposed to the runtim
2101 {
2102 Handle<JSFunction> apply =
2103 InstallFunction(builtins, "ReflectApply", JS_OBJECT_TYPE,
2104 JSObject::kHeaderSize, MaybeHandle<JSObject>(),
2105 Builtins::kReflectApply);
2106 Handle<JSFunction> construct =
2107 InstallFunction(builtins, "ReflectConstruct", JS_OBJECT_TYPE,
2108 JSObject::kHeaderSize, MaybeHandle<JSObject>(),
2109 Builtins::kReflectConstruct);
2110 if (FLAG_vector_ics) {
2111 // Apply embeds an IC, so we need a type vector of size 1 in the shared
2112 // function info.
2113 FeedbackVectorSpec spec(0, 1);
2114 spec.SetKind(0, Code::CALL_IC);
2115 Handle<TypeFeedbackVector> feedback_vector =
2116 factory()->NewTypeFeedbackVector(spec);
2117 apply->shared()->set_feedback_vector(*feedback_vector);
2118
2119 feedback_vector = factory()->NewTypeFeedbackVector(spec);
2120 construct->shared()->set_feedback_vector(*feedback_vector);
2121 }
2122
2123 apply->shared()->set_internal_formal_parameter_count(3);
2124 apply->shared()->set_length(3);
2125
2126 construct->shared()->set_internal_formal_parameter_count(3);
2127 construct->shared()->set_length(2);
2128 }
2129
2088 if (FLAG_disable_native_files) { 2130 if (FLAG_disable_native_files) {
2089 PrintF("Warning: Running without installed natives!\n"); 2131 PrintF("Warning: Running without installed natives!\n");
2090 return true; 2132 return true;
2091 } 2133 }
2092 2134
2093 // Install public symbols. 2135 // Install public symbols.
2094 { 2136 {
2095 static const PropertyAttributes attributes = 2137 static const PropertyAttributes attributes =
2096 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); 2138 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
2097 #define INSTALL_PUBLIC_SYMBOL(name, varname, description) \ 2139 #define INSTALL_PUBLIC_SYMBOL(name, varname, description) \
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
2277 static const char* harmony_numeric_literals_natives[] = {NULL}; 2319 static const char* harmony_numeric_literals_natives[] = {NULL};
2278 static const char* harmony_tostring_natives[] = {"native harmony-tostring.js", 2320 static const char* harmony_tostring_natives[] = {"native harmony-tostring.js",
2279 NULL}; 2321 NULL};
2280 static const char* harmony_templates_natives[] = { 2322 static const char* harmony_templates_natives[] = {
2281 "native harmony-templates.js", NULL}; 2323 "native harmony-templates.js", NULL};
2282 static const char* harmony_sloppy_natives[] = {NULL}; 2324 static const char* harmony_sloppy_natives[] = {NULL};
2283 static const char* harmony_unicode_natives[] = {NULL}; 2325 static const char* harmony_unicode_natives[] = {NULL};
2284 static const char* harmony_unicode_regexps_natives[] = {NULL}; 2326 static const char* harmony_unicode_regexps_natives[] = {NULL};
2285 static const char* harmony_computed_property_names_natives[] = {NULL}; 2327 static const char* harmony_computed_property_names_natives[] = {NULL};
2286 static const char* harmony_rest_parameters_natives[] = {NULL}; 2328 static const char* harmony_rest_parameters_natives[] = {NULL};
2329 static const char* harmony_reflect_natives[] = {"native harmony-reflect.js",
2330 NULL};
2287 2331
2288 for (int i = ExperimentalNatives::GetDebuggerCount(); 2332 for (int i = ExperimentalNatives::GetDebuggerCount();
2289 i < ExperimentalNatives::GetBuiltinsCount(); i++) { 2333 i < ExperimentalNatives::GetBuiltinsCount(); i++) {
2290 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \ 2334 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \
2291 if (FLAG_##id) { \ 2335 if (FLAG_##id) { \
2292 for (size_t j = 0; id##_natives[j] != NULL; j++) { \ 2336 for (size_t j = 0; id##_natives[j] != NULL; j++) { \
2293 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \ 2337 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \
2294 if (strncmp(script_name.start(), id##_natives[j], \ 2338 if (strncmp(script_name.start(), id##_natives[j], \
2295 script_name.length()) == 0) { \ 2339 script_name.length()) == 0) { \
2296 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \ 2340 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
2919 return from + sizeof(NestingCounterType); 2963 return from + sizeof(NestingCounterType);
2920 } 2964 }
2921 2965
2922 2966
2923 // Called when the top-level V8 mutex is destroyed. 2967 // Called when the top-level V8 mutex is destroyed.
2924 void Bootstrapper::FreeThreadResources() { 2968 void Bootstrapper::FreeThreadResources() {
2925 DCHECK(!IsActive()); 2969 DCHECK(!IsActive());
2926 } 2970 }
2927 2971
2928 } } // namespace v8::internal 2972 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm64/builtins-arm64.cc ('k') | src/builtins.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698