|
|
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 #
Messages
Total messages: 85 (60 generated)
The CQ bit was checked by mtrofin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: v8_win_compile_dbg on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_win_compile_dbg/builds/2...)
The CQ bit was checked by mtrofin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: v8_win_rel_ng on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_win_rel_ng/builds/13565)
The CQ bit was checked by mtrofin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Description was changed from ========== [wasm] reuse the first compiled module BUG= ========== to ========== [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= ==========
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: v8_linux64_gyp_rel_ng on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux64_gyp_rel_ng/build...) v8_linux64_gyp_rel_ng_triggered on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux64_gyp_rel_ng_trigg...)
The CQ bit was checked by mtrofin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Description was changed from ========== [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= ========== to ========== [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 ==========
mtrofin@chromium.org changed reviewers: + bradnelson@chromium.org
Oddly, we need to disable ignition for the test counting remaining instances after GC. Having ignition "on" does not run the finalizer when we force gc.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: v8_linux_dbg_ng on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_dbg_ng/builds/12009) v8_linux_dbg_ng_triggered on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_dbg_ng_triggered/b...)
The CQ bit was checked by mtrofin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: v8_linux_rel_ng on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_rel_ng/builds/11961) v8_linux_rel_ng_triggered on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_rel_ng_triggered/b...)
The CQ bit was checked by mtrofin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: v8_linux64_avx2_rel_ng on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux64_avx2_rel_ng/buil...) v8_linux64_avx2_rel_ng_triggered on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux64_avx2_rel_ng_trig...)
The CQ bit was checked by mtrofin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
https://codereview.chromium.org/2305903002/diff/100001/src/snapshot/code-seri... File src/snapshot/code-serializer.cc (right): https://codereview.chromium.org/2305903002/diff/100001/src/snapshot/code-seri... src/snapshot/code-serializer.cc:102: return SerializeGeneric(*isolate()->factory()->undefined_value(), So the links contain undefined when serialized? https://codereview.chromium.org/2305903002/diff/100001/src/wasm/wasm-module.cc File src/wasm/wasm-module.cc (left): https://codereview.chromium.org/2305903002/diff/100001/src/wasm/wasm-module.c... src/wasm/wasm-module.cc:456: DCHECK(code->deoptimization_data() == nullptr || Why? https://codereview.chromium.org/2305903002/diff/100001/src/wasm/wasm-module.cc File src/wasm/wasm-module.cc (right): https://codereview.chromium.org/2305903002/diff/100001/src/wasm/wasm-module.c... src/wasm/wasm-module.cc:162: kWasmCompiledModule, Optional: Realize the default is zero, but I've sometimes seen the pattern where an explicit =0 is a signal that other code depends on this enum being tightly packed. https://codereview.chromium.org/2305903002/diff/100001/src/wasm/wasm-module.c... src/wasm/wasm-module.cc:1207: if (!weak_module_obj->cleared()) { Why? https://codereview.chromium.org/2305903002/diff/100001/src/wasm/wasm-module.c... src/wasm/wasm-module.cc:1211: DCHECK_NULL(GetPrevInstance(current_template)); Separate out the remove from chain operation? Or comment that's what's going on? https://codereview.chromium.org/2305903002/diff/100001/src/wasm/wasm-module.c... src/wasm/wasm-module.cc:1322: FlushAssemblyCache(isolate, compiled_functions); Because the code has never run? Probably not. https://codereview.chromium.org/2305903002/diff/100001/src/wasm/wasm-module.c... src/wasm/wasm-module.cc:1600: // replaced with the instance's actual imports in SetupImports. reflow comment https://codereview.chromium.org/2305903002/diff/100001/test/mjsunit/wasm/comp... File test/mjsunit/wasm/compiled-module-management.js (right): https://codereview.chromium.org/2305903002/diff/100001/test/mjsunit/wasm/comp... test/mjsunit/wasm/compiled-module-management.js:5: // Flags: --no-ignition --no-ignition-staging --expose-wasm --expose-gc --allow-natives-syntax You can split these into two Flags: to stay under 80.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: v8_linux_rel_ng on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_rel_ng/builds/12009) v8_linux_rel_ng_triggered on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_rel_ng_triggered/b...)
The CQ bit was checked by mtrofin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: v8_linux_dbg_ng on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_dbg_ng/builds/12078) v8_linux_dbg_ng_triggered on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_dbg_ng_triggered/b...)
The CQ bit was checked by mtrofin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
https://codereview.chromium.org/2305903002/diff/100001/src/snapshot/code-seri... File src/snapshot/code-serializer.cc (right): https://codereview.chromium.org/2305903002/diff/100001/src/snapshot/code-seri... src/snapshot/code-serializer.cc:102: return SerializeGeneric(*isolate()->factory()->undefined_value(), On 2016/09/02 16:56:59, bradnelson wrote: > So the links contain undefined when serialized? Yes. The module obtained by deserializing this is its own separate JSObject instance, with its own wasm module instances chain https://codereview.chromium.org/2305903002/diff/100001/src/wasm/wasm-module.cc File src/wasm/wasm-module.cc (left): https://codereview.chromium.org/2305903002/diff/100001/src/wasm/wasm-module.c... src/wasm/wasm-module.cc:456: DCHECK(code->deoptimization_data() == nullptr || On 2016/09/02 16:57:00, bradnelson wrote: > Why? Because now the deopt will be valid, but belonging to the code object we used as prototype for this new one. https://codereview.chromium.org/2305903002/diff/100001/src/wasm/wasm-module.cc File src/wasm/wasm-module.cc (right): https://codereview.chromium.org/2305903002/diff/100001/src/wasm/wasm-module.c... src/wasm/wasm-module.cc:162: kWasmCompiledModule, On 2016/09/02 16:56:59, bradnelson wrote: > Optional: > Realize the default is zero, but I've sometimes seen the pattern where an > explicit =0 is a signal that other code depends on this enum being tightly > packed. Done. https://codereview.chromium.org/2305903002/diff/100001/src/wasm/wasm-module.c... src/wasm/wasm-module.cc:1207: if (!weak_module_obj->cleared()) { On 2016/09/02 16:57:00, bradnelson wrote: > Why? It may be cleared when this happens: var m = new WebAssembly.Module(...); var i1 = new WebAssembly.Instance(m); var i2 = new WebAssembly.Instance(m); m = nullptr; gc(); In this case, we don't care anymore to maintain the links, because no new instances may be created. I added a comment. https://codereview.chromium.org/2305903002/diff/100001/src/wasm/wasm-module.c... src/wasm/wasm-module.cc:1211: DCHECK_NULL(GetPrevInstance(current_template)); On 2016/09/02 16:57:00, bradnelson wrote: > Separate out the remove from chain operation? > Or comment that's what's going on? There nothing else than the delete - we're called here when an instance is dying. https://codereview.chromium.org/2305903002/diff/100001/src/wasm/wasm-module.c... src/wasm/wasm-module.cc:1322: FlushAssemblyCache(isolate, compiled_functions); On 2016/09/02 16:56:59, bradnelson wrote: > Because the code has never run? Probably not. Acknowledged. https://codereview.chromium.org/2305903002/diff/100001/src/wasm/wasm-module.c... src/wasm/wasm-module.cc:1600: // replaced with the instance's actual imports in SetupImports. On 2016/09/02 16:57:00, bradnelson wrote: > reflow comment Done. https://codereview.chromium.org/2305903002/diff/100001/test/mjsunit/wasm/comp... File test/mjsunit/wasm/compiled-module-management.js (right): https://codereview.chromium.org/2305903002/diff/100001/test/mjsunit/wasm/comp... test/mjsunit/wasm/compiled-module-management.js:5: // Flags: --no-ignition --no-ignition-staging --expose-wasm --expose-gc --allow-natives-syntax On 2016/09/02 16:57:00, bradnelson wrote: > You can split these into two Flags: to stay under 80. Done.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: v8_linux_rel_ng on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_rel_ng/builds/12020) v8_linux_rel_ng_triggered on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_rel_ng_triggered/b...)
The CQ bit was checked by mtrofin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: v8_linux_rel_ng on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_rel_ng/builds/12024) v8_linux_rel_ng_triggered on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_rel_ng_triggered/b...)
The CQ bit was checked by mtrofin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Fixed remaining gcmole issues.
lgtm
The CQ bit was checked by mtrofin@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
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)
mtrofin@chromium.org changed reviewers: + verwaest@chromium.org, vogelheim@chromium.org, yangguo@chromium.org
Toon/Daniel/Yang - I need signoff for the serializer part. PTAL? Thanks!
lgtm for src/snapshot/... https://codereview.chromium.org/2305903002/diff/220001/src/snapshot/code-seri... File src/snapshot/code-serializer.cc (right): https://codereview.chromium.org/2305903002/diff/220001/src/snapshot/code-seri... src/snapshot/code-serializer.cc:101: if (SkipOver(obj)) { I would have preferred a more expressive name, or a comment on why this is here. You're effectively implementing special case handling for one object type (weak cells) in one CodeSerializer subclass. But since the name only explains the mechanism (skip over this value), there is no easy way for a reader to figure out what the intent is, and if this is a commonly used mechanism or just an edge case.
The CQ bit was checked by mtrofin@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from bradnelson@chromium.org Link to the patchset: https://codereview.chromium.org/2305903002/#ps220001 (title: "feedback")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
On 2016/09/05 08:09:52, vogelheim wrote: > lgtm for src/snapshot/... > > https://codereview.chromium.org/2305903002/diff/220001/src/snapshot/code-seri... > File src/snapshot/code-serializer.cc (right): > > https://codereview.chromium.org/2305903002/diff/220001/src/snapshot/code-seri... > src/snapshot/code-serializer.cc:101: if (SkipOver(obj)) { > I would have preferred a more expressive name, or a comment on why this is here. > > You're effectively implementing special case handling for one object type (weak > cells) in one CodeSerializer subclass. But since the name only explains the > mechanism (skip over this value), there is no easy way for a reader to figure > out what the intent is, and if this is a commonly used mechanism or just an edge > case. Good point. I'll have to address a more involved case shortly, time at which SkipOver either goes, in favor of new mechanism, or I'll rename it as per your feedback.
Message was sent while issue was closed.
Description was changed from ========== [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 ========== to ========== [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 ==========
Message was sent while issue was closed.
Committed patchset #12 (id:220001)
Message was sent while issue was closed.
Description was changed from ========== [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 ========== to ========== [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 Cr-Commit-Position: refs/heads/master@{#39153} ==========
Message was sent while issue was closed.
Patchset 12 (id:??) landed as https://crrev.com/01f5af515728aebe6c5246f4f7dd6c573e8748af Cr-Commit-Position: refs/heads/master@{#39153}
Message was sent while issue was closed.
A revert of this CL (patchset #12 id:220001) has been created in https://codereview.chromium.org/2306403002/ by machenbach@chromium.org. The reason for reverting is: mac gc stress failures: https://build.chromium.org/p/client.v8/builders/V8%20Mac%20GC%20Stress/builds....
Message was sent while issue was closed.
mstarzinger@chromium.org changed reviewers: + mstarzinger@chromium.org
Message was sent while issue was closed.
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.
Message was sent while issue was closed.
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. I'd also liked to see a more expressive name than "SkipOver". I see that the name was kept when this CL landed.
Message was sent while issue was closed.
https://codereview.chromium.org/2305903002/diff/220001/src/snapshot/code-seri... File src/snapshot/code-serializer.cc (right): https://codereview.chromium.org/2305903002/diff/220001/src/snapshot/code-seri... src/snapshot/code-serializer.cc:101: if (SkipOver(obj)) { On 2016/09/05 08:09:52, vogelheim wrote: > I would have preferred a more expressive name, or a comment on why this is here. > > You're effectively implementing special case handling for one object type (weak > cells) in one CodeSerializer subclass. But since the name only explains the > mechanism (skip over this value), there is no easy way for a reader to figure > out what the intent is, and if this is a commonly used mechanism or just an edge > case. I wonder whether it' not cleaner to implement a separate Serialize method for the wasm code serializer that filters weak cells before calling this Serialize method.
Message was sent while issue was closed.
On 2016/09/10 03:55:55, Yang 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. > > I'd also liked to see a more expressive name than "SkipOver". I see that the > name was kept when this CL landed. I'll rename it when I resubmit. Would "ElideObject" be a better name?
Message was sent while issue was closed.
On 2016/09/10 03:58:37, Yang wrote: > https://codereview.chromium.org/2305903002/diff/220001/src/snapshot/code-seri... > File src/snapshot/code-serializer.cc (right): > > https://codereview.chromium.org/2305903002/diff/220001/src/snapshot/code-seri... > src/snapshot/code-serializer.cc:101: if (SkipOver(obj)) { > On 2016/09/05 08:09:52, vogelheim wrote: > > I would have preferred a more expressive name, or a comment on why this is > here. > > > > You're effectively implementing special case handling for one object type > (weak > > cells) in one CodeSerializer subclass. But since the name only explains the > > mechanism (skip over this value), there is no easy way for a reader to figure > > out what the intent is, and if this is a commonly used mechanism or just an > edge > > case. > > I wonder whether it' not cleaner to implement a separate Serialize method for > the wasm code serializer that filters weak cells before calling this Serialize > method. Probably. As I mentioned earlier, there is a bit more to do after this CL, such as eliding deopt info on code objects before serializing, and re-adding after. I could probably treat these skipoed over objects similarly. My goal for now is to ensure the newly introduced instance management is correct. I'll change the api name though, for the interim.
Message was sent while issue was closed.
Description was changed from ========== [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 Cr-Commit-Position: refs/heads/master@{#39153} ========== to ========== [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 Cr-Commit-Position: refs/heads/master@{#39153} ==========
The CQ bit was checked by mtrofin@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from bradnelson@chromium.org, vogelheim@chromium.org Link to the patchset: https://codereview.chromium.org/2305903002/#ps240001 (title: "GC before cloning")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Description was changed from ========== [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 Cr-Commit-Position: refs/heads/master@{#39153} ========== to ========== [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 Cr-Commit-Position: refs/heads/master@{#39153} ==========
Message was sent while issue was closed.
Committed patchset #13 (id:240001)
Message was sent while issue was closed.
Description was changed from ========== [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 Cr-Commit-Position: refs/heads/master@{#39153} ========== to ========== [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} ==========
Message was sent while issue was closed.
Patchset 13 (id:??) landed as https://crrev.com/b4dc310aab9b8aae362bcc226a9b0bb160ed2450 Cr-Commit-Position: refs/heads/master@{#39361}
Message was sent while issue was closed.
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!
Message was sent while issue was closed.
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.
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. |