| Summary: | Implement control flow statements in WebAssembly | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Sukolsak Sakshuwong <sukolsak> | ||||||
| Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> | ||||||
| Status: | RESOLVED FIXED | ||||||||
| Severity: | Normal | CC: | commit-queue, fpizlo, ggaren, saam, sukolsak, ysuzuki | ||||||
| Priority: | P2 | ||||||||
| Version: | WebKit Nightly Build | ||||||||
| Hardware: | Unspecified | ||||||||
| OS: | Unspecified | ||||||||
| Bug Depends on: | |||||||||
| Bug Blocks: | 146064 | ||||||||
| Attachments: |
|
||||||||
|
Description
Sukolsak Sakshuwong
2015-09-07 10:53:27 PDT
Created attachment 260741 [details]
Patch
Created attachment 260742 [details]
Patch
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);
}
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.) 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. Comment on attachment 260742 [details] Patch Clearing flags on attachment: 260742 Committed r189514: <http://trac.webkit.org/changeset/189514> All reviewed patches have been landed. Closing bug. |