Closed Bug 1330373 Opened 5 years ago Closed 4 years ago

XDR Decoded function cannot be relazified.

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla56
Tracking Status
firefox56 --- fixed

People

(Reporter: nbp, Assigned: nbp)

References

Details

Attachments

(1 file)

While testing the following (no --ion-eager, no --baseline-eager):


load(libdir + 'bytecode-cache.js');
gczeal(0);
test = `
  assertEq(isLazyFunction(f), generation == 0 || generation == 3);
  function f() { return 1; };
  f();
  expect = isRelazifiableFunction(f);
  print(expect);
  assertEq(isLazyFunction(f), false);
`;
evalWithCache(test, {
  checkAfter: function (ctx) {
    gc(ctx.global.f, "shrinking"); // relazify f, if possible.
    evaluate("assertEq(isLazyFunction(f), expect);", ctx);
  }
});


It outputs:

true
false
false
true

Which implies that we cannot relazify functions which have been decoded through XDR.  After Bug 900784 has landed, this might become a memory consumption, as functions which used to be relazifiable will no longer be in follow-up executions.

I do not think this bug should block 900784 landing, but this would defenitely matter more after its landing.
This patch moves the XDR incremtnal encode call to be used after
initializing the LazyScript point to the JSScript.

Otherwise, any code encoded with the incremental encoder would prevent the
relazification from working when the code would be decoded.
Attachment #8878082 - Flags: review?(shu)
Comment on attachment 8878082 [details] [diff] [review]
Capture JSScript::lazyScript field when encoding bytecode incrementally.

Review of attachment 8878082 [details] [diff] [review]:
-----------------------------------------------------------------

::: js/src/jit-test/tests/xdr/relazify.js
@@ +7,5 @@
> +// Generations 0 and 3 are executed from the source, thus f is not executed yet.
> +// Generations 1 and 2 are decoded, thus we recorded the delazified f function.
> +test = `
> +  function f() { return 1; };
> +  assertEq(isLazyFunction(f), generation == 0 || generation == 3);

What is generation? Is this some magic variable?
Attachment #8878082 - Flags: review?(shu) → review+
(In reply to Shu-yu Guo [:shu] from comment #2)
> ::: js/src/jit-test/tests/xdr/relazify.js
> @@ +7,5 @@
> > +// Generations 0 and 3 are executed from the source, thus f is not executed yet.
> > +// Generations 1 and 2 are decoded, thus we recorded the delazified f function.
> > +test = `
> > +  function f() { return 1; };
> > +  assertEq(isLazyFunction(f), generation == 0 || generation == 3);
> 
> What is generation? Is this some magic variable?

Generation is a number added to the global by the evalWithCache function.  The evalWithCache function re-evaluate the text code/bytecode, and increment the generation counter after each execution.  This is used to emulate divergent replay after a recording, such as testing that we can delazify a function which was not recorded in the last execution.
Pushed by npierron@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/e28dbb88b4c4
Capture JSScript::lazyScript field when encoding bytecode incrementally. r=shu
https://hg.mozilla.org/mozilla-central/rev/e28dbb88b4c4
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
Nicolas, this permafails Linux x64 CCov opt Jit6. It didn't get backed out because this is tier 2. Please take a look:

https://treeherder.mozilla.org/logviewer.html#?job_id=107865438&repo=mozilla-central

[task 2017-06-17T02:10:02.899517Z] 02:10:02     INFO -  TEST-PASS | tests/jit-test/jit-test/tests/xdr/lazy.js | Success (code 0, args "")
[task 2017-06-17T02:10:03.110166Z] 02:10:03     INFO -  TEST-PASS | tests/jit-test/jit-test/tests/xdr/lazy.js | Success (code 0, args "--baseline-eager")
[task 2017-06-17T02:10:03.469820Z] 02:10:03     INFO -  evalWithCacheCode.js:2:3 Error: Assertion failed: got false, expected true
[task 2017-06-17T02:10:03.470844Z] 02:10:03     INFO -  Stack:
[task 2017-06-17T02:10:03.471776Z] 02:10:03     INFO -    @evalWithCacheCode.js:2:3
[task 2017-06-17T02:10:03.472716Z] 02:10:03     INFO -    evalWithCache@/home/worker/workspace/build/tests/jit-test/jit-test/lib/bytecode-cache.js:34:14
[task 2017-06-17T02:10:03.473680Z] 02:10:03     INFO -    @/home/worker/workspace/build/tests/jit-test/jit-test/tests/xdr/relazify.js:16:1
[task 2017-06-17T02:10:03.474275Z] 02:10:03     INFO -  Exit code: 3
[task 2017-06-17T02:10:03.474902Z] 02:10:03     INFO -  FAIL - xdr/relazify.js
[task 2017-06-17T02:10:03.475689Z] 02:10:03  WARNING -  TEST-UNEXPECTED-FAIL | tests/jit-test/jit-test/tests/xdr/relazify.js | evalWithCacheCode.js:2:3 Error: Assertion failed: got false, expected true (code 3, args "")
[task 2017-06-17T02:10:03.476634Z] 02:10:03     INFO -  INFO exit-status     : 3
[task 2017-06-17T02:10:03.477519Z] 02:10:03     INFO -  INFO timed-out       : False
[task 2017-06-17T02:10:03.484421Z] 02:10:03     INFO -  INFO stderr         2> evalWithCacheCode.js:2:3 Error: Assertion failed: got false, expected true
[task 2017-06-17T02:10:03.484986Z] 02:10:03     INFO -  INFO stderr         2> Stack:
[task 2017-06-17T02:10:03.485397Z] 02:10:03     INFO -  INFO stderr         2> @evalWithCacheCode.js:2:3
[task 2017-06-17T02:10:03.485841Z] 02:10:03     INFO -  INFO stderr         2> evalWithCache@/home/worker/workspace/build/tests/jit-test/jit-test/lib/bytecode-cache.js:34:14
[task 2017-06-17T02:10:03.486283Z] 02:10:03     INFO -  INFO stderr         2> @/home/worker/workspace/build/tests/jit-test/jit-test/tests/xdr/relazify.js:16:1
Flags: needinfo?(nicolas.b.pierron)
Depends on: 1374203
(In reply to Sebastian Hengst [:aryx][:archaeopteryx] (needinfo on intermittent or backout) from comment #6)
> Nicolas, this permafails Linux x64 CCov opt Jit6. It didn't get backed out
> because this is tier 2. Please take a look:
> 
> https://treeherder.mozilla.org/logviewer.html#?job_id=107865438&repo=mozilla-
> central

This got addressed as part of Bug 1374203
Flags: needinfo?(nicolas.b.pierron)
Assignee: nobody → nicolas.b.pierron
You need to log in before you can comment on or make changes to this bug.