[asm.js] Fix associativity of multiplicative expressions.
R=clemensh@chromium.org TEST=mjsunit/asm/regress-719866 BUG=chromium:719866 Change-Id: I6cc9f222769aa036275654286c9c6271ef2d1334 Reviewed-on: https://chromium-review.googlesource.com/520945 Reviewed-by: Clemens Hammacher <clemensh@chromium.org> Commit-Queue: Michael Starzinger <mstarzinger@chromium.org> Cr-Commit-Position: refs/heads/master@{#45660}
This commit is contained in:
parent
c588bf858f
commit
15691758b3
@ -1677,7 +1677,7 @@ AsmType* AsmJsParser::MultiplicativeExpression() {
|
||||
}
|
||||
} else if (Check('/')) {
|
||||
AsmType* b;
|
||||
RECURSEn(b = MultiplicativeExpression());
|
||||
RECURSEn(b = UnaryExpression());
|
||||
if (a->IsA(AsmType::DoubleQ()) && b->IsA(AsmType::DoubleQ())) {
|
||||
current_function_builder_->Emit(kExprF64Div);
|
||||
a = AsmType::Double();
|
||||
@ -1695,7 +1695,7 @@ AsmType* AsmJsParser::MultiplicativeExpression() {
|
||||
}
|
||||
} else if (Check('%')) {
|
||||
AsmType* b;
|
||||
RECURSEn(b = MultiplicativeExpression());
|
||||
RECURSEn(b = UnaryExpression());
|
||||
if (a->IsA(AsmType::DoubleQ()) && b->IsA(AsmType::DoubleQ())) {
|
||||
current_function_builder_->Emit(kExprF64Mod);
|
||||
a = AsmType::Double();
|
||||
|
18
test/mjsunit/asm/regress-719866.js
Normal file
18
test/mjsunit/asm/regress-719866.js
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 2017 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
function Module(stdlib) {
|
||||
"use asm";
|
||||
function f(a,b,c) {
|
||||
a = +a;
|
||||
b = +b;
|
||||
c = +c;
|
||||
var r = 0.0;
|
||||
r = a / b * c;
|
||||
return +r;
|
||||
}
|
||||
return { f:f }
|
||||
}
|
||||
var m = Module(this);
|
||||
assertEquals(16, m.f(32, 4, 2));
|
Loading…
Reference in New Issue
Block a user