Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
test262
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pmaksimo
test262
Commits
73be2127
Commit
73be2127
authored
6 years ago
by
Rick Waldron
Browse files
Options
Downloads
Patches
Plain Diff
Atomics: wake/wake-in-order.js, capture waiterlist order for wake comparison
parent
fc4a6f12
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
harness/atomicsHelper.js
+3
-5
3 additions, 5 deletions
harness/atomicsHelper.js
test/built-ins/Atomics/wake/wake-in-order.js
+49
-30
49 additions, 30 deletions
test/built-ins/Atomics/wake/wake-in-order.js
with
52 additions
and
35 deletions
harness/atomicsHelper.js
+
3
−
5
View file @
73be2127
...
@@ -36,13 +36,11 @@ function getReport() {
...
@@ -36,13 +36,11 @@ function getReport() {
* @param {Number} expected The number of agents that are expected to report as active.
* @param {Number} expected The number of agents that are expected to report as active.
*/
*/
function
waitUntil
(
i32a
,
index
,
expected
)
{
function
waitUntil
(
i32a
,
index
,
expected
)
{
var
i
=
0
;
while
(
Atomics
.
load
(
i32a
,
index
)
!==
expected
)
{
while
(
Atomics
.
load
(
i32a
,
index
)
!==
expected
&&
i
<
15
)
{
/* nothing */
$262
.
agent
.
sleep
(
10
);
i
++
;
}
}
const
agents
=
Atomics
.
load
(
i32a
,
index
);
const
agents
=
Atomics
.
load
(
i32a
,
index
);
assert
.
sameValue
(
agents
,
expected
,
`'agents' equals the value of expected
(
${
expected
}
)`
);
assert
.
sameValue
(
agents
,
expected
,
`'agents' equals the value of
'
expected
'
(
${
expected
}
)`
);
}
}
...
...
This diff is collapsed.
Click to expand it.
test/built-ins/Atomics/wake/wake-in-order.js
+
49
−
30
View file @
73be2127
...
@@ -19,40 +19,59 @@ const NUMELEM = RUNNING + 1;
...
@@ -19,40 +19,59 @@ const NUMELEM = RUNNING + 1;
// them go into a wait, thus controlling the waiting order. Then we wake them
// them go into a wait, thus controlling the waiting order. Then we wake them
// one by one and observe the wakeup order.
// one by one and observe the wakeup order.
for
(
var
i
=
0
;
i
<
NUMAGENT
;
i
++
)
{
for
(
var
attempt
=
0
;
attempt
<
10
;
attempt
++
)
{
$262
.
agent
.
start
(
`
for
(
var
i
=
0
;
i
<
NUMAGENT
;
i
++
)
{
$262.agent.
receiveBroadcast(function(sab) {
$262
.
agent
.
start
(
`
const i32a = new Int32Array
(sab)
;
$262.agent.receiveBroadcast(function
(sab)
{
Atomics.add(i32a,
${
RUNNING
}
, 1
);
const i32a = new Int32Array(sab
);
while (
Atomics.
lo
ad(i32a,
${
SPIN
+
i
}
) === 0)
Atomics.a
d
d(i32a,
${
RUNNING
}
, 1);
/* nothing */ ;
while (Atomics.load(i32a,
${
SPIN
+
i
}
) === 0) {
$262.agent.report(
${
i
}
+ Atomics.wait(i32a,
${
WAKEUP
}
, 0));
/* nothing */
$262.agent.leaving();
}
});
$262.agent.report(
${
i
}
);
`
);
Atomics.wait(i32a,
${
WAKEUP
}
, 0
);
}
$262.agent.report(
${
i
}
);
$262.agent.leaving();
const
i32a
=
new
Int32Array
(
});
new
SharedArrayBuffer
(
NUMELEM
*
Int32Array
.
BYTES_PER_ELEMENT
)
`
);
);
}
$262
.
agent
.
broadcast
(
i32a
.
buffer
);
const
i32a
=
new
Int32Array
(
new
SharedArrayBuffer
(
NUMELEM
*
Int32Array
.
BYTES_PER_ELEMENT
)
);
// Wait for agents to be running.
$262
.
agent
.
broadcast
(
i32a
.
buffer
);
waitUntil
(
i32a
,
RUNNING
,
NUMAGENT
);
// Sleep to allow the agents a fair chance to wait. If we don't,
// Wait for agents to be running.
// we risk sending the wakeup before agents are sleeping, and we hang.
waitUntil
(
i32a
,
RUNNING
,
NUMAGENT
);
$262
.
agent
.
sleep
(
50
);
// Make them sleep in order 0 1 2 on i32a[0]
// Sleep to allow the agents a fair chance to wait. If we don't,
for
(
var
i
=
0
;
i
<
NUMAGENT
;
i
++
)
{
// we risk sending the wakeup before agents are sleeping, and we hang.
Atomics
.
store
(
i32a
,
SPIN
+
i
,
1
);
$262
.
agent
.
sleep
(
50
);
$262
.
agent
.
sleep
(
50
);
}
// Wake them up one at a time and check the order is 0 1 2
var
waiterlist
=
[];
for
(
var
i
=
0
;
i
<
NUMAGENT
;
i
++
)
{
assert
.
sameValue
(
Atomics
.
store
(
i32a
,
SPIN
+
0
,
1
),
1
);
assert
.
sameValue
(
Atomics
.
wake
(
i32a
,
WAKEUP
,
1
),
1
,
'
Atomics.wake(i32a, WAKEUP, 1) returns 1
'
);
waiterlist
.
push
(
getReport
());
assert
.
sameValue
(
getReport
(),
i
+
'
ok
'
,
'
getReport() returns i + "ok"
'
);
assert
.
sameValue
(
Atomics
.
store
(
i32a
,
SPIN
+
1
,
1
),
1
);
waiterlist
.
push
(
getReport
());
assert
.
sameValue
(
Atomics
.
store
(
i32a
,
SPIN
+
2
,
1
),
1
);
waiterlist
.
push
(
getReport
());
var
notified
=
[];
assert
.
sameValue
(
Atomics
.
wake
(
i32a
,
WAKEUP
,
1
),
1
);
notified
.
push
(
getReport
());
assert
.
sameValue
(
Atomics
.
wake
(
i32a
,
WAKEUP
,
1
),
1
);
notified
.
push
(
getReport
());
assert
.
sameValue
(
Atomics
.
wake
(
i32a
,
WAKEUP
,
1
),
1
);
notified
.
push
(
getReport
());
assert
.
sameValue
(
notified
.
join
(
''
),
waiterlist
.
join
(
''
),
`Attempt #
${
attempt
}
: notified and waiterlist order do not match.`
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment