WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
166295
WebAssembly JS API: cleanup & pass VM around to {Compile/Runtime}Error
https://bugs.webkit.org/show_bug.cgi?id=166295
Summary
WebAssembly JS API: cleanup & pass VM around to {Compile/Runtime}Error
JF Bastien
Reported
2016-12-20 15:55:02 PST
As suggested here:
https://bugs.webkit.org/show_bug.cgi?id=165805#c3
These should be updated accordingly.
Attachments
patch
(21.27 KB, patch)
2016-12-20 16:43 PST
,
JF Bastien
mark.lam
: review-
mark.lam
: commit-queue-
Details
Formatted Diff
Diff
patch
(34.58 KB, patch)
2016-12-20 22:49 PST
,
JF Bastien
no flags
Details
Formatted Diff
Diff
patch
(34.64 KB, patch)
2016-12-21 09:58 PST
,
JF Bastien
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2016-12-20 15:55:44 PST
<
rdar://problem/29762017
>
JF Bastien
Comment 2
2016-12-20 16:43:05 PST
Created
attachment 297568
[details]
patch
Mark Lam
Comment 3
2016-12-20 17:20:08 PST
Comment on
attachment 297568
[details]
patch View in context:
https://bugs.webkit.org/attachment.cgi?id=297568&action=review
I think this needs some fixes.
> JSTests/wasm/function-tests/trap-store-2.js:49 > + assert.throws(() => foo(i, address), WebAssembly.RuntimeError, "Out of bounds memory access");
This is a difference in behavior. The original does "foo(6, address);" instead. Which one is the bug?
> Source/JavaScriptCore/jit/ThunkGenerators.cpp:1158 > + JSWebAssemblyRuntimeError* error = JSWebAssemblyRuntimeError::create(exec, vm, globalObject->WebAssemblyRuntimeErrorStructure(), Wasm::errorMessageForExceptionType(type));
You should use VM& instead of VM* because VM should always be valid.
> Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.cpp:35 > +JSWebAssemblyCompileError* JSWebAssemblyCompileError::create(ExecState* state, VM* vm, Structure* structure, const String& message)
Ditto. Use VM&.
> Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.cpp:38 > + instance->m_sourceAppender = defaultSourceAppender;
This is a change in behavior that is not described in your ChangeLog. Is this intentional? If intentional, why not do it in finishCreation() where we are supposed to initialize the object?
> Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.h:39 > + static JSWebAssemblyCompileError* create(ExecState*, VM*, Structure*, const String&); > + static JSWebAssemblyCompileError* create(ExecState* state, VM* vm, Structure* structure, JSValue message)
Use VM& instead of VM*.
> Source/JavaScriptCore/wasm/js/JSWebAssemblyRuntimeError.cpp:35 > +JSWebAssemblyRuntimeError* JSWebAssemblyRuntimeError::create(ExecState* state, VM* vm, Structure* structure, const String& message)
Use VM&.
> Source/JavaScriptCore/wasm/js/JSWebAssemblyRuntimeError.cpp:38 > + instance->m_sourceAppender = defaultSourceAppender;
Do this initialization in finishCreation() where we do all initialization.
JF Bastien
Comment 4
2016-12-20 22:29:44 PST
Comment on
attachment 297568
[details]
patch View in context:
https://bugs.webkit.org/attachment.cgi?id=297568&action=review
>> Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.cpp:38 >> + instance->m_sourceAppender = defaultSourceAppender; > > This is a change in behavior that is not described in your ChangeLog. Is this intentional? If intentional, why not do it in finishCreation() where we are supposed to initialize the object?
That's where ErrorInstance does it, so I did the same. Should I fix both? Agreed on adding to ChangeLog.
JF Bastien
Comment 5
2016-12-20 22:49:20 PST
Created
attachment 297581
[details]
patch Address other comments: - Use VM&. - Fix copy-paste mistake in a test. - Mention behavior change for source appender in ChangeLog. See comment above for finishCreation(), I haven't changed it for now, let me know which way to go (change ErrorInstance as well, or leave both as-is).
Mark Lam
Comment 6
2016-12-21 09:18:24 PST
Comment on
attachment 297568
[details]
patch View in context:
https://bugs.webkit.org/attachment.cgi?id=297568&action=review
>>> Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.cpp:38 >>> + instance->m_sourceAppender = defaultSourceAppender; >> >> This is a change in behavior that is not described in your ChangeLog. Is this intentional? If intentional, why not do it in finishCreation() where we are supposed to initialize the object? > > That's where ErrorInstance does it, so I did the same. Should I fix both? > > Agreed on adding to ChangeLog.
You're right. I still think it's bad form to do initialization work outside of finishCreation(). We should avoid it. If we want to be pedantic, then I'd say fix ErrorInstance too in a separate patch.
Mark Lam
Comment 7
2016-12-21 09:28:29 PST
Comment on
attachment 297581
[details]
patch View in context:
https://bugs.webkit.org/attachment.cgi?id=297581&action=review
> Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.cpp:38 > + instance->m_sourceAppender = defaultSourceAppender;
I'll let this slide for now because of ErrorInstance's bad form. I think we should fix this eventually to do this initialization in finishCreation(). Otherwise, there's no point in having a separate finishCreation() from this create() function.
> Source/JavaScriptCore/wasm/js/JSWebAssemblyRuntimeError.cpp:38 > + instance->m_sourceAppender = defaultSourceAppender;
Ditto.
> Source/JavaScriptCore/wasm/js/JSWebAssemblyRuntimeError.cpp:39 > + instance->finishCreation(state, vm, message, true);
We're unconditionally passing true for useCurrentFrame here, but the original client of JSWebAssemblyRuntimeError::create() passes false. Is this intentional? Side note: as a matter of style, when passing bools like this, it's hard to tell what that bool is for. So, instead, this is how we express it to make it clear what we're passing true for: bool useCurrentFrame = true; instance->finishCreation(state, vm, message, useCurrentFrame);
> Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp:54 > - return JSValue::encode(JSWebAssemblyRuntimeError::create(state, structure, message, false)); > + return JSValue::encode(JSWebAssemblyRuntimeError::create(state, vm, structure, message));
Originally, we're passing false for useCurrentFrame here but in the new JSWebAssemblyRuntimeError::create() we always pass true. Is this intentional?
JF Bastien
Comment 8
2016-12-21 09:58:53 PST
Created
attachment 297596
[details]
patch (In reply to
comment #7
)
> Comment on
attachment 297581
[details]
> patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=297581&action=review
> > > Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.cpp:38 > > + instance->m_sourceAppender = defaultSourceAppender; > > I'll let this slide for now because of ErrorInstance's bad form. I think we > should fix this eventually to do this initialization in finishCreation(). > Otherwise, there's no point in having a separate finishCreation() from this > create() function.
Sounds good, I'll do this in a follow-up.
> > Source/JavaScriptCore/wasm/js/JSWebAssemblyRuntimeError.cpp:39 > > + instance->finishCreation(state, vm, message, true); > > We're unconditionally passing true for useCurrentFrame here, but the > original client of JSWebAssemblyRuntimeError::create() passes false. Is > this intentional?
Ah yes, it seems clearer. Added to the ChangeLog.
> Side note: as a matter of style, when passing bools like this, it's hard to > tell what that bool is for. So, instead, this is how we express it to make > it clear what we're passing true for: > bool useCurrentFrame = true; > instance->finishCreation(state, vm, message, useCurrentFrame);
Done.
Mark Lam
Comment 9
2016-12-21 10:05:08 PST
Comment on
attachment 297596
[details]
patch r=me
WebKit Commit Bot
Comment 10
2016-12-21 12:34:47 PST
Comment on
attachment 297596
[details]
patch Clearing flags on attachment: 297596 Committed
r210073
: <
http://trac.webkit.org/changeset/210073
>
WebKit Commit Bot
Comment 11
2016-12-21 12:34:51 PST
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