WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
165163
We should have a Wasm callee
https://bugs.webkit.org/show_bug.cgi?id=165163
Summary
We should have a Wasm callee
Saam Barati
Reported
2016-11-29 14:55:31 PST
And we should be able to patch stores of the callee into the entrypoint of a wasm function
Attachments
WIP
(13.42 KB, patch)
2016-11-29 16:47 PST
,
Saam Barati
no flags
Details
Formatted Diff
Diff
WIP
(36.50 KB, patch)
2016-11-29 18:42 PST
,
Saam Barati
no flags
Details
Formatted Diff
Diff
RFC WIP
(57.84 KB, patch)
2016-12-01 15:18 PST
,
Saam Barati
no flags
Details
Formatted Diff
Diff
WIP
(59.46 KB, patch)
2016-12-01 20:08 PST
,
Saam Barati
no flags
Details
Formatted Diff
Diff
WIP
(59.47 KB, patch)
2016-12-01 20:12 PST
,
Saam Barati
no flags
Details
Formatted Diff
Diff
patch
(63.52 KB, patch)
2016-12-02 12:55 PST
,
Saam Barati
keith_miller
: review+
Details
Formatted Diff
Diff
patch for landing
(54.89 KB, patch)
2016-12-04 13:22 PST
,
Saam Barati
no flags
Details
Formatted Diff
Diff
Show Obsolete
(6)
View All
Add attachment
proposed patch, testcase, etc.
Saam Barati
Comment 1
2016-11-29 16:47:55 PST
Created
attachment 295673
[details]
WIP It probably doesn't compile yet.
Saam Barati
Comment 2
2016-11-29 18:42:22 PST
Created
attachment 295691
[details]
WIP it compiles
Filip Pizlo
Comment 3
2016-11-29 18:45:27 PST
Comment on
attachment 295691
[details]
WIP View in context:
https://bugs.webkit.org/attachment.cgi?id=295691&action=review
> Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp:202 > + // FIXME: how do we make sure this is the first thing to execute?
Remove this.
> Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp:205 > + getCalleePatchpoint->effects = Effects::none();
Remove this.
Saam Barati
Comment 4
2016-12-01 15:18:06 PST
Created
attachment 295904
[details]
RFC WIP
Saam Barati
Comment 5
2016-12-01 15:48:48 PST
Comment on
attachment 295904
[details]
RFC WIP View in context:
https://bugs.webkit.org/attachment.cgi?id=295904&action=review
> Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp:236 > + Value* offsetOfCodeBlock = m_currentBlock->appendNew<Const64Value>(m_proc, Origin(), CallFrameSlot::codeBlock * sizeof(Register)); > + m_currentBlock->appendNew<MemoryValue>(m_proc, Store, Origin(), > + m_currentBlock->appendNew<Const64Value>(m_proc, Origin(), 0), > + m_currentBlock->appendNew<Value>(m_proc, Add, Origin(), framePointer, offsetOfCodeBlock));
We probably shouldn't do this, but it will mean I need to audit the stack walking behavior to make sure it doesn't take a non-null codeblock to mean that the CodeBlock is a valid value.
Saam Barati
Comment 6
2016-12-01 15:50:03 PST
Comment on
attachment 295904
[details]
RFC WIP View in context:
https://bugs.webkit.org/attachment.cgi?id=295904&action=review
> Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.h:68 > + AuxiliaryBarrier<JSWebAssemblyCallee**> m_callees;
We could probably allocate a variable sized cell and just have this buffer be at the end of this cell's fields similar to lexical environments
Saam Barati
Comment 7
2016-12-01 15:51:49 PST
Comment on
attachment 295904
[details]
RFC WIP View in context:
https://bugs.webkit.org/attachment.cgi?id=295904&action=review
> Source/JavaScriptCore/wasm/WasmPlan.h:40 > +class MarkedArgumentBuffer;
This should be deleted.
JF Bastien
Comment 8
2016-12-01 15:56:56 PST
Comment on
attachment 295904
[details]
RFC WIP View in context:
https://bugs.webkit.org/attachment.cgi?id=295904&action=review
> Source/JavaScriptCore/jsc.cpp:2540 > + return JSValue::decode(vmEntryToWasm(callee->jsEntryPoint(), vm, &protoCallFrame));
FYI I'm renaming this to jsToWasmEntryPoint to be clearer.
> Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.h:58 > + return m_callees.get()[calleeIndex];
.at() wouldn't remove the need for the assert.
> Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.h:68 > + AuxiliaryBarrier<JSWebAssemblyCallee**> m_callees;
Can't this be a Vector<WriteBarrier> ? Seems like the code would be simpler that way.
Saam Barati
Comment 9
2016-12-01 16:05:12 PST
Comment on
attachment 295904
[details]
RFC WIP View in context:
https://bugs.webkit.org/attachment.cgi?id=295904&action=review
>>> Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.h:68 >>> + AuxiliaryBarrier<JSWebAssemblyCallee**> m_callees; >> >> We could probably allocate a variable sized cell and just have this buffer be at the end of this cell's fields similar to lexical environments > > Can't this be a Vector<WriteBarrier> ? Seems like the code would be simpler that way.
I'm just going to make it inline at the end of this object.
Saam Barati
Comment 10
2016-12-01 20:08:14 PST
Created
attachment 295924
[details]
WIP I think this might be done, I just want to read it over and write a changelog.
Saam Barati
Comment 11
2016-12-01 20:12:44 PST
Created
attachment 295925
[details]
WIP fixed a comment.
Saam Barati
Comment 12
2016-12-02 12:55:46 PST
Created
attachment 295985
[details]
patch
JF Bastien
Comment 13
2016-12-02 13:57:34 PST
Comment on
attachment 295985
[details]
patch View in context:
https://bugs.webkit.org/attachment.cgi?id=295985&action=review
Looks good.
> Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.h:81 > + unsigned m_calleeCount;
So there's usually no maker at the end here? It's valid C to put JSWebAssemblyCallee m_callee[];
Keith Miller
Comment 14
2016-12-02 16:09:42 PST
Comment on
attachment 295985
[details]
patch View in context:
https://bugs.webkit.org/attachment.cgi?id=295985&action=review
r=me with some comments.
> Source/JavaScriptCore/jsc.cpp:-2588 > - if (!plan.compiledFunction(i)) > - dataLogLn("failed to compile function at index", i);
Why'd you delete this?
> Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp:213 > + PatchpointValue* getCalleePatchpoint = m_currentBlock->appendNew<B3::PatchpointValue>(m_proc, Int64, Origin());
I think this should all be done in some function in WasmCallingConvention.h. My hope was to make it easier to manage all the various calling convention stuff if it's all there.
> Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp:229 > + m_currentBlock->appendNew<MemoryValue>(m_proc, Store, Origin(),
You can make sure other potentially trapping memory ops are not move over this with: m_currentBlock->appendNew<MemoryValue>(m_proc, traps(Store), Origin(), ... I guess I forgot to add that to the wasm memory opcodes. I'll make a patch for that now.
Saam Barati
Comment 15
2016-12-04 12:24:14 PST
Comment on
attachment 295985
[details]
patch View in context:
https://bugs.webkit.org/attachment.cgi?id=295985&action=review
>> Source/JavaScriptCore/jsc.cpp:-2588 >> - dataLogLn("failed to compile function at index", i); > > Why'd you delete this?
I thought it was redundant with ``` if (plan.failed()) CRASH(); ``` and ``` if (plan.compiledFunctionCount() != functionCount) CRASH(); ``` Is it not?
>> Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp:213 >> + PatchpointValue* getCalleePatchpoint = m_currentBlock->appendNew<B3::PatchpointValue>(m_proc, Int64, Origin()); > > I think this should all be done in some function in WasmCallingConvention.h. My hope was to make it easier to manage all the various calling convention stuff if it's all there.
Ok, will do.
>> Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp:229 >> + m_currentBlock->appendNew<MemoryValue>(m_proc, Store, Origin(), > > You can make sure other potentially trapping memory ops are not move over this with: m_currentBlock->appendNew<MemoryValue>(m_proc, traps(Store), Origin(), ... > > I guess I forgot to add that to the wasm memory opcodes. I'll make a patch for that now.
Actually, after reading though some B3 code, it would be invalid for this to happen. All trapping memory accesses claim to read the entire heap, so it would be invalid for this store to not execute before those.
>> Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.h:81 >> + unsigned m_calleeCount; > > So there's usually no maker at the end here? It's valid C to put JSWebAssemblyCallee m_callee[];
We don't usually do this with the various cells that are implemented this way. I'm not sure why.
Keith Miller
Comment 16
2016-12-04 12:57:51 PST
Comment on
attachment 295985
[details]
patch View in context:
https://bugs.webkit.org/attachment.cgi?id=295985&action=review
>>> Source/JavaScriptCore/jsc.cpp:-2588 >>> - dataLogLn("failed to compile function at index", i); >> >> Why'd you delete this? > > I thought it was redundant with > ``` > if (plan.failed()) CRASH(); > ``` > and > ``` > if (plan.compiledFunctionCount() != functionCount) CRASH(); > ``` > > Is it not?
Ah I missed the plan.failed(). Yeah, this probably doesn't do anything.
Saam Barati
Comment 17
2016-12-04 13:22:47 PST
Created
attachment 296100
[details]
patch for landing
Saam Barati
Comment 18
2016-12-04 13:24:41 PST
landed in:
https://trac.webkit.org/changeset/209312
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