Commit efcd385d authored by franzih's avatar franzih Committed by Commit bot

[builtins] Migrate ArrayBufferPrototypeByteLength to C++.

Working on eliminating the use of ClassOf(). This function was checking IS_ARRAYBUFFER.

BUG=

Review-Url: https://codereview.chromium.org/2126603003
Cr-Commit-Position: refs/heads/master@{#37565}
parent 3172f6a9
...@@ -2887,6 +2887,7 @@ void Genesis::InitializeGlobal_harmony_array_prototype_values() { ...@@ -2887,6 +2887,7 @@ void Genesis::InitializeGlobal_harmony_array_prototype_values() {
Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target, Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target,
const char* name) { const char* name) {
// Create the %ArrayBufferPrototype%
// Setup the {prototype} with the given {name} for @@toStringTag. // Setup the {prototype} with the given {name} for @@toStringTag.
Handle<JSObject> prototype = Handle<JSObject> prototype =
factory()->NewJSObject(isolate()->object_function(), TENURED); factory()->NewJSObject(isolate()->object_function(), TENURED);
...@@ -2911,6 +2912,11 @@ Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target, ...@@ -2911,6 +2912,11 @@ Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target,
SimpleInstallFunction(array_buffer_fun, factory()->isView_string(), SimpleInstallFunction(array_buffer_fun, factory()->isView_string(),
Builtins::kArrayBufferIsView, 1, true); Builtins::kArrayBufferIsView, 1, true);
// Install the "byteLength" getter on the {prototype}.
SimpleInstallGetter(prototype, factory()->byte_length_string(),
Builtins::kArrayBufferPrototypeGetByteLength, false,
kArrayBufferByteLength);
return array_buffer_fun; return array_buffer_fun;
} }
......
...@@ -5622,6 +5622,15 @@ BUILTIN(ArrayBufferConstructor_ConstructStub) { ...@@ -5622,6 +5622,15 @@ BUILTIN(ArrayBufferConstructor_ConstructStub) {
return *result; return *result;
} }
// ES6 section 24.1.4.1 get ArrayBuffer.prototype.byteLength
BUILTIN(ArrayBufferPrototypeGetByteLength) {
HandleScope scope(isolate);
CHECK_RECEIVER(JSArrayBuffer, array_buffer,
"get ArrayBuffer.prototype.byteLength");
// TODO(franzih): According to the ES6 spec, we should throw a TypeError
// here if the JSArrayBuffer is detached.
return array_buffer->byte_length();
}
// ES6 section 24.1.3.1 ArrayBuffer.isView ( arg ) // ES6 section 24.1.3.1 ArrayBuffer.isView ( arg )
BUILTIN(ArrayBufferIsView) { BUILTIN(ArrayBufferIsView) {
......
...@@ -54,6 +54,7 @@ class CodeStubAssembler; ...@@ -54,6 +54,7 @@ class CodeStubAssembler;
\ \
V(ArrayBufferConstructor, BUILTIN_EXIT) \ V(ArrayBufferConstructor, BUILTIN_EXIT) \
V(ArrayBufferConstructor_ConstructStub, BUILTIN_EXIT) \ V(ArrayBufferConstructor_ConstructStub, BUILTIN_EXIT) \
V(ArrayBufferPrototypeGetByteLength, BUILTIN_EXIT) \
V(ArrayBufferIsView, BUILTIN_EXIT) \ V(ArrayBufferIsView, BUILTIN_EXIT) \
\ \
V(BooleanConstructor, BUILTIN_EXIT) \ V(BooleanConstructor, BUILTIN_EXIT) \
......
...@@ -27,14 +27,6 @@ utils.Import(function(from) { ...@@ -27,14 +27,6 @@ utils.Import(function(from) {
// ------------------------------------------------------------------- // -------------------------------------------------------------------
function ArrayBufferGetByteLen() {
if (!IS_ARRAYBUFFER(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
'ArrayBuffer.prototype.byteLength', this);
}
return %_ArrayBufferGetByteLength(this);
}
// ES6 Draft 15.13.5.5.3 // ES6 Draft 15.13.5.5.3
function ArrayBufferSlice(start, end) { function ArrayBufferSlice(start, end) {
if (!IS_ARRAYBUFFER(this)) { if (!IS_ARRAYBUFFER(this)) {
...@@ -92,9 +84,6 @@ function ArrayBufferSpecies() { ...@@ -92,9 +84,6 @@ function ArrayBufferSpecies() {
utils.InstallGetter(GlobalArrayBuffer, speciesSymbol, ArrayBufferSpecies); utils.InstallGetter(GlobalArrayBuffer, speciesSymbol, ArrayBufferSpecies);
utils.InstallGetter(GlobalArrayBuffer.prototype, "byteLength",
ArrayBufferGetByteLen);
utils.InstallFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [ utils.InstallFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [
"slice", ArrayBufferSlice "slice", ArrayBufferSlice
]); ]);
......
...@@ -6774,6 +6774,7 @@ enum BuiltinFunctionId { ...@@ -6774,6 +6774,7 @@ enum BuiltinFunctionId {
// list of math functions. // list of math functions.
kMathPowHalf, kMathPowHalf,
// These are manually assigned to special getters during bootstrapping. // These are manually assigned to special getters during bootstrapping.
kArrayBufferByteLength,
kDataViewBuffer, kDataViewBuffer,
kDataViewByteLength, kDataViewByteLength,
kDataViewByteOffset, kDataViewByteOffset,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment