From d7d154b3bc060f205b6fa3b6c9f83903660c05b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Bargull?= <andre.bargull@gmail.com>
Date: Fri, 17 Aug 2018 07:48:45 -0700
Subject: [PATCH] Remove requirement that ToNumber(value) completes in less
 than $262.agent.MAX_TIME_EPSILON

$262.agent.MAX_TIME_EPSILON was intended to be used for callers like `Atomics.wait(typedArray, indexNumber, valueNumber, timeoutNumber)` where all parameters with the `Number` suffix denote values which are already Number values. It should not be used for `Atomics.wait(typedArray, indexObject, valueObject, timeoutObject)` where all parameters with the `Object` suffix denote values which are Object values, because in that case we'd require that `ToNumber(objectValue)` (potentially invoked multiple times) completes in less than 100 milliseconds (the default value for MAX_TIME_EPSILON).

Also removes $262.agent.MAX_TIME_EPSILON because it is now no longer used.
---
 harness/atomicsHelper.js                                 | 7 -------
 .../Atomics/wait/bigint/false-for-timeout-agent.js       | 9 ---------
 test/built-ins/Atomics/wait/false-for-timeout-agent.js   | 9 ---------
 test/built-ins/Atomics/wait/null-for-timeout-agent.js    | 9 ---------
 test/built-ins/Atomics/wait/object-for-timeout-agent.js  | 9 ---------
 .../wait/poisoned-object-for-timeout-throws-agent.js     | 9 ---------
 .../Atomics/wait/symbol-for-index-throws-agent.js        | 8 --------
 .../Atomics/wait/symbol-for-timeout-throws-agent.js      | 8 --------
 .../Atomics/wait/symbol-for-value-throws-agent.js        | 8 --------
 test/built-ins/Atomics/wait/true-for-timeout-agent.js    | 9 ---------
 10 files changed, 85 deletions(-)

diff --git a/harness/atomicsHelper.js b/harness/atomicsHelper.js
index c9a20388f3..aa308a3387 100644
--- a/harness/atomicsHelper.js
+++ b/harness/atomicsHelper.js
@@ -5,13 +5,6 @@ description: >
     Collection of functions used to interact with Atomics.* operations across agent boundaries.
 ---*/
 
-/**
- * The amount of slack allowed for testing time-related Atomics methods (i.e. wait and notify).
- * The absolute value of the difference of the observed time and the expected time must
- * be epsilon-close.
- */
-$262.agent.MAX_TIME_EPSILON = 100;
-
 /**
  * @return {String} A report sent from an agent.
  */
diff --git a/test/built-ins/Atomics/wait/bigint/false-for-timeout-agent.js b/test/built-ins/Atomics/wait/bigint/false-for-timeout-agent.js
index 219db0b56a..e7987f30b9 100644
--- a/test/built-ins/Atomics/wait/bigint/false-for-timeout-agent.js
+++ b/test/built-ins/Atomics/wait/bigint/false-for-timeout-agent.js
@@ -35,16 +35,13 @@ $262.agent.start(`
     const i64a = new BigInt64Array(sab);
     Atomics.add(i64a, ${RUNNING}, 1n);
 
-    const before = $262.agent.monotonicNow();
     const status1 = Atomics.wait(i64a, 0, 0n, false);
     const status2 = Atomics.wait(i64a, 0, 0n, valueOf);
     const status3 = Atomics.wait(i64a, 0, 0n, toPrimitive);
-    const duration = $262.agent.monotonicNow() - before;
 
     $262.agent.report(status1);
     $262.agent.report(status2);
     $262.agent.report(status3);
-    $262.agent.report(duration);
     $262.agent.leaving();
   });
 `);
@@ -75,10 +72,4 @@ assert.sameValue(
   '$262.agent.getReport() returns "timed-out"'
 );
 
-const lapse = $262.agent.getReport();
-
-assert(lapse >= 0, 'The result of `(lapse >= 0)` is true (timeout should be a min of 0ms)');
-
-assert(lapse <= $262.agent.MAX_TIME_EPSILON, 'The result of `(lapse <= $262.agent.MAX_TIME_EPSILON)` is true');
-
 assert.sameValue(Atomics.notify(i64a, 0), 0, 'Atomics.notify(i64a, 0) returns 0');
