Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Issue 2305903002: [wasm] reuse the first compiled module (Closed)

Created:
4 years, 3 months ago by Mircea Trofin
Modified:
4 years, 2 months ago
CC:
v8-reviews_googlegroups.com
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

[wasm] reuse the first compiled module. This change avoids needing to keep around an unused compiled module. Instead, the result of compiling the wasm bytes is given to the first instance. The module object and that instance object point to the same compiled module. Instances are, then, cloned from the compiled module the module object points to. When an instance is collected, we make sure that the module object still has a clone available, and, if the last instance is GC-ed, we also reset the compiled module so that it does not reference its heap, so that it (==heap) may be collected. This is achieved by linking the clones in a double-linked list and registering a finalizer for each. When we create an instance, we tie it in the front of the list, making the module object point to it (O(1)). When the finalizer is called, we relink the list over the dying object (O(1)). The costliest operation is finalizing the last instance, since we need to visit all wasm functions and reset heap references. BUG=v8:5316 Committed: https://crrev.com/01f5af515728aebe6c5246f4f7dd6c573e8748af Committed: https://crrev.com/b4dc310aab9b8aae362bcc226a9b0bb160ed2450 Cr-Original-Commit-Position: refs/heads/master@{#39153} Cr-Commit-Position: refs/heads/master@{#39361}

Patch Set 1 #

Patch Set 2 : serializer fix #

Patch Set 3 : signed/unsigned (win ) #

Patch Set 4 : no ignition #

Patch Set 5 #

Patch Set 6 : use HeapNumber for storing mem size #

Total comments: 16

Patch Set 7 : git cl try #

Patch Set 8 : use HeapNumber for storing mem size #

Patch Set 9 : feedback #

Patch Set 10 : gcmole #

Patch Set 11 : more gcmole #

Patch Set 12 : feedback #

Total comments: 3

Patch Set 13 : GC before cloning #

Unified diffs Side-by-side diffs Delta from patch set Stats (+583 lines, -146 lines) Patch
M src/runtime/runtime.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +4 lines, -1 line 0 comments Download
M src/runtime/runtime-test.cc View 1 chunk +26 lines, -0 lines 0 comments Download
M src/runtime/runtime-wasm.cc View 1 2 3 4 5 6 7 8 9 10 11 12 4 chunks +10 lines, -13 lines 0 comments Download
M src/snapshot/code-serializer.h View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +3 lines, -0 lines 0 comments Download
M src/snapshot/code-serializer.cc View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +4 lines, -0 lines 0 comments Download
M src/wasm/wasm-module.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +13 lines, -0 lines 0 comments Download
M src/wasm/wasm-module.cc View 1 2 3 4 5 6 7 8 9 10 11 12 24 chunks +432 lines, -117 lines 0 comments Download
A test/mjsunit/wasm/compiled-module-management.js View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +50 lines, -0 lines 0 comments Download
M test/mjsunit/wasm/instantiate-module-basic.js View 1 chunk +41 lines, -15 lines 0 comments Download

Messages

