Commit f772c22c authored by bakkot's avatar bakkot Committed by Commit bot

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
Review-Url: https://codereview.chromium.org/2096873002
Cr-Original-Commit-Position: refs/heads/master@{#37234}
Cr-Commit-Position: refs/heads/master@{#37407}
parent 09720349
......@@ -270,18 +270,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 MakeTypeError(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);
......
......@@ -126,9 +126,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],
......@@ -364,9 +361,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],
......@@ -498,6 +492,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