diff --git a/test/built-ins/Atomics/wait/false-for-timeout-agent.js b/test/built-ins/Atomics/wait/false-for-timeout-agent.js
index d25a44b72d..737963f321 100644
--- a/test/built-ins/Atomics/wait/false-for-timeout-agent.js
+++ b/test/built-ins/Atomics/wait/false-for-timeout-agent.js
@@ -35,16 +35,13 @@ $262.agent.start(`
     const i32a = new Int32Array(sab);
     Atomics.add(i32a, ${RUNNING}, 1);
 
-    const before = $262.agent.monotonicNow();
     const status1 = Atomics.wait(i32a, 0, 0, false);
     const status2 = Atomics.wait(i32a, 0, 0, valueOf);
     const status3 = Atomics.wait(i32a, 0, 0, toPrimitive);
-    const duration = $262.agent.monotonicNow() - before;
 
     $262.agent.report(status1);
     $262.agent.report(status2);
     $262.agent.report(status3);
-    $262.agent.report(duration);
     $262.agent.leaving();
   });
 `);
@@ -75,10 +72,4 @@ assert.sameValue(
   '$262.agent.getReport() returns "timed-out"'
 );
 
-const lapse = $262.agent.getReport();
-
-assert(lapse >= 0, 'The result of `(lapse >= 0)` is true (timeout should be a min of 0ms)');
-
-assert(lapse <= $262.agent.MAX_TIME_EPSILON, 'The result of `(lapse <= $262.agent.MAX_TIME_EPSILON)` is true');
-
 assert.sameValue(Atomics.notify(i32a, 0), 0, 'Atomics.notify(i32a, 0) returns 0');
diff --git a/test/built-ins/Atomics/wait/null-for-timeout-agent.js b/test/built-ins/Atomics/wait/null-for-timeout-agent.js
index 265ebefb9e..3e0818bd4d 100644
--- a/test/built-ins/Atomics/wait/null-for-timeout-agent.js
+++ b/test/built-ins/Atomics/wait/null-for-timeout-agent.js
@@ -35,16 +35,13 @@ $262.agent.start(`
     const i32a = new Int32Array(sab);
     Atomics.add(i32a, ${RUNNING}, 1);
 
-    const before = $262.agent.monotonicNow();
     const status1 = Atomics.wait(i32a, 0, 0, null);
     const status2 = Atomics.wait(i32a, 0, 0, valueOf);
     const status3 = Atomics.wait(i32a, 0, 0, toPrimitive);
-    const duration = $262.agent.monotonicNow() - before;
 
     $262.agent.report(status1);
     $262.agent.report(status2);
     $262.agent.report(status3);
-    $262.agent.report(duration);
     $262.agent.leaving();
   });
 `);
@@ -75,10 +72,4 @@ assert.sameValue(
   '$262.agent.getReport() returns "timed-out"'
 );
 
-const lapse = $262.agent.getReport();
-
-assert(lapse >= 0, 'The result of `(lapse >= 0)` is true (timeout should be a min of 0ms)');
-
-assert(lapse <= $262.agent.MAX_TIME_EPSILON, 'The result of `(lapse <= $262.agent.MAX_TIME_EPSILON)` is true (timeout should be a max of $262.agent.MAX_TIME_EPSILON)');
-
 assert.sameValue(Atomics.notify(i32a, 0), 0, 'Atomics.notify(i32a, 0) returns 0');
diff --git a/test/built-ins/Atomics/wait/object-for-timeout-agent.js b/test/built-ins/Atomics/wait/object-for-timeout-agent.js
index 3e216b1256..3217e42261 100644
--- a/test/built-ins/Atomics/wait/object-for-timeout-agent.js
+++ b/test/built-ins/Atomics/wait/object-for-timeout-agent.js
@@ -41,16 +41,13 @@ $262.agent.start(`
     const i32a = new Int32Array(sab);
     Atomics.add(i32a, ${RUNNING}, 1);
 
-    const before = $262.agent.monotonicNow();
     const status1 = Atomics.wait(i32a, 0, 0, valueOf);
     const status2 = Atomics.wait(i32a, 0, 0, toString);
     const status3 = Atomics.wait(i32a, 0, 0, toPrimitive);
-    const duration = $262.agent.monotonicNow() - before;
 
     $262.agent.report(status1);
     $262.agent.report(status2);
     $262.agent.report(status3);
-    $262.agent.report(duration);
     $262.agent.leaving();
   });
 `);
@@ -81,10 +78,4 @@ assert.sameValue(
   '$262.agent.getReport() returns "timed-out"'
 );
 
