OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/simplified-lowering.h" | 5 #include "src/compiler/simplified-lowering.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/address-map.h" | 9 #include "src/address-map.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 1987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1998 if (lower()) DeferReplacement(node, lowering->Float64Sign(node)); | 1998 if (lower()) DeferReplacement(node, lowering->Float64Sign(node)); |
1999 } | 1999 } |
2000 return; | 2000 return; |
2001 } | 2001 } |
2002 case IrOpcode::kNumberSqrt: { | 2002 case IrOpcode::kNumberSqrt: { |
2003 VisitUnop(node, UseInfo::TruncatingFloat64(), | 2003 VisitUnop(node, UseInfo::TruncatingFloat64(), |
2004 MachineRepresentation::kFloat64); | 2004 MachineRepresentation::kFloat64); |
2005 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); | 2005 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); |
2006 return; | 2006 return; |
2007 } | 2007 } |
| 2008 case IrOpcode::kNumberToBoolean: { |
| 2009 Type* const input_type = TypeOf(node->InputAt(0)); |
| 2010 if (input_type->Is(Type::Integral32())) { |
| 2011 VisitUnop(node, UseInfo::TruncatingWord32(), |
| 2012 MachineRepresentation::kBit); |
| 2013 if (lower()) lowering->DoIntegral32ToBit(node); |
| 2014 } else if (input_type->Is(Type::OrderedNumber())) { |
| 2015 VisitUnop(node, UseInfo::TruncatingFloat64(), |
| 2016 MachineRepresentation::kBit); |
| 2017 if (lower()) lowering->DoOrderedNumberToBit(node); |
| 2018 } else { |
| 2019 VisitUnop(node, UseInfo::TruncatingFloat64(), |
| 2020 MachineRepresentation::kBit); |
| 2021 if (lower()) lowering->DoNumberToBit(node); |
| 2022 } |
| 2023 return; |
| 2024 } |
2008 case IrOpcode::kNumberToInt32: { | 2025 case IrOpcode::kNumberToInt32: { |
2009 // Just change representation if necessary. | 2026 // Just change representation if necessary. |
2010 VisitUnop(node, UseInfo::TruncatingWord32(), | 2027 VisitUnop(node, UseInfo::TruncatingWord32(), |
2011 MachineRepresentation::kWord32); | 2028 MachineRepresentation::kWord32); |
2012 if (lower()) DeferReplacement(node, node->InputAt(0)); | 2029 if (lower()) DeferReplacement(node, node->InputAt(0)); |
2013 return; | 2030 return; |
2014 } | 2031 } |
2015 case IrOpcode::kNumberToUint32: { | 2032 case IrOpcode::kNumberToUint32: { |
2016 // Just change representation if necessary. | 2033 // Just change representation if necessary. |
2017 VisitUnop(node, UseInfo::TruncatingWord32(), | 2034 VisitUnop(node, UseInfo::TruncatingWord32(), |
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3180 CallDescriptor::Flags flags = CallDescriptor::kNoFlags; | 3197 CallDescriptor::Flags flags = CallDescriptor::kNoFlags; |
3181 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 3198 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
3182 isolate(), graph()->zone(), callable.descriptor(), 0, flags, properties); | 3199 isolate(), graph()->zone(), callable.descriptor(), 0, flags, properties); |
3183 node->InsertInput(graph()->zone(), 0, | 3200 node->InsertInput(graph()->zone(), 0, |
3184 jsgraph()->HeapConstant(callable.code())); | 3201 jsgraph()->HeapConstant(callable.code())); |
3185 node->AppendInput(graph()->zone(), jsgraph()->NoContextConstant()); | 3202 node->AppendInput(graph()->zone(), jsgraph()->NoContextConstant()); |
3186 node->AppendInput(graph()->zone(), graph()->start()); | 3203 node->AppendInput(graph()->zone(), graph()->start()); |
3187 NodeProperties::ChangeOp(node, common()->Call(desc)); | 3204 NodeProperties::ChangeOp(node, common()->Call(desc)); |
3188 } | 3205 } |
3189 | 3206 |
| 3207 void SimplifiedLowering::DoIntegral32ToBit(Node* node) { |
| 3208 Node* const input = node->InputAt(0); |
| 3209 Node* const zero = jsgraph()->Int32Constant(0); |
| 3210 Operator const* const op = machine()->Word32Equal(); |
| 3211 |
| 3212 node->ReplaceInput(0, graph()->NewNode(op, input, zero)); |
| 3213 node->AppendInput(graph()->zone(), zero); |
| 3214 NodeProperties::ChangeOp(node, op); |
| 3215 } |
| 3216 |
| 3217 void SimplifiedLowering::DoOrderedNumberToBit(Node* node) { |
| 3218 Node* const input = node->InputAt(0); |
| 3219 |
| 3220 node->ReplaceInput(0, graph()->NewNode(machine()->Float64Equal(), input, |
| 3221 jsgraph()->Float64Constant(0.0))); |
| 3222 node->AppendInput(graph()->zone(), jsgraph()->Int32Constant(0)); |
| 3223 NodeProperties::ChangeOp(node, machine()->Word32Equal()); |
| 3224 } |
| 3225 |
| 3226 void SimplifiedLowering::DoNumberToBit(Node* node) { |
| 3227 Node* const input = node->InputAt(0); |
| 3228 |
| 3229 node->ReplaceInput(0, jsgraph()->Float64Constant(0.0)); |
| 3230 node->AppendInput(graph()->zone(), |
| 3231 graph()->NewNode(machine()->Float64Abs(), input)); |
| 3232 NodeProperties::ChangeOp(node, machine()->Float64LessThan()); |
| 3233 } |
| 3234 |
3190 Node* SimplifiedLowering::ToNumberCode() { | 3235 Node* SimplifiedLowering::ToNumberCode() { |
3191 if (!to_number_code_.is_set()) { | 3236 if (!to_number_code_.is_set()) { |
3192 Callable callable = CodeFactory::ToNumber(isolate()); | 3237 Callable callable = CodeFactory::ToNumber(isolate()); |
3193 to_number_code_.set(jsgraph()->HeapConstant(callable.code())); | 3238 to_number_code_.set(jsgraph()->HeapConstant(callable.code())); |
3194 } | 3239 } |
3195 return to_number_code_.get(); | 3240 return to_number_code_.get(); |
3196 } | 3241 } |
3197 | 3242 |
3198 Operator const* SimplifiedLowering::ToNumberOperator() { | 3243 Operator const* SimplifiedLowering::ToNumberOperator() { |
3199 if (!to_number_operator_.is_set()) { | 3244 if (!to_number_operator_.is_set()) { |
3200 Callable callable = CodeFactory::ToNumber(isolate()); | 3245 Callable callable = CodeFactory::ToNumber(isolate()); |
3201 CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState; | 3246 CallDescriptor::Flags flags = CallDescriptor::kNeedsFrameState; |
3202 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 3247 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
3203 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 3248 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
3204 Operator::kNoProperties); | 3249 Operator::kNoProperties); |
3205 to_number_operator_.set(common()->Call(desc)); | 3250 to_number_operator_.set(common()->Call(desc)); |
3206 } | 3251 } |
3207 return to_number_operator_.get(); | 3252 return to_number_operator_.get(); |
3208 } | 3253 } |
3209 | 3254 |
3210 } // namespace compiler | 3255 } // namespace compiler |
3211 } // namespace internal | 3256 } // namespace internal |
3212 } // namespace v8 | 3257 } // namespace v8 |
OLD | NEW |