Commit dd0ba4d1 authored by bmeurer's avatar bmeurer Committed by Commit bot

[builtins] Get rid of a few %_ClassOf uses.

With subclassing and @@toStringTag, %_ClassOf is not necessarily what
you want for ES6 anymore, so better avoid relying on %_ClassOf in our
builtins.

R=yangguo@chromium.org

Review URL: https://codereview.chromium.org/1439003002

Cr-Commit-Position: refs/heads/master@{#31953}
parent 6d616229
......@@ -32,7 +32,7 @@ function CheckSharedIntegerTypedArray(ia) {
function CheckSharedInteger32TypedArray(ia) {
CheckSharedIntegerTypedArray(ia);
if (%_ClassOf(ia) !== 'Int32Array') {
if (!%IsSharedInteger32TypedArray(ia)) {
throw MakeTypeError(kNotInt32SharedTypedArray, ia);
}
}
......
......@@ -62,11 +62,11 @@ function NAMECheckJS(a) {
}
function NAMEToString() {
if (typeof(this) !== 'TYPE' && %_ClassOf(this) !== 'NAME') {
var value = %_ValueOf(this);
if (typeof(value) !== 'TYPE') {
throw MakeTypeError(kIncompatibleMethodReceiver,
"NAME.prototype.toString", this);
}
var value = %_ValueOf(this);
var str = "SIMD.NAME(";
str += %NAMEExtractLane(value, 0);
for (var i = 1; i < LANES; i++) {
......@@ -76,11 +76,11 @@ function NAMEToString() {
}
function NAMEToLocaleString() {
if (typeof(this) !== 'TYPE' && %_ClassOf(this) !== 'NAME') {
var value = %_ValueOf(this);
if (typeof(value) !== 'TYPE') {
throw MakeTypeError(kIncompatibleMethodReceiver,
"NAME.prototype.toLocaleString", this);
}
var value = %_ValueOf(this);
var str = "SIMD.NAME(";
str += %NAMEExtractLane(value, 0).toLocaleString();
for (var i = 1; i < LANES; i++) {
......@@ -90,11 +90,12 @@ function NAMEToLocaleString() {
}
function NAMEValueOf() {
if (typeof(this) !== 'TYPE' && %_ClassOf(this) !== 'NAME') {
var value = %_ValueOf(this);
if (typeof(value) !== 'TYPE') {
throw MakeTypeError(kIncompatibleMethodReceiver,
"NAME.prototype.valueOf", this);
}
return %_ValueOf(this);
return value;
}
function NAMEExtractLaneJS(instance, lane) {
......
......@@ -111,7 +111,6 @@ macro IS_SYMBOL_WRAPPER(arg) = (%_ClassOf(arg) === 'Symbol');
macro IS_BOOLEAN_WRAPPER(arg) = (%_ClassOf(arg) === 'Boolean');
macro IS_ERROR(arg) = (%_ClassOf(arg) === 'Error');
macro IS_SCRIPT(arg) = (%_ClassOf(arg) === 'Script');
macro IS_ARGUMENTS(arg) = (%_ClassOf(arg) === 'Arguments');
macro IS_GLOBAL(arg) = (%_ClassOf(arg) === 'global');
macro IS_ARRAYBUFFER(arg) = (%_ClassOf(arg) === 'ArrayBuffer');
macro IS_DATAVIEW(arg) = (%_ClassOf(arg) === 'DataView');
......
......@@ -433,6 +433,19 @@ RUNTIME_FUNCTION(Runtime_IsSharedIntegerTypedArray) {
}
RUNTIME_FUNCTION(Runtime_IsSharedInteger32TypedArray) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
if (!args[0]->IsJSTypedArray()) {
return isolate->heap()->false_value();
}
Handle<JSTypedArray> obj(JSTypedArray::cast(args[0]));
return isolate->heap()->ToBoolean(obj->GetBuffer()->is_shared() &&
obj->type() == kExternalInt32Array);
}
RUNTIME_FUNCTION(Runtime_DataViewInitialize) {
HandleScope scope(isolate);
DCHECK(args.length() == 4);
......
......@@ -1008,6 +1008,7 @@ namespace internal {
F(IsTypedArray, 1, 1) \
F(IsSharedTypedArray, 1, 1) \
F(IsSharedIntegerTypedArray, 1, 1) \
F(IsSharedInteger32TypedArray, 1, 1) \
F(DataViewInitialize, 4, 1) \
F(DataViewGetUint8, 3, 1) \
F(DataViewGetInt8, 3, 1) \
......
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