-const lapse = $262.agent.getReport();
-
-assert(lapse >= 0, 'The result of `(lapse >= 0)` is true (timeout should be a min of 0ms)');
-
-assert(lapse <= $262.agent.MAX_TIME_EPSILON, 'The result of `(lapse <= $262.agent.MAX_TIME_EPSILON)` is true (timeout should be a max of $$262.agent.MAX_TIME_EPSILON)');
-
 assert.sameValue(Atomics.notify(i32a, 0), 0, 'Atomics.notify(i32a, 0) returns 0');
diff --git a/test/built-ins/Atomics/wait/poisoned-object-for-timeout-throws-agent.js b/test/built-ins/Atomics/wait/poisoned-object-for-timeout-throws-agent.js
index d6352bac29..156f04176c 100644
--- a/test/built-ins/Atomics/wait/poisoned-object-for-timeout-throws-agent.js
+++ b/test/built-ins/Atomics/wait/poisoned-object-for-timeout-throws-agent.js
@@ -38,7 +38,6 @@ $262.agent.start(`
     let status1 = "";
     let status2 = "";
 
-    const start = $262.agent.monotonicNow();
     try {
       Atomics.wait(i32a, 0, 0, poisonedValueOf);
     } catch (error) {
@@ -49,11 +48,9 @@ $262.agent.start(`
     } catch (error) {
       status2 = "poisonedToPrimitive";
     }
-    const duration = $262.agent.monotonicNow() - start;
 
     $262.agent.report(status1);
     $262.agent.report(status2);
-    $262.agent.report(duration);
     $262.agent.leaving();
   });
 `);
@@ -79,10 +76,4 @@ assert.sameValue(
   '$262.agent.getReport() returns "poisonedToPrimitive"'
 );
 
-const lapse = $262.agent.getReport();
-
-assert(lapse >= 0, 'The result of `(lapse >= 0)` is true (timeout should be a min of 0ms)');
-
-assert(lapse <= $262.agent.MAX_TIME_EPSILON, 'The result of `(lapse <= $262.agent.MAX_TIME_EPSILON)` is true (timeout should be a max of $$262.agent.MAX_TIME_EPSILON)');
-
 assert.sameValue(Atomics.notify(i32a, 0), 0, 'Atomics.notify(i32a, 0) returns 0');
diff --git a/test/built-ins/Atomics/wait/symbol-for-index-throws-agent.js b/test/built-ins/Atomics/wait/symbol-for-index-throws-agent.js
index d323e6a5a4..21902487ca 100644
--- a/test/built-ins/Atomics/wait/symbol-for-index-throws-agent.js
+++ b/test/built-ins/Atomics/wait/symbol-for-index-throws-agent.js
@@ -51,7 +51,6 @@ $262.agent.start(`
     let status1 = "";
     let status2 = "";
 
-    const start = $262.agent.monotonicNow();
     try {
       Atomics.wait(i32a, Symbol("1"), poisonedValueOf, poisonedValueOf);
     } catch (error) {
@@ -62,11 +61,9 @@ $262.agent.start(`
     } catch (error) {
       status2 = 'Symbol("2")';
     }
-    const duration = $262.agent.monotonicNow() - start;
 
     $262.agent.report(status1);
     $262.agent.report(status2);
-    $262.agent.report(duration);
     $262.agent.leaving();
   });
 `);
@@ -92,9 +89,4 @@ assert.sameValue(
   '$262.agent.getReport() returns "Symbol("2")"'
 );
 
-const lapse = $262.agent.getReport();
-
-assert(lapse >= 0, 'The result of `(lapse >= 0)` is true (The result of `(lapse >= 0)` is true (timeout should be a min of 0ms))');
-assert(lapse <= $262.agent.MAX_TIME_EPSILON, 'The result of `(lapse <= $262.agent.MAX_TIME_EPSILON)` is true (The result of `(lapse <= $262.agent.MAX_TIME_EPSILON)` is true (timeout should be a max of $$262.agent.MAX_TIME_EPSILON))');
-
 assert.sameValue(Atomics.notify(i32a, 0), 0, 'Atomics.notify(i32a, 0) returns 0');
diff --git a/test/built-ins/Atomics/wait/symbol-for-timeout-throws-agent.js b/test/built-ins/Atomics/wait/symbol-for-timeout-throws-agent.js
index 96b1d731e4..efba942cd6 100644
--- a/test/built-ins/Atomics/wait/symbol-for-timeout-throws-agent.js
+++ b/test/built-ins/Atomics/wait/symbol-for-timeout-throws-agent.js
@@ -26,7 +26,6 @@ $262.agent.start(`
     let status1 = "";
     let status2 = "";
 
-    const start = $262.agent.monotonicNow();
     try {
       Atomics.wait(i32a, 0, 0, Symbol("1"));
     } catch (error) {
@@ -37,11 +36,9 @@ $262.agent.start(`
     } catch (error) {
       status2 = 'Symbol("2")';
     }
-    const duration = $262.agent.monotonicNow() - start;
 
     $262.agent.report(status1);
     $262.agent.report(status2);
-    $262.agent.report(duration);
     $262.agent.leaving();
   });
 `);
@@ -67,9 +64,4 @@ assert.sameValue(
   '$262.agent.getReport() returns "Symbol("2")"'
 );
 
-const lapse = $262.agent.getReport();
-
-assert(lapse >= 0, 'The result of `(lapse >= 0)` is true (timeout should be a min of 0ms)');
-assert(lapse <= $262.agent.MAX_TIME_EPSILON, 'The result of `(lapse <= $262.agent.MAX_TIME_EPSILON)` is true (timeout should be a max of $$262.agent.MAX_TIME_EPSILON)');
-
 assert.sameValue(Atomics.notify(i32a, 0), 0, 'Atomics.notify(i32a, 0) returns 0');
diff --git a/test/built-ins/Atomics/wait/symbol-for-value-throws-agent.js b/test/built-ins/Atomics/wait/symbol-for-value-throws-agent.js
index 7cc4f4ca1e..d4de5f952b 100644
--- a/test/built-ins/Atomics/wait/symbol-for-value-throws-agent.js
+++ b/test/built-ins/Atomics/wait/symbol-for-value-throws-agent.js
@@ -42,7 +42,6 @@ $262.agent.start(`
     let status1 = "";
     let status2 = "";
 
