-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add inlining support for asm.js/wasm #3681
Conversation
33303c0
to
9fcb1b0
Compare
0ec1c7c
to
7baad00
Compare
case Js::OpCode::LdAsmJsEnv: | ||
if (instr->m_func == inlinee) | ||
{ | ||
instr->SetSrc1(funcObjOpnd); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this never be an AddrOpnd in asmjs? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backend changes look good to me |
i think you're right this one i don't need. the reason for other one is we can introduce call during lowerer in an inlinee which was leaf, where the parent was also leaf, and only the inner func is updated. this leads to problems later where we end up encoding a call from a leaf func. In reply to: 328701050 [](ancestors = 328701050) Refers to: lib/Backend/LinearScan.cpp:2113 in 7baad00. [](commit_id = 7baad00, deletion_comment = False) |
b0b06fc
to
3eca75e
Compare
Reviewed 67 of 74 files at r1, 9 of 10 files at r2. a discussion (no related file): a discussion (no related file): a discussion (no related file): const buf = WebAssembly.wabt.convertWast2Wasm(`
(module
(type $t1 (func (result i32)))
(type $t2 (func (param i32) (result i32)))
(import "test" "foo" (func $foo (type $t1)))
(import "test" "print" (func $print (type $t2)))
(func $f2 (export "a") (type $t2) (local f32)
(call $print (call $foo))
)
(func (export "f2") (type $t1)
(i32.const 2)
)
)`);
const module = new WebAssembly.Module(buf);
const {exports: {a: a1, f2}} = new WebAssembly.Instance(module, {test: {foo: () => 1, print}});
const {exports: {a: a2}} = new WebAssembly.Instance(module, {test: {foo: f2, print}});
a1();
a1();
a2(); Without inlining, it prints lib/Backend/BackendOpCodeAttrAsmJs.cpp, line 17 at r2 (raw file):
We seem to only set the lib/Backend/Sym.h, line 179 at r2 (raw file):
I can't find any references to this function. Is it still needed ? lib/Runtime/Language/DynamicProfileInfo.cpp, line 417 at r2 (raw file):
nit: asm.js/wasm function body lib/WasmReader/WasmByteCodeGenerator.cpp, line 966 at r2 (raw file):
change check for GetReader()->m_currentNode.call.funcType == FunctionIndexTypes::Function lib/WasmReader/WasmByteCodeGenerator.cpp, line 1136 at r2 (raw file):
unnessary check since we have the same check above. test/AsmJs/rlexe.xml, line 613 at r2 (raw file):
Why was this needed ? test/wasm/inlining.js, line 1 at r2 (raw file):
You didn't add this file to wasm/rlexe.xml Comments from Reviewable |
3eca75e
to
7be7690
Compare
Reviewed 5 of 5 files at r3. Comments from Reviewable |
Review status: 76 of 77 files reviewed at latest revision, 10 unresolved discussions, some commit checks failed. a discussion (no related file): Previously, Cellule (Michael Ferris) wrote…
Disabled inlining/profiling when this is enabled and seems to work now a discussion (no related file): Previously, Cellule (Michael Ferris) wrote…
Yeah, I thought about this, but seems like something we can optimize later lib/Backend/BackendOpCodeAttrAsmJs.cpp, line 17 at r2 (raw file): Previously, Cellule (Michael Ferris) wrote…
Done. lib/Backend/Sym.h, line 179 at r2 (raw file): Previously, Cellule (Michael Ferris) wrote…
Done. lib/Runtime/Language/DynamicProfileInfo.cpp, line 417 at r2 (raw file): Previously, Cellule (Michael Ferris) wrote…
Done. lib/WasmReader/WasmByteCodeGenerator.cpp, line 966 at r2 (raw file): Previously, Cellule (Michael Ferris) wrote…
Done. lib/WasmReader/WasmByteCodeGenerator.cpp, line 1136 at r2 (raw file): Previously, Cellule (Michael Ferris) wrote…
Done. test/AsmJs/rlexe.xml, line 613 at r2 (raw file): Previously, Cellule (Michael Ferris) wrote…
something changed now that we are profiling causing different deferral between interpreter/dynapogo so trace was printing in different spot test/wasm/inlining.js, line 1 at r2 (raw file): Previously, Cellule (Michael Ferris) wrote…
Done. Comments from Reviewable |
3ccd90c
to
75f5e8f
Compare
Reviewed 8 of 8 files at r5. Comments from Reviewable |
Merge pull request #3681 from MikeHolman:wasminline Add support for profiling in asm.js, and profile direct internal calls. Use temp registers rather than hard coded registers for intermediate bytecode values, so backend correctly understands that these are temps and not locals. (Also allowed me to remove the I_Conv_* opcodes.) Tell inliner to try to inline candidate asm.js/wasm functions. Required some special handling for functions with no parameters and non-var arguments, and skipping function object bailout check. Simplify how we emit calls in asm.js bytecode generator to evaluate arguments before emitting argouts. Prior code required complicated tracking of call depth during bytecode gen, which led to complicated call nesting (and subsequently made inlining more complicated). Track calls for asm.js/wasm during globopt, and change inline argument tracking to use inlinee argout size rather than count for frame size calculation. (This will be needed for stackwalking, which we punted for asm.js in general... but is something we should really get around to.) For inlining heuristics, we are more aggressive at inlining than normal JS, for the reason that bytecode is already low level, so it will blow up in size less than JS bytecode will. Preliminary perf indicates overall improvements of about 4.5% in Unity and 1% in Jetstream Closes #2794 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/microsoft/chakracore/3681) <!-- Reviewable:end -->
Add support for profiling in asm.js, and profile direct internal calls.
Use temp registers rather than hard coded registers for intermediate bytecode values, so backend correctly understands that these are temps and not locals. (Also allowed me to remove the I_Conv_* opcodes.)
Tell inliner to try to inline candidate asm.js/wasm functions. Required some special handling for functions with no parameters and non-var arguments, and skipping function object bailout check.
Simplify how we emit calls in asm.js bytecode generator to evaluate arguments before emitting argouts. Prior code required complicated tracking of call depth during bytecode gen, which led to complicated call nesting (and subsequently made inlining more complicated).
Track calls for asm.js/wasm during globopt, and change inline argument tracking to use inlinee argout size rather than count for frame size calculation. (This will be needed for stackwalking, which we punted for asm.js in general... but is something we should really get around to.)
For inlining heuristics, we are more aggressive at inlining than normal JS, for the reason that bytecode is already low level, so it will blow up in size less than JS bytecode will.
Preliminary perf indicates overall improvements of about 4.5% in Unity and 1% in Jetstream
Closes #2794
This change is