[v8-test262-automation] Changes from https://github.com/v8/v8.git at sha dde25872 on Mon Dec 17 2018 19:18:49 GMT+0000 (Coordinated Universal Time)

This commit is contained in:
test262-automation 2018-12-17 19:19:30 +00:00 committed by Rick Waldron
parent 46c557247e
commit 058d7abf93
12 changed files with 1453 additions and 362 deletions

View File

@ -151,14 +151,10 @@
clear.call(wc);
})();
(function TestMakeRef() {
let wf = new WeakFactory(() => {});
let wr = wf.makeRef({});
let wc = wf.makeCell({});
(function TestWeakRefConstructor() {
let wr = new WeakRef({});
assertEquals(wr.toString(), "[object WeakRef]");
assertNotSame(wr.__proto__, Object.prototype);
assertSame(wr.__proto__.__proto__, wc.__proto__);
assertEquals(wr.holdings, undefined);
let deref_desc = Object.getOwnPropertyDescriptor(wr.__proto__, "deref");
assertEquals(true, deref_desc.configurable);
@ -166,70 +162,36 @@
assertEquals("function", typeof deref_desc.value);
})();
(function TestMakeRefWithHoldings() {
let wf = new WeakFactory(() => {});
let obj = {a: 1};
let holdings = {b: 2};
let wr = wf.makeRef(obj, holdings);
assertSame(wr.holdings, holdings);
(function TestWeakRefConstructorWithNonObject() {
let message = "WeakRef: target must be an object";
assertThrows(() => new WeakRef(), TypeError, message);
assertThrows(() => new WeakRef(1), TypeError, message);
assertThrows(() => new WeakRef(false), TypeError, message);
assertThrows(() => new WeakRef("foo"), TypeError, message);
assertThrows(() => new WeakRef(Symbol()), TypeError, message);
assertThrows(() => new WeakRef(null), TypeError, message);
assertThrows(() => new WeakRef(undefined), TypeError, message);
})();
(function TestMakeRefWithHoldingsSetHoldings() {
let wf = new WeakFactory(() => {});
let obj = {a: 1};
let holdings = {b: 2};
let wr = wf.makeRef(obj, holdings);
assertSame(wr.holdings, holdings);
wr.holdings = 5;
assertSame(wr.holdings, holdings);
(function TestWeakRefConstructorCallAsFunction() {
let caught = false;
let message = "";
try {
let f = WeakRef({});
} catch (e) {
message = e.message;
caught = true;
} finally {
assertTrue(caught);
assertEquals(message, "Constructor WeakRef requires 'new'");
}
})();
(function TestMakeRefWithHoldingsSetHoldingsStrict() {
"use strict";
let wf = new WeakFactory(() => {});
let obj = {a: 1};
let holdings = {b: 2};
let wr = wf.makeRef(obj, holdings);
assertSame(wr.holdings, holdings);
assertThrows(() => { wr.holdings = 5; }, TypeError);
assertSame(wr.holdings, holdings);
})();
(function TestMakeRefWithNonObject() {
let wf = new WeakFactory(() => {});
let message = "WeakFactory.prototype.makeRef: target must be an object";
assertThrows(() => wf.makeRef(), TypeError, message);
assertThrows(() => wf.makeRef(1), TypeError, message);
assertThrows(() => wf.makeRef(false), TypeError, message);
assertThrows(() => wf.makeRef("foo"), TypeError, message);
assertThrows(() => wf.makeRef(Symbol()), TypeError, message);
assertThrows(() => wf.makeRef(null), TypeError, message);
assertThrows(() => wf.makeRef(undefined), TypeError, message);
})();
(function TestMakeRefWithProxy() {
(function TestWeakRefWithProxy() {
let handler = {};
let obj = {};
let proxy = new Proxy(obj, handler);
let wf = new WeakFactory(() => {});
let wr = wf.makeRef(proxy);
})();
(function TestMakeRefTargetAndHoldingsSameValue() {
let wf = new WeakFactory(() => {});
let obj = {a: 1};
// SameValue(target, holdings) not ok
assertThrows(() => wf.makeRef(obj, obj), TypeError,
"WeakFactory.prototype.makeRef: target and holdings must not be same");
let holdings = {a: 1};
let wr = wf.makeRef(obj, holdings);
})();
(function TestMakeRefWithoutWeakFactory() {
assertThrows(() => WeakFactory.prototype.makeRef.call({}, {}), TypeError);
// Does not throw:
let wf = new WeakFactory(() => {});
WeakFactory.prototype.makeRef.call(wf, {});
let wr = new WeakRef(proxy);
})();
(function TestCleanupSomeWithoutWeakFactory() {
@ -243,24 +205,10 @@
(function TestDerefWithoutWeakRef() {
let wf = new WeakFactory(() => {});
let wc = wf.makeCell({});
let wr = wf.makeRef({});
let wr = new WeakRef({});
let deref = Object.getOwnPropertyDescriptor(wr.__proto__, "deref").value;
assertThrows(() => deref.call({}), TypeError);
assertThrows(() => deref.call(wc), TypeError);
// Does not throw:
deref.call(wr);
})();
(function TestWeakRefClearAfterProtoChange() {
let wf = new WeakFactory(() => {});
let wc = wf.makeCell({});
let wr = wf.makeRef({});
// Does not throw:
wr.clear();
wr.__proto__ = {};
assertThrows(() => wr.clear(), TypeError);
let clear = Object.getOwnPropertyDescriptor(wc.__proto__, "clear").value;
// Does not throw:
clear.call(wr);
})();

View File

@ -1,51 +0,0 @@
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-weak-refs --expose-gc --noincremental-marking --allow-natives-syntax
let cleanup_count = 0;
let cleanup_cells = [];
let cleanup = function(iter) {
for (wc of iter) {
cleanup_cells.push(wc);
}
++cleanup_count;
}
let o = {};
let wf = new WeakFactory(cleanup);
let weak_ref;
(function() {
weak_ref = wf.makeRef(o);
// cleanupSome won't do anything since there are no dirty WeakCells.
wf.cleanupSome();
assertEquals(0, cleanup_count);
})();
// Clear the KeepDuringJob set.
%PerformMicrotaskCheckpoint();
weak_ref.deref();
o = null;
// The WeakRef is not detected as dirty, since the KeepDuringJob set keeps the
// target object alive.
gc();
wf.cleanupSome();
assertEquals(0, cleanup_count);
%PerformMicrotaskCheckpoint();
// Next turn.
// This GC detects the WeakRef as dirty.
gc();
// Clear the WeakRef just before we would've called cleanupSome.
weak_ref.clear();
wf.cleanupSome();
assertEquals(0, cleanup_count);

View File

@ -1,57 +0,0 @@
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-weak-refs --expose-gc --noincremental-marking --allow-natives-syntax
let cleanup_count = 0;
let cleanup_cells = [];
let cleanup = function(iter) {
for (wc of iter) {
cleanup_cells.push(wc);
}
++cleanup_count;
}
let o = {};
let wf = new WeakFactory(cleanup);
let weak_ref;
(function() {
weak_ref = wf.makeRef(o);
// cleanupSome won't do anything since there are no dirty WeakCells.
wf.cleanupSome();
assertEquals(0, cleanup_count);
})();
// Clear the KeepDuringJob set.
%PerformMicrotaskCheckpoint();
weak_ref.deref();
o = null;
// The WeakRef is not detected as dirty, since the KeepDuringJob set keeps the
// target object alive.
gc();
wf.cleanupSome();
assertEquals(0, cleanup_count);
%PerformMicrotaskCheckpoint();
// Next turn.
// Now the WeakRef can be cleared.
gc();
wf.cleanupSome();
assertEquals(1, cleanup_count);
assertEquals(1, cleanup_cells.length);
assertEquals(weak_ref, cleanup_cells[0]);
// The cleanup task is not executed again since all WeakCells have been
// processed.
%PerformMicrotaskCheckpoint();
// Next turn.
assertEquals(1, cleanup_count);

View File

@ -1,43 +0,0 @@
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-weak-refs --expose-gc --noincremental-marking --allow-natives-syntax
let cleanup_count = 0;
let cleanup_cells = [];
let cleanup = function(iter) {
for (wc of iter) {
cleanup_cells.push(wc);
}
++cleanup_count;
}
let wf = new WeakFactory(cleanup);
let weak_ref;
(function() {
let o = {};
weak_ref = wf.makeRef(o);
// cleanupSome won't do anything since there are no dirty WeakCells.
wf.cleanupSome();
assertEquals(0, cleanup_count);
})();
// The WeakRef is not detected as dirty, since the KeepDuringJob set keeps the
// target object alive.
gc();
wf.cleanupSome();
assertEquals(0, cleanup_count);
%PerformMicrotaskCheckpoint();
// Next turn.
// Now the WeakRef can be cleared.
gc();
wf.cleanupSome();
assertEquals(1, cleanup_count);
assertEquals(1, cleanup_cells.length);
assertEquals(weak_ref, cleanup_cells[0]);

View File

@ -1,46 +0,0 @@
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-weak-refs --expose-gc --noincremental-marking --allow-natives-syntax
let cleanup_started = false;
let cleanup_succeeded = false;
let cleanup = function(iter) {
cleanup_start = true;
let cells = [];
for (wc of iter) {
cells.push(wc);
}
assertEquals(1, cells.length);
assertEquals(w1, cells[0]);
cleanup_succeeded = true;
}
let wf = new WeakFactory(cleanup);
let wr;
(function() {
let o = { foo: "bar" };
wr = wf.makeRef(o);
})();
// Since the WeakRef was created during this turn, they're not cleared by GC.
gc();
assertNotEquals(undefined, wr.deref());
%PerformMicrotaskCheckpoint();
// New turn.
let o = wr.deref();
assertEquals("bar", o.foo);
wr.clear();
assertEquals(undefined, wr.deref());
let timeout_func1 = function() {
assertFalse(cleanup_started);
assertFalse(cleanup_succeeded);
}
// Assert that the cleanup function won't be called.
setTimeout(timeout_func1, 0);

View File

@ -4,35 +4,18 @@
// Flags: --harmony-weak-refs --expose-gc --noincremental-marking --allow-natives-syntax
let cleanup_count = 0;
let cleared_cells1 = [];
let cleared_cells2 = [];
let cleanup = function(iter) {
if (cleanup_count == 0) {
for (wc of iter) {
cleared_cells1.push(wc);
}
} else {
assertEquals(1, cleanup_count);
for (wc of iter) {
cleared_cells2.push(wc);
}
}
++cleanup_count;
}
let wf = new WeakFactory(cleanup);
let o1 = {};
let o2 = {};
let wr1;
let wr2;
(function() {
wr1 = wf.makeRef(o1);
wr2 = wf.makeRef(o2);
wr1 = new WeakRef(o1);
wr2 = new WeakRef(o2);
})();
// Since the WeakRefs were created during this turn, they're not cleared by GC.
gc();
(function() {
assertNotEquals(undefined, wr1.deref());
assertNotEquals(undefined, wr2.deref());
@ -41,8 +24,6 @@ gc();
%PerformMicrotaskCheckpoint();
// New turn.
assertEquals(0, cleanup_count);
wr1.deref();
o1 = null;
gc(); // deref makes sure we don't clean up wr1
@ -50,8 +31,6 @@ gc(); // deref makes sure we don't clean up wr1
%PerformMicrotaskCheckpoint();
// New turn.
assertEquals(0, cleanup_count);
wr2.deref();
o2 = null;
gc(); // deref makes sure we don't clean up wr2
@ -59,13 +38,11 @@ gc(); // deref makes sure we don't clean up wr2
%PerformMicrotaskCheckpoint();
// New turn.
assertEquals(1, cleanup_count);
assertEquals(wr1, cleared_cells1[0]);
assertEquals(undefined, wr1.deref());
gc();
%PerformMicrotaskCheckpoint();
// New turn.
assertEquals(2, cleanup_count);
assertEquals(wr2, cleared_cells2[0]);
assertEquals(undefined, wr2.deref());

View File

@ -11,9 +11,8 @@ let cleanup = function(iter) {
for (wc of iter) {
cells.push(wc);
}
assertEquals(2, cells.length);
assertTrue(cells.includes(weak_ref));
assertTrue(cells.includes(weak_cell));
assertEquals(1, cells.length);
assertEquals(weak_cell, cells[0]);
cleanup_called = true;
}
@ -22,8 +21,8 @@ let weak_ref;
let weak_cell;
(function() {
let o = {};
weak_ref = wf.makeRef(o);
weak_cell = wf.makeRef(o);
weak_ref = new WeakRef(o);
weak_cell = wf.makeCell(o);
})();
// Since the WeakRef was created during this turn, it is not cleared by GC. The
@ -43,3 +42,4 @@ gc();
// Next turn.
assertTrue(cleanup_called);
assertEquals(undefined, weak_ref.deref());

View File

@ -4,24 +4,10 @@
// Flags: --harmony-weak-refs --expose-gc --noincremental-marking --allow-natives-syntax
let cleanup_called = false;
let cleanup = function(iter) {
assertFalse(cleanup_called);
let count = 0;
for (wc of iter) {
++count;
assertEquals(wr, wc);
assertEquals(undefined, wc.deref());
}
assertEquals(1, count);
cleanup_called = true;
}
let wf = new WeakFactory(cleanup);
let wr;
(function() {
let o = {};
wr = wf.makeRef(o);
wr = new WeakRef(o);
// Don't deref here, we want to test that the creation is enough to keep the
// WeakRef alive until the end of the turn.
})();
@ -36,11 +22,6 @@ gc();
%PerformMicrotaskCheckpoint();
// Next turn.
assertFalse(cleanup_called);
gc();
%PerformMicrotaskCheckpoint();
// Next turn.
assertTrue(cleanup_called);
assertEquals(undefined, wr.deref());

View File

@ -4,25 +4,13 @@
// Flags: --harmony-weak-refs --expose-gc --noincremental-marking --allow-natives-syntax
let cleanup_count = 0;
let cleanup_cells = [];
let cleanup = function(iter) {
for (wc of iter) {
assertEquals(undefined, wc.deref());
cleanup_cells.push(wc);
}
++cleanup_count;
}
let wf = new WeakFactory(cleanup);
let wf_control = new WeakFactory(cleanup);
let wr;
let wr_control; // control WeakRef for testing what happens without deref
(function() {
let o1 = {};
wr = wf.makeRef(o1);
wr = new WeakRef(o1);
let o2 = {};
wr_control = wf_control.makeRef(o2);
wr_control = new WeakRef(o2);
})();
let strong = {a: wr.deref(), b: wr_control.deref()};
@ -32,14 +20,6 @@ gc();
%PerformMicrotaskCheckpoint();
// Next turn.
gc();
%PerformMicrotaskCheckpoint();
// Next turn.
// We have a strong reference to the objects, so the WeakRefs are not cleared yet.
assertEquals(0, cleanup_count);
// Call deref inside a closure, trying to avoid accidentally storing a strong
// reference into the object in the stack frame.
(function() {
@ -60,17 +40,6 @@ gc();
%PerformMicrotaskCheckpoint();
// Next turn.
assertEquals(1, cleanup_count);
assertEquals(1, cleanup_cells.length);
assertEquals(wc, cleanup_cells[0]);
gc();
%PerformMicrotaskCheckpoint();
// Next turn.
assertEquals(2, cleanup_count);
assertEquals(2, cleanup_cells.length);
assertEquals(wr, cleanup_cells[1]);
assertEquals(undefined, wr.deref());

View File

@ -60,6 +60,7 @@ function rand() {
// To make the test results predictable, we use a 100% deterministic
// alternative.
// Robert Jenkins' 32 bit integer hash function.
seed = seed & 0xffffffff;
seed = ((seed + 0x7ed55d16) + (seed << 12)) & 0xffffffff;
seed = ((seed ^ 0xc761c23c) ^ (seed >>> 19)) & 0xffffffff;
seed = ((seed + 0x165667b1) + (seed << 5)) & 0xffffffff;

View File

@ -59,6 +59,7 @@ function rand() {
// To make the test results predictable, we use a 100% deterministic
// alternative.
// Robert Jenkins' 32 bit integer hash function.
seed = seed & 0xffffffff;
seed = ((seed + 0x7ed55d16) + (seed << 12)) & 0xffffffff;
seed = ((seed ^ 0xc761c23c) ^ (seed >>> 19)) & 0xffffffff;
seed = ((seed + 0x165667b1) + (seed << 5)) & 0xffffffff;

File diff suppressed because it is too large Load Diff