Commit 95e0ba65 authored by bakkot's avatar bakkot Committed by Commit bot

Reland of Amends the TypedArray constructor to use the path for primitives for...

Reland of Amends the TypedArray constructor to use the path for primitives for all (patchset #1 id:1 of https://codereview.chromium.org/2120763002/ )

Reason for revert:
WebGL tests have been updated and rolled (at https://codereview.chromium.org/2227023002), so this should no longer fail outdated tests.

Original issue's description:
> Revert of Amends the TypedArray constructor to use the path for primitives for all (patchset #4 id:60001 of https://codereview.chromium.org/2096873002/ )
>
> Reason for revert:
> Speculative revert to unblock roll https://codereview.chromium.org/2114113002/
>
> Original issue's description:
> > Amends the TypedArray constructor to use the path for primitives for all
> > types of primitives, not just undefined, booleans, numbers, and strings.
> > (The missing cases were null and Symbol.) This is required by the
> > specification, and there are test262 tests which we were failing due to
> > this bug.
> >
> > BUG=v8:5124
> >
> > Committed: https://crrev.com/f788bd9cce19815cba746e47bb65abfe25c16208
> > Committed: https://crrev.com/f772c22cd1c492aa0235a8e6012d0386146d2eb2
> > Cr-Original-Commit-Position: refs/heads/master@{#37234}
> > Cr-Commit-Position: refs/heads/master@{#37407}
>
> TBR=littledan@chromium.org,bakkot@google.com
> NOTREECHECKS=true
> BUG=v8:5124
>
> Committed: https://crrev.com/9c0aef52fa672db856ebfac7f4bdcd7d7b103663
> Cr-Commit-Position: refs/heads/master@{#37487}

TBR=littledan@chromium.org,hablich@chromium.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=v8:5124

Review-Url: https://codereview.chromium.org/2255543002
Cr-Commit-Position: refs/heads/master@{#38691}
parent 931ac008
......@@ -259,18 +259,17 @@ function NAMEConstructor(arg1, arg2, arg3) {
if (!IS_UNDEFINED(new.target)) {
if (IS_ARRAYBUFFER(arg1) || IS_SHAREDARRAYBUFFER(arg1)) {
NAMEConstructByArrayBuffer(this, arg1, arg2, arg3);
} else if (IS_NUMBER(arg1) || IS_STRING(arg1) ||
IS_BOOLEAN(arg1) || IS_UNDEFINED(arg1)) {
NAMEConstructByLength(this, arg1);
} else if (IS_TYPEDARRAY(arg1)) {
NAMEConstructByTypedArray(this, arg1);
} else {
} else if (IS_RECEIVER(arg1)) {
var iteratorFn = arg1[iteratorSymbol];
if (IS_UNDEFINED(iteratorFn) || iteratorFn === ArrayValues) {
NAMEConstructByArrayLike(this, arg1, arg1.length);
} else {
NAMEConstructByIterable(this, arg1, iteratorFn);
}
} else {
NAMEConstructByLength(this, arg1);
}
} else {
throw %make_type_error(kConstructorNotFunction, "NAME")
......
......@@ -229,6 +229,27 @@ function TestTypedArray(constr, elementSize, typicalElement) {
RangeError);
}
var aFromUndef = new constr();
assertSame(elementSize, aFromUndef.BYTES_PER_ELEMENT);
assertSame(0, aFromUndef.length);
assertSame(0*elementSize, aFromUndef.byteLength);
assertSame(0, aFromUndef.byteOffset);
assertSame(0*elementSize, aFromUndef.buffer.byteLength);
var aFromNull = new constr(null);
assertSame(elementSize, aFromNull.BYTES_PER_ELEMENT);
assertSame(0, aFromNull.length);
assertSame(0*elementSize, aFromNull.byteLength);
assertSame(0, aFromNull.byteOffset);
assertSame(0*elementSize, aFromNull.buffer.byteLength);
var aFromBool = new constr(true);
assertSame(elementSize, aFromBool.BYTES_PER_ELEMENT);
assertSame(1, aFromBool.length);
assertSame(1*elementSize, aFromBool.byteLength);
assertSame(0, aFromBool.byteOffset);
assertSame(1*elementSize, aFromBool.buffer.byteLength);
var aFromString = new constr("30");
assertSame(elementSize, aFromString.BYTES_PER_ELEMENT);
assertSame(30, aFromString.length);
......@@ -236,6 +257,8 @@ function TestTypedArray(constr, elementSize, typicalElement) {
assertSame(0, aFromString.byteOffset);
assertSame(30*elementSize, aFromString.buffer.byteLength);
assertThrows(function() { new constr(Symbol()); }, TypeError);
var jsArray = [];
for (i = 0; i < 30; i++) {
jsArray.push(typicalElement);
......
......@@ -137,9 +137,6 @@
'intl402/DateTimeFormat/12.1.1_1': [FAIL],
'intl402/NumberFormat/11.1.1_1': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=4727
'built-ins/TypedArrays/length-arg-is-symbol-throws': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=4784
'built-ins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws': [FAIL],
'built-ins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws': [FAIL],
......@@ -358,9 +355,6 @@
# https://bugs.chromium.org/p/v8/issues/detail?id=5121
'language/expressions/assignment/destructuring/obj-prop-__proto__dup': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=5124
'built-ins/TypedArrays/length-arg-toindex-length': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=4973
'language/literals/numeric/non-octal-decimal-integer-strict': [FAIL],
......@@ -492,6 +486,9 @@
'built-ins/RegExp/prototype/multiline/15.10.7.4-1': [FAIL],
# https://github.com/tc39/test262/issues/694
'built-ins/TypedArrays/length-arg-toindex-length': [FAIL],
# https://github.com/tc39/test262/issues/696
'language/statements/class/subclass/builtin-objects/ArrayBuffer/regular-subclassing': [FAIL],
# https://github.com/tc39/test262/issues/685
......
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