[Webkit-unassigned] [Bug 149340] Implement type conversion instructions in WebAssembly

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Sep 18 13:37:15 PDT 2015


https://bugs.webkit.org/show_bug.cgi?id=149340

--- Comment #4 from Sukolsak Sakshuwong <sukolsak at gmail.com> ---
(In reply to comment #3)
> Comment on attachment 261498 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=261498&action=review
> 
> > Source/JavaScriptCore/wasm/WASMFunctionCompiler.h:378
> > +    int buildConvertType(int, WASMExpressionType fromType, WASMExpressionType toType, WASMTypeConversion conversion)
> 
> Shouldn't the first argument and return type be of type ContextExpression?

ContextExpression is a macro for "typename Context::Expression". It is only used in the parser. Methods in the parser are templatized and take Context as the template parameter. The current possible Contexts are WASMFunctionSyntaxChecker WASMFunctionCompiler. In the future, we will have WASMFunctionLLVMIRGenerator.

In the context of WASMFunctionSyntaxChecker or WASMFunctionCompiler, Expression is just a typedef of int, because we never use it. In the context of WASMFunctionLLVMIRGenerator, Expression will be a typedef of FTL::LValue (or LLVMValueRef.)

I could use Expression, of course. But that seems to introduce unnecessary indirectness. I use the same design as the JSC parser. For example,

- In parser/SyntaxChecker.h, we have "int createBreakStatement(const JSTokenLocation&, int, int) { return StatementResult; }"

- In parser/ASTBuilder.h, we have "StatementNode* createBreakStatement(const JSTokenLocation& location, const Identifier* ident, const JSTextPosition& start, const JSTextPosition& end)"

> > Source/JavaScriptCore/wasm/WASMFunctionCompiler.h:382
> > +            load32(temporaryAddress(m_tempStackTop - 1), GPRInfo::regT0);
> 
> Everything looks fine, but I'm unfamiliar with this expression of
> "temporaryAddress(m_tempStackTop - 1)".  Just to make sure there is no bug
> here, can you explain what it means?  Specifically,
> 1. why is it called a "temporary" address?
> 2. why is it referring to "m_tempStackTop - 1"?  My interpretation is that
> you're operating on the operand at the top of the stack.  Hence, my naive
> expectation is that you would want "m_tempStackTop" instead?
> 
> Can you please clarify?  Thanks.

A WebAssembly call frame consists of [space for callee save registers] + [local variables] + [temporaries] + [padding for slow path calls] + [padding for stack pointer alignment]. We can think of [temporaries] as a stack, where m_tempStackTop is the size of the stack. m_tempStackTop starts from zero, because there is no value there. When there is a value there, temporaries[m_tempStackTop - 1] is the top value of the stack. temporaryAddress(m_tempStackTop - 1) is basically the address of temporaries[m_tempStackTop - 1].

We calculate the maximum size of [temporaries] in the syntax checking phrase.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20150918/42069491/attachment.html>


More information about the webkit-unassigned mailing list