Bug 179343 - WebAssembly: improve stack trace
Summary: WebAssembly: improve stack trace
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebAssembly (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: JF Bastien
URL:
Keywords: InRadar
Depends on:
Blocks: 179106 180273 180441
  Show dependency treegraph
 
Reported: 2017-11-06 13:41 PST by JF Bastien
Modified: 2017-12-05 13:39 PST (History)
11 users (show)

See Also:


Attachments
patch (18.82 KB, patch)
2017-11-06 13:48 PST, JF Bastien
no flags Details | Formatted Diff | Diff
patch (18.99 KB, patch)
2017-11-06 14:06 PST, JF Bastien
saam: review+
saam: commit-queue-
Details | Formatted Diff | Diff
patch (18.92 KB, patch)
2017-11-30 16:06 PST, JF Bastien
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description JF Bastien 2017-11-06 13:41:41 PST
Our stack traces aren't great because:

  - They don't include a way to figure ouch which module the function is in
  - They treat stubs the same as user functions
  - They don't honor module name from name section, if present (which right now is never the case because toolchains don't generate the name section)

This makes it annoying to debug code.

Further, the proposed design has slightly changed since we originally implemented this:
  https://github.com/WebAssembly/design/blob/master/Web.md#developer-facing-display-conventions
Comment 1 JF Bastien 2017-11-06 13:48:21 PST
Created attachment 326154 [details]
patch
Comment 2 JF Bastien 2017-11-06 14:06:20 PST
Created attachment 326157 [details]
patch
Comment 3 Build Bot 2017-11-06 14:08:08 PST
Attachment 326157 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/wasm/WasmNameSection.h:29:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 17 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Saam Barati 2017-11-06 15:53:22 PST
Comment on attachment 326157 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=326157&action=review

r=me

> Source/JavaScriptCore/wasm/WasmModuleInformation.cpp:47
> +    , hash(sha1(source))

should we do this lazily?

> Source/JavaScriptCore/wasm/WasmNameSection.h:40
> +        for (size_t i = 0; i != hash.length(); ++i)

nit: we usually use < instead of != here

> Source/JavaScriptCore/wasm/WasmNameSection.h:43
> +    NameSection() = delete;

Isn't this implicit in you defining the above constructor?

> Source/JavaScriptCore/wasm/WasmNameSection.h:44
> +    NameSection(const NameSection&) = delete;

WTF_MAKE_NONCOPYABLE?
Comment 5 JF Bastien 2017-11-30 16:06:50 PST
Created attachment 328047 [details]
patch

(In reply to Saam Barati from comment #4)
> Comment on attachment 326157 [details]
> patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=326157&action=review
> 
> r=me
> 
> > Source/JavaScriptCore/wasm/WasmModuleInformation.cpp:47
> > +    , hash(sha1(source))
> 
> should we do this lazily?

Nah, I don't think it's worth it. I think we'll eventually want to drop sections which aren't referenced, so hashing won't be possible that late and we'll have to un-lazy.

> > Source/JavaScriptCore/wasm/WasmNameSection.h:40
> > +        for (size_t i = 0; i != hash.length(); ++i)
> 
> nit: we usually use < instead of != here

Done.

> > Source/JavaScriptCore/wasm/WasmNameSection.h:43
> > +    NameSection() = delete;
> 
> Isn't this implicit in you defining the above constructor?

Yeah, I was just being explicit, but I can remove.

> > Source/JavaScriptCore/wasm/WasmNameSection.h:44
> > +    NameSection(const NameSection&) = delete;
> 
> WTF_MAKE_NONCOPYABLE?

I'm not a fan of macros that replace a clear one-line thing :-)
Comment 6 Saam Barati 2017-11-30 18:11:53 PST
Comment on attachment 326157 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=326157&action=review

>>> Source/JavaScriptCore/wasm/WasmNameSection.h:44
>>> +    NameSection(const NameSection&) = delete;
>> 
>> WTF_MAKE_NONCOPYABLE?
> 
> I'm not a fan of macros that replace a clear one-line thing :-)

Except the macro is doing more than what you're doing by hand. You aren't deleting the copy assignment operator. So I think you might not actually getting the guarantee I believe you want.

Also, regarding your motivation for skipping the macro: I disagree. The macro gives a name to this action. It's much more understandable because the name is obvious. As a reader of this code, even if you didn't understand C++ that well, the name of the macro describes what's going on. This syntax won't make sense to somebody who doesn't have at least decent understanding of C++.
Comment 7 Saam Barati 2017-11-30 18:17:03 PST
Comment on attachment 326157 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=326157&action=review

>>>> Source/JavaScriptCore/wasm/WasmNameSection.h:44
>>>> +    NameSection(const NameSection&) = delete;
>>> 
>>> WTF_MAKE_NONCOPYABLE?
>> 
>> I'm not a fan of macros that replace a clear one-line thing :-)
> 
> Except the macro is doing more than what you're doing by hand. You aren't deleting the copy assignment operator. So I think you might not actually getting the guarantee I believe you want.
> 
> Also, regarding your motivation for skipping the macro: I disagree. The macro gives a name to this action. It's much more understandable because the name is obvious. As a reader of this code, even if you didn't understand C++ that well, the name of the macro describes what's going on. This syntax won't make sense to somebody who doesn't have at least decent understanding of C++.

I guess you could just want to prevent copy construction but not copy assignment, but that seems weird.
Comment 8 WebKit Commit Bot 2017-11-30 18:41:13 PST
Comment on attachment 328047 [details]
patch

Clearing flags on attachment: 328047

Committed r225378: <https://trac.webkit.org/changeset/225378>
Comment 9 WebKit Commit Bot 2017-11-30 18:41:15 PST
All reviewed patches have been landed.  Closing bug.
Comment 10 Radar WebKit Bug Importer 2017-11-30 18:43:13 PST
<rdar://problem/35788939>
Comment 11 Joseph Pecoraro 2017-11-30 19:11:28 PST
Comment on attachment 328047 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=328047&action=review

> Source/JavaScriptCore/wasm/WasmIndexOrName.cpp:49
> +        return String("wasm-stub");

You should use `ASCIILiteral("wasm-stub")` in this case to prevent a copy:
https://trac.webkit.org/wiki/EfficientStrings

> Source/JavaScriptCore/wasm/WasmIndexOrName.cpp:53
> +        return makeString(moduleName, ".wasm-function[", String::number(ion.m_indexName.index & ~IndexOrName::indexTag), "]");
> +    return makeString(moduleName, ".wasm-function[", String(ion.m_indexName.name->data(), ion.m_indexName.name->size()), "]");

Nit: You could used a char ']' at the end instead of a "]" (may avoid a strlen if the compiler doesn't optimize it out).

> Source/JavaScriptCore/wasm/WasmIndexOrName.h:46
> +    NameSection* nameSection() const { return m_nameSection ? m_nameSection.get() : nullptr; }

Style: This should just be `return m_nameSection.get()`, the ternary is unnecessary.

> Source/JavaScriptCore/wasm/WasmNameSection.h:47
> +        return std::make_pair(functionIndexSpace < functionNames.size() ? &functionNames[functionIndexSpace] : nullptr, RefPtr<NameSection>(this));

Style: `RefPtr<NameSection>(this)` is typically written as `makeRefPtr(this)`.
Comment 12 Saam Barati 2017-12-04 13:48:08 PST
This looks to be a 1-2% WasmBench regression on some Macs.
Comment 13 Saam Barati 2017-12-04 13:48:26 PST
My guess is SHA1 is hurting compile times.
Comment 14 JF Bastien 2017-12-05 13:39:48 PST
I'd measured this to be neutral, and am surprised it would regress. I can't repro, tried a few things, so here's a speculative disable:
  https://bugs.webkit.org/show_bug.cgi?id=180441