зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1240984 - Remove the same-data/change-data distinction when detaching ArrayBuffers, r=Waldo
--HG-- extra : rebase_source : b5f8ce4be8efa10f45faa7503f9f08f7aa059b05
This commit is contained in:
Родитель
352c38a321
Коммит
eaf061e379
|
@ -2273,38 +2273,18 @@ DetachArrayBuffer(JSContext* cx, unsigned argc, Value* vp)
|
|||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
if (args.length() != 2) {
|
||||
JS_ReportError(cx, "wrong number of arguments to detachArrayBuffer()");
|
||||
if (args.length() != 1) {
|
||||
JS_ReportError(cx, "detachArrayBuffer() requires a single argument");
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedObject obj(cx);
|
||||
if (!JS_ValueToObject(cx, args[0], &obj))
|
||||
return false;
|
||||
|
||||
if (!obj) {
|
||||
if (!args[0].isObject()) {
|
||||
JS_ReportError(cx, "detachArrayBuffer must be passed an object");
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedString str(cx, JS::ToString(cx, args[1]));
|
||||
if (!str)
|
||||
return false;
|
||||
JSAutoByteString dataDisposition(cx, str);
|
||||
if (!dataDisposition)
|
||||
return false;
|
||||
|
||||
DetachDataDisposition changeData;
|
||||
if (strcmp(dataDisposition.ptr(), "same-data") == 0) {
|
||||
changeData = KeepData;
|
||||
} else if (strcmp(dataDisposition.ptr(), "change-data") == 0) {
|
||||
changeData = ChangeData;
|
||||
} else {
|
||||
JS_ReportError(cx, "unknown parameter 2 to detachArrayBuffer()");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!JS_DetachArrayBuffer(cx, obj, changeData))
|
||||
RootedObject obj(cx, &args[0].toObject());
|
||||
if (!JS_DetachArrayBuffer(cx, obj))
|
||||
return false;
|
||||
|
||||
args.rval().setUndefined();
|
||||
|
@ -3941,11 +3921,9 @@ gc::ZealModeHelpText),
|
|||
" Deserialize data generated by serialize."),
|
||||
|
||||
JS_FN_HELP("detachArrayBuffer", DetachArrayBuffer, 1, 0,
|
||||
"detachArrayBuffer(buffer, \"change-data\"|\"same-data\")",
|
||||
"detachArrayBuffer(buffer)",
|
||||
" Detach the given ArrayBuffer object from its memory, i.e. as if it\n"
|
||||
" had been transferred to a WebWorker. \"change-data\" will update\n"
|
||||
" the internal data pointer. \"same-data\" will leave it set to \n"
|
||||
" its original value, mimicking, e.g., asm.js ArrayBuffer detaching."),
|
||||
" had been transferred to a WebWorker."),
|
||||
|
||||
JS_FN_HELP("helperThreadCount", HelperThreadCount, 0, 0,
|
||||
"helperThreadCount()",
|
||||
|
|
|
@ -9,7 +9,7 @@ load(libdir + "asserts.js")
|
|||
var StructType = TypedObject.StructType;
|
||||
var uint32 = TypedObject.uint32;
|
||||
|
||||
function main(variant)
|
||||
function main()
|
||||
{
|
||||
var Point = new StructType({ x: uint32, y: uint32 });
|
||||
var Line = new StructType({ from: Point, to: Point });
|
||||
|
@ -20,9 +20,8 @@ function main(variant)
|
|||
assertThrowsInstanceOf(function()
|
||||
{
|
||||
line.to = { x: 22,
|
||||
get y() { detachArrayBuffer(buf, variant); return 44; } };
|
||||
get y() { detachArrayBuffer(buf); return 44; } };
|
||||
}, TypeError, "setting into a detached buffer is bad mojo");
|
||||
}
|
||||
|
||||
main("same-data");
|
||||
main("change-data");
|
||||
main();
|
||||
|
|
|
@ -8,17 +8,16 @@ load(libdir + "asserts.js")
|
|||
|
||||
var {StructType, uint32, Object, Any, storage, objectType} = TypedObject;
|
||||
|
||||
function main(variant) { // once a C programmer, always a C programmer.
|
||||
function main() { // once a C programmer, always a C programmer.
|
||||
var Uints = uint32.array(0);
|
||||
var Unit = new StructType({}); // Empty struct type
|
||||
var buffer = new ArrayBuffer(0); // Empty buffer
|
||||
var p = new Unit(buffer); // OK
|
||||
detachArrayBuffer(buffer, variant);
|
||||
detachArrayBuffer(buffer);
|
||||
assertThrowsInstanceOf(() => new Unit(buffer), TypeError,
|
||||
"Able to instantiate atop detached buffer");
|
||||
assertThrowsInstanceOf(() => new Uints(buffer), TypeError,
|
||||
"Able to instantiate atop detached buffer");
|
||||
}
|
||||
|
||||
main("same-data");
|
||||
main("change-data");
|
||||
main();
|
||||
|
|
|
@ -3,13 +3,13 @@ if (typeof TypedObject === "undefined")
|
|||
|
||||
var {StructType, uint32, storage} = TypedObject;
|
||||
var S = new StructType({f: uint32, g: uint32});
|
||||
function main(variant) {
|
||||
function main() {
|
||||
var s = new S({f: 22, g: 44});
|
||||
detachArrayBuffer(storage(s).buffer, variant);
|
||||
detachArrayBuffer(storage(s).buffer);
|
||||
print(storage(s).byteOffset);
|
||||
}
|
||||
try {
|
||||
main("same-data");
|
||||
main();
|
||||
assertEq(true, false);
|
||||
} catch (e) {
|
||||
assertEq(e instanceof TypeError, true);
|
||||
|
|
|
@ -8,13 +8,13 @@ function readFromS(s) {
|
|||
return s.f + s.g;
|
||||
}
|
||||
|
||||
function main(variant) {
|
||||
function main() {
|
||||
var s = new S({f: 22, g: 44});
|
||||
|
||||
for (var i = 0; i < 10; i++)
|
||||
assertEq(readFromS(s), 66);
|
||||
|
||||
detachArrayBuffer(storage(s).buffer, variant);
|
||||
detachArrayBuffer(storage(s).buffer);
|
||||
|
||||
for (var i = 0; i < 10; i++) {
|
||||
var ok = false;
|
||||
|
@ -29,5 +29,4 @@ function main(variant) {
|
|||
}
|
||||
}
|
||||
|
||||
main("same-data");
|
||||
main("change-data");
|
||||
main();
|
||||
|
|
|
@ -14,7 +14,7 @@ function readFrom(a) {
|
|||
return a[2].f + a[2].g;
|
||||
}
|
||||
|
||||
function main(variant) {
|
||||
function main() {
|
||||
var a = new A();
|
||||
a[2].f = 22;
|
||||
a[2].g = 44;
|
||||
|
@ -22,7 +22,7 @@ function main(variant) {
|
|||
for (var i = 0; i < 10; i++)
|
||||
assertEq(readFrom(a), 66);
|
||||
|
||||
detachArrayBuffer(storage(a).buffer, variant);
|
||||
detachArrayBuffer(storage(a).buffer);
|
||||
|
||||
for (var i = 0; i < 10; i++) {
|
||||
var ok = false;
|
||||
|
@ -37,5 +37,4 @@ function main(variant) {
|
|||
}
|
||||
}
|
||||
|
||||
main("same-data");
|
||||
main("change-data");
|
||||
main();
|
||||
|
|
|
@ -12,7 +12,7 @@ function readFrom(a) {
|
|||
return a[2].f + a[2].g;
|
||||
}
|
||||
|
||||
function main(variant) {
|
||||
function main() {
|
||||
var a = new A();
|
||||
a[2].f = 22;
|
||||
a[2].g = 44;
|
||||
|
@ -20,7 +20,7 @@ function main(variant) {
|
|||
for (var i = 0; i < 10; i++)
|
||||
assertEq(readFrom(a), 66);
|
||||
|
||||
detachArrayBuffer(storage(a).buffer, variant);
|
||||
detachArrayBuffer(storage(a).buffer);
|
||||
|
||||
for (var i = 0; i < 10; i++) {
|
||||
var ok = false;
|
||||
|
@ -35,5 +35,4 @@ function main(variant) {
|
|||
}
|
||||
}
|
||||
|
||||
main("same-data");
|
||||
main("change-data");
|
||||
main();
|
||||
|
|
|
@ -23,6 +23,6 @@ if (isAsmJSCompilationAvailable())
|
|||
|
||||
try
|
||||
{
|
||||
set({ valueOf() { detachArrayBuffer(buffer, "same-data"); return 17; } });
|
||||
set({ valueOf() { detachArrayBuffer(buffer); return 17; } });
|
||||
}
|
||||
catch (e) { /* if an exception thrown, swallow */ }
|
||||
|
|
|
@ -1,25 +1,23 @@
|
|||
for (var variant of ["same-data", "change-data"]) {
|
||||
var ab = new ArrayBuffer(4);
|
||||
var i32 = new Int32Array(ab);
|
||||
i32[0] = 42;
|
||||
detachArrayBuffer(ab, variant);
|
||||
assertEq(i32.length, 0);
|
||||
assertEq(ab.byteLength, 0);
|
||||
assertEq(i32[0], undefined);
|
||||
var ab = new ArrayBuffer(4);
|
||||
var i32 = new Int32Array(ab);
|
||||
i32[0] = 42;
|
||||
detachArrayBuffer(ab);
|
||||
assertEq(i32.length, 0);
|
||||
assertEq(ab.byteLength, 0);
|
||||
assertEq(i32[0], undefined);
|
||||
|
||||
var ab = new ArrayBuffer(12);
|
||||
var i32 = new Int32Array(ab);
|
||||
i32[0] = 42;
|
||||
detachArrayBuffer(ab, variant);
|
||||
assertEq(i32.length, 0);
|
||||
assertEq(ab.byteLength, 0);
|
||||
assertEq(i32[0], undefined);
|
||||
var ab = new ArrayBuffer(12);
|
||||
var i32 = new Int32Array(ab);
|
||||
i32[0] = 42;
|
||||
detachArrayBuffer(ab);
|
||||
assertEq(i32.length, 0);
|
||||
assertEq(ab.byteLength, 0);
|
||||
assertEq(i32[0], undefined);
|
||||
|
||||
var ab = new ArrayBuffer(4096);
|
||||
var i32 = new Int32Array(ab);
|
||||
i32[0] = 42;
|
||||
detachArrayBuffer(ab, variant);
|
||||
assertEq(i32.length, 0);
|
||||
assertEq(ab.byteLength, 0);
|
||||
assertEq(i32[0], undefined);
|
||||
}
|
||||
var ab = new ArrayBuffer(4096);
|
||||
var i32 = new Int32Array(ab);
|
||||
i32[0] = 42;
|
||||
detachArrayBuffer(ab);
|
||||
assertEq(i32.length, 0);
|
||||
assertEq(ab.byteLength, 0);
|
||||
assertEq(i32[0], undefined);
|
||||
|
|
|
@ -174,7 +174,7 @@ for (var constructor of constructors) {
|
|||
|
||||
function detachAndConvertTo(x) {
|
||||
return { valueOf() {
|
||||
detachArrayBuffer(tarray.buffer, "change-data");
|
||||
detachArrayBuffer(tarray.buffer);
|
||||
return x;
|
||||
} };
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ var INLINABLE_INT8_AMOUNT = 4;
|
|||
|
||||
// Large arrays with non-inline data
|
||||
|
||||
// Detaching and replacing data.
|
||||
var ab1 = new ArrayBuffer(NONINLINABLE_AMOUNT * SIZEOF_INT32);
|
||||
var ta1 = new Int32Array(ab1);
|
||||
for (var i = 0; i < ta1.length; i++)
|
||||
|
@ -13,40 +12,17 @@ for (var i = 0; i < ta1.length; i++)
|
|||
function q1() { return ta1[NONINLINABLE_AMOUNT - 1]; }
|
||||
assertEq(q1(), NONINLINABLE_AMOUNT - 1 + 43);
|
||||
assertEq(q1(), NONINLINABLE_AMOUNT - 1 + 43);
|
||||
detachArrayBuffer(ab1, "change-data");
|
||||
detachArrayBuffer(ab1);
|
||||
assertEq(q1(), undefined);
|
||||
|
||||
// Detaching preserving data pointer.
|
||||
var ab2 = new ArrayBuffer(NONINLINABLE_AMOUNT * SIZEOF_INT32);
|
||||
var ta2 = new Int32Array(ab2);
|
||||
for (var i = 0; i < ta2.length; i++)
|
||||
ta2[i] = i + 77;
|
||||
function q2() { return ta2[NONINLINABLE_AMOUNT - 1]; }
|
||||
assertEq(q2(), NONINLINABLE_AMOUNT - 1 + 77);
|
||||
assertEq(q2(), NONINLINABLE_AMOUNT - 1 + 77);
|
||||
detachArrayBuffer(ab2, "same-data");
|
||||
assertEq(q2(), undefined);
|
||||
|
||||
// Small arrays with inline data
|
||||
|
||||
// Detaching and replacing data.
|
||||
var ab3 = new ArrayBuffer(INLINABLE_INT8_AMOUNT);
|
||||
var ta3 = new Int8Array(ab3);
|
||||
for (var i = 0; i < ta3.length; i++)
|
||||
ta3[i] = i + 13;
|
||||
function q3() { return ta3[INLINABLE_INT8_AMOUNT - 1]; }
|
||||
assertEq(q3(), INLINABLE_INT8_AMOUNT - 1 + 13);
|
||||
assertEq(q3(), INLINABLE_INT8_AMOUNT - 1 + 13);
|
||||
detachArrayBuffer(ab3, "change-data");
|
||||
assertEq(q3(), undefined);
|
||||
|
||||
// Detaching preserving data pointer.
|
||||
var ab4 = new ArrayBuffer(4);
|
||||
var ta4 = new Int8Array(ab4);
|
||||
for (var i = 0; i < ta4.length; i++)
|
||||
ta4[i] = i + 17;
|
||||
function q4() { return ta4[INLINABLE_INT8_AMOUNT - 1]; }
|
||||
assertEq(q4(), INLINABLE_INT8_AMOUNT - 1 + 17);
|
||||
assertEq(q4(), INLINABLE_INT8_AMOUNT - 1 + 17);
|
||||
detachArrayBuffer(ab4, "same-data");
|
||||
assertEq(q4(), undefined);
|
||||
var ab2 = new ArrayBuffer(INLINABLE_INT8_AMOUNT);
|
||||
var ta2 = new Int8Array(ab2);
|
||||
for (var i = 0; i < ta2.length; i++)
|
||||
ta2[i] = i + 13;
|
||||
function q2() { return ta2[INLINABLE_INT8_AMOUNT - 1]; }
|
||||
assertEq(q2(), INLINABLE_INT8_AMOUNT - 1 + 13);
|
||||
assertEq(q2(), INLINABLE_INT8_AMOUNT - 1 + 13);
|
||||
detachArrayBuffer(ab2);
|
||||
assertEq(q2(), undefined);
|
||||
|
|
|
@ -3,40 +3,20 @@ var OUT_OF_LINE_INT8_AMOUNT = 237;
|
|||
|
||||
// Small and inline
|
||||
|
||||
// Detaching and replacing data.
|
||||
var ab1 = new ArrayBuffer(INLINE_INT8_AMOUNT);
|
||||
var ta1 = new Int8Array(ab1);
|
||||
function q1() { return ta1.length; }
|
||||
q1();
|
||||
q1();
|
||||
detachArrayBuffer(ab1, "change-data");
|
||||
detachArrayBuffer(ab1);
|
||||
assertEq(q1(), 0);
|
||||
|
||||
// Detaching preserving data pointer.
|
||||
var ab2 = new ArrayBuffer(INLINE_INT8_AMOUNT);
|
||||
// Large and out-of-line
|
||||
|
||||
var ab2 = new ArrayBuffer(OUT_OF_LINE_INT8_AMOUNT);
|
||||
var ta2 = new Int8Array(ab2);
|
||||
function q2() { return ta2.length; }
|
||||
q2();
|
||||
q2();
|
||||
detachArrayBuffer(ab2, "same-data");
|
||||
detachArrayBuffer(ab2);
|
||||
assertEq(q2(), 0);
|
||||
|
||||
// Large and out-of-line
|
||||
|
||||
// Detaching and replacing data.
|
||||
var ab3 = new ArrayBuffer(OUT_OF_LINE_INT8_AMOUNT);
|
||||
var ta3 = new Int8Array(ab3);
|
||||
function q3() { return ta3.length; }
|
||||
q3();
|
||||
q3();
|
||||
detachArrayBuffer(ab3, "change-data");
|
||||
assertEq(q3(), 0);
|
||||
|
||||
// Detaching preserving data pointer.
|
||||
var ab4 = new ArrayBuffer(OUT_OF_LINE_INT8_AMOUNT);
|
||||
var ta4 = new Int8Array(ab4);
|
||||
function q4() { return ta4.length; }
|
||||
q4();
|
||||
q4();
|
||||
detachArrayBuffer(ab4, "same-data");
|
||||
assertEq(q4(), 0);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function detachArrayBufferEventually(arr, i, variant)
|
||||
function detachArrayBufferEventually(arr, i)
|
||||
{
|
||||
with (arr)
|
||||
{
|
||||
|
@ -6,20 +6,19 @@ function detachArrayBufferEventually(arr, i, variant)
|
|||
}
|
||||
|
||||
if (i === 2000)
|
||||
detachArrayBuffer(arr.buffer, variant);
|
||||
detachArrayBuffer(arr.buffer);
|
||||
}
|
||||
|
||||
function test(variant)
|
||||
function test()
|
||||
{
|
||||
var buf = new ArrayBuffer(1000);
|
||||
var ta = new Int8Array(buf);
|
||||
|
||||
for (var i = 0; i < 2500; i++)
|
||||
{
|
||||
detachArrayBufferEventually(ta, i, variant);
|
||||
detachArrayBufferEventually(ta, i);
|
||||
assertEq(ta.length, i >= 2000 ? 0 : 1000);
|
||||
}
|
||||
}
|
||||
|
||||
test("change-data");
|
||||
test("same-data");
|
||||
test();
|
||||
|
|
|
@ -7,6 +7,6 @@ load();
|
|||
load();
|
||||
load();
|
||||
|
||||
detachArrayBuffer(buffer, "change-data");
|
||||
detachArrayBuffer(buffer);
|
||||
|
||||
load();
|
||||
|
|
|
@ -7,6 +7,6 @@ store();
|
|||
store();
|
||||
store();
|
||||
|
||||
detachArrayBuffer(buffer, "change-data");
|
||||
detachArrayBuffer(buffer);
|
||||
|
||||
store();
|
||||
|
|
|
@ -22,7 +22,7 @@ BEGIN_TEST(testExternalArrayBuffer)
|
|||
GC(cx);
|
||||
CHECK(VerifyObject(obj, length));
|
||||
GC(cx);
|
||||
JS_DetachArrayBuffer(cx, obj, KeepData);
|
||||
JS_DetachArrayBuffer(cx, obj);
|
||||
GC(cx);
|
||||
CHECK(VerifyObject(obj, 0));
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ bool TestDetachObject()
|
|||
{
|
||||
JS::RootedObject obj(cx, CreateNewObject(8, 12));
|
||||
CHECK(obj);
|
||||
JS_DetachArrayBuffer(cx, obj, ChangeData);
|
||||
JS_DetachArrayBuffer(cx, obj);
|
||||
CHECK(JS_IsDetachedArrayBufferObject(obj));
|
||||
|
||||
return true;
|
||||
|
|
|
@ -2097,11 +2097,6 @@ JS_GetArrayBufferViewData(JSObject* obj, bool* isSharedMemory, const JS::AutoChe
|
|||
extern JS_FRIEND_API(JSObject*)
|
||||
JS_GetArrayBufferViewBuffer(JSContext* cx, JS::HandleObject obj, bool* isSharedMemory);
|
||||
|
||||
enum DetachDataDisposition {
|
||||
ChangeData,
|
||||
KeepData
|
||||
};
|
||||
|
||||
/**
|
||||
* Detach an ArrayBuffer, causing all associated views to no longer refer to
|
||||
* the ArrayBuffer's original attached memory.
|
||||
|
@ -2109,8 +2104,7 @@ enum DetachDataDisposition {
|
|||
* The |changeData| argument is obsolete and ignored.
|
||||
*/
|
||||
extern JS_FRIEND_API(bool)
|
||||
JS_DetachArrayBuffer(JSContext* cx, JS::HandleObject obj,
|
||||
DetachDataDisposition changeData);
|
||||
JS_DetachArrayBuffer(JSContext* cx, JS::HandleObject obj);
|
||||
|
||||
/**
|
||||
* Check whether the obj is a detached ArrayBufferObject. Note that this may
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
// |reftest| skip-if(!xulRuntime.shell) -- needs detachArrayBuffer
|
||||
|
||||
for (var detachArg of ['change-data', 'same-data']) {
|
||||
var buf = new ArrayBuffer([1,2]);
|
||||
var bufView = new DataView(buf);
|
||||
var buf = new ArrayBuffer([1,2]);
|
||||
var bufView = new DataView(buf);
|
||||
|
||||
detachArrayBuffer(buf, detachArg);
|
||||
detachArrayBuffer(buf);
|
||||
|
||||
assertThrowsInstanceOf(() => bufView.getInt8(0), TypeError);
|
||||
}
|
||||
assertThrowsInstanceOf(() => bufView.getInt8(0), TypeError);
|
||||
|
||||
if (typeof reportCompare === 'function')
|
||||
reportCompare(0, 0, "OK");
|
||||
|
|
|
@ -23,7 +23,7 @@ for (let fun of ['getInt8', 'getInt16']) {
|
|||
if ('detachArrayBuffer' in this) {
|
||||
// ToIndex is called before detachment check, so we can tell the difference
|
||||
// between a ToIndex failure and a real out of bounds failure.
|
||||
detachArrayBuffer(buffer, 'same-data');
|
||||
detachArrayBuffer(buffer);
|
||||
|
||||
check(view);
|
||||
|
||||
|
|
|
@ -13,15 +13,13 @@ const constructors = [
|
|||
];
|
||||
|
||||
for (var constructor of constructors) {
|
||||
for (var detachType of ["change-data", "same-data"]) {
|
||||
var buf = new constructor();
|
||||
detachArrayBuffer(buf.buffer, detachType);
|
||||
assertThrowsInstanceOf(() => new constructor(buf), TypeError);
|
||||
var buf = new constructor();
|
||||
detachArrayBuffer(buf.buffer);
|
||||
assertThrowsInstanceOf(() => new constructor(buf), TypeError);
|
||||
|
||||
var buffer = new ArrayBuffer();
|
||||
detachArrayBuffer(buffer, detachType);
|
||||
assertThrowsInstanceOf(() => new constructor(buffer), TypeError);
|
||||
}
|
||||
var buffer = new ArrayBuffer();
|
||||
detachArrayBuffer(buffer);
|
||||
assertThrowsInstanceOf(() => new constructor(buffer), TypeError);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// all relevant functions.
|
||||
let buffer = new ArrayBuffer(32);
|
||||
let array = new Int32Array(buffer);
|
||||
detachArrayBuffer(buffer, "change-data");
|
||||
detachArrayBuffer(buffer);
|
||||
|
||||
// A nice poisoned callable to ensure that we fail on a detached buffer check
|
||||
// before a method attempts to do anything with its arguments.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
assertThrowsInstanceOf(() => {
|
||||
let buffer = new ArrayBuffer(32);
|
||||
let array = new Int32Array(buffer);
|
||||
detachArrayBuffer(buffer, "change-data");
|
||||
detachArrayBuffer(buffer);
|
||||
array.sort();
|
||||
}, TypeError);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ print(BUGNUMBER + ": " + summary);
|
|||
* BEGIN TEST *
|
||||
**************/
|
||||
|
||||
function testStart(dataType)
|
||||
function testStart()
|
||||
{
|
||||
var ab = new ArrayBuffer(0x1000);
|
||||
|
||||
|
@ -25,7 +25,7 @@ function testStart(dataType)
|
|||
{
|
||||
valueOf: function()
|
||||
{
|
||||
detachArrayBuffer(ab, dataType);
|
||||
detachArrayBuffer(ab);
|
||||
gc();
|
||||
return 0x800;
|
||||
}
|
||||
|
@ -43,10 +43,9 @@ function testStart(dataType)
|
|||
assertEq(ok, true, "start weirdness should have thrown");
|
||||
assertEq(ab.byteLength, 0, "detaching should work for start weirdness");
|
||||
}
|
||||
testStart("change-data");
|
||||
testStart("same-data");
|
||||
testStart();
|
||||
|
||||
function testEnd(dataType)
|
||||
function testEnd()
|
||||
{
|
||||
var ab = new ArrayBuffer(0x1000);
|
||||
|
||||
|
@ -54,7 +53,7 @@ function testEnd(dataType)
|
|||
{
|
||||
valueOf: function()
|
||||
{
|
||||
detachArrayBuffer(ab, dataType);
|
||||
detachArrayBuffer(ab);
|
||||
gc();
|
||||
return 0x1000;
|
||||
}
|
||||
|
@ -72,8 +71,7 @@ function testEnd(dataType)
|
|||
assertEq(ok, true, "byteLength weirdness should have thrown");
|
||||
assertEq(ab.byteLength, 0, "detaching should work for byteLength weirdness");
|
||||
}
|
||||
testEnd("change-data");
|
||||
testEnd("same-data");
|
||||
testEnd();
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ print(BUGNUMBER + ": " + summary);
|
|||
* BEGIN TEST *
|
||||
**************/
|
||||
|
||||
function testByteOffset(dataType)
|
||||
function testByteOffset()
|
||||
{
|
||||
var ab = new ArrayBuffer(0x1000);
|
||||
|
||||
|
@ -25,7 +25,7 @@ function testByteOffset(dataType)
|
|||
{
|
||||
valueOf: function()
|
||||
{
|
||||
detachArrayBuffer(ab, dataType);
|
||||
detachArrayBuffer(ab);
|
||||
gc();
|
||||
return 0x800;
|
||||
}
|
||||
|
@ -43,10 +43,9 @@ function testByteOffset(dataType)
|
|||
assertEq(ok, true, "byteOffset weirdness should have thrown");
|
||||
assertEq(ab.byteLength, 0, "detaching should work for byteOffset weirdness");
|
||||
}
|
||||
testByteOffset("change-data");
|
||||
testByteOffset("same-data");
|
||||
testByteOffset();
|
||||
|
||||
function testByteLength(dataType)
|
||||
function testByteLength()
|
||||
{
|
||||
var ab = new ArrayBuffer(0x1000);
|
||||
|
||||
|
@ -54,7 +53,7 @@ function testByteLength(dataType)
|
|||
{
|
||||
valueOf: function()
|
||||
{
|
||||
detachArrayBuffer(ab, dataType);
|
||||
detachArrayBuffer(ab);
|
||||
gc();
|
||||
return 0x800;
|
||||
}
|
||||
|
@ -72,8 +71,7 @@ function testByteLength(dataType)
|
|||
assertEq(ok, true, "byteLength weirdness should have thrown");
|
||||
assertEq(ab.byteLength, 0, "detaching should work for byteLength weirdness");
|
||||
}
|
||||
testByteLength("change-data");
|
||||
testByteLength("same-data");
|
||||
testByteLength();
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ print(BUGNUMBER + ": " + summary);
|
|||
* BEGIN TEST *
|
||||
**************/
|
||||
|
||||
function testIndex(dataType)
|
||||
function testIndex()
|
||||
{
|
||||
var ab = new ArrayBuffer(0x1000);
|
||||
|
||||
|
@ -27,7 +27,7 @@ function testIndex(dataType)
|
|||
{
|
||||
valueOf: function()
|
||||
{
|
||||
detachArrayBuffer(ab, dataType);
|
||||
detachArrayBuffer(ab);
|
||||
gc();
|
||||
return 0xFFF;
|
||||
}
|
||||
|
@ -45,10 +45,9 @@ function testIndex(dataType)
|
|||
assertEq(ok, true, "should have thrown");
|
||||
assertEq(ab.byteLength, 0, "should have been detached correctly");
|
||||
}
|
||||
testIndex("change-data");
|
||||
testIndex("same-data");
|
||||
testIndex();
|
||||
|
||||
function testValue(dataType)
|
||||
function testValue()
|
||||
{
|
||||
var ab = new ArrayBuffer(0x100000);
|
||||
|
||||
|
@ -58,7 +57,7 @@ function testValue(dataType)
|
|||
{
|
||||
valueOf: function()
|
||||
{
|
||||
detachArrayBuffer(ab, dataType);
|
||||
detachArrayBuffer(ab);
|
||||
gc();
|
||||
return 0x42;
|
||||
}
|
||||
|
@ -76,8 +75,7 @@ function testValue(dataType)
|
|||
assertEq(ok, true, "should have thrown");
|
||||
assertEq(ab.byteLength, 0, "should have been detached correctly");
|
||||
}
|
||||
testValue("change-data");
|
||||
testValue("same-data");
|
||||
testValue();
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ var ctors = [Int8Array, Uint8Array, Uint8ClampedArray,
|
|||
Int32Array, Uint32Array,
|
||||
Float32Array, Float64Array];
|
||||
ctors.forEach(function(TypedArray) {
|
||||
["change-data", "same-data"].forEach(function(dataHandling) {
|
||||
var buf = new ArrayBuffer(512 * 1024);
|
||||
var ta = new TypedArray(buf);
|
||||
|
||||
|
@ -41,7 +40,7 @@ ctors.forEach(function(TypedArray) {
|
|||
9: 0,
|
||||
get length()
|
||||
{
|
||||
detachArrayBuffer(buf, dataHandling);
|
||||
detachArrayBuffer(buf);
|
||||
return 10;
|
||||
}
|
||||
};
|
||||
|
@ -57,7 +56,6 @@ ctors.forEach(function(TypedArray) {
|
|||
}
|
||||
|
||||
assertEq(passed, true);
|
||||
});
|
||||
});
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
@ -17,7 +17,7 @@ print(BUGNUMBER + ": " + summary);
|
|||
* BEGIN TEST *
|
||||
**************/
|
||||
|
||||
function testBegin(dataType)
|
||||
function testBegin()
|
||||
{
|
||||
var ab = new ArrayBuffer(0x1000);
|
||||
|
||||
|
@ -25,7 +25,7 @@ function testBegin(dataType)
|
|||
{
|
||||
valueOf: function()
|
||||
{
|
||||
detachArrayBuffer(ab, dataType);
|
||||
detachArrayBuffer(ab);
|
||||
return 0x800;
|
||||
}
|
||||
};
|
||||
|
@ -44,10 +44,9 @@ function testBegin(dataType)
|
|||
assertEq(ok, true, "start weirdness should have thrown");
|
||||
assertEq(ab.byteLength, 0, "detaching should work for start weirdness");
|
||||
}
|
||||
testBegin("change-data");
|
||||
testBegin("same-data");
|
||||
testBegin();
|
||||
|
||||
function testBeginWithEnd(dataType)
|
||||
function testBeginWithEnd()
|
||||
{
|
||||
var ab = new ArrayBuffer(0x1000);
|
||||
|
||||
|
@ -55,7 +54,7 @@ function testBeginWithEnd(dataType)
|
|||
{
|
||||
valueOf: function()
|
||||
{
|
||||
detachArrayBuffer(ab, dataType);
|
||||
detachArrayBuffer(ab);
|
||||
return 0x800;
|
||||
}
|
||||
};
|
||||
|
@ -74,10 +73,9 @@ function testBeginWithEnd(dataType)
|
|||
assertEq(ok, true, "start weirdness should have thrown");
|
||||
assertEq(ab.byteLength, 0, "detaching should work for start weirdness");
|
||||
}
|
||||
testBeginWithEnd("change-data");
|
||||
testBeginWithEnd("same-data");
|
||||
testBeginWithEnd();
|
||||
|
||||
function testEnd(dataType)
|
||||
function testEnd()
|
||||
{
|
||||
var ab = new ArrayBuffer(0x1000);
|
||||
|
||||
|
@ -85,7 +83,7 @@ function testEnd(dataType)
|
|||
{
|
||||
valueOf: function()
|
||||
{
|
||||
detachArrayBuffer(ab, dataType);
|
||||
detachArrayBuffer(ab);
|
||||
return 0x1000;
|
||||
}
|
||||
};
|
||||
|
@ -104,8 +102,7 @@ function testEnd(dataType)
|
|||
assertEq(ok, true, "start weirdness should have thrown");
|
||||
assertEq(ab.byteLength, 0, "detaching should work for start weirdness");
|
||||
}
|
||||
testEnd("change-data");
|
||||
testEnd("same-data");
|
||||
testEnd();
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
|
|
@ -24,13 +24,9 @@ print(BUGNUMBER + ": " + summary);
|
|||
// back on normal logic"), somewhat because it's consistent with current
|
||||
// behavior (as of this test's addition) for out-of-bounds sets.
|
||||
|
||||
var ab1 = new ArrayBuffer(64);
|
||||
var ta1 = new Uint32Array(ab1);
|
||||
ta1[4] = { valueOf() { detachArrayBuffer(ab1, "change-data"); return 5; } };
|
||||
|
||||
var ab2 = new ArrayBuffer(64);
|
||||
var ta2 = new Uint32Array(ab2);
|
||||
ta2[4] = { valueOf() { detachArrayBuffer(ab2, "same-data"); return 5; } };
|
||||
var ab = new ArrayBuffer(64);
|
||||
var ta = new Uint32Array(ab);
|
||||
ta[4] = { valueOf() { detachArrayBuffer(ab); return 5; } };
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ var summary =
|
|||
"Behavior of mapping from an array whose buffer is detached midway through " +
|
||||
"mapping";
|
||||
|
||||
function mapOneDimArrayOfUint8(dataHandling)
|
||||
function mapOneDimArrayOfUint8()
|
||||
{
|
||||
var FourByteArray = TypedObject.uint8.array(4);
|
||||
var FourByteArrayArray = FourByteArray.array(4);
|
||||
|
@ -23,7 +23,7 @@ function mapOneDimArrayOfUint8(dataHandling)
|
|||
arr.map(function(v)
|
||||
{
|
||||
if (count++ > 0)
|
||||
detachArrayBuffer(buf, dataHandling);
|
||||
detachArrayBuffer(buf);
|
||||
return new FourByteArray();
|
||||
});
|
||||
}, TypeError, "mapping of a detached object worked?");
|
||||
|
@ -33,8 +33,7 @@ function runTests()
|
|||
{
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
mapOneDimArrayOfUint8("change-data");
|
||||
mapOneDimArrayOfUint8("same-data");
|
||||
mapOneDimArrayOfUint8();
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
|
|
|
@ -17,7 +17,7 @@ print(BUGNUMBER + ": " + summary);
|
|||
* BEGIN TEST *
|
||||
**************/
|
||||
|
||||
function testBegin(dataType)
|
||||
function testBegin()
|
||||
{
|
||||
var ab = new ArrayBuffer(0x1000);
|
||||
|
||||
|
@ -25,7 +25,7 @@ function testBegin(dataType)
|
|||
{
|
||||
valueOf: function()
|
||||
{
|
||||
detachArrayBuffer(ab, dataType);
|
||||
detachArrayBuffer(ab);
|
||||
return 0x800;
|
||||
}
|
||||
};
|
||||
|
@ -44,10 +44,9 @@ function testBegin(dataType)
|
|||
assertEq(ok, true, "start weirdness should have thrown");
|
||||
assertEq(ab.byteLength, 0, "detaching should work for start weirdness");
|
||||
}
|
||||
testBegin("change-data");
|
||||
testBegin("same-data");
|
||||
testBegin();
|
||||
|
||||
function testEnd(dataType)
|
||||
function testEnd()
|
||||
{
|
||||
var ab = new ArrayBuffer(0x1000);
|
||||
|
||||
|
@ -55,7 +54,7 @@ function testEnd(dataType)
|
|||
{
|
||||
valueOf: function()
|
||||
{
|
||||
detachArrayBuffer(ab, dataType);
|
||||
detachArrayBuffer(ab);
|
||||
return 0x1000;
|
||||
}
|
||||
};
|
||||
|
@ -74,10 +73,9 @@ function testEnd(dataType)
|
|||
assertEq(ok, true, "start weirdness should have thrown");
|
||||
assertEq(ab.byteLength, 0, "detaching should work for start weirdness");
|
||||
}
|
||||
testEnd("change-data");
|
||||
testEnd("same-data");
|
||||
testEnd();
|
||||
|
||||
function testDest(dataType)
|
||||
function testDest()
|
||||
{
|
||||
var ab = new ArrayBuffer(0x1000);
|
||||
|
||||
|
@ -85,7 +83,7 @@ function testDest(dataType)
|
|||
{
|
||||
valueOf: function()
|
||||
{
|
||||
detachArrayBuffer(ab, dataType);
|
||||
detachArrayBuffer(ab);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
@ -104,8 +102,7 @@ function testDest(dataType)
|
|||
assertEq(ok, true, "start weirdness should have thrown");
|
||||
assertEq(ab.byteLength, 0, "detaching should work for start weirdness");
|
||||
}
|
||||
testDest("change-data");
|
||||
testDest("same-data");
|
||||
testDest();
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
|
|
@ -13,61 +13,33 @@ print(BUGNUMBER + ": " + summary);
|
|||
* BEGIN TEST *
|
||||
**************/
|
||||
|
||||
var ab1 = new ArrayBuffer(200);
|
||||
var a1 = new Uint8Array(ab1);
|
||||
var a1_2 = new Uint8Array(10);
|
||||
var ab = new ArrayBuffer(200);
|
||||
var a = new Uint8Array(ab);
|
||||
var a_2 = new Uint8Array(10);
|
||||
|
||||
var src1 = [ 10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
];
|
||||
Object.defineProperty(src1, 4, {
|
||||
var src = [ 10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
];
|
||||
Object.defineProperty(src, 4, {
|
||||
get: function () {
|
||||
detachArrayBuffer(ab1, "change-data");
|
||||
detachArrayBuffer(ab);
|
||||
gc();
|
||||
return 200;
|
||||
}
|
||||
});
|
||||
|
||||
a1.set(src1);
|
||||
a.set(src);
|
||||
|
||||
// Not really needed
|
||||
Array.reverse(a1_2);
|
||||
|
||||
var ab2 = new ArrayBuffer(200);
|
||||
var a2 = new Uint8Array(ab2);
|
||||
var a2_2 = new Uint8Array(10);
|
||||
|
||||
var src2 = [ 10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
10, 20, 30, 40,
|
||||
];
|
||||
Object.defineProperty(src2, 4, {
|
||||
get: function () {
|
||||
detachArrayBuffer(ab2, "same-data");
|
||||
gc();
|
||||
return 200;
|
||||
}
|
||||
});
|
||||
|
||||
a2.set(src2);
|
||||
|
||||
// Not really needed
|
||||
Array.reverse(a2_2);
|
||||
Array.reverse(a_2);
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
|
|
@ -1178,8 +1178,7 @@ JS_GetArrayBufferData(JSObject* obj, bool* isSharedMemory, const JS::AutoCheckCa
|
|||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
JS_DetachArrayBuffer(JSContext* cx, HandleObject obj,
|
||||
DetachDataDisposition changeData)
|
||||
JS_DetachArrayBuffer(JSContext* cx, HandleObject obj)
|
||||
{
|
||||
if (!obj->is<ArrayBufferObject>()) {
|
||||
JS_ReportError(cx, "ArrayBuffer object required");
|
||||
|
|
Загрузка…
Ссылка в новой задаче