Index: src/compiler/effect-control-linearizer.cc |
diff --git a/src/compiler/effect-control-linearizer.cc b/src/compiler/effect-control-linearizer.cc |
index 10c982a7cbdff3d6726ce6f6b8ab9dde220d868b..dab5fac632ea1358011b1e7d55bf63f4e269cca1 100644 |
--- a/src/compiler/effect-control-linearizer.cc |
+++ b/src/compiler/effect-control-linearizer.cc |
@@ -922,70 +922,56 @@ Node* EffectControlLinearizer::LowerTruncateTaggedToBit(Node* node) { |
Node* value = node->InputAt(0); |
auto if_smi = __ MakeDeferredLabel<1>(); |
- auto if_not_oddball = __ MakeDeferredLabel<1>(); |
- auto if_not_string = __ MakeDeferredLabel<1>(); |
- auto if_not_heapnumber = __ MakeDeferredLabel<1>(); |
- auto done = __ MakeLabel<5>(MachineRepresentation::kBit); |
+ auto if_heapnumber = __ MakeDeferredLabel<1>(); |
+ auto done = __ MakeLabel<6>(MachineRepresentation::kBit); |
Node* zero = __ Int32Constant(0); |
Node* fzero = __ Float64Constant(0.0); |
+ // Check if {value} is false. |
+ __ GotoIf(__ WordEqual(value, __ FalseConstant()), &done, zero); |
+ |
// Check if {value} is a Smi. |
Node* check_smi = ObjectIsSmi(value); |
__ GotoIf(check_smi, &if_smi); |
- // Load the map instance type of {value}. |
+ // Check if {value} is the empty string. |
+ __ GotoIf(__ WordEqual(value, __ EmptyStringConstant()), &done, zero); |
+ |
+ // Load the map of {value}. |
Node* value_map = __ LoadField(AccessBuilder::ForMap(), value); |
- Node* value_instance_type = |
- __ LoadField(AccessBuilder::ForMapInstanceType(), value_map); |
- // Check if {value} is an Oddball. |
- Node* check_oddball = |
- __ Word32Equal(value_instance_type, __ Int32Constant(ODDBALL_TYPE)); |
- |
- __ GotoUnless(check_oddball, &if_not_oddball); |
- // The only Oddball {value} that is trueish is true itself. |
- __ Goto(&done, __ WordEqual(value, __ TrueConstant())); |
- |
- __ Bind(&if_not_oddball); |
- // Check if {value} is a String. |
- Node* check_string = __ Int32LessThan(value_instance_type, |
- __ Int32Constant(FIRST_NONSTRING_TYPE)); |
- __ GotoUnless(check_string, &if_not_string); |
- // For String {value}, we need to check that the length is not zero. |
- Node* value_length = __ LoadField(AccessBuilder::ForStringLength(), value); |
- __ Goto(&done, __ Word32Equal( |
- __ WordEqual(value_length, __ IntPtrConstant(0)), zero)); |
- |
- __ Bind(&if_not_string); |
- // Check if {value} is a HeapNumber. |
- Node* check_heapnumber = |
- __ Word32Equal(value_instance_type, __ Int32Constant(HEAP_NUMBER_TYPE)); |
- __ GotoUnless(check_heapnumber, &if_not_heapnumber); |
- |
- // For HeapNumber {value}, just check that its value is not 0.0, -0.0 or |
- // NaN. |
- // Load the raw value of {value}. |
- Node* value_value = __ LoadField(AccessBuilder::ForHeapNumberValue(), value); |
- __ Goto(&done, __ Float64LessThan(fzero, __ Float64Abs(value_value))); |
- |
- // The {value} is either a JSReceiver, a Symbol or some Simd128Value. In |
- // those cases we can just the undetectable bit on the map, which will only |
- // be set for certain JSReceivers, i.e. document.all. |
- __ Bind(&if_not_heapnumber); |
- |
- // Load the {value} map bit field. |
+ // Check if the {value} is undetectable and immediately return false. |
Node* value_map_bitfield = |
__ LoadField(AccessBuilder::ForMapBitField(), value_map); |
- __ Goto(&done, __ Word32Equal( |
- __ Word32And(value_map_bitfield, |
+ __ GotoUnless( |
+ __ Word32Equal(__ Word32And(value_map_bitfield, |
__ Int32Constant(1 << Map::kIsUndetectable)), |
- zero)); |
+ zero), |
+ &done, zero); |
+ |
+ // Check if {value} is a HeapNumber. |
+ __ GotoIf(__ WordEqual(value_map, __ HeapNumberMapConstant()), |
+ &if_heapnumber); |
+ |
+ // All other values that reach here are true. |
+ __ Goto(&done, __ Int32Constant(1)); |
+ |
+ __ Bind(&if_heapnumber); |
+ { |
+ // For HeapNumber {value}, just check that its value is not 0.0, -0.0 or |
+ // NaN. |
+ Node* value_value = |
+ __ LoadField(AccessBuilder::ForHeapNumberValue(), value); |
+ __ Goto(&done, __ Float64LessThan(fzero, __ Float64Abs(value_value))); |
+ } |
__ Bind(&if_smi); |
- // If {value} is a Smi, then we only need to check that it's not zero. |
- __ Goto(&done, |
- __ Word32Equal(__ WordEqual(value, __ IntPtrConstant(0)), zero)); |
+ { |
+ // If {value} is a Smi, then we only need to check that it's not zero. |
+ __ Goto(&done, |
+ __ Word32Equal(__ WordEqual(value, __ IntPtrConstant(0)), zero)); |
+ } |
__ Bind(&done); |
return done.PhiAt(0); |