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 2869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2880 JSObject::GetProperty(array_prototype, factory()->unscopables_symbol()) | 2880 JSObject::GetProperty(array_prototype, factory()->unscopables_symbol()) |
2881 .ToHandleChecked(); | 2881 .ToHandleChecked(); |
2882 DCHECK(unscopables->IsJSObject()); | 2882 DCHECK(unscopables->IsJSObject()); |
2883 JSObject::AddProperty(Handle<JSObject>::cast(unscopables), | 2883 JSObject::AddProperty(Handle<JSObject>::cast(unscopables), |
2884 factory()->values_string(), factory()->true_value(), | 2884 factory()->values_string(), factory()->true_value(), |
2885 NONE); | 2885 NONE); |
2886 } | 2886 } |
2887 | 2887 |
2888 Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target, | 2888 Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target, |
2889 const char* name) { | 2889 const char* name) { |
| 2890 // Create the %ArrayBufferPrototype% |
2890 // Setup the {prototype} with the given {name} for @@toStringTag. | 2891 // Setup the {prototype} with the given {name} for @@toStringTag. |
2891 Handle<JSObject> prototype = | 2892 Handle<JSObject> prototype = |
2892 factory()->NewJSObject(isolate()->object_function(), TENURED); | 2893 factory()->NewJSObject(isolate()->object_function(), TENURED); |
2893 JSObject::AddProperty(prototype, factory()->to_string_tag_symbol(), | 2894 JSObject::AddProperty(prototype, factory()->to_string_tag_symbol(), |
2894 factory()->NewStringFromAsciiChecked(name), | 2895 factory()->NewStringFromAsciiChecked(name), |
2895 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); | 2896 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); |
2896 | 2897 |
2897 // Allocate the constructor with the given {prototype}. | 2898 // Allocate the constructor with the given {prototype}. |
2898 Handle<JSFunction> array_buffer_fun = | 2899 Handle<JSFunction> array_buffer_fun = |
2899 InstallFunction(target, name, JS_ARRAY_BUFFER_TYPE, | 2900 InstallFunction(target, name, JS_ARRAY_BUFFER_TYPE, |
2900 JSArrayBuffer::kSizeWithInternalFields, prototype, | 2901 JSArrayBuffer::kSizeWithInternalFields, prototype, |
2901 Builtins::kArrayBufferConstructor); | 2902 Builtins::kArrayBufferConstructor); |
2902 array_buffer_fun->shared()->set_construct_stub( | 2903 array_buffer_fun->shared()->set_construct_stub( |
2903 *isolate()->builtins()->ArrayBufferConstructor_ConstructStub()); | 2904 *isolate()->builtins()->ArrayBufferConstructor_ConstructStub()); |
2904 array_buffer_fun->shared()->DontAdaptArguments(); | 2905 array_buffer_fun->shared()->DontAdaptArguments(); |
2905 array_buffer_fun->shared()->set_length(1); | 2906 array_buffer_fun->shared()->set_length(1); |
2906 | 2907 |
2907 // Install the "constructor" property on the {prototype}. | 2908 // Install the "constructor" property on the {prototype}. |
2908 JSObject::AddProperty(prototype, factory()->constructor_string(), | 2909 JSObject::AddProperty(prototype, factory()->constructor_string(), |
2909 array_buffer_fun, DONT_ENUM); | 2910 array_buffer_fun, DONT_ENUM); |
2910 | 2911 |
2911 SimpleInstallFunction(array_buffer_fun, factory()->isView_string(), | 2912 SimpleInstallFunction(array_buffer_fun, factory()->isView_string(), |
2912 Builtins::kArrayBufferIsView, 1, true); | 2913 Builtins::kArrayBufferIsView, 1, true); |
2913 | 2914 |
| 2915 // Install the "byteLength" getter on the {prototype}. |
| 2916 SimpleInstallGetter(prototype, factory()->byte_length_string(), |
| 2917 Builtins::kArrayBufferPrototypeGetByteLength, false, |
| 2918 kArrayBufferByteLength); |
| 2919 |
2914 return array_buffer_fun; | 2920 return array_buffer_fun; |
2915 } | 2921 } |
2916 | 2922 |
2917 | 2923 |
2918 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, | 2924 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, |
2919 const char* name, | 2925 const char* name, |
2920 ElementsKind elements_kind) { | 2926 ElementsKind elements_kind) { |
2921 // --- I n t e r n a l A r r a y --- | 2927 // --- I n t e r n a l A r r a y --- |
2922 // An array constructor on the builtins object that works like | 2928 // An array constructor on the builtins object that works like |
2923 // the public Array constructor, except that its prototype | 2929 // the public Array constructor, except that its prototype |
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4010 } | 4016 } |
4011 | 4017 |
4012 | 4018 |
4013 // Called when the top-level V8 mutex is destroyed. | 4019 // Called when the top-level V8 mutex is destroyed. |
4014 void Bootstrapper::FreeThreadResources() { | 4020 void Bootstrapper::FreeThreadResources() { |
4015 DCHECK(!IsActive()); | 4021 DCHECK(!IsActive()); |
4016 } | 4022 } |
4017 | 4023 |
4018 } // namespace internal | 4024 } // namespace internal |
4019 } // namespace v8 | 4025 } // namespace v8 |
OLD | NEW |