Closed
Bug 1246433
Opened 9 years ago
Closed 9 years ago
wasm: parsing and encoding for consts
Categories
(Core :: JavaScript Engine: JIT, defect)
Core
JavaScript Engine: JIT
Tracking
()
RESOLVED
FIXED
mozilla47
Tracking | Status | |
---|---|---|
firefox47 | --- | fixed |
People
(Reporter: sunfish, Assigned: sunfish)
References
Details
Attachments
(1 file, 1 obsolete file)
43.52 KB,
patch
|
luke
:
review+
|
Details | Diff | Splinter Review |
Const nodes for i32, i64, f32, f64, in both decimal and hexadecimal forms.
Assignee | ||
Comment 1•9 years ago
|
||
This uses the JS code for parsing decimal floating-point literals. It's guarded by custom tokenizing code so it only sees the strings we want it to see, and I believe it does the right thing for that set of strings.
It also contains a from-scratch hexadecimal floating-point parser. It doesn't use the libc strtod because not all platforms have the strtod_l form for avoiding the global locale, and also, Windows' strtod doesn't appear to have hexadecimal support. I considered other open-source options, such as a recent version of dtoa.c or LLVM's APFloat, however they carry complexity both in their own code and in what would be needed to integrate them into Baldr. The code here is significantly simplified by doing only what we need here and avoiding configuration.
Attachment #8716776 -
Flags: review?(luke)
Assignee | ||
Comment 2•9 years ago
|
||
Minor code cleanups.
Attachment #8716776 -
Attachment is obsolete: true
Attachment #8716776 -
Flags: review?(luke)
Attachment #8716777 -
Flags: review?(luke)
![]() |
||
Comment 3•9 years ago
|
||
Comment on attachment 8716777 [details] [diff] [review]
wasm-literals.patch
Review of attachment 8716777 [details] [diff] [review]:
-----------------------------------------------------------------
Very nice!
::: js/src/asmjs/Wasm.cpp
@@ +228,5 @@
> + return f.fail("unable to read f32.const immediate");
> + if (IsNaN(value)) {
> + const float jsNaN = (float)JS::GenericNaN();
> + if (memcmp(&value, &jsNaN, sizeof(value)) != 0)
> + return f.fail("NYI: NaN literals with custom payloads");
Ahh, this would be fixed by making MConstant not use js::Value right?
::: js/src/asmjs/WasmBinary.h
@@ +405,5 @@
> + if (i != 0)
> + byte |= 0x80;
> + if (!writeU8(byte))
> + return false;
> + } while(i != 0);
Perhaps factor out into a private template function called by both writeVarU(32|64)? (And similarly for readVarU(32|64)?
::: js/src/asmjs/WasmText.cpp
@@ +700,5 @@
> return false;
> }
>
> +static WasmToken LexHexFloatLiteral(const char16_t *begin, const char16_t *end,
> + const char16_t **curp) {
Can you put 'static WasmToken' on its own line as well as the { (on this and all the other static functions in this file?
Attachment #8716777 -
Flags: review?(luke) → review+
Assignee | ||
Comment 5•9 years ago
|
||
(In reply to Luke Wagner [:luke] from comment #3)
> Comment on attachment 8716777 [details] [diff] [review]
> wasm-literals.patch
>
> Review of attachment 8716777 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> Very nice!
>
> ::: js/src/asmjs/Wasm.cpp
> @@ +228,5 @@
> > + return f.fail("unable to read f32.const immediate");
> > + if (IsNaN(value)) {
> > + const float jsNaN = (float)JS::GenericNaN();
> > + if (memcmp(&value, &jsNaN, sizeof(value)) != 0)
> > + return f.fail("NYI: NaN literals with custom payloads");
>
> Ahh, this would be fixed by making MConstant not use js::Value right?
Yes, that's right.
> ::: js/src/asmjs/WasmBinary.h
> @@ +405,5 @@
> > + if (i != 0)
> > + byte |= 0x80;
> > + if (!writeU8(byte))
> > + return false;
> > + } while(i != 0);
>
> Perhaps factor out into a private template function called by both
> writeVarU(32|64)? (And similarly for readVarU(32|64)?
Done.
> ::: js/src/asmjs/WasmText.cpp
> @@ +700,5 @@
> > return false;
> > }
> >
> > +static WasmToken LexHexFloatLiteral(const char16_t *begin, const char16_t *end,
> > + const char16_t **curp) {
>
> Can you put 'static WasmToken' on its own line as well as the { (on this and
> all the other static functions in this file?
Done.
Both patches backed out in https://hg.mozilla.org/integration/mozilla-inbound/rev/0596083c0bb2 because it was still busted in a different way after the followup.
Flags: needinfo?(sunfish)
Assignee | ||
Updated•9 years ago
|
Flags: needinfo?(sunfish)
Comment 9•9 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox47:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
You need to log in
before you can comment on or make changes to this bug.
Description
•