| 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, Builtins::Name call, |
| 226 BuiltinFunctionId id); | 226 BuiltinFunctionId id, bool is_shared); |
| 227 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, | 227 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, |
| 228 const char* name, | 228 const char* name, |
| 229 ElementsKind elements_kind); | 229 ElementsKind elements_kind); |
| 230 bool InstallNatives(GlobalContextType context_type); | 230 bool InstallNatives(GlobalContextType context_type); |
| 231 | 231 |
| 232 void InstallTypedArray(const char* name, ElementsKind elements_kind, | 232 void InstallTypedArray(const char* name, ElementsKind elements_kind, |
| 233 Handle<JSFunction>* fun); | 233 Handle<JSFunction>* fun); |
| 234 bool InstallExperimentalNatives(); | 234 bool InstallExperimentalNatives(); |
| 235 bool InstallExtraNatives(); | 235 bool InstallExtraNatives(); |
| 236 bool InstallExperimentalExtraNatives(); | 236 bool InstallExperimentalExtraNatives(); |
| (...skipping 2306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2543 v8_break_iterator_constructor, DONT_ENUM); | 2543 v8_break_iterator_constructor, DONT_ENUM); |
| 2544 InstallWithIntrinsicDefaultProto( | 2544 InstallWithIntrinsicDefaultProto( |
| 2545 isolate, v8_break_iterator_constructor, | 2545 isolate, v8_break_iterator_constructor, |
| 2546 Context::INTL_V8_BREAK_ITERATOR_FUNCTION_INDEX); | 2546 Context::INTL_V8_BREAK_ITERATOR_FUNCTION_INDEX); |
| 2547 } | 2547 } |
| 2548 #endif // V8_I18N_SUPPORT | 2548 #endif // V8_I18N_SUPPORT |
| 2549 | 2549 |
| 2550 { // -- A r r a y B u f f e r | 2550 { // -- A r r a y B u f f e r |
| 2551 Handle<JSFunction> array_buffer_fun = InstallArrayBuffer( | 2551 Handle<JSFunction> array_buffer_fun = InstallArrayBuffer( |
| 2552 global, "ArrayBuffer", Builtins::kArrayBufferPrototypeGetByteLength, | 2552 global, "ArrayBuffer", Builtins::kArrayBufferPrototypeGetByteLength, |
| 2553 BuiltinFunctionId::kArrayBufferByteLength); | 2553 BuiltinFunctionId::kArrayBufferByteLength, false); |
| 2554 InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun, | 2554 InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun, |
| 2555 Context::ARRAY_BUFFER_FUN_INDEX); | 2555 Context::ARRAY_BUFFER_FUN_INDEX); |
| 2556 InstallSpeciesGetter(array_buffer_fun); | 2556 InstallSpeciesGetter(array_buffer_fun); |
| 2557 } | 2557 } |
| 2558 | 2558 |
| 2559 { // -- T y p e d A r r a y | 2559 { // -- T y p e d A r r a y |
| 2560 Handle<JSObject> prototype = | 2560 Handle<JSObject> prototype = |
| 2561 factory->NewJSObject(isolate->object_function(), TENURED); | 2561 factory->NewJSObject(isolate->object_function(), TENURED); |
| 2562 native_context()->set_typed_array_prototype(*prototype); | 2562 native_context()->set_typed_array_prototype(*prototype); |
| 2563 | 2563 |
| (...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3681 void Genesis::InitializeGlobal_harmony_sharedarraybuffer() { | 3681 void Genesis::InitializeGlobal_harmony_sharedarraybuffer() { |
| 3682 if (!FLAG_harmony_sharedarraybuffer) return; | 3682 if (!FLAG_harmony_sharedarraybuffer) return; |
| 3683 | 3683 |
| 3684 Handle<JSGlobalObject> global(native_context()->global_object()); | 3684 Handle<JSGlobalObject> global(native_context()->global_object()); |
| 3685 Isolate* isolate = global->GetIsolate(); | 3685 Isolate* isolate = global->GetIsolate(); |
| 3686 Factory* factory = isolate->factory(); | 3686 Factory* factory = isolate->factory(); |
| 3687 | 3687 |
| 3688 Handle<JSFunction> shared_array_buffer_fun = | 3688 Handle<JSFunction> shared_array_buffer_fun = |
| 3689 InstallArrayBuffer(global, "SharedArrayBuffer", | 3689 InstallArrayBuffer(global, "SharedArrayBuffer", |
| 3690 Builtins::kSharedArrayBufferPrototypeGetByteLength, | 3690 Builtins::kSharedArrayBufferPrototypeGetByteLength, |
| 3691 BuiltinFunctionId::kSharedArrayBufferByteLength); | 3691 BuiltinFunctionId::kSharedArrayBufferByteLength, true); |
| 3692 native_context()->set_shared_array_buffer_fun(*shared_array_buffer_fun); | 3692 native_context()->set_shared_array_buffer_fun(*shared_array_buffer_fun); |
| 3693 | 3693 |
| 3694 Handle<String> name = factory->InternalizeUtf8String("Atomics"); | 3694 Handle<String> name = factory->InternalizeUtf8String("Atomics"); |
| 3695 Handle<JSFunction> cons = factory->NewFunction(name); | 3695 Handle<JSFunction> cons = factory->NewFunction(name); |
| 3696 JSFunction::SetInstancePrototype( | 3696 JSFunction::SetInstancePrototype( |
| 3697 cons, | 3697 cons, |
| 3698 Handle<Object>(native_context()->initial_object_prototype(), isolate)); | 3698 Handle<Object>(native_context()->initial_object_prototype(), isolate)); |
| 3699 Handle<JSObject> atomics_object = factory->NewJSObject(cons, TENURED); | 3699 Handle<JSObject> atomics_object = factory->NewJSObject(cons, TENURED); |
| 3700 DCHECK(atomics_object->IsJSObject()); | 3700 DCHECK(atomics_object->IsJSObject()); |
| 3701 JSObject::AddProperty(global, name, atomics_object, DONT_ENUM); | 3701 JSObject::AddProperty(global, name, atomics_object, DONT_ENUM); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3860 factory()->InternalizeUtf8String("ToLocaleUpperCaseI18N")) | 3860 factory()->InternalizeUtf8String("ToLocaleUpperCaseI18N")) |
| 3861 .ToHandleChecked()); | 3861 .ToHandleChecked()); |
| 3862 SetFunction(string_prototype, to_locale_upper_case, | 3862 SetFunction(string_prototype, to_locale_upper_case, |
| 3863 factory()->InternalizeUtf8String("toLocaleUpperCase")); | 3863 factory()->InternalizeUtf8String("toLocaleUpperCase")); |
| 3864 } | 3864 } |
| 3865 #endif | 3865 #endif |
| 3866 | 3866 |
| 3867 Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target, | 3867 Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target, |
| 3868 const char* name, | 3868 const char* name, |
| 3869 Builtins::Name call, | 3869 Builtins::Name call, |
| 3870 BuiltinFunctionId id) { | 3870 BuiltinFunctionId id, |
| 3871 bool is_shared) { |
| 3871 // Create the %ArrayBufferPrototype% | 3872 // Create the %ArrayBufferPrototype% |
| 3872 // Setup the {prototype} with the given {name} for @@toStringTag. | 3873 // Setup the {prototype} with the given {name} for @@toStringTag. |
| 3873 Handle<JSObject> prototype = | 3874 Handle<JSObject> prototype = |
| 3874 factory()->NewJSObject(isolate()->object_function(), TENURED); | 3875 factory()->NewJSObject(isolate()->object_function(), TENURED); |
| 3875 JSObject::AddProperty(prototype, factory()->to_string_tag_symbol(), | 3876 JSObject::AddProperty(prototype, factory()->to_string_tag_symbol(), |
| 3876 factory()->NewStringFromAsciiChecked(name), | 3877 factory()->NewStringFromAsciiChecked(name), |
| 3877 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); | 3878 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); |
| 3878 | 3879 |
| 3879 // Allocate the constructor with the given {prototype}. | 3880 // Allocate the constructor with the given {prototype}. |
| 3880 Handle<JSFunction> array_buffer_fun = | 3881 Handle<JSFunction> array_buffer_fun = |
| 3881 InstallFunction(target, name, JS_ARRAY_BUFFER_TYPE, | 3882 InstallFunction(target, name, JS_ARRAY_BUFFER_TYPE, |
| 3882 JSArrayBuffer::kSizeWithInternalFields, prototype, | 3883 JSArrayBuffer::kSizeWithInternalFields, prototype, |
| 3883 Builtins::kArrayBufferConstructor); | 3884 Builtins::kArrayBufferConstructor); |
| 3884 array_buffer_fun->shared()->SetConstructStub( | 3885 array_buffer_fun->shared()->SetConstructStub( |
| 3885 *isolate()->builtins()->ArrayBufferConstructor_ConstructStub()); | 3886 *isolate()->builtins()->ArrayBufferConstructor_ConstructStub()); |
| 3886 array_buffer_fun->shared()->DontAdaptArguments(); | 3887 array_buffer_fun->shared()->DontAdaptArguments(); |
| 3887 array_buffer_fun->shared()->set_length(1); | 3888 array_buffer_fun->shared()->set_length(1); |
| 3888 | 3889 |
| 3889 // Install the "constructor" property on the {prototype}. | 3890 // Install the "constructor" property on the {prototype}. |
| 3890 JSObject::AddProperty(prototype, factory()->constructor_string(), | 3891 JSObject::AddProperty(prototype, factory()->constructor_string(), |
| 3891 array_buffer_fun, DONT_ENUM); | 3892 array_buffer_fun, DONT_ENUM); |
| 3892 | 3893 |
| 3893 SimpleInstallFunction(array_buffer_fun, factory()->isView_string(), | 3894 SimpleInstallFunction(array_buffer_fun, factory()->isView_string(), |
| 3894 Builtins::kArrayBufferIsView, 1, true); | 3895 Builtins::kArrayBufferIsView, 1, true); |
| 3895 | 3896 |
| 3896 // Install the "byteLength" getter on the {prototype}. | 3897 // Install the "byteLength" getter on the {prototype}. |
| 3897 SimpleInstallGetter(prototype, factory()->byte_length_string(), call, false, | 3898 SimpleInstallGetter(prototype, factory()->byte_length_string(), call, false, |
| 3898 id); | 3899 id); |
| 3899 | 3900 |
| 3901 // TODO(binji): support SharedArrayBuffer.prototype.slice as well. |
| 3902 if (!is_shared) { |
| 3903 SimpleInstallFunction(prototype, "slice", |
| 3904 Builtins::kArrayBufferPrototypeSlice, 2, true); |
| 3905 } |
| 3906 |
| 3900 return array_buffer_fun; | 3907 return array_buffer_fun; |
| 3901 } | 3908 } |
| 3902 | 3909 |
| 3903 | 3910 |
| 3904 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, | 3911 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, |
| 3905 const char* name, | 3912 const char* name, |
| 3906 ElementsKind elements_kind) { | 3913 ElementsKind elements_kind) { |
| 3907 // --- I n t e r n a l A r r a y --- | 3914 // --- I n t e r n a l A r r a y --- |
| 3908 // An array constructor on the builtins object that works like | 3915 // An array constructor on the builtins object that works like |
| 3909 // the public Array constructor, except that its prototype | 3916 // the public Array constructor, except that its prototype |
| (...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5089 } | 5096 } |
| 5090 | 5097 |
| 5091 | 5098 |
| 5092 // Called when the top-level V8 mutex is destroyed. | 5099 // Called when the top-level V8 mutex is destroyed. |
| 5093 void Bootstrapper::FreeThreadResources() { | 5100 void Bootstrapper::FreeThreadResources() { |
| 5094 DCHECK(!IsActive()); | 5101 DCHECK(!IsActive()); |
| 5095 } | 5102 } |
| 5096 | 5103 |
| 5097 } // namespace internal | 5104 } // namespace internal |
| 5098 } // namespace v8 | 5105 } // namespace v8 |
| OLD | NEW |