Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Unified Diff: src/bootstrapper.cc

Issue 1500543002: [es6] Unify ArrayBuffer and SharedArrayBuffer constructors. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Get the exceptions right. Other fixes. Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/builtins.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index 258142b8e11f2ddd4c0a2d59571dff17ec5692b4..1780c133e611cc1f6103f2621ee0d484b80acae1 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -205,6 +205,8 @@ class Genesis BASE_EMBEDDED {
DECLARE_FEATURE_INITIALIZATION(promise_extra, "")
#undef DECLARE_FEATURE_INITIALIZATION
+ Handle<JSFunction> InstallArrayBuffer(Handle<JSObject> target,
+ const char* name);
Handle<JSFunction> InstallInternalArray(Handle<JSObject> target,
const char* name,
ElementsKind elements_kind);
@@ -1345,11 +1347,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
{ // -- A r r a y B u f f e r
Handle<JSFunction> array_buffer_fun =
- InstallFunction(
- global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE,
- JSArrayBuffer::kSizeWithInternalFields,
- isolate->initial_object_prototype(),
- Builtins::kIllegal);
+ InstallArrayBuffer(global, "ArrayBuffer");
InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun,
Context::ARRAY_BUFFER_FUN_INDEX);
}
@@ -2237,13 +2235,9 @@ void Genesis::InitializeGlobal_harmony_reflect() {
void Genesis::InitializeGlobal_harmony_sharedarraybuffer() {
if (!FLAG_harmony_sharedarraybuffer) return;
- Handle<JSGlobalObject> global(
- JSGlobalObject::cast(native_context()->global_object()));
-
- Handle<JSFunction> shared_array_buffer_fun = InstallFunction(
- global, "SharedArrayBuffer", JS_ARRAY_BUFFER_TYPE,
- JSArrayBuffer::kSizeWithInternalFields,
- isolate()->initial_object_prototype(), Builtins::kIllegal);
+ Handle<JSGlobalObject> global(native_context()->global_object());
+ Handle<JSFunction> shared_array_buffer_fun =
+ InstallArrayBuffer(global, "SharedArrayBuffer");
native_context()->set_shared_array_buffer_fun(*shared_array_buffer_fun);
}
@@ -2335,6 +2329,36 @@ void Genesis::InitializeGlobal_harmony_proxies() {
}
+Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target,
+ const char* name) {
+ // Setup the {prototype} with the given {name} for @@toStringTag.
+ Handle<JSObject> prototype =
+ factory()->NewJSObject(isolate()->object_function(), TENURED);
+ JSObject::AddProperty(prototype, factory()->to_string_tag_symbol(),
+ factory()->NewStringFromAsciiChecked(name),
+ static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
+
+ // Allocate the constructor with the given {prototype}.
+ Handle<JSFunction> array_buffer_fun =
+ InstallFunction(target, name, JS_ARRAY_BUFFER_TYPE,
+ JSArrayBuffer::kSizeWithInternalFields, prototype,
+ Builtins::kArrayBufferConstructor);
+ array_buffer_fun->shared()->set_construct_stub(
+ *isolate()->builtins()->ArrayBufferConstructor_ConstructStub());
+ array_buffer_fun->shared()->DontAdaptArguments();
+ array_buffer_fun->shared()->set_length(1);
+
+ // Install the "constructor" property on the {prototype}.
+ JSObject::AddProperty(prototype, factory()->constructor_string(),
+ array_buffer_fun, DONT_ENUM);
+
+ SimpleInstallFunction(array_buffer_fun, factory()->isView_string(),
+ Builtins::kArrayBufferIsView, 1, true);
+
+ return array_buffer_fun;
+}
+
+
Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target,
const char* name,
ElementsKind elements_kind) {
« no previous file with comments | « no previous file | src/builtins.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698