Commit 8f8457d2 authored by domenic's avatar domenic Committed by Commit bot

Add methods to extras' InternalPackedArray

https://codereview.chromium.org/1343113003 introduced a separate InternalPackedArray constructor to the extras utils object, distinct from the one used by natives. However, it omitted the code to set up the methods for that InternalPackedArray. This makes all the basic manipulation methods available.

BUG=v8:4276
LOG=Y
R=jochen@chromium.org,yangguo@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#31272}
parent 6b4d7f81
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(function(global, utils) {
(function(global, utils, extrasUtils) {
"use strict";
......@@ -1624,6 +1624,17 @@ utils.SetUpLockedPrototype(InternalPackedArray, GlobalArray(), [
"shift", getFunction("shift", ArrayShift)
]);
// V8 extras get a separate copy of InternalPackedArray. We give them the basic
// manipulation methods.
utils.SetUpLockedPrototype(extrasUtils.InternalPackedArray, GlobalArray(), [
"push", getFunction("push", ArrayPush),
"pop", getFunction("pop", ArrayPop),
"shift", getFunction("shift", ArrayShift),
"unshift", getFunction("unshift", ArrayUnshift),
"splice", getFunction("splice", ArraySplice),
"slice", getFunction("slice", ArraySlice)
]);
// -------------------------------------------------------------------
// Exports
......
......@@ -28,6 +28,18 @@
const Promise = global.Promise;
const Promise_resolve = v8.simpleBind(Promise.resolve, Promise);
const arrayToTest = new v8.InternalPackedArray();
arrayToTest.push(1);
arrayToTest.push(2);
arrayToTest.pop();
arrayToTest.unshift("a", "b", "c");
arrayToTest.shift();
arrayToTest.splice(0, 1);
const slicedArray = arrayToTest.slice();
const arraysOK = arrayToTest.length === 2 && arrayToTest[0] === "c" &&
arrayToTest[1] === 1 && slicedArray.length === 2 &&
slicedArray[0] === "c" && slicedArray[1] === 1;
binding.testExtraCanUseUtils = function() {
const fulfilledPromise = v8.createPromise();
v8.resolvePromise(
......@@ -35,9 +47,9 @@
hasOwn({ test: 'test' }, 'test') ? 1 : -1
);
const fulfilledPromise2 = Promise_resolve(call(function (arg1) {
return (this.prop === arg1 && arg1 === 'value') ? 2 : -1;
}, { prop: 'value' }, 'value'));
const fulfilledPromise2 = Promise_resolve(call(function (arg1, arg2) {
return (this.prop === arg1 && arg1 === 'value' && arg2) ? 2 : -1;
}, { prop: 'value' }, 'value', arraysOK));
const rejectedPromise = v8.createPromise();
v8.rejectPromise(rejectedPromise, apply(function (arg1, arg2) {
......
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