| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 void ConfigureUtilsObject(ContextType context_type); | 197 void ConfigureUtilsObject(ContextType context_type); |
| 198 | 198 |
| 199 #define DECLARE_FEATURE_INITIALIZATION(id, descr) \ | 199 #define DECLARE_FEATURE_INITIALIZATION(id, descr) \ |
| 200 void InitializeGlobal_##id(); | 200 void InitializeGlobal_##id(); |
| 201 | 201 |
| 202 HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION) | 202 HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION) |
| 203 HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION) | 203 HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION) |
| 204 HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION) | 204 HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION) |
| 205 #undef DECLARE_FEATURE_INITIALIZATION | 205 #undef DECLARE_FEATURE_INITIALIZATION |
| 206 | 206 |
| 207 Handle<JSFunction> InstallArrayBuffer(Handle<JSObject> target, |
| 208 const char* name); |
| 207 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, | 209 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, |
| 208 const char* name, | 210 const char* name, |
| 209 ElementsKind elements_kind); | 211 ElementsKind elements_kind); |
| 210 bool InstallNatives(ContextType context_type); | 212 bool InstallNatives(ContextType context_type); |
| 211 | 213 |
| 212 void InstallTypedArray(const char* name, ElementsKind elements_kind, | 214 void InstallTypedArray(const char* name, ElementsKind elements_kind, |
| 213 Handle<JSFunction>* fun); | 215 Handle<JSFunction>* fun); |
| 214 bool InstallExperimentalNatives(); | 216 bool InstallExperimentalNatives(); |
| 215 bool InstallExtraNatives(); | 217 bool InstallExtraNatives(); |
| 216 bool InstallExperimentalExtraNatives(); | 218 bool InstallExperimentalExtraNatives(); |
| (...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1223 cons, | 1225 cons, |
| 1224 Handle<Object>(native_context()->initial_object_prototype(), isolate)); | 1226 Handle<Object>(native_context()->initial_object_prototype(), isolate)); |
| 1225 cons->shared()->set_instance_class_name(*name); | 1227 cons->shared()->set_instance_class_name(*name); |
| 1226 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); | 1228 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); |
| 1227 DCHECK(json_object->IsJSObject()); | 1229 DCHECK(json_object->IsJSObject()); |
| 1228 JSObject::AddProperty(global, name, json_object, DONT_ENUM); | 1230 JSObject::AddProperty(global, name, json_object, DONT_ENUM); |
| 1229 } | 1231 } |
| 1230 | 1232 |
| 1231 { // -- A r r a y B u f f e r | 1233 { // -- A r r a y B u f f e r |
| 1232 Handle<JSFunction> array_buffer_fun = | 1234 Handle<JSFunction> array_buffer_fun = |
| 1233 InstallFunction( | 1235 InstallArrayBuffer(global, "ArrayBuffer"); |
| 1234 global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE, | |
| 1235 JSArrayBuffer::kSizeWithInternalFields, | |
| 1236 isolate->initial_object_prototype(), | |
| 1237 Builtins::kIllegal); | |
| 1238 native_context()->set_array_buffer_fun(*array_buffer_fun); | 1236 native_context()->set_array_buffer_fun(*array_buffer_fun); |
| 1239 } | 1237 } |
| 1240 | 1238 |
| 1241 { // -- T y p e d A r r a y s | 1239 { // -- T y p e d A r r a y s |
| 1242 #define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ | 1240 #define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ |
| 1243 { \ | 1241 { \ |
| 1244 Handle<JSFunction> fun; \ | 1242 Handle<JSFunction> fun; \ |
| 1245 InstallTypedArray(#Type "Array", TYPE##_ELEMENTS, &fun); \ | 1243 InstallTypedArray(#Type "Array", TYPE##_ELEMENTS, &fun); \ |
| 1246 native_context()->set_##type##_array_fun(*fun); \ | 1244 native_context()->set_##type##_array_fun(*fun); \ |
| 1247 } | 1245 } |
| (...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2056 SimpleInstallFunction(reflect, factory->set_string(), | 2054 SimpleInstallFunction(reflect, factory->set_string(), |
| 2057 Builtins::kReflectSet, 3, false); | 2055 Builtins::kReflectSet, 3, false); |
| 2058 SimpleInstallFunction(reflect, factory->setPrototypeOf_string(), | 2056 SimpleInstallFunction(reflect, factory->setPrototypeOf_string(), |
| 2059 Builtins::kReflectSetPrototypeOf, 2, true); | 2057 Builtins::kReflectSetPrototypeOf, 2, true); |
| 2060 } | 2058 } |
| 2061 | 2059 |
| 2062 | 2060 |
| 2063 void Genesis::InitializeGlobal_harmony_sharedarraybuffer() { | 2061 void Genesis::InitializeGlobal_harmony_sharedarraybuffer() { |
| 2064 if (!FLAG_harmony_sharedarraybuffer) return; | 2062 if (!FLAG_harmony_sharedarraybuffer) return; |
| 2065 | 2063 |
| 2066 Handle<JSGlobalObject> global( | 2064 Handle<JSGlobalObject> global(native_context()->global_object()); |
| 2067 JSGlobalObject::cast(native_context()->global_object())); | 2065 Handle<JSFunction> shared_array_buffer_fun = |
| 2068 | 2066 InstallArrayBuffer(global, "SharedArrayBuffer"); |
| 2069 Handle<JSFunction> shared_array_buffer_fun = InstallFunction( | |
| 2070 global, "SharedArrayBuffer", JS_ARRAY_BUFFER_TYPE, | |
| 2071 JSArrayBuffer::kSizeWithInternalFields, | |
| 2072 isolate()->initial_object_prototype(), Builtins::kIllegal); | |
| 2073 native_context()->set_shared_array_buffer_fun(*shared_array_buffer_fun); | 2067 native_context()->set_shared_array_buffer_fun(*shared_array_buffer_fun); |
| 2074 } | 2068 } |
| 2075 | 2069 |
| 2076 | 2070 |
| 2077 void Genesis::InitializeGlobal_harmony_simd() { | 2071 void Genesis::InitializeGlobal_harmony_simd() { |
| 2078 if (!FLAG_harmony_simd) return; | 2072 if (!FLAG_harmony_simd) return; |
| 2079 | 2073 |
| 2080 Handle<JSGlobalObject> global( | 2074 Handle<JSGlobalObject> global( |
| 2081 JSGlobalObject::cast(native_context()->global_object())); | 2075 JSGlobalObject::cast(native_context()->global_object())); |
| 2082 Isolate* isolate = global->GetIsolate(); | 2076 Isolate* isolate = global->GetIsolate(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2116 // TODO(verwaest): Set to null in InstallFunction. | 2110 // TODO(verwaest): Set to null in InstallFunction. |
| 2117 proxy_fun->initial_map()->set_prototype(isolate->heap()->null_value()); | 2111 proxy_fun->initial_map()->set_prototype(isolate->heap()->null_value()); |
| 2118 proxy_fun->shared()->set_construct_stub( | 2112 proxy_fun->shared()->set_construct_stub( |
| 2119 *isolate->builtins()->ProxyConstructor_ConstructStub()); | 2113 *isolate->builtins()->ProxyConstructor_ConstructStub()); |
| 2120 proxy_fun->shared()->set_internal_formal_parameter_count(2); | 2114 proxy_fun->shared()->set_internal_formal_parameter_count(2); |
| 2121 proxy_fun->shared()->set_length(2); | 2115 proxy_fun->shared()->set_length(2); |
| 2122 native_context()->set_proxy_function(*proxy_fun); | 2116 native_context()->set_proxy_function(*proxy_fun); |
| 2123 } | 2117 } |
| 2124 | 2118 |
| 2125 | 2119 |
| 2120 Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target, |
| 2121 const char* name) { |
| 2122 // Setup the {prototype} with the given {name} for @@toStringTag. |
| 2123 Handle<JSObject> prototype = |
| 2124 factory()->NewJSObject(isolate()->object_function(), TENURED); |
| 2125 JSObject::AddProperty(prototype, factory()->to_string_tag_symbol(), |
| 2126 factory()->NewStringFromAsciiChecked(name), |
| 2127 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); |
| 2128 |
| 2129 // Allocate the constructor with the given {prototype}. |
| 2130 Handle<JSFunction> array_buffer_fun = |
| 2131 InstallFunction(target, name, JS_ARRAY_BUFFER_TYPE, |
| 2132 JSArrayBuffer::kSizeWithInternalFields, prototype, |
| 2133 Builtins::kArrayBufferConstructor); |
| 2134 array_buffer_fun->shared()->set_construct_stub( |
| 2135 *isolate()->builtins()->ArrayBufferConstructor_ConstructStub()); |
| 2136 array_buffer_fun->shared()->set_internal_formal_parameter_count(1); |
| 2137 array_buffer_fun->shared()->set_length(1); |
| 2138 |
| 2139 // Install the "constructor" property on the {prototype}. |
| 2140 JSObject::AddProperty(prototype, factory()->constructor_string(), |
| 2141 array_buffer_fun, DONT_ENUM); |
| 2142 |
| 2143 Handle<JSFunction> array_buffer_is_view_fun = InstallFunction( |
| 2144 array_buffer_fun, "isView", JS_OBJECT_TYPE, JSObject::kHeaderSize, |
| 2145 MaybeHandle<JSObject>(), Builtins::kArrayBufferIsView); |
| 2146 array_buffer_is_view_fun->shared()->set_internal_formal_parameter_count(1); |
| 2147 array_buffer_is_view_fun->shared()->set_length(1); |
| 2148 |
| 2149 return array_buffer_fun; |
| 2150 } |
| 2151 |
| 2152 |
| 2126 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, | 2153 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, |
| 2127 const char* name, | 2154 const char* name, |
| 2128 ElementsKind elements_kind) { | 2155 ElementsKind elements_kind) { |
| 2129 // --- I n t e r n a l A r r a y --- | 2156 // --- I n t e r n a l A r r a y --- |
| 2130 // An array constructor on the builtins object that works like | 2157 // An array constructor on the builtins object that works like |
| 2131 // the public Array constructor, except that its prototype | 2158 // the public Array constructor, except that its prototype |
| 2132 // doesn't inherit from Object.prototype. | 2159 // doesn't inherit from Object.prototype. |
| 2133 // To be used only for internal work by builtins. Instances | 2160 // To be used only for internal work by builtins. Instances |
| 2134 // must not be leaked to user code. | 2161 // must not be leaked to user code. |
| 2135 Handle<JSObject> prototype = | 2162 Handle<JSObject> prototype = |
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3145 } | 3172 } |
| 3146 | 3173 |
| 3147 | 3174 |
| 3148 // Called when the top-level V8 mutex is destroyed. | 3175 // Called when the top-level V8 mutex is destroyed. |
| 3149 void Bootstrapper::FreeThreadResources() { | 3176 void Bootstrapper::FreeThreadResources() { |
| 3150 DCHECK(!IsActive()); | 3177 DCHECK(!IsActive()); |
| 3151 } | 3178 } |
| 3152 | 3179 |
| 3153 } // namespace internal | 3180 } // namespace internal |
| 3154 } // namespace v8 | 3181 } // namespace v8 |
| OLD | NEW |