| 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 static bool InstallRequestedExtensions(Isolate* isolate, | 235 static bool InstallRequestedExtensions(Isolate* isolate, |
| 236 v8::ExtensionConfiguration* extensions, | 236 v8::ExtensionConfiguration* extensions, |
| 237 ExtensionStates* extension_states); | 237 ExtensionStates* extension_states); |
| 238 static bool InstallExtension(Isolate* isolate, | 238 static bool InstallExtension(Isolate* isolate, |
| 239 const char* name, | 239 const char* name, |
| 240 ExtensionStates* extension_states); | 240 ExtensionStates* extension_states); |
| 241 static bool InstallExtension(Isolate* isolate, | 241 static bool InstallExtension(Isolate* isolate, |
| 242 v8::RegisteredExtension* current, | 242 v8::RegisteredExtension* current, |
| 243 ExtensionStates* extension_states); | 243 ExtensionStates* extension_states); |
| 244 static bool InstallSpecialObjects(Handle<Context> native_context); | 244 static bool InstallSpecialObjects(Handle<Context> native_context); |
| 245 bool InstallJSBuiltins(Handle<JSBuiltinsObject> builtins); | |
| 246 bool ConfigureApiObject(Handle<JSObject> object, | 245 bool ConfigureApiObject(Handle<JSObject> object, |
| 247 Handle<ObjectTemplateInfo> object_template); | 246 Handle<ObjectTemplateInfo> object_template); |
| 248 bool ConfigureGlobalObjects( | 247 bool ConfigureGlobalObjects( |
| 249 v8::Local<v8::ObjectTemplate> global_proxy_template); | 248 v8::Local<v8::ObjectTemplate> global_proxy_template); |
| 250 | 249 |
| 251 // Migrates all properties from the 'from' object to the 'to' | 250 // Migrates all properties from the 'from' object to the 'to' |
| 252 // object and overrides the prototype in 'to' with the one from | 251 // object and overrides the prototype in 'to' with the one from |
| 253 // 'from'. | 252 // 'from'. |
| 254 void TransferObject(Handle<JSObject> from, Handle<JSObject> to); | 253 void TransferObject(Handle<JSObject> from, Handle<JSObject> to); |
| 255 void TransferNamedProperties(Handle<JSObject> from, Handle<JSObject> to); | 254 void TransferNamedProperties(Handle<JSObject> from, Handle<JSObject> to); |
| (...skipping 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1862 InstallExperimentalNatives_##id(isolate, native_context, container); | 1861 InstallExperimentalNatives_##id(isolate, native_context, container); |
| 1863 | 1862 |
| 1864 HARMONY_INPROGRESS(INSTALL_NATIVE_FUNCTIONS_FOR) | 1863 HARMONY_INPROGRESS(INSTALL_NATIVE_FUNCTIONS_FOR) |
| 1865 HARMONY_STAGED(INSTALL_NATIVE_FUNCTIONS_FOR) | 1864 HARMONY_STAGED(INSTALL_NATIVE_FUNCTIONS_FOR) |
| 1866 HARMONY_SHIPPING(INSTALL_NATIVE_FUNCTIONS_FOR) | 1865 HARMONY_SHIPPING(INSTALL_NATIVE_FUNCTIONS_FOR) |
| 1867 #undef INSTALL_NATIVE_FUNCTIONS_FOR | 1866 #undef INSTALL_NATIVE_FUNCTIONS_FOR |
| 1868 } | 1867 } |
| 1869 | 1868 |
| 1870 #undef INSTALL_NATIVE | 1869 #undef INSTALL_NATIVE |
| 1871 | 1870 |
| 1871 |
| 1872 bool Bootstrapper::InstallJSBuiltins(Isolate* isolate, |
| 1873 Handle<JSObject> container) { |
| 1874 HandleScope scope(isolate); |
| 1875 Handle<JSBuiltinsObject> builtins = isolate->js_builtins_object(); |
| 1876 for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) { |
| 1877 Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i); |
| 1878 Handle<Object> function_object = |
| 1879 Object::GetProperty(isolate, container, Builtins::GetName(id)) |
| 1880 .ToHandleChecked(); |
| 1881 DCHECK(function_object->IsJSFunction()); |
| 1882 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); |
| 1883 builtins->set_javascript_builtin(id, *function); |
| 1884 } |
| 1885 return true; |
| 1886 } |
| 1887 |
| 1888 |
| 1872 #define EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(id) \ | 1889 #define EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(id) \ |
| 1873 void Genesis::InitializeGlobal_##id() {} | 1890 void Genesis::InitializeGlobal_##id() {} |
| 1874 | 1891 |
| 1875 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_modules) | 1892 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_modules) |
| 1876 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_array_includes) | 1893 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_array_includes) |
| 1877 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrow_functions) | 1894 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrow_functions) |
| 1878 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies) | 1895 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies) |
| 1879 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy) | 1896 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy) |
| 1880 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy_function) | 1897 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy_function) |
| 1881 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy_let) | 1898 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy_let) |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2091 JSObject::NormalizeProperties(utils, CLEAR_INOBJECT_PROPERTIES, 16, | 2108 JSObject::NormalizeProperties(utils, CLEAR_INOBJECT_PROPERTIES, 16, |
| 2092 "utils container for native scripts"); | 2109 "utils container for native scripts"); |
| 2093 native_context()->set_natives_utils_object(*utils); | 2110 native_context()->set_natives_utils_object(*utils); |
| 2094 | 2111 |
| 2095 int builtin_index = Natives::GetDebuggerCount(); | 2112 int builtin_index = Natives::GetDebuggerCount(); |
| 2096 // Only run prologue.js and runtime.js at this point. | 2113 // Only run prologue.js and runtime.js at this point. |
| 2097 DCHECK_EQ(builtin_index, Natives::GetIndex("prologue")); | 2114 DCHECK_EQ(builtin_index, Natives::GetIndex("prologue")); |
| 2098 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false; | 2115 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false; |
| 2099 DCHECK_EQ(builtin_index, Natives::GetIndex("runtime")); | 2116 DCHECK_EQ(builtin_index, Natives::GetIndex("runtime")); |
| 2100 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false; | 2117 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false; |
| 2101 if (!InstallJSBuiltins(builtins)) return false; | |
| 2102 | 2118 |
| 2103 // A thin context is ready at this point. | 2119 // A thin context is ready at this point. |
| 2104 if (context_type == THIN_CONTEXT) return true; | 2120 if (context_type == THIN_CONTEXT) return true; |
| 2105 | 2121 |
| 2106 if (FLAG_expose_natives_as != NULL) { | 2122 if (FLAG_expose_natives_as != NULL) { |
| 2107 Handle<String> utils_key = factory()->NewStringFromAsciiChecked("utils"); | 2123 Handle<String> utils_key = factory()->NewStringFromAsciiChecked("utils"); |
| 2108 JSObject::AddProperty(builtins, utils_key, utils, NONE); | 2124 JSObject::AddProperty(builtins, utils_key, utils, NONE); |
| 2109 } | 2125 } |
| 2110 | 2126 |
| 2111 { // -- S c r i p t | 2127 { // -- S c r i p t |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2901 base::OS::PrintError("Error installing extension '%s'.\n", | 2917 base::OS::PrintError("Error installing extension '%s'.\n", |
| 2902 current->extension()->name()); | 2918 current->extension()->name()); |
| 2903 isolate->clear_pending_exception(); | 2919 isolate->clear_pending_exception(); |
| 2904 } | 2920 } |
| 2905 extension_states->set_state(current, INSTALLED); | 2921 extension_states->set_state(current, INSTALLED); |
| 2906 isolate->NotifyExtensionInstalled(); | 2922 isolate->NotifyExtensionInstalled(); |
| 2907 return result; | 2923 return result; |
| 2908 } | 2924 } |
| 2909 | 2925 |
| 2910 | 2926 |
| 2911 bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) { | |
| 2912 HandleScope scope(isolate()); | |
| 2913 for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) { | |
| 2914 Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i); | |
| 2915 Handle<Object> function_object = Object::GetProperty( | |
| 2916 isolate(), builtins, Builtins::GetName(id)).ToHandleChecked(); | |
| 2917 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); | |
| 2918 builtins->set_javascript_builtin(id, *function); | |
| 2919 } | |
| 2920 return true; | |
| 2921 } | |
| 2922 | |
| 2923 | |
| 2924 bool Genesis::ConfigureGlobalObjects( | 2927 bool Genesis::ConfigureGlobalObjects( |
| 2925 v8::Local<v8::ObjectTemplate> global_proxy_template) { | 2928 v8::Local<v8::ObjectTemplate> global_proxy_template) { |
| 2926 Handle<JSObject> global_proxy( | 2929 Handle<JSObject> global_proxy( |
| 2927 JSObject::cast(native_context()->global_proxy())); | 2930 JSObject::cast(native_context()->global_proxy())); |
| 2928 Handle<JSObject> global_object( | 2931 Handle<JSObject> global_object( |
| 2929 JSObject::cast(native_context()->global_object())); | 2932 JSObject::cast(native_context()->global_object())); |
| 2930 | 2933 |
| 2931 if (!global_proxy_template.IsEmpty()) { | 2934 if (!global_proxy_template.IsEmpty()) { |
| 2932 // Configure the global proxy object. | 2935 // Configure the global proxy object. |
| 2933 Handle<ObjectTemplateInfo> global_proxy_data = | 2936 Handle<ObjectTemplateInfo> global_proxy_data = |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3278 } | 3281 } |
| 3279 | 3282 |
| 3280 | 3283 |
| 3281 // Called when the top-level V8 mutex is destroyed. | 3284 // Called when the top-level V8 mutex is destroyed. |
| 3282 void Bootstrapper::FreeThreadResources() { | 3285 void Bootstrapper::FreeThreadResources() { |
| 3283 DCHECK(!IsActive()); | 3286 DCHECK(!IsActive()); |
| 3284 } | 3287 } |
| 3285 | 3288 |
| 3286 } // namespace internal | 3289 } // namespace internal |
| 3287 } // namespace v8 | 3290 } // namespace v8 |
| OLD | NEW |