-    const before = $262.agent.monotonicNow();
     try {
       Atomics.wait(i32a, 0, Symbol("1"), poisonedValueOf);
     } catch (error) {
@@ -53,11 +52,9 @@ $262.agent.start(`
     } catch (error) {
       status2 = 'Symbol("2")';
     }
-    const duration = $262.agent.monotonicNow() - before;
 
     $262.agent.report(status1);
     $262.agent.report(status2);
-    $262.agent.report(duration);
     $262.agent.leaving();
   });
 `);
@@ -83,9 +80,4 @@ assert.sameValue(
   '$262.agent.getReport() returns "Symbol("2")"'
 );
 
-const lapse = $262.agent.getReport();
-
-assert(lapse >= 0, 'The result of `(lapse >= 0)` is true (timeout should be a min of 0ms)');
-assert(lapse <= $262.agent.MAX_TIME_EPSILON, 'The result of `(lapse <= $262.agent.MAX_TIME_EPSILON)` is true (timeout should be a max of $$262.agent.MAX_TIME_EPSILON)');
-
 assert.sameValue(Atomics.notify(i32a, 0), 0, 'Atomics.notify(i32a, 0) returns 0');
diff --git a/test/built-ins/Atomics/wait/true-for-timeout-agent.js b/test/built-ins/Atomics/wait/true-for-timeout-agent.js
index ef0ef6f277..b6bec0f039 100644
--- a/test/built-ins/Atomics/wait/true-for-timeout-agent.js
+++ b/test/built-ins/Atomics/wait/true-for-timeout-agent.js
@@ -35,16 +35,13 @@ $262.agent.start(`
     const i32a = new Int32Array(sab);
     Atomics.add(i32a, ${RUNNING}, 1);
 
-    const start = $262.agent.monotonicNow();
     const status1 = Atomics.wait(i32a, 0, 0, true);
     const status2 = Atomics.wait(i32a, 0, 0, valueOf);
     const status3 = Atomics.wait(i32a, 0, 0, toPrimitive);
-    const duration = $262.agent.monotonicNow() - start;
 
     $262.agent.report(status1);
     $262.agent.report(status2);
     $262.agent.report(status3);
-    $262.agent.report(duration);
     $262.agent.leaving();
   });
 `);
@@ -75,10 +72,4 @@ assert.sameValue(
   '$262.agent.getReport() returns "timed-out"'
 );
 
-const lapse = $262.agent.getReport();
-
-assert(lapse >= 0, 'The result of `(lapse >= 0)` is true (timeout should be a min of 0ms)');
-
-assert(lapse <= $262.agent.MAX_TIME_EPSILON, 'The result of `(lapse <= $262.agent.MAX_TIME_EPSILON)` is true (timeout should be a max of $$262.agent.MAX_TIME_EPSILON)');
-
 assert.sameValue(Atomics.notify(i32a, 0), 0, 'Atomics.notify(i32a, 0) returns 0');
-- 
GitLab