| 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 HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION) | 214 HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION) |
| 215 HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION) | 215 HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION) |
| 216 HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION) | 216 HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION) |
| 217 #undef DECLARE_FEATURE_INITIALIZATION | 217 #undef DECLARE_FEATURE_INITIALIZATION |
| 218 | 218 |
| 219 void InstallOneBuiltinFunction(const char* object, const char* method, | 219 void InstallOneBuiltinFunction(const char* object, const char* method, |
| 220 Builtins::Name name); | 220 Builtins::Name name); |
| 221 void InitializeGlobal_experimental_fast_array_builtins(); | 221 void InitializeGlobal_experimental_fast_array_builtins(); |
| 222 | 222 |
| 223 Handle<JSFunction> InstallArrayBuffer(Handle<JSObject> target, | 223 Handle<JSFunction> InstallArrayBuffer(Handle<JSObject> target, |
| 224 const char* name, Builtins::Name call, | 224 const char* name, |
| 225 BuiltinFunctionId id, bool is_shared); | 225 Builtins::Name call_byteLength, |
| 226 BuiltinFunctionId byteLength_id, |
| 227 Builtins::Name call_slice); |
| 226 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, | 228 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, |
| 227 const char* name, | 229 const char* name, |
| 228 ElementsKind elements_kind); | 230 ElementsKind elements_kind); |
| 229 bool InstallNatives(GlobalContextType context_type); | 231 bool InstallNatives(GlobalContextType context_type); |
| 230 | 232 |
| 231 void InstallTypedArray(const char* name, ElementsKind elements_kind, | 233 void InstallTypedArray(const char* name, ElementsKind elements_kind, |
| 232 Handle<JSFunction>* fun); | 234 Handle<JSFunction>* fun); |
| 233 bool InstallExtraNatives(); | 235 bool InstallExtraNatives(); |
| 234 bool InstallExperimentalExtraNatives(); | 236 bool InstallExperimentalExtraNatives(); |
| 235 bool InstallDebuggerNatives(); | 237 bool InstallDebuggerNatives(); |
| (...skipping 2319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2555 v8_break_iterator_constructor, DONT_ENUM); | 2557 v8_break_iterator_constructor, DONT_ENUM); |
| 2556 InstallWithIntrinsicDefaultProto( | 2558 InstallWithIntrinsicDefaultProto( |
| 2557 isolate, v8_break_iterator_constructor, | 2559 isolate, v8_break_iterator_constructor, |
| 2558 Context::INTL_V8_BREAK_ITERATOR_FUNCTION_INDEX); | 2560 Context::INTL_V8_BREAK_ITERATOR_FUNCTION_INDEX); |
| 2559 } | 2561 } |
| 2560 #endif // V8_I18N_SUPPORT | 2562 #endif // V8_I18N_SUPPORT |
| 2561 | 2563 |
| 2562 { // -- A r r a y B u f f e r | 2564 { // -- A r r a y B u f f e r |
| 2563 Handle<JSFunction> array_buffer_fun = InstallArrayBuffer( | 2565 Handle<JSFunction> array_buffer_fun = InstallArrayBuffer( |
| 2564 global, "ArrayBuffer", Builtins::kArrayBufferPrototypeGetByteLength, | 2566 global, "ArrayBuffer", Builtins::kArrayBufferPrototypeGetByteLength, |
| 2565 BuiltinFunctionId::kArrayBufferByteLength, false); | 2567 BuiltinFunctionId::kArrayBufferByteLength, |
| 2568 Builtins::kArrayBufferPrototypeSlice); |
| 2566 InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun, | 2569 InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun, |
| 2567 Context::ARRAY_BUFFER_FUN_INDEX); | 2570 Context::ARRAY_BUFFER_FUN_INDEX); |
| 2568 InstallSpeciesGetter(array_buffer_fun); | 2571 InstallSpeciesGetter(array_buffer_fun); |
| 2569 } | 2572 } |
| 2570 | 2573 |
| 2571 { // -- T y p e d A r r a y | 2574 { // -- T y p e d A r r a y |
| 2572 Handle<JSObject> prototype = | 2575 Handle<JSObject> prototype = |
| 2573 factory->NewJSObject(isolate->object_function(), TENURED); | 2576 factory->NewJSObject(isolate->object_function(), TENURED); |
| 2574 native_context()->set_typed_array_prototype(*prototype); | 2577 native_context()->set_typed_array_prototype(*prototype); |
| 2575 | 2578 |
| (...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3716 void Genesis::InitializeGlobal_harmony_sharedarraybuffer() { | 3719 void Genesis::InitializeGlobal_harmony_sharedarraybuffer() { |
| 3717 if (!FLAG_harmony_sharedarraybuffer) return; | 3720 if (!FLAG_harmony_sharedarraybuffer) return; |
| 3718 | 3721 |
| 3719 Handle<JSGlobalObject> global(native_context()->global_object()); | 3722 Handle<JSGlobalObject> global(native_context()->global_object()); |
| 3720 Isolate* isolate = global->GetIsolate(); | 3723 Isolate* isolate = global->GetIsolate(); |
| 3721 Factory* factory = isolate->factory(); | 3724 Factory* factory = isolate->factory(); |
| 3722 | 3725 |
| 3723 Handle<JSFunction> shared_array_buffer_fun = | 3726 Handle<JSFunction> shared_array_buffer_fun = |
| 3724 InstallArrayBuffer(global, "SharedArrayBuffer", | 3727 InstallArrayBuffer(global, "SharedArrayBuffer", |
| 3725 Builtins::kSharedArrayBufferPrototypeGetByteLength, | 3728 Builtins::kSharedArrayBufferPrototypeGetByteLength, |
| 3726 BuiltinFunctionId::kSharedArrayBufferByteLength, true); | 3729 BuiltinFunctionId::kSharedArrayBufferByteLength, |
| 3730 Builtins::kSharedArrayBufferPrototypeSlice); |
| 3727 native_context()->set_shared_array_buffer_fun(*shared_array_buffer_fun); | 3731 native_context()->set_shared_array_buffer_fun(*shared_array_buffer_fun); |
| 3728 | 3732 |
| 3729 Handle<String> name = factory->InternalizeUtf8String("Atomics"); | 3733 Handle<String> name = factory->InternalizeUtf8String("Atomics"); |
| 3730 Handle<JSFunction> cons = factory->NewFunction(name); | 3734 Handle<JSFunction> cons = factory->NewFunction(name); |
| 3731 JSFunction::SetInstancePrototype( | 3735 JSFunction::SetInstancePrototype( |
| 3732 cons, | 3736 cons, |
| 3733 Handle<Object>(native_context()->initial_object_prototype(), isolate)); | 3737 Handle<Object>(native_context()->initial_object_prototype(), isolate)); |
| 3734 Handle<JSObject> atomics_object = factory->NewJSObject(cons, TENURED); | 3738 Handle<JSObject> atomics_object = factory->NewJSObject(cons, TENURED); |
| 3735 DCHECK(atomics_object->IsJSObject()); | 3739 DCHECK(atomics_object->IsJSObject()); |
| 3736 JSObject::AddProperty(global, name, atomics_object, DONT_ENUM); | 3740 JSObject::AddProperty(global, name, atomics_object, DONT_ENUM); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3919 exports_container, | 3923 exports_container, |
| 3920 factory()->InternalizeUtf8String("ToLocaleUpperCaseI18N")) | 3924 factory()->InternalizeUtf8String("ToLocaleUpperCaseI18N")) |
| 3921 .ToHandleChecked()); | 3925 .ToHandleChecked()); |
| 3922 SetFunction(string_prototype, to_locale_upper_case, | 3926 SetFunction(string_prototype, to_locale_upper_case, |
| 3923 factory()->InternalizeUtf8String("toLocaleUpperCase")); | 3927 factory()->InternalizeUtf8String("toLocaleUpperCase")); |
| 3924 } | 3928 } |
| 3925 #endif | 3929 #endif |
| 3926 | 3930 |
| 3927 Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target, | 3931 Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target, |
| 3928 const char* name, | 3932 const char* name, |
| 3929 Builtins::Name call, | 3933 Builtins::Name call_byteLength, |
| 3930 BuiltinFunctionId id, | 3934 BuiltinFunctionId byteLength_id, |
| 3931 bool is_shared) { | 3935 Builtins::Name call_slice) { |
| 3932 // Create the %ArrayBufferPrototype% | 3936 // Create the %ArrayBufferPrototype% |
| 3933 // Setup the {prototype} with the given {name} for @@toStringTag. | 3937 // Setup the {prototype} with the given {name} for @@toStringTag. |
| 3934 Handle<JSObject> prototype = | 3938 Handle<JSObject> prototype = |
| 3935 factory()->NewJSObject(isolate()->object_function(), TENURED); | 3939 factory()->NewJSObject(isolate()->object_function(), TENURED); |
| 3936 JSObject::AddProperty(prototype, factory()->to_string_tag_symbol(), | 3940 JSObject::AddProperty(prototype, factory()->to_string_tag_symbol(), |
| 3937 factory()->NewStringFromAsciiChecked(name), | 3941 factory()->NewStringFromAsciiChecked(name), |
| 3938 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); | 3942 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); |
| 3939 | 3943 |
| 3940 // Allocate the constructor with the given {prototype}. | 3944 // Allocate the constructor with the given {prototype}. |
| 3941 Handle<JSFunction> array_buffer_fun = | 3945 Handle<JSFunction> array_buffer_fun = |
| 3942 InstallFunction(target, name, JS_ARRAY_BUFFER_TYPE, | 3946 InstallFunction(target, name, JS_ARRAY_BUFFER_TYPE, |
| 3943 JSArrayBuffer::kSizeWithEmbedderFields, prototype, | 3947 JSArrayBuffer::kSizeWithEmbedderFields, prototype, |
| 3944 Builtins::kArrayBufferConstructor); | 3948 Builtins::kArrayBufferConstructor); |
| 3945 array_buffer_fun->shared()->SetConstructStub( | 3949 array_buffer_fun->shared()->SetConstructStub( |
| 3946 *isolate()->builtins()->ArrayBufferConstructor_ConstructStub()); | 3950 *isolate()->builtins()->ArrayBufferConstructor_ConstructStub()); |
| 3947 array_buffer_fun->shared()->DontAdaptArguments(); | 3951 array_buffer_fun->shared()->DontAdaptArguments(); |
| 3948 array_buffer_fun->shared()->set_length(1); | 3952 array_buffer_fun->shared()->set_length(1); |
| 3949 | 3953 |
| 3950 // Install the "constructor" property on the {prototype}. | 3954 // Install the "constructor" property on the {prototype}. |
| 3951 JSObject::AddProperty(prototype, factory()->constructor_string(), | 3955 JSObject::AddProperty(prototype, factory()->constructor_string(), |
| 3952 array_buffer_fun, DONT_ENUM); | 3956 array_buffer_fun, DONT_ENUM); |
| 3953 | 3957 |
| 3954 SimpleInstallFunction(array_buffer_fun, factory()->isView_string(), | 3958 SimpleInstallFunction(array_buffer_fun, factory()->isView_string(), |
| 3955 Builtins::kArrayBufferIsView, 1, true); | 3959 Builtins::kArrayBufferIsView, 1, true); |
| 3956 | 3960 |
| 3957 // Install the "byteLength" getter on the {prototype}. | 3961 // Install the "byteLength" getter on the {prototype}. |
| 3958 SimpleInstallGetter(prototype, factory()->byte_length_string(), call, false, | 3962 SimpleInstallGetter(prototype, factory()->byte_length_string(), |
| 3959 id); | 3963 call_byteLength, false, byteLength_id); |
| 3960 | 3964 |
| 3961 // TODO(binji): support SharedArrayBuffer.prototype.slice as well. | 3965 SimpleInstallFunction(prototype, "slice", call_slice, 2, true); |
| 3962 if (!is_shared) { | |
| 3963 SimpleInstallFunction(prototype, "slice", | |
| 3964 Builtins::kArrayBufferPrototypeSlice, 2, true); | |
| 3965 } | |
| 3966 | 3966 |
| 3967 return array_buffer_fun; | 3967 return array_buffer_fun; |
| 3968 } | 3968 } |
| 3969 | 3969 |
| 3970 | 3970 |
| 3971 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, | 3971 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, |
| 3972 const char* name, | 3972 const char* name, |
| 3973 ElementsKind elements_kind) { | 3973 ElementsKind elements_kind) { |
| 3974 // --- I n t e r n a l A r r a y --- | 3974 // --- I n t e r n a l A r r a y --- |
| 3975 // An array constructor on the builtins object that works like | 3975 // An array constructor on the builtins object that works like |
| (...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5094 } | 5094 } |
| 5095 | 5095 |
| 5096 | 5096 |
| 5097 // Called when the top-level V8 mutex is destroyed. | 5097 // Called when the top-level V8 mutex is destroyed. |
| 5098 void Bootstrapper::FreeThreadResources() { | 5098 void Bootstrapper::FreeThreadResources() { |
| 5099 DCHECK(!IsActive()); | 5099 DCHECK(!IsActive()); |
| 5100 } | 5100 } |
| 5101 | 5101 |
| 5102 } // namespace internal | 5102 } // namespace internal |
| 5103 } // namespace v8 | 5103 } // namespace v8 |
| OLD | NEW |