WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
148934
Implement control flow statements in WebAssembly
https://bugs.webkit.org/show_bug.cgi?id=148934
Summary
Implement control flow statements in WebAssembly
Sukolsak Sakshuwong
Reported
2015-09-07 10:53:27 PDT
This patch implements if, while, do, label, break, and continue statements in WebAssembly. Switches will be implemented in a subsequent patch.
Attachments
Patch
(19.61 KB, patch)
2015-09-07 10:58 PDT
,
Sukolsak Sakshuwong
no flags
Details
Formatted Diff
Diff
Patch
(19.63 KB, patch)
2015-09-07 11:10 PDT
,
Sukolsak Sakshuwong
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Sukolsak Sakshuwong
Comment 1
2015-09-07 10:58:52 PDT
Created
attachment 260741
[details]
Patch
Sukolsak Sakshuwong
Comment 2
2015-09-07 11:10:12 PDT
Created
attachment 260742
[details]
Patch
Sukolsak Sakshuwong
Comment 3
2015-09-08 07:27:02 PDT
When we implement an LLVM IR generator for WebAssembly, JumpTarget will be just an LLVM Basic Block. The code will look like this: typedef LBasicBlock JumpTarget; LBasicBlock newTarget() { return m_out.newBlock(); } void linkTarget(LBasicBlock target) { m_out.jump(target); m_out.appendTo(target); } void jumpToTarget(LBasicBlock target) { m_out.jump(target); } void jumpToTargetIf(JumpCondition condition, LValue expression, LBasicBlock target) { LBasicBlock notTaken = m_out.newBlock(); m_out.branch((condition == JumpCondition::Zero) ? m_out.isZero32(expression) : m_out.notZero32(expression), FTL::unsure(target), FTL::unsure(notTaken)); m_out.appendTo(notTaken); }
Geoffrey Garen
Comment 4
2015-09-08 11:13:19 PDT
Comment on
attachment 260742
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=260742&action=review
r=me
> Source/JavaScriptCore/wasm/WASMFunctionCompiler.h:407 > + void endLabel() > + { > + linkTarget(m_breakLabelTargets.last()); > + > + m_breakLabelTargets.removeLast(); > + m_continueLabelTargets.removeLast(); > + }
Is it guaranteed that WASM can't have arbitrary gotos? (An arbitrary goto would make the push/pop model of labels invalid.)
Sukolsak Sakshuwong
Comment 5
2015-09-08 11:36:15 PDT
Thanks! (In reply to
comment #4
)
> Comment on
attachment 260742
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=260742&action=review
> > r=me > > > Source/JavaScriptCore/wasm/WASMFunctionCompiler.h:407 > > + void endLabel() > > + { > > + linkTarget(m_breakLabelTargets.last()); > > + > > + m_breakLabelTargets.removeLast(); > > + m_continueLabelTargets.removeLast(); > > + } > > Is it guaranteed that WASM can't have arbitrary gotos? (An arbitrary goto > would make the push/pop model of labels invalid.)
goto is not part of the MVP, but it is under consideration for a future version. <
https://github.com/WebAssembly/design/blob/master/FutureFeatures.md#more-expressive-control-flow
> The WASM format that we are using doesn't have goto.
WebKit Commit Bot
Comment 6
2015-09-08 16:05:08 PDT
Comment on
attachment 260742
[details]
Patch Clearing flags on attachment: 260742 Committed
r189514
: <
http://trac.webkit.org/changeset/189514
>
WebKit Commit Bot
Comment 7
2015-09-08 16:05:12 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug