diff --git a/src/ic/binary-op-assembler.cc b/src/ic/binary-op-assembler.cc index 25c2181ab2..4937938df7 100644 --- a/src/ic/binary-op-assembler.cc +++ b/src/ic/binary-op-assembler.cc @@ -279,6 +279,7 @@ TNode BinaryOpAssembler::Generate_BinaryOperationWithFeedback( { Comment("perform smi operation"); var_result = smiOperation(lhs_smi, CAST(rhs), &var_type_feedback); + UpdateFeedback(var_type_feedback.value(), maybe_feedback_vector, slot_id); Goto(&end); } } @@ -321,6 +322,7 @@ TNode BinaryOpAssembler::Generate_BinaryOperationWithFeedback( BIND(&do_float_operation); { var_type_feedback = SmiConstant(BinaryOperationFeedback::kNumber); + UpdateFeedback(var_type_feedback.value(), maybe_feedback_vector, slot_id); TNode lhs_value = var_float_lhs.value(); TNode rhs_value = var_float_rhs.value(); TNode value = floatOperation(lhs_value, rhs_value); @@ -384,6 +386,7 @@ TNode BinaryOpAssembler::Generate_BinaryOperationWithFeedback( BIND(&if_both_bigint); { var_type_feedback = SmiConstant(BinaryOperationFeedback::kBigInt); + UpdateFeedback(var_type_feedback.value(), maybe_feedback_vector, slot_id); if (op == Operation::kSubtract) { Label bigint_too_big(this); var_result = @@ -415,6 +418,7 @@ TNode BinaryOpAssembler::Generate_BinaryOperationWithFeedback( BIND(&call_stub); { + UpdateFeedback(var_type_feedback.value(), maybe_feedback_vector, slot_id); TNode result; switch (op) { case Operation::kSubtract: @@ -437,7 +441,6 @@ TNode BinaryOpAssembler::Generate_BinaryOperationWithFeedback( } BIND(&end); - UpdateFeedback(var_type_feedback.value(), maybe_feedback_vector, slot_id); return var_result.value(); } diff --git a/test/mjsunit/regress/regress-9441.js b/test/mjsunit/regress/regress-9441.js new file mode 100644 index 0000000000..d2fb17a239 --- /dev/null +++ b/test/mjsunit/regress/regress-9441.js @@ -0,0 +1,23 @@ +// Copyright 2020 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. + +// Flags: --allow-natives-syntax --opt --no-always-opt + +function foo(a, b) { + return a - b; +} + +%PrepareFunctionForOptimization(foo); +assertEquals(-1n, foo(1n, 2n)); +%OptimizeFunctionOnNextCall(foo); +assertEquals(1n, foo(2n, 1n)); +assertOptimized(foo); +assertThrows(() => foo(2n, undefined)); +assertUnoptimized(foo); +%PrepareFunctionForOptimization(foo); +%OptimizeFunctionOnNextCall(foo); +assertEquals(-1n, foo(1n, 2n)); +assertOptimized(foo); +assertThrows(() => foo(undefined, 2n)); +assertOptimized(foo);