Total messages: 85 (60 generated)
Mircea Trofin
Oddly, we need to disable ignition for the test counting remaining instances after GC. Having ...
4 years, 3 months ago (2016-09-02 04:43:35 UTC) #18
bradnelson
https://codereview.chromium.org/2305903002/diff/100001/src/snapshot/code-serializer.cc File src/snapshot/code-serializer.cc (right): https://codereview.chromium.org/2305903002/diff/100001/src/snapshot/code-serializer.cc#newcode102 src/snapshot/code-serializer.cc:102: return SerializeGeneric(*isolate()->factory()->undefined_value(), So the links contain undefined when serialized? ...
4 years, 3 months ago (2016-09-02 16:57:00 UTC) #31
Mircea Trofin
https://codereview.chromium.org/2305903002/diff/100001/src/snapshot/code-serializer.cc File src/snapshot/code-serializer.cc (right): https://codereview.chromium.org/2305903002/diff/100001/src/snapshot/code-serializer.cc#newcode102 src/snapshot/code-serializer.cc:102: return SerializeGeneric(*isolate()->factory()->undefined_value(), On 2016/09/02 16:56:59, bradnelson wrote: > So ...
4 years, 3 months ago (2016-09-02 20:55:30 UTC) #40
Mircea Trofin
Fixed remaining gcmole issues.
4 years, 3 months ago (2016-09-03 00:28:10 UTC) #51
bradnelson
lgtm
4 years, 3 months ago (2016-09-03 01:19:53 UTC) #52
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2305903002/200001
4 years, 3 months ago (2016-09-03 01:30:44 UTC) #54
commit-bot: I haz the power
Try jobs failed on following builders: v8_presubmit on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_presubmit/builds/23237)
4 years, 3 months ago (2016-09-03 01:37:35 UTC) #56
Mircea Trofin
Toon/Daniel/Yang - I need signoff for the serializer part. PTAL? Thanks!
4 years, 3 months ago (2016-09-03 04:14:42 UTC) #58
vogelheim
lgtm for src/snapshot/... https://codereview.chromium.org/2305903002/diff/220001/src/snapshot/code-serializer.cc File src/snapshot/code-serializer.cc (right): https://codereview.chromium.org/2305903002/diff/220001/src/snapshot/code-serializer.cc#newcode101 src/snapshot/code-serializer.cc:101: if (SkipOver(obj)) { I would have ...
4 years, 3 months ago (2016-09-05 08:09:52 UTC) #59
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2305903002/220001
4 years, 3 months ago (2016-09-05 09:41:38 UTC) #62
Mircea Trofin
On 2016/09/05 08:09:52, vogelheim wrote: > lgtm for src/snapshot/... > > https://codereview.chromium.org/2305903002/diff/220001/src/snapshot/code-serializer.cc > File src/snapshot/code-serializer.cc ...
4 years, 3 months ago (2016-09-05 09:46:37 UTC) #63
commit-bot: I haz the power
Committed patchset #12 (id:220001)
4 years, 3 months ago (2016-09-05 10:08:07 UTC) #65
commit-bot: I haz the power
Patchset 12 (id:??) landed as https://crrev.com/01f5af515728aebe6c5246f4f7dd6c573e8748af Cr-Commit-Position: refs/heads/master@{#39153}
4 years, 3 months ago (2016-09-05 10:08:49 UTC) #67
Michael Achenbach
A revert of this CL (patchset #12 id:220001) has been created in https://codereview.chromium.org/2306403002/ by machenbach@chromium.org. ...
4 years, 3 months ago (2016-09-05 10:49:20 UTC) #68
Michael Starzinger
https://codereview.chromium.org/2305903002/diff/220001/test/mjsunit/wasm/compiled-module-management.js File test/mjsunit/wasm/compiled-module-management.js (right): https://codereview.chromium.org/2305903002/diff/220001/test/mjsunit/wasm/compiled-module-management.js#newcode35 test/mjsunit/wasm/compiled-module-management.js:35: gc(); The failure in Ignition is working as intended. ...
4 years, 3 months ago (2016-09-07 12:56:59 UTC) #70
Yang
On 2016/09/07 12:56:59, Michael Starzinger wrote: > https://codereview.chromium.org/2305903002/diff/220001/test/mjsunit/wasm/compiled-module-management.js > File test/mjsunit/wasm/compiled-module-management.js (right): > > https://codereview.chromium.org/2305903002/diff/220001/test/mjsunit/wasm/compiled-module-management.js#newcode35 ...
4 years, 3 months ago (2016-09-10 03:55:55 UTC) #71
Yang
https://codereview.chromium.org/2305903002/diff/220001/src/snapshot/code-serializer.cc File src/snapshot/code-serializer.cc (right): https://codereview.chromium.org/2305903002/diff/220001/src/snapshot/code-serializer.cc#newcode101 src/snapshot/code-serializer.cc:101: if (SkipOver(obj)) { On 2016/09/05 08:09:52, vogelheim wrote: > ...
4 years, 3 months ago (2016-09-10 03:58:37 UTC) #72
Mircea Trofin
On 2016/09/10 03:55:55, Yang wrote: > On 2016/09/07 12:56:59, Michael Starzinger wrote: > > > ...
4 years, 3 months ago (2016-09-10 03:59:05 UTC) #73
Mircea Trofin
On 2016/09/10 03:58:37, Yang wrote: > https://codereview.chromium.org/2305903002/diff/220001/src/snapshot/code-serializer.cc > File src/snapshot/code-serializer.cc (right): > > https://codereview.chromium.org/2305903002/diff/220001/src/snapshot/code-serializer.cc#newcode101 > ...
4 years, 3 months ago (2016-09-10 04:05:16 UTC) #74
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2305903002/240001
4 years, 3 months ago (2016-09-12 22:45:31 UTC) #78
commit-bot: I haz the power
Committed patchset #13 (id:240001)
4 years, 3 months ago (2016-09-12 23:12:31 UTC) #80
commit-bot: I haz the power
Patchset 13 (id:??) landed as https://crrev.com/b4dc310aab9b8aae362bcc226a9b0bb160ed2450 Cr-Commit-Position: refs/heads/master@{#39361}
4 years, 3 months ago (2016-09-12 23:13:29 UTC) #82
Mircea Trofin
On 2016/09/07 12:56:59, Michael Starzinger wrote: > https://codereview.chromium.org/2305903002/diff/220001/test/mjsunit/wasm/compiled-module-management.js > File test/mjsunit/wasm/compiled-module-management.js (right): > > https://codereview.chromium.org/2305903002/diff/220001/test/mjsunit/wasm/compiled-module-management.js#newcode35 ...
4 years, 3 months ago (2016-09-14 18:59:20 UTC) #83
Michael Starzinger
On 2016/09/14 18:59:20, Mircea Trofin wrote: > On 2016/09/07 12:56:59, Michael Starzinger wrote: > > ...
4 years, 2 months ago (2016-09-27 09:35:54 UTC) #84
Mircea Trofin
4 years, 2 months ago (2016-10-07 21:58:10 UTC) #85
Message was sent while issue was closed.
On 2016/09/27 09:35:54, Michael Starzinger wrote:
> On 2016/09/14 18:59:20, Mircea Trofin wrote:
> > On 2016/09/07 12:56:59, Michael Starzinger wrote:
> > >
> >
>
https://codereview.chromium.org/2305903002/diff/220001/test/mjsunit/wasm/comp...
> > > File test/mjsunit/wasm/compiled-module-management.js (right):
> > > 
> > >
> >
>
https://codereview.chromium.org/2305903002/diff/220001/test/mjsunit/wasm/comp...
> > > test/mjsunit/wasm/compiled-module-management.js:35: gc();
> > > The failure in Ignition is working as intended. Object lifetime is not
> > specified
> > > by JavaScript and is not observable via normal JavaScript code. Therefore
it
> > is
> > > perfectly legal to hold on to hidden temporary variables and extend
lifetime
> > > until the end of the function body (which Ignition does).
> > > 
> > > If we want to stick with observing lifetime here, then I would vote for
> > changing
> > > the test so that "i1", "i2" and so forth are stored in a global structure
> and
> > > nulled out there. The initialization (i.e. lines 23 till 31) can then life
> in
> > a
> > > separate function from the one which nulls out the instances (making them
> > > unreachable). By splitting up initialization and mutation into two
different
> > > functions, Ignition shouldn't keep the instance alive any longer.
> > > 
> > > Note that even that is just a best effort approach. I could very well
> imaging
> > > that inlining could combine those two function bodies again and
> (accidentally)
> > > extend the lifetime again.
> > 
> > Sorry for the delayed reply, I wanted to fix up the blocker to this CL
first.
> > 
> > Do we have a "no inline" test-only flag, perhaps a "natives" call ( a quick
> grep
> > didn't reveal 
> > anything). Do we want to, or is moving to the suggested alternative for this
> > test not
> > a sufficient motivation for this added functionality (==no inlining).
> > 
> > Thanks!
> 
> Sorry for lat reply, my Gmail at the mail. We have %NeverOptimizeFunction(f),
> which will also prevent inlining of "f" into any other function.

I see - I'll give that a try and update the test to not avoid ignition.

Powered by Google App Engine
This is Rietveld 408576698