| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 void InitializeGlobal_##id(); | 215 void InitializeGlobal_##id(); |
| 216 | 216 |
| 217 HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION) | 217 HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION) |
| 218 HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION) | 218 HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION) |
| 219 HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION) | 219 HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION) |
| 220 #undef DECLARE_FEATURE_INITIALIZATION | 220 #undef DECLARE_FEATURE_INITIALIZATION |
| 221 | 221 |
| 222 void InitializeGlobal_enable_fast_array_builtins(); | 222 void InitializeGlobal_enable_fast_array_builtins(); |
| 223 | 223 |
| 224 Handle<JSFunction> InstallArrayBuffer(Handle<JSObject> target, | 224 Handle<JSFunction> InstallArrayBuffer(Handle<JSObject> target, |
| 225 const char* name, Builtins::Name call, | 225 const char* name, |
| 226 BuiltinFunctionId id, bool is_shared); | 226 Builtins::Name call_byteLength, |
| 227 BuiltinFunctionId byteLength_id, |
| 228 Builtins::Name call_slice); |
| 227 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, | 229 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, |
| 228 const char* name, | 230 const char* name, |
| 229 ElementsKind elements_kind); | 231 ElementsKind elements_kind); |
| 230 bool InstallNatives(GlobalContextType context_type); | 232 bool InstallNatives(GlobalContextType context_type); |
| 231 | 233 |
| 232 void InstallTypedArray(const char* name, ElementsKind elements_kind, | 234 void InstallTypedArray(const char* name, ElementsKind elements_kind, |
| 233 Handle<JSFunction>* fun); | 235 Handle<JSFunction>* fun); |
| 234 bool InstallExperimentalNatives(); | 236 bool InstallExperimentalNatives(); |
| 235 bool InstallExtraNatives(); | 237 bool InstallExtraNatives(); |
| 236 bool InstallExperimentalExtraNatives(); | 238 bool InstallExperimentalExtraNatives(); |
| (...skipping 2313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2550 v8_break_iterator_constructor, DONT_ENUM); | 2552 v8_break_iterator_constructor, DONT_ENUM); |
| 2551 InstallWithIntrinsicDefaultProto( | 2553 InstallWithIntrinsicDefaultProto( |
| 2552 isolate, v8_break_iterator_constructor, | 2554 isolate, v8_break_iterator_constructor, |
| 2553 Context::INTL_V8_BREAK_ITERATOR_FUNCTION_INDEX); | 2555 Context::INTL_V8_BREAK_ITERATOR_FUNCTION_INDEX); |
| 2554 } | 2556 } |
| 2555 #endif // V8_I18N_SUPPORT | 2557 #endif // V8_I18N_SUPPORT |
| 2556 | 2558 |
| 2557 { // -- A r r a y B u f f e r | 2559 { // -- A r r a y B u f f e r |
| 2558 Handle<JSFunction> array_buffer_fun = InstallArrayBuffer( | 2560 Handle<JSFunction> array_buffer_fun = InstallArrayBuffer( |
| 2559 global, "ArrayBuffer", Builtins::kArrayBufferPrototypeGetByteLength, | 2561 global, "ArrayBuffer", Builtins::kArrayBufferPrototypeGetByteLength, |
| 2560 BuiltinFunctionId::kArrayBufferByteLength, false); | 2562 BuiltinFunctionId::kArrayBufferByteLength, |
| 2563 Builtins::kArrayBufferPrototypeSlice); |
| 2561 InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun, | 2564 InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun, |
| 2562 Context::ARRAY_BUFFER_FUN_INDEX); | 2565 Context::ARRAY_BUFFER_FUN_INDEX); |
| 2563 InstallSpeciesGetter(array_buffer_fun); | 2566 InstallSpeciesGetter(array_buffer_fun); |
| 2564 } | 2567 } |
| 2565 | 2568 |
| 2566 { // -- T y p e d A r r a y | 2569 { // -- T y p e d A r r a y |
| 2567 Handle<JSObject> prototype = | 2570 Handle<JSObject> prototype = |
| 2568 factory->NewJSObject(isolate->object_function(), TENURED); | 2571 factory->NewJSObject(isolate->object_function(), TENURED); |
| 2569 native_context()->set_typed_array_prototype(*prototype); | 2572 native_context()->set_typed_array_prototype(*prototype); |
| 2570 | 2573 |
| (...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3742 void Genesis::InitializeGlobal_harmony_sharedarraybuffer() { | 3745 void Genesis::InitializeGlobal_harmony_sharedarraybuffer() { |
| 3743 if (!FLAG_harmony_sharedarraybuffer) return; | 3746 if (!FLAG_harmony_sharedarraybuffer) return; |
| 3744 | 3747 |
| 3745 Handle<JSGlobalObject> global(native_context()->global_object()); | 3748 Handle<JSGlobalObject> global(native_context()->global_object()); |
| 3746 Isolate* isolate = global->GetIsolate(); | 3749 Isolate* isolate = global->GetIsolate(); |
| 3747 Factory* factory = isolate->factory(); | 3750 Factory* factory = isolate->factory(); |
| 3748 | 3751 |
| 3749 Handle<JSFunction> shared_array_buffer_fun = | 3752 Handle<JSFunction> shared_array_buffer_fun = |
| 3750 InstallArrayBuffer(global, "SharedArrayBuffer", | 3753 InstallArrayBuffer(global, "SharedArrayBuffer", |
| 3751 Builtins::kSharedArrayBufferPrototypeGetByteLength, | 3754 Builtins::kSharedArrayBufferPrototypeGetByteLength, |
| 3752 BuiltinFunctionId::kSharedArrayBufferByteLength, true); | 3755 BuiltinFunctionId::kSharedArrayBufferByteLength, |
| 3756 Builtins::kSharedArrayBufferPrototypeSlice); |
| 3753 native_context()->set_shared_array_buffer_fun(*shared_array_buffer_fun); | 3757 native_context()->set_shared_array_buffer_fun(*shared_array_buffer_fun); |
| 3754 | 3758 |
| 3755 Handle<String> name = factory->InternalizeUtf8String("Atomics"); | 3759 Handle<String> name = factory->InternalizeUtf8String("Atomics"); |
| 3756 Handle<JSFunction> cons = factory->NewFunction(name); | 3760 Handle<JSFunction> cons = factory->NewFunction(name); |
| 3757 JSFunction::SetInstancePrototype( | 3761 JSFunction::SetInstancePrototype( |
| 3758 cons, | 3762 cons, |
| 3759 Handle<Object>(native_context()->initial_object_prototype(), isolate)); | 3763 Handle<Object>(native_context()->initial_object_prototype(), isolate)); |
| 3760 Handle<JSObject> atomics_object = factory->NewJSObject(cons, TENURED); | 3764 Handle<JSObject> atomics_object = factory->NewJSObject(cons, TENURED); |
| 3761 DCHECK(atomics_object->IsJSObject()); | 3765 DCHECK(atomics_object->IsJSObject()); |
| 3762 JSObject::AddProperty(global, name, atomics_object, DONT_ENUM); | 3766 JSObject::AddProperty(global, name, atomics_object, DONT_ENUM); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3923 exports_container, | 3927 exports_container, |
| 3924 factory()->InternalizeUtf8String("ToLocaleUpperCaseI18N")) | 3928 factory()->InternalizeUtf8String("ToLocaleUpperCaseI18N")) |
| 3925 .ToHandleChecked()); | 3929 .ToHandleChecked()); |
| 3926 SetFunction(string_prototype, to_locale_upper_case, | 3930 SetFunction(string_prototype, to_locale_upper_case, |
| 3927 factory()->InternalizeUtf8String("toLocaleUpperCase")); | 3931 factory()->InternalizeUtf8String("toLocaleUpperCase")); |
| 3928 } | 3932 } |
| 3929 #endif | 3933 #endif |
| 3930 | 3934 |
| 3931 Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target, | 3935 Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target, |
| 3932 const char* name, | 3936 const char* name, |
| 3933 Builtins::Name call, | 3937 Builtins::Name call_byteLength, |
| 3934 BuiltinFunctionId id, | 3938 BuiltinFunctionId byteLength_id, |
| 3935 bool is_shared) { | 3939 Builtins::Name call_slice) { |
| 3936 // Create the %ArrayBufferPrototype% | 3940 // Create the %ArrayBufferPrototype% |
| 3937 // Setup the {prototype} with the given {name} for @@toStringTag. | 3941 // Setup the {prototype} with the given {name} for @@toStringTag. |
| 3938 Handle<JSObject> prototype = | 3942 Handle<JSObject> prototype = |
| 3939 factory()->NewJSObject(isolate()->object_function(), TENURED); | 3943 factory()->NewJSObject(isolate()->object_function(), TENURED); |
| 3940 JSObject::AddProperty(prototype, factory()->to_string_tag_symbol(), | 3944 JSObject::AddProperty(prototype, factory()->to_string_tag_symbol(), |
| 3941 factory()->NewStringFromAsciiChecked(name), | 3945 factory()->NewStringFromAsciiChecked(name), |
| 3942 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); | 3946 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); |
| 3943 | 3947 |
| 3944 // Allocate the constructor with the given {prototype}. | 3948 // Allocate the constructor with the given {prototype}. |
| 3945 Handle<JSFunction> array_buffer_fun = | 3949 Handle<JSFunction> array_buffer_fun = |
| 3946 InstallFunction(target, name, JS_ARRAY_BUFFER_TYPE, | 3950 InstallFunction(target, name, JS_ARRAY_BUFFER_TYPE, |
| 3947 JSArrayBuffer::kSizeWithInternalFields, prototype, | 3951 JSArrayBuffer::kSizeWithInternalFields, prototype, |
| 3948 Builtins::kArrayBufferConstructor); | 3952 Builtins::kArrayBufferConstructor); |
| 3949 array_buffer_fun->shared()->SetConstructStub( | 3953 array_buffer_fun->shared()->SetConstructStub( |
| 3950 *isolate()->builtins()->ArrayBufferConstructor_ConstructStub()); | 3954 *isolate()->builtins()->ArrayBufferConstructor_ConstructStub()); |
| 3951 array_buffer_fun->shared()->DontAdaptArguments(); | 3955 array_buffer_fun->shared()->DontAdaptArguments(); |
| 3952 array_buffer_fun->shared()->set_length(1); | 3956 array_buffer_fun->shared()->set_length(1); |
| 3953 | 3957 |
| 3954 // Install the "constructor" property on the {prototype}. | 3958 // Install the "constructor" property on the {prototype}. |
| 3955 JSObject::AddProperty(prototype, factory()->constructor_string(), | 3959 JSObject::AddProperty(prototype, factory()->constructor_string(), |
| 3956 array_buffer_fun, DONT_ENUM); | 3960 array_buffer_fun, DONT_ENUM); |
| 3957 | 3961 |
| 3958 SimpleInstallFunction(array_buffer_fun, factory()->isView_string(), | 3962 SimpleInstallFunction(array_buffer_fun, factory()->isView_string(), |
| 3959 Builtins::kArrayBufferIsView, 1, true); | 3963 Builtins::kArrayBufferIsView, 1, true); |
| 3960 | 3964 |
| 3961 // Install the "byteLength" getter on the {prototype}. | 3965 // Install the "byteLength" getter on the {prototype}. |
| 3962 SimpleInstallGetter(prototype, factory()->byte_length_string(), call, false, | 3966 SimpleInstallGetter(prototype, factory()->byte_length_string(), |
| 3963 id); | 3967 call_byteLength, false, byteLength_id); |
| 3964 | 3968 |
| 3965 // TODO(binji): support SharedArrayBuffer.prototype.slice as well. | 3969 SimpleInstallFunction(prototype, "slice", call_slice, 2, true); |
| 3966 if (!is_shared) { | |
| 3967 SimpleInstallFunction(prototype, "slice", | |
| 3968 Builtins::kArrayBufferPrototypeSlice, 2, true); | |
| 3969 } | |
| 3970 | 3970 |
| 3971 return array_buffer_fun; | 3971 return array_buffer_fun; |
| 3972 } | 3972 } |
| 3973 | 3973 |
| 3974 | 3974 |
| 3975 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, | 3975 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, |
| 3976 const char* name, | 3976 const char* name, |
| 3977 ElementsKind elements_kind) { | 3977 ElementsKind elements_kind) { |
| 3978 // --- I n t e r n a l A r r a y --- | 3978 // --- I n t e r n a l A r r a y --- |
| 3979 // An array constructor on the builtins object that works like | 3979 // An array constructor on the builtins object that works like |
| (...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5160 } | 5160 } |
| 5161 | 5161 |
| 5162 | 5162 |
| 5163 // Called when the top-level V8 mutex is destroyed. | 5163 // Called when the top-level V8 mutex is destroyed. |
| 5164 void Bootstrapper::FreeThreadResources() { | 5164 void Bootstrapper::FreeThreadResources() { |
| 5165 DCHECK(!IsActive()); | 5165 DCHECK(!IsActive()); |
| 5166 } | 5166 } |
| 5167 | 5167 |
| 5168 } // namespace internal | 5168 } // namespace internal |
| 5169 } // namespace v8 | 5169 } // namespace v8 |
| OLD | NEW |