| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/js-intrinsic-lowering.h" | 5 #include "src/compiler/js-intrinsic-lowering.h" |
| 6 | 6 |
| 7 #include "src/compiler/access-builder.h" | 7 #include "src/compiler/access-builder.h" |
| 8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
| 9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 case Runtime::kDeoptimizeNow: | 24 case Runtime::kDeoptimizeNow: |
| 25 return ReduceDeoptimizeNow(node); | 25 return ReduceDeoptimizeNow(node); |
| 26 case Runtime::kInlineIsSmi: | 26 case Runtime::kInlineIsSmi: |
| 27 return ReduceInlineIsSmi(node); | 27 return ReduceInlineIsSmi(node); |
| 28 case Runtime::kInlineIsNonNegativeSmi: | 28 case Runtime::kInlineIsNonNegativeSmi: |
| 29 return ReduceInlineIsNonNegativeSmi(node); | 29 return ReduceInlineIsNonNegativeSmi(node); |
| 30 case Runtime::kInlineIsArray: | 30 case Runtime::kInlineIsArray: |
| 31 return ReduceInlineIsInstanceType(node, JS_ARRAY_TYPE); | 31 return ReduceInlineIsInstanceType(node, JS_ARRAY_TYPE); |
| 32 case Runtime::kInlineIsFunction: | 32 case Runtime::kInlineIsFunction: |
| 33 return ReduceInlineIsInstanceType(node, JS_FUNCTION_TYPE); | 33 return ReduceInlineIsInstanceType(node, JS_FUNCTION_TYPE); |
| 34 case Runtime::kInlineOptimizedConstructDouble: |
| 35 return ReduceInlineOptimizedConstructDouble(node); |
| 36 case Runtime::kInlineOptimizedDoubleLo: |
| 37 return ReduceInlineOptimizedDoubleLo(node); |
| 38 case Runtime::kInlineOptimizedDoubleHi: |
| 39 return ReduceInlineOptimizedDoubleHi(node); |
| 34 case Runtime::kInlineIsRegExp: | 40 case Runtime::kInlineIsRegExp: |
| 35 return ReduceInlineIsInstanceType(node, JS_REGEXP_TYPE); | 41 return ReduceInlineIsInstanceType(node, JS_REGEXP_TYPE); |
| 36 case Runtime::kInlineValueOf: | 42 case Runtime::kInlineValueOf: |
| 37 return ReduceInlineValueOf(node); | 43 return ReduceInlineValueOf(node); |
| 38 default: | 44 default: |
| 39 break; | 45 break; |
| 40 } | 46 } |
| 41 return NoChange(); | 47 return NoChange(); |
| 42 } | 48 } |
| 43 | 49 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 Reduction JSIntrinsicLowering::ReduceInlineIsSmi(Node* node) { | 91 Reduction JSIntrinsicLowering::ReduceInlineIsSmi(Node* node) { |
| 86 return Change(node, simplified()->ObjectIsSmi()); | 92 return Change(node, simplified()->ObjectIsSmi()); |
| 87 } | 93 } |
| 88 | 94 |
| 89 | 95 |
| 90 Reduction JSIntrinsicLowering::ReduceInlineIsNonNegativeSmi(Node* node) { | 96 Reduction JSIntrinsicLowering::ReduceInlineIsNonNegativeSmi(Node* node) { |
| 91 return Change(node, simplified()->ObjectIsNonNegativeSmi()); | 97 return Change(node, simplified()->ObjectIsNonNegativeSmi()); |
| 92 } | 98 } |
| 93 | 99 |
| 94 | 100 |
| 101 Reduction JSIntrinsicLowering::ReduceInlineOptimizedConstructDouble( |
| 102 Node* node) { |
| 103 Node* high = NodeProperties::GetValueInput(node, 0); |
| 104 Node* low = NodeProperties::GetValueInput(node, 1); |
| 105 Node* value = |
| 106 graph()->NewNode(machine()->Float64InsertHighWord32(), |
| 107 graph()->NewNode(machine()->Float64InsertLowWord32(), |
| 108 jsgraph()->Constant(0), low), |
| 109 high); |
| 110 NodeProperties::ReplaceWithValue(node, value); |
| 111 return Replace(value); |
| 112 } |
| 113 |
| 114 |
| 115 Reduction JSIntrinsicLowering::ReduceInlineOptimizedDoubleLo(Node* node) { |
| 116 return Change(node, machine()->Float64ExtractLowWord32()); |
| 117 } |
| 118 |
| 119 |
| 120 Reduction JSIntrinsicLowering::ReduceInlineOptimizedDoubleHi(Node* node) { |
| 121 return Change(node, machine()->Float64ExtractHighWord32()); |
| 122 } |
| 123 |
| 124 |
| 95 Reduction JSIntrinsicLowering::ReduceInlineIsInstanceType( | 125 Reduction JSIntrinsicLowering::ReduceInlineIsInstanceType( |
| 96 Node* node, InstanceType instance_type) { | 126 Node* node, InstanceType instance_type) { |
| 97 // if (%_IsSmi(value)) { | 127 // if (%_IsSmi(value)) { |
| 98 // return false; | 128 // return false; |
| 99 // } else { | 129 // } else { |
| 100 // return %_GetInstanceType(%_GetMap(value)) == instance_type; | 130 // return %_GetInstanceType(%_GetMap(value)) == instance_type; |
| 101 // } | 131 // } |
| 102 MachineType const type = static_cast<MachineType>(kTypeBool | kRepTagged); | 132 MachineType const type = static_cast<MachineType>(kTypeBool | kRepTagged); |
| 103 | 133 |
| 104 Node* value = NodeProperties::GetValueInput(node, 0); | 134 Node* value = NodeProperties::GetValueInput(node, 0); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 } | 255 } |
| 226 | 256 |
| 227 | 257 |
| 228 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { | 258 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { |
| 229 return jsgraph()->machine(); | 259 return jsgraph()->machine(); |
| 230 } | 260 } |
| 231 | 261 |
| 232 } // namespace compiler | 262 } // namespace compiler |
| 233 } // namespace internal | 263 } // namespace internal |
| 234 } // namespace v8 | 264 } // namespace v8 |
| OLD | NEW |