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

Unified Diff: src/code-stub-assembler.cc

Issue 2380543002: [stubs] Don't unconditionally canonicalize in ChangeFloat64ToTagged. (Closed)
Patch Set: REBASE Created 4 years, 3 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.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stub-assembler.cc
diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc
index d45fb019f9a2e2881da60f9c6b03c107cc40d9ed..f22f2d9d50a453e482fff770bdf6ddcbede5d284 100644
--- a/src/code-stub-assembler.cc
+++ b/src/code-stub-assembler.cc
@@ -1870,53 +1870,64 @@ Node* CodeStubAssembler::TruncateHeapNumberValueToWord32(Node* object) {
return TruncateFloat64ToWord32(value);
}
-Node* CodeStubAssembler::ChangeFloat64ToTagged(Node* value) {
- Node* value32 = RoundFloat64ToInt32(value);
- Node* value64 = ChangeInt32ToFloat64(value32);
-
- Label if_valueisint32(this), if_valueisheapnumber(this), if_join(this);
+Node* CodeStubAssembler::ChangeFloat64ToTagged(Node* value,
+ CanonicalizationMode mode) {
+ switch (mode) {
+ case CanonicalizationMode::kDontCanonicalize: {
+ return AllocateHeapNumberWithValue(value);
+ }
+ case CanonicalizationMode::kCanonicalize: {
+ Node* value32 = RoundFloat64ToInt32(value);
+ Node* value64 = ChangeInt32ToFloat64(value32);
- Label if_valueisequal(this), if_valueisnotequal(this);
- Branch(Float64Equal(value, value64), &if_valueisequal, &if_valueisnotequal);
- Bind(&if_valueisequal);
- {
- GotoUnless(Word32Equal(value32, Int32Constant(0)), &if_valueisint32);
- BranchIfInt32LessThan(Float64ExtractHighWord32(value), Int32Constant(0),
- &if_valueisheapnumber, &if_valueisint32);
- }
- Bind(&if_valueisnotequal);
- Goto(&if_valueisheapnumber);
+ Label if_valueisint32(this), if_valueisheapnumber(this), if_join(this);
- Variable var_result(this, MachineRepresentation::kTagged);
- Bind(&if_valueisint32);
- {
- if (Is64()) {
- Node* result = SmiTag(ChangeInt32ToInt64(value32));
- var_result.Bind(result);
- Goto(&if_join);
- } else {
- Node* pair = Int32AddWithOverflow(value32, value32);
- Node* overflow = Projection(1, pair);
- Label if_overflow(this, Label::kDeferred), if_notoverflow(this);
- Branch(overflow, &if_overflow, &if_notoverflow);
- Bind(&if_overflow);
+ Label if_valueisequal(this), if_valueisnotequal(this);
+ Branch(Float64Equal(value, value64), &if_valueisequal,
+ &if_valueisnotequal);
+ Bind(&if_valueisequal);
+ {
+ GotoUnless(Word32Equal(value32, Int32Constant(0)), &if_valueisint32);
+ BranchIfInt32LessThan(Float64ExtractHighWord32(value), Int32Constant(0),
+ &if_valueisheapnumber, &if_valueisint32);
+ }
+ Bind(&if_valueisnotequal);
Goto(&if_valueisheapnumber);
- Bind(&if_notoverflow);
+
+ Variable var_result(this, MachineRepresentation::kTagged);
+ Bind(&if_valueisint32);
+ {
+ if (Is64()) {
+ Node* result = SmiTag(ChangeInt32ToInt64(value32));
+ var_result.Bind(result);
+ Goto(&if_join);
+ } else {
+ Node* pair = Int32AddWithOverflow(value32, value32);
+ Node* overflow = Projection(1, pair);
+ Label if_overflow(this, Label::kDeferred), if_notoverflow(this);
+ Branch(overflow, &if_overflow, &if_notoverflow);
+ Bind(&if_overflow);
+ Goto(&if_valueisheapnumber);
+ Bind(&if_notoverflow);
+ {
+ Node* result = Projection(0, pair);
+ var_result.Bind(result);
+ Goto(&if_join);
+ }
+ }
+ }
+ Bind(&if_valueisheapnumber);
{
- Node* result = Projection(0, pair);
+ Node* result = AllocateHeapNumberWithValue(value);
var_result.Bind(result);
Goto(&if_join);
}
+ Bind(&if_join);
+ return var_result.value();
}
}
- Bind(&if_valueisheapnumber);
- {
- Node* result = AllocateHeapNumberWithValue(value);
- var_result.Bind(result);
- Goto(&if_join);
- }
- Bind(&if_join);
- return var_result.value();
+ UNREACHABLE();
+ return nullptr;
}
Node* CodeStubAssembler::ChangeInt32ToTagged(Node* value) {
@@ -2632,12 +2643,21 @@ Node* CodeStubAssembler::ToInteger(Node* context, Node* input,
// Truncate {arg} towards zero.
Node* value = Float64Trunc(arg_value);
- if (mode == kTruncateMinusZero) {
- // Truncate -0.0 to 0.
- GotoIf(Float64Equal(value, Float64Constant(0.0)), &return_zero);
+ // Perform optional minus zero truncation.
+ switch (mode) {
+ case kNoTruncation:
+ break;
+ case kTruncateMinusZero: {
+ // Truncate -0.0 to 0.
+ GotoIf(Float64Equal(value, Float64Constant(0.0)), &return_zero);
+ break;
+ }
}
- var_arg.Bind(ChangeFloat64ToTagged(value));
+ // Tag the {value} using Smi canonicalization, i.e. if {value} can be
+ // represented as a Smi, then this will produce a Smi.
+ var_arg.Bind(
+ ChangeFloat64ToTagged(value, CanonicalizationMode::kCanonicalize));
Goto(&out);
}
« no previous file with comments | « src/code-stub-assembler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698