| 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 DECLARE_FEATURE_INITIALIZATION(promise_extra, "") | 205 DECLARE_FEATURE_INITIALIZATION(promise_extra, "") |
| 206 #undef DECLARE_FEATURE_INITIALIZATION | 206 #undef DECLARE_FEATURE_INITIALIZATION |
| 207 | 207 |
| 208 Handle<JSFunction> InstallArrayBuffer(Handle<JSObject> target, |
| 209 const char* name); |
| 208 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, | 210 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, |
| 209 const char* name, | 211 const char* name, |
| 210 ElementsKind elements_kind); | 212 ElementsKind elements_kind); |
| 211 bool InstallNatives(ContextType context_type); | 213 bool InstallNatives(ContextType context_type); |
| 212 | 214 |
| 213 void InstallTypedArray(const char* name, ElementsKind elements_kind, | 215 void InstallTypedArray(const char* name, ElementsKind elements_kind, |
| 214 Handle<JSFunction>* fun); | 216 Handle<JSFunction>* fun); |
| 215 bool InstallExperimentalNatives(); | 217 bool InstallExperimentalNatives(); |
| 216 bool InstallExtraNatives(); | 218 bool InstallExtraNatives(); |
| 217 bool InstallExperimentalExtraNatives(); | 219 bool InstallExperimentalExtraNatives(); |
| (...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1338 cons, | 1340 cons, |
| 1339 Handle<Object>(native_context()->initial_object_prototype(), isolate)); | 1341 Handle<Object>(native_context()->initial_object_prototype(), isolate)); |
| 1340 cons->shared()->set_instance_class_name(*name); | 1342 cons->shared()->set_instance_class_name(*name); |
| 1341 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); | 1343 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); |
| 1342 DCHECK(json_object->IsJSObject()); | 1344 DCHECK(json_object->IsJSObject()); |
| 1343 JSObject::AddProperty(global, name, json_object, DONT_ENUM); | 1345 JSObject::AddProperty(global, name, json_object, DONT_ENUM); |
| 1344 } | 1346 } |
| 1345 | 1347 |
| 1346 { // -- A r r a y B u f f e r | 1348 { // -- A r r a y B u f f e r |
| 1347 Handle<JSFunction> array_buffer_fun = | 1349 Handle<JSFunction> array_buffer_fun = |
| 1348 InstallFunction( | 1350 InstallArrayBuffer(global, "ArrayBuffer"); |
| 1349 global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE, | |
| 1350 JSArrayBuffer::kSizeWithInternalFields, | |
| 1351 isolate->initial_object_prototype(), | |
| 1352 Builtins::kIllegal); | |
| 1353 InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun, | 1351 InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun, |
| 1354 Context::ARRAY_BUFFER_FUN_INDEX); | 1352 Context::ARRAY_BUFFER_FUN_INDEX); |
| 1355 } | 1353 } |
| 1356 | 1354 |
| 1357 { // -- T y p e d A r r a y s | 1355 { // -- T y p e d A r r a y s |
| 1358 #define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ | 1356 #define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ |
| 1359 { \ | 1357 { \ |
| 1360 Handle<JSFunction> fun; \ | 1358 Handle<JSFunction> fun; \ |
| 1361 InstallTypedArray(#Type "Array", TYPE##_ELEMENTS, &fun); \ | 1359 InstallTypedArray(#Type "Array", TYPE##_ELEMENTS, &fun); \ |
| 1362 InstallWithIntrinsicDefaultProto(isolate, fun, \ | 1360 InstallWithIntrinsicDefaultProto(isolate, fun, \ |
| (...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2230 SimpleInstallFunction(reflect, factory->set_string(), | 2228 SimpleInstallFunction(reflect, factory->set_string(), |
| 2231 Builtins::kReflectSet, 3, false); | 2229 Builtins::kReflectSet, 3, false); |
| 2232 SimpleInstallFunction(reflect, factory->setPrototypeOf_string(), | 2230 SimpleInstallFunction(reflect, factory->setPrototypeOf_string(), |
| 2233 Builtins::kReflectSetPrototypeOf, 2, true); | 2231 Builtins::kReflectSetPrototypeOf, 2, true); |
| 2234 } | 2232 } |
| 2235 | 2233 |
| 2236 | 2234 |
| 2237 void Genesis::InitializeGlobal_harmony_sharedarraybuffer() { | 2235 void Genesis::InitializeGlobal_harmony_sharedarraybuffer() { |
| 2238 if (!FLAG_harmony_sharedarraybuffer) return; | 2236 if (!FLAG_harmony_sharedarraybuffer) return; |
| 2239 | 2237 |
| 2240 Handle<JSGlobalObject> global( | 2238 Handle<JSGlobalObject> global(native_context()->global_object()); |
| 2241 JSGlobalObject::cast(native_context()->global_object())); | 2239 Handle<JSFunction> shared_array_buffer_fun = |
| 2242 | 2240 InstallArrayBuffer(global, "SharedArrayBuffer"); |
| 2243 Handle<JSFunction> shared_array_buffer_fun = InstallFunction( | |
| 2244 global, "SharedArrayBuffer", JS_ARRAY_BUFFER_TYPE, | |
| 2245 JSArrayBuffer::kSizeWithInternalFields, | |
| 2246 isolate()->initial_object_prototype(), Builtins::kIllegal); | |
| 2247 native_context()->set_shared_array_buffer_fun(*shared_array_buffer_fun); | 2241 native_context()->set_shared_array_buffer_fun(*shared_array_buffer_fun); |
| 2248 } | 2242 } |
| 2249 | 2243 |
| 2250 | 2244 |
| 2251 void Genesis::InitializeGlobal_harmony_simd() { | 2245 void Genesis::InitializeGlobal_harmony_simd() { |
| 2252 if (!FLAG_harmony_simd) return; | 2246 if (!FLAG_harmony_simd) return; |
| 2253 | 2247 |
| 2254 Handle<JSGlobalObject> global( | 2248 Handle<JSGlobalObject> global( |
| 2255 JSGlobalObject::cast(native_context()->global_object())); | 2249 JSGlobalObject::cast(native_context()->global_object())); |
| 2256 Isolate* isolate = global->GetIsolate(); | 2250 Isolate* isolate = global->GetIsolate(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2328 proxy_function->shared()->set_construct_stub( | 2322 proxy_function->shared()->set_construct_stub( |
| 2329 *isolate->builtins()->ProxyConstructor_ConstructStub()); | 2323 *isolate->builtins()->ProxyConstructor_ConstructStub()); |
| 2330 proxy_function->shared()->set_internal_formal_parameter_count(2); | 2324 proxy_function->shared()->set_internal_formal_parameter_count(2); |
| 2331 proxy_function->shared()->set_length(2); | 2325 proxy_function->shared()->set_length(2); |
| 2332 | 2326 |
| 2333 native_context()->set_proxy_function(*proxy_function); | 2327 native_context()->set_proxy_function(*proxy_function); |
| 2334 InstallFunction(global, name, proxy_function, factory->Object_string()); | 2328 InstallFunction(global, name, proxy_function, factory->Object_string()); |
| 2335 } | 2329 } |
| 2336 | 2330 |
| 2337 | 2331 |
| 2332 Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target, |
| 2333 const char* name) { |
| 2334 // Setup the {prototype} with the given {name} for @@toStringTag. |
| 2335 Handle<JSObject> prototype = |
| 2336 factory()->NewJSObject(isolate()->object_function(), TENURED); |
| 2337 JSObject::AddProperty(prototype, factory()->to_string_tag_symbol(), |
| 2338 factory()->NewStringFromAsciiChecked(name), |
| 2339 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); |
| 2340 |
| 2341 // Allocate the constructor with the given {prototype}. |
| 2342 Handle<JSFunction> array_buffer_fun = |
| 2343 InstallFunction(target, name, JS_ARRAY_BUFFER_TYPE, |
| 2344 JSArrayBuffer::kSizeWithInternalFields, prototype, |
| 2345 Builtins::kArrayBufferConstructor); |
| 2346 array_buffer_fun->shared()->set_construct_stub( |
| 2347 *isolate()->builtins()->ArrayBufferConstructor_ConstructStub()); |
| 2348 array_buffer_fun->shared()->DontAdaptArguments(); |
| 2349 array_buffer_fun->shared()->set_length(1); |
| 2350 |
| 2351 // Install the "constructor" property on the {prototype}. |
| 2352 JSObject::AddProperty(prototype, factory()->constructor_string(), |
| 2353 array_buffer_fun, DONT_ENUM); |
| 2354 |
| 2355 SimpleInstallFunction(array_buffer_fun, factory()->isView_string(), |
| 2356 Builtins::kArrayBufferIsView, 1, true); |
| 2357 |
| 2358 return array_buffer_fun; |
| 2359 } |
| 2360 |
| 2361 |
| 2338 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, | 2362 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, |
| 2339 const char* name, | 2363 const char* name, |
| 2340 ElementsKind elements_kind) { | 2364 ElementsKind elements_kind) { |
| 2341 // --- I n t e r n a l A r r a y --- | 2365 // --- I n t e r n a l A r r a y --- |
| 2342 // An array constructor on the builtins object that works like | 2366 // An array constructor on the builtins object that works like |
| 2343 // the public Array constructor, except that its prototype | 2367 // the public Array constructor, except that its prototype |
| 2344 // doesn't inherit from Object.prototype. | 2368 // doesn't inherit from Object.prototype. |
| 2345 // To be used only for internal work by builtins. Instances | 2369 // To be used only for internal work by builtins. Instances |
| 2346 // must not be leaked to user code. | 2370 // must not be leaked to user code. |
| 2347 Handle<JSObject> prototype = | 2371 Handle<JSObject> prototype = |
| (...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3358 } | 3382 } |
| 3359 | 3383 |
| 3360 | 3384 |
| 3361 // Called when the top-level V8 mutex is destroyed. | 3385 // Called when the top-level V8 mutex is destroyed. |
| 3362 void Bootstrapper::FreeThreadResources() { | 3386 void Bootstrapper::FreeThreadResources() { |
| 3363 DCHECK(!IsActive()); | 3387 DCHECK(!IsActive()); |
| 3364 } | 3388 } |
| 3365 | 3389 |
| 3366 } // namespace internal | 3390 } // namespace internal |
| 3367 } // namespace v8 | 3391 } // namespace v8 |
| OLD | NEW |