| 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/ieee754.h" | 9 #include "src/base/ieee754.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 | 214 |
| 215 HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION) | 215 HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION) |
| 216 HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION) | 216 HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION) |
| 217 HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION) | 217 HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION) |
| 218 #undef DECLARE_FEATURE_INITIALIZATION | 218 #undef DECLARE_FEATURE_INITIALIZATION |
| 219 | 219 |
| 220 void InitializeGlobal_enable_fast_array_builtins(); | 220 void InitializeGlobal_enable_fast_array_builtins(); |
| 221 | 221 |
| 222 Handle<JSFunction> InstallArrayBuffer(Handle<JSObject> target, | 222 Handle<JSFunction> InstallArrayBuffer(Handle<JSObject> target, |
| 223 const char* name, Builtins::Name call, | 223 const char* name, Builtins::Name call, |
| 224 BuiltinFunctionId id); | 224 BuiltinFunctionId id, bool is_shared); |
| 225 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, | 225 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, |
| 226 const char* name, | 226 const char* name, |
| 227 ElementsKind elements_kind); | 227 ElementsKind elements_kind); |
| 228 bool InstallNatives(GlobalContextType context_type); | 228 bool InstallNatives(GlobalContextType context_type); |
| 229 | 229 |
| 230 void InstallTypedArray(const char* name, ElementsKind elements_kind, | 230 void InstallTypedArray(const char* name, ElementsKind elements_kind, |
| 231 Handle<JSFunction>* fun); | 231 Handle<JSFunction>* fun); |
| 232 bool InstallExperimentalNatives(); | 232 bool InstallExperimentalNatives(); |
| 233 bool InstallExtraNatives(); | 233 bool InstallExtraNatives(); |
| 234 bool InstallExperimentalExtraNatives(); | 234 bool InstallExperimentalExtraNatives(); |
| (...skipping 2187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2422 v8_break_iterator_constructor, DONT_ENUM); | 2422 v8_break_iterator_constructor, DONT_ENUM); |
| 2423 InstallWithIntrinsicDefaultProto( | 2423 InstallWithIntrinsicDefaultProto( |
| 2424 isolate, v8_break_iterator_constructor, | 2424 isolate, v8_break_iterator_constructor, |
| 2425 Context::INTL_V8_BREAK_ITERATOR_FUNCTION_INDEX); | 2425 Context::INTL_V8_BREAK_ITERATOR_FUNCTION_INDEX); |
| 2426 } | 2426 } |
| 2427 #endif // V8_I18N_SUPPORT | 2427 #endif // V8_I18N_SUPPORT |
| 2428 | 2428 |
| 2429 { // -- A r r a y B u f f e r | 2429 { // -- A r r a y B u f f e r |
| 2430 Handle<JSFunction> array_buffer_fun = InstallArrayBuffer( | 2430 Handle<JSFunction> array_buffer_fun = InstallArrayBuffer( |
| 2431 global, "ArrayBuffer", Builtins::kArrayBufferPrototypeGetByteLength, | 2431 global, "ArrayBuffer", Builtins::kArrayBufferPrototypeGetByteLength, |
| 2432 BuiltinFunctionId::kArrayBufferByteLength); | 2432 BuiltinFunctionId::kArrayBufferByteLength, false); |
| 2433 InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun, | 2433 InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun, |
| 2434 Context::ARRAY_BUFFER_FUN_INDEX); | 2434 Context::ARRAY_BUFFER_FUN_INDEX); |
| 2435 InstallSpeciesGetter(array_buffer_fun); | 2435 InstallSpeciesGetter(array_buffer_fun); |
| 2436 } | 2436 } |
| 2437 | 2437 |
| 2438 { // -- T y p e d A r r a y | 2438 { // -- T y p e d A r r a y |
| 2439 Handle<JSObject> prototype = | 2439 Handle<JSObject> prototype = |
| 2440 factory->NewJSObject(isolate->object_function(), TENURED); | 2440 factory->NewJSObject(isolate->object_function(), TENURED); |
| 2441 native_context()->set_typed_array_prototype(*prototype); | 2441 native_context()->set_typed_array_prototype(*prototype); |
| 2442 | 2442 |
| (...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3555 void Genesis::InitializeGlobal_harmony_sharedarraybuffer() { | 3555 void Genesis::InitializeGlobal_harmony_sharedarraybuffer() { |
| 3556 if (!FLAG_harmony_sharedarraybuffer) return; | 3556 if (!FLAG_harmony_sharedarraybuffer) return; |
| 3557 | 3557 |
| 3558 Handle<JSGlobalObject> global(native_context()->global_object()); | 3558 Handle<JSGlobalObject> global(native_context()->global_object()); |
| 3559 Isolate* isolate = global->GetIsolate(); | 3559 Isolate* isolate = global->GetIsolate(); |
| 3560 Factory* factory = isolate->factory(); | 3560 Factory* factory = isolate->factory(); |
| 3561 | 3561 |
| 3562 Handle<JSFunction> shared_array_buffer_fun = | 3562 Handle<JSFunction> shared_array_buffer_fun = |
| 3563 InstallArrayBuffer(global, "SharedArrayBuffer", | 3563 InstallArrayBuffer(global, "SharedArrayBuffer", |
| 3564 Builtins::kSharedArrayBufferPrototypeGetByteLength, | 3564 Builtins::kSharedArrayBufferPrototypeGetByteLength, |
| 3565 BuiltinFunctionId::kSharedArrayBufferByteLength); | 3565 BuiltinFunctionId::kSharedArrayBufferByteLength, true); |
| 3566 native_context()->set_shared_array_buffer_fun(*shared_array_buffer_fun); | 3566 native_context()->set_shared_array_buffer_fun(*shared_array_buffer_fun); |
| 3567 | 3567 |
| 3568 Handle<String> name = factory->InternalizeUtf8String("Atomics"); | 3568 Handle<String> name = factory->InternalizeUtf8String("Atomics"); |
| 3569 Handle<JSFunction> cons = factory->NewFunction(name); | 3569 Handle<JSFunction> cons = factory->NewFunction(name); |
| 3570 JSFunction::SetInstancePrototype( | 3570 JSFunction::SetInstancePrototype( |
| 3571 cons, | 3571 cons, |
| 3572 Handle<Object>(native_context()->initial_object_prototype(), isolate)); | 3572 Handle<Object>(native_context()->initial_object_prototype(), isolate)); |
| 3573 Handle<JSObject> atomics_object = factory->NewJSObject(cons, TENURED); | 3573 Handle<JSObject> atomics_object = factory->NewJSObject(cons, TENURED); |
| 3574 DCHECK(atomics_object->IsJSObject()); | 3574 DCHECK(atomics_object->IsJSObject()); |
| 3575 JSObject::AddProperty(global, name, atomics_object, DONT_ENUM); | 3575 JSObject::AddProperty(global, name, atomics_object, DONT_ENUM); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3673 factory()->InternalizeUtf8String("ToLocaleUpperCaseI18N")) | 3673 factory()->InternalizeUtf8String("ToLocaleUpperCaseI18N")) |
| 3674 .ToHandleChecked()); | 3674 .ToHandleChecked()); |
| 3675 SetFunction(string_prototype, to_locale_upper_case, | 3675 SetFunction(string_prototype, to_locale_upper_case, |
| 3676 factory()->InternalizeUtf8String("toLocaleUpperCase")); | 3676 factory()->InternalizeUtf8String("toLocaleUpperCase")); |
| 3677 } | 3677 } |
| 3678 #endif | 3678 #endif |
| 3679 | 3679 |
| 3680 Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target, | 3680 Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target, |
| 3681 const char* name, | 3681 const char* name, |
| 3682 Builtins::Name call, | 3682 Builtins::Name call, |
| 3683 BuiltinFunctionId id) { | 3683 BuiltinFunctionId id, |
| 3684 bool is_shared) { |
| 3684 // Create the %ArrayBufferPrototype% | 3685 // Create the %ArrayBufferPrototype% |
| 3685 // Setup the {prototype} with the given {name} for @@toStringTag. | 3686 // Setup the {prototype} with the given {name} for @@toStringTag. |
| 3686 Handle<JSObject> prototype = | 3687 Handle<JSObject> prototype = |
| 3687 factory()->NewJSObject(isolate()->object_function(), TENURED); | 3688 factory()->NewJSObject(isolate()->object_function(), TENURED); |
| 3688 JSObject::AddProperty(prototype, factory()->to_string_tag_symbol(), | 3689 JSObject::AddProperty(prototype, factory()->to_string_tag_symbol(), |
| 3689 factory()->NewStringFromAsciiChecked(name), | 3690 factory()->NewStringFromAsciiChecked(name), |
| 3690 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); | 3691 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); |
| 3691 | 3692 |
| 3692 // Allocate the constructor with the given {prototype}. | 3693 // Allocate the constructor with the given {prototype}. |
| 3693 Handle<JSFunction> array_buffer_fun = | 3694 Handle<JSFunction> array_buffer_fun = |
| 3694 InstallFunction(target, name, JS_ARRAY_BUFFER_TYPE, | 3695 InstallFunction(target, name, JS_ARRAY_BUFFER_TYPE, |
| 3695 JSArrayBuffer::kSizeWithInternalFields, prototype, | 3696 JSArrayBuffer::kSizeWithInternalFields, prototype, |
| 3696 Builtins::kArrayBufferConstructor); | 3697 Builtins::kArrayBufferConstructor); |
| 3697 array_buffer_fun->shared()->SetConstructStub( | 3698 array_buffer_fun->shared()->SetConstructStub( |
| 3698 *isolate()->builtins()->ArrayBufferConstructor_ConstructStub()); | 3699 *isolate()->builtins()->ArrayBufferConstructor_ConstructStub()); |
| 3699 array_buffer_fun->shared()->DontAdaptArguments(); | 3700 array_buffer_fun->shared()->DontAdaptArguments(); |
| 3700 array_buffer_fun->shared()->set_length(1); | 3701 array_buffer_fun->shared()->set_length(1); |
| 3701 | 3702 |
| 3702 // Install the "constructor" property on the {prototype}. | 3703 // Install the "constructor" property on the {prototype}. |
| 3703 JSObject::AddProperty(prototype, factory()->constructor_string(), | 3704 JSObject::AddProperty(prototype, factory()->constructor_string(), |
| 3704 array_buffer_fun, DONT_ENUM); | 3705 array_buffer_fun, DONT_ENUM); |
| 3705 | 3706 |
| 3706 SimpleInstallFunction(array_buffer_fun, factory()->isView_string(), | 3707 SimpleInstallFunction(array_buffer_fun, factory()->isView_string(), |
| 3707 Builtins::kArrayBufferIsView, 1, true); | 3708 Builtins::kArrayBufferIsView, 1, true); |
| 3708 | 3709 |
| 3709 // Install the "byteLength" getter on the {prototype}. | 3710 // Install the "byteLength" getter on the {prototype}. |
| 3710 SimpleInstallGetter(prototype, factory()->byte_length_string(), call, false, | 3711 SimpleInstallGetter(prototype, factory()->byte_length_string(), call, false, |
| 3711 id); | 3712 id); |
| 3712 | 3713 |
| 3714 // TODO(binji): support SharedArrayBuffer.prototype.slice as well. |
| 3715 if (!is_shared) { |
| 3716 SimpleInstallFunction(prototype, "slice", |
| 3717 Builtins::kArrayBufferPrototypeSlice, 2, true); |
| 3718 } |
| 3719 |
| 3713 return array_buffer_fun; | 3720 return array_buffer_fun; |
| 3714 } | 3721 } |
| 3715 | 3722 |
| 3716 | 3723 |
| 3717 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, | 3724 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, |
| 3718 const char* name, | 3725 const char* name, |
| 3719 ElementsKind elements_kind) { | 3726 ElementsKind elements_kind) { |
| 3720 // --- I n t e r n a l A r r a y --- | 3727 // --- I n t e r n a l A r r a y --- |
| 3721 // An array constructor on the builtins object that works like | 3728 // An array constructor on the builtins object that works like |
| 3722 // the public Array constructor, except that its prototype | 3729 // the public Array constructor, except that its prototype |
| (...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4889 } | 4896 } |
| 4890 | 4897 |
| 4891 | 4898 |
| 4892 // Called when the top-level V8 mutex is destroyed. | 4899 // Called when the top-level V8 mutex is destroyed. |
| 4893 void Bootstrapper::FreeThreadResources() { | 4900 void Bootstrapper::FreeThreadResources() { |
| 4894 DCHECK(!IsActive()); | 4901 DCHECK(!IsActive()); |
| 4895 } | 4902 } |
| 4896 | 4903 |
| 4897 } // namespace internal | 4904 } // namespace internal |
| 4898 } // namespace v8 | 4905 } // namespace v8 |
| OLD | NEW |