Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
TypedArray: Make byteOffset, byteLength, and length configurable
Browse files Browse the repository at this point in the history
Removes the DONT_DELETE enum bit from the properties to make them
configurable.

Also, updates the regress-typedarray-length test to --
- Check for true boolean return value on deletion of these
  properties.
- Check for undefined return value on trying to access these
  properties after deletion.

BUG=v8:4902
LOG=Y

Review-Url: https://codereview.chromium.org/2001393004
Cr-Commit-Position: refs/heads/master@{#36528}
  • Loading branch information
gsathya authored and Commit bot committed May 25, 2016
1 parent 06cc9b7 commit 91e2039
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 35 deletions.
9 changes: 4 additions & 5 deletions src/js/typedarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -827,12 +827,11 @@ utils.InstallFunctions(TypedArray, DONT_ENUM, [
"of", TypedArrayOf
]);
utils.InstallGetter(TypedArray.prototype, "buffer", TypedArrayGetBuffer);
utils.InstallGetter(TypedArray.prototype, "byteOffset", TypedArrayGetByteOffset,
DONT_ENUM | DONT_DELETE);
utils.InstallGetter(TypedArray.prototype, "byteOffset",
TypedArrayGetByteOffset);
utils.InstallGetter(TypedArray.prototype, "byteLength",
TypedArrayGetByteLength, DONT_ENUM | DONT_DELETE);
utils.InstallGetter(TypedArray.prototype, "length", TypedArrayGetLength,
DONT_ENUM | DONT_DELETE);
TypedArrayGetByteLength);
utils.InstallGetter(TypedArray.prototype, "length", TypedArrayGetLength);
utils.InstallGetter(TypedArray.prototype, toStringTagSymbol,
TypedArrayGetToStringTag);
utils.InstallFunctions(TypedArray.prototype, DONT_ENUM, [
Expand Down
32 changes: 16 additions & 16 deletions test/mjsunit/regress/regress-typedarray-length.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,42 +108,42 @@ assertEquals(undefined, get(a));
assertEquals("blah", get(a));
})();

// Ensure we cannot delete length, byteOffset, byteLength.
// Ensure we can delete length, byteOffset, byteLength.
assertTrue(Int32Array.prototype.__proto__.hasOwnProperty("length"));
assertTrue(Int32Array.prototype.__proto__.hasOwnProperty("byteOffset"));
assertTrue(Int32Array.prototype.__proto__.hasOwnProperty("byteLength"));
assertFalse(delete Int32Array.prototype.__proto__.length);
assertFalse(delete Int32Array.prototype.__proto__.byteOffset);
assertFalse(delete Int32Array.prototype.__proto__.byteLength);
assertTrue(delete Int32Array.prototype.__proto__.length);
assertTrue(delete Int32Array.prototype.__proto__.byteOffset);
assertTrue(delete Int32Array.prototype.__proto__.byteLength);

a = new Int32Array(100);

get = function(a) {
return a.length;
}

assertEquals(100, get(a));
assertEquals(100, get(a));
assertEquals(100, get(a));
assertEquals(undefined, get(a));
assertEquals(undefined, get(a));
assertEquals(undefined, get(a));
%OptimizeFunctionOnNextCall(get);
assertEquals(100, get(a));
assertEquals(undefined, get(a));

get = function(a) {
return a.byteLength;
}

assertEquals(400, get(a));
assertEquals(400, get(a));
assertEquals(400, get(a));
assertEquals(undefined, get(a));
assertEquals(undefined, get(a));
assertEquals(undefined, get(a));
%OptimizeFunctionOnNextCall(get);
assertEquals(400, get(a));
assertEquals(undefined, get(a));

get = function(a) {
return a.byteOffset;
}

assertEquals(0, get(a));
assertEquals(0, get(a));
assertEquals(0, get(a));
assertEquals(undefined, get(a));
assertEquals(undefined, get(a));
assertEquals(undefined, get(a));
%OptimizeFunctionOnNextCall(get);
assertEquals(0, get(a));
assertEquals(undefined, get(a));
14 changes: 0 additions & 14 deletions test/test262/test262.status
Original file line number Diff line number Diff line change
Expand Up @@ -233,20 +233,6 @@
# https://bugs.chromium.org/p/v8/issues/detail?id=4034
'built-ins/ThrowTypeError/unique-per-realm-function-proto': [FAIL],

# https://bugs.chromium.org/p/v8/issues/detail?id=4902
'built-ins/TypedArray/prototype/byteLength/prop-desc': [FAIL],
'built-ins/TypedArray/prototype/byteOffset/prop-desc': [FAIL],
'built-ins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop': [FAIL],
'built-ins/TypedArray/prototype/every/get-length-ignores-length-prop': [FAIL],
'built-ins/TypedArray/prototype/every/get-length-uses-internal-arraylength': [FAIL],
'built-ins/TypedArray/prototype/fill/get-length-ignores-length-prop': [FAIL],
'built-ins/TypedArray/prototype/find/get-length-ignores-length-prop': [FAIL],
'built-ins/TypedArray/prototype/findIndex/get-length-ignores-length-prop': [FAIL],
'built-ins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength': [FAIL],
'built-ins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength': [FAIL],
'built-ins/TypedArray/prototype/length/prop-desc': [FAIL],
'built-ins/TypedArray/prototype/some/get-length-uses-internal-arraylength': [FAIL],

# https://bugs.chromium.org/p/v8/issues/detail?id=4231
'language/eval-code/direct/var-env-lower-lex-catch-non-strict': [FAIL],
'language/statements/try/early-catch-lex': [FAIL],
Expand Down

0 comments on commit 91e2039

Please sign in to comment.