Closed Bug 1244272 Opened 8 years ago Closed 8 years ago

wasm: Implement a binary operator

Categories

(Core :: JavaScript Engine: JIT, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla47
Tracking Status
firefox47 --- fixed

People

(Reporter: sunfish, Assigned: sunfish)

References

Details

Attachments

(3 files)

I'm starting with i32.add to start threading it through all the places that need it.
Attachment #8713797 - Flags: review?(luke)
Building on the previous patch, here are the rest of the i32 binary operators (except comparisons).
Attachment #8713827 - Flags: review?(luke)
And here are all the float binary opcodes except comparisons.

min/max don't work yet because the implementation needs refactoring to deal with them not being variadic in wasm, and copysign doesn't have Ion support yet.
Attachment #8713831 - Flags: review?(luke)
Comment on attachment 8713797 [details] [diff] [review]
wasm-binary-operators.patch

Review of attachment 8713797 [details] [diff] [review]:
-----------------------------------------------------------------

Excellent.  But don't you miss writing ML ;-) ?

::: js/src/asmjs/WasmText.cpp
@@ +587,5 @@
> +                    return WasmToken(WasmToken::ValueType, ValType::F32, begin, cur_);
> +
> +                switch (*cur_) {
> +                  case 'c':
> +                    if (consume(end_, MOZ_UTF16("const")))

Especially since perf doesn't matter, I probably should've done it the way you've done here, with 'switch (*cur_)' instead of 'switch (*cur_++)' so that way the MOZ_UTF16 strings can hold the full string instead of stripping the first character.  Feel free to do that in this or a later patch or I will in some later patch.

@@ +635,5 @@
> +                        return WasmToken(WasmToken::Const, ValType::I64, begin, cur_);
> +                    break;
> +                }
> +            } else if (consume(end_, MOZ_UTF16("mport"))) {
> +                return WasmToken(WasmToken::Import, begin, cur_);

For consistency with other cases, could you have each then-branch end in return/break so that way we can have a sequence of if{}if{}if{} instead of if{}else if{}else if {}?
Attachment #8713797 - Flags: review?(luke) → review+
Comment on attachment 8713827 [details] [diff] [review]
wasm-all-i32-binops.patch

Review of attachment 8713827 [details] [diff] [review]:
-----------------------------------------------------------------

weeeeeeeeeee
Attachment #8713827 - Flags: review?(luke) → review+
Comment on attachment 8713831 [details] [diff] [review]
wasm-float-binops.patch

Review of attachment 8713831 [details] [diff] [review]:
-----------------------------------------------------------------

Oh min/max.
Attachment #8713831 - Flags: review?(luke) → review+
> For consistency with other cases, could you have each then-branch end in return/break so that way we can have a sequence of if{}if{}if{} instead of if{}else if{}else if {}?

Done.
Blocks: 1244571
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: