Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Unified Diff: src/code-stubs.cc

Issue 2141953002: [Turbofan]: Add integer multiplication with overflow to typed lowering. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@multiply
Patch Set: Code comments. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/code-stub-assembler.cc ('k') | src/compiler/effect-control-linearizer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stubs.cc
diff --git a/src/code-stubs.cc b/src/code-stubs.cc
index d41a4a7b7edf84d67e5ea9598d7c5a90bb73fd18..57d0839365a07333240391727ee237808b2796f1 100644
--- a/src/code-stubs.cc
+++ b/src/code-stubs.cc
@@ -1097,56 +1097,10 @@ compiler::Node* MultiplyStub::Generate(CodeStubAssembler* assembler,
assembler->Bind(&rhs_is_smi);
{
- // Both {lhs} and {rhs} are Smis. Convert them to integers and multiply.
- Node* lhs32 = assembler->SmiToWord32(lhs);
- Node* rhs32 = assembler->SmiToWord32(rhs);
- Node* pair = assembler->Int32MulWithOverflow(lhs32, rhs32);
-
- Node* overflow = assembler->Projection(1, pair);
-
- // Check if the multiplication overflowed.
- Label if_overflow(assembler, Label::kDeferred),
- if_notoverflow(assembler);
- assembler->Branch(overflow, &if_overflow, &if_notoverflow);
- assembler->Bind(&if_notoverflow);
- {
- // If the answer is zero, we may need to return -0.0, depending on the
- // input.
- Label answer_zero(assembler), answer_not_zero(assembler);
- Node* answer = assembler->Projection(0, pair);
- Node* zero = assembler->Int32Constant(0);
- assembler->Branch(assembler->WordEqual(answer, zero), &answer_zero,
- &answer_not_zero);
- assembler->Bind(&answer_not_zero);
- {
- var_result.Bind(assembler->ChangeInt32ToTagged(answer));
- assembler->Goto(&return_result);
- }
- assembler->Bind(&answer_zero);
- {
- Node* or_result = assembler->Word32Or(lhs32, rhs32);
- Label if_should_be_negative_zero(assembler),
- if_should_be_zero(assembler);
- assembler->Branch(assembler->Int32LessThan(or_result, zero),
- &if_should_be_negative_zero, &if_should_be_zero);
- assembler->Bind(&if_should_be_negative_zero);
- {
- var_result.Bind(assembler->MinusZeroConstant());
- assembler->Goto(&return_result);
- }
- assembler->Bind(&if_should_be_zero);
- {
- var_result.Bind(zero);
- assembler->Goto(&return_result);
- }
- }
- }
- assembler->Bind(&if_overflow);
- {
- var_lhs_float64.Bind(assembler->SmiToFloat64(lhs));
- var_rhs_float64.Bind(assembler->SmiToFloat64(rhs));
- assembler->Goto(&do_fmul);
- }
+ // Both {lhs} and {rhs} are Smis. The result is not necessarily a smi,
+ // in case of overflow.
+ var_result.Bind(assembler->SmiMul(lhs, rhs));
+ assembler->Goto(&return_result);
}
assembler->Bind(&rhs_is_not_smi);
« no previous file with comments | « src/code-stub-assembler.cc ('k') | src/compiler/effect-control-linearizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698