| 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 14 matching lines...) Expand all Loading... |
| 25 case Runtime::kInlineDeoptimizeNow: | 25 case Runtime::kInlineDeoptimizeNow: |
| 26 return ReduceInlineDeoptimizeNow(node); | 26 return ReduceInlineDeoptimizeNow(node); |
| 27 case Runtime::kInlineIsSmi: | 27 case Runtime::kInlineIsSmi: |
| 28 return ReduceInlineIsSmi(node); | 28 return ReduceInlineIsSmi(node); |
| 29 case Runtime::kInlineIsNonNegativeSmi: | 29 case Runtime::kInlineIsNonNegativeSmi: |
| 30 return ReduceInlineIsNonNegativeSmi(node); | 30 return ReduceInlineIsNonNegativeSmi(node); |
| 31 case Runtime::kInlineIsArray: | 31 case Runtime::kInlineIsArray: |
| 32 return ReduceInlineIsInstanceType(node, JS_ARRAY_TYPE); | 32 return ReduceInlineIsInstanceType(node, JS_ARRAY_TYPE); |
| 33 case Runtime::kInlineIsFunction: | 33 case Runtime::kInlineIsFunction: |
| 34 return ReduceInlineIsInstanceType(node, JS_FUNCTION_TYPE); | 34 return ReduceInlineIsInstanceType(node, JS_FUNCTION_TYPE); |
| 35 case Runtime::kInlineJSValueGetValue: |
| 36 return ReduceInlineJSValueGetValue(node); |
| 35 case Runtime::kInlineConstructDouble: | 37 case Runtime::kInlineConstructDouble: |
| 36 return ReduceInlineConstructDouble(node); | 38 return ReduceInlineConstructDouble(node); |
| 37 case Runtime::kInlineDoubleLo: | 39 case Runtime::kInlineDoubleLo: |
| 38 return ReduceInlineDoubleLo(node); | 40 return ReduceInlineDoubleLo(node); |
| 39 case Runtime::kInlineDoubleHi: | 41 case Runtime::kInlineDoubleHi: |
| 40 return ReduceInlineDoubleHi(node); | 42 return ReduceInlineDoubleHi(node); |
| 41 case Runtime::kInlineIsRegExp: | 43 case Runtime::kInlineIsRegExp: |
| 42 return ReduceInlineIsInstanceType(node, JS_REGEXP_TYPE); | 44 return ReduceInlineIsInstanceType(node, JS_REGEXP_TYPE); |
| 43 case Runtime::kInlineMathFloor: | 45 case Runtime::kInlineMathFloor: |
| 44 return ReduceInlineMathFloor(node); | 46 return ReduceInlineMathFloor(node); |
| 45 case Runtime::kInlineMathSqrt: | 47 case Runtime::kInlineMathSqrt: |
| 46 return ReduceInlineMathSqrt(node); | 48 return ReduceInlineMathSqrt(node); |
| 49 case Runtime::kInlineStringGetLength: |
| 50 return ReduceInlineStringGetLength(node); |
| 47 case Runtime::kInlineValueOf: | 51 case Runtime::kInlineValueOf: |
| 48 return ReduceInlineValueOf(node); | 52 return ReduceInlineValueOf(node); |
| 49 default: | 53 default: |
| 50 break; | 54 break; |
| 51 } | 55 } |
| 52 return NoChange(); | 56 return NoChange(); |
| 53 } | 57 } |
| 54 | 58 |
| 55 | 59 |
| 56 Reduction JSIntrinsicLowering::ReduceInlineDeoptimizeNow(Node* node) { | 60 Reduction JSIntrinsicLowering::ReduceInlineDeoptimizeNow(Node* node) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 Reduction JSIntrinsicLowering::ReduceInlineIsSmi(Node* node) { | 100 Reduction JSIntrinsicLowering::ReduceInlineIsSmi(Node* node) { |
| 97 return Change(node, simplified()->ObjectIsSmi()); | 101 return Change(node, simplified()->ObjectIsSmi()); |
| 98 } | 102 } |
| 99 | 103 |
| 100 | 104 |
| 101 Reduction JSIntrinsicLowering::ReduceInlineIsNonNegativeSmi(Node* node) { | 105 Reduction JSIntrinsicLowering::ReduceInlineIsNonNegativeSmi(Node* node) { |
| 102 return Change(node, simplified()->ObjectIsNonNegativeSmi()); | 106 return Change(node, simplified()->ObjectIsNonNegativeSmi()); |
| 103 } | 107 } |
| 104 | 108 |
| 105 | 109 |
| 110 Reduction JSIntrinsicLowering::ReduceInlineJSValueGetValue(Node* node) { |
| 111 Node* value = NodeProperties::GetValueInput(node, 0); |
| 112 Node* effect = NodeProperties::GetEffectInput(node); |
| 113 Node* control = NodeProperties::GetControlInput(node); |
| 114 return Change(node, simplified()->LoadField(AccessBuilder::ForValue()), value, |
| 115 effect, control); |
| 116 } |
| 117 |
| 118 |
| 106 Reduction JSIntrinsicLowering::ReduceInlineConstructDouble(Node* node) { | 119 Reduction JSIntrinsicLowering::ReduceInlineConstructDouble(Node* node) { |
| 107 Node* high = NodeProperties::GetValueInput(node, 0); | 120 Node* high = NodeProperties::GetValueInput(node, 0); |
| 108 Node* low = NodeProperties::GetValueInput(node, 1); | 121 Node* low = NodeProperties::GetValueInput(node, 1); |
| 109 Node* value = | 122 Node* value = |
| 110 graph()->NewNode(machine()->Float64InsertHighWord32(), | 123 graph()->NewNode(machine()->Float64InsertHighWord32(), |
| 111 graph()->NewNode(machine()->Float64InsertLowWord32(), | 124 graph()->NewNode(machine()->Float64InsertLowWord32(), |
| 112 jsgraph()->Constant(0), low), | 125 jsgraph()->Constant(0), low), |
| 113 high); | 126 high); |
| 114 NodeProperties::ReplaceWithValue(node, value); | 127 NodeProperties::ReplaceWithValue(node, value); |
| 115 return Replace(value); | 128 return Replace(value); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 if (!machine()->HasFloat64RoundDown()) return NoChange(); | 183 if (!machine()->HasFloat64RoundDown()) return NoChange(); |
| 171 return Change(node, machine()->Float64RoundDown()); | 184 return Change(node, machine()->Float64RoundDown()); |
| 172 } | 185 } |
| 173 | 186 |
| 174 | 187 |
| 175 Reduction JSIntrinsicLowering::ReduceInlineMathSqrt(Node* node) { | 188 Reduction JSIntrinsicLowering::ReduceInlineMathSqrt(Node* node) { |
| 176 return Change(node, machine()->Float64Sqrt()); | 189 return Change(node, machine()->Float64Sqrt()); |
| 177 } | 190 } |
| 178 | 191 |
| 179 | 192 |
| 193 Reduction JSIntrinsicLowering::ReduceInlineStringGetLength(Node* node) { |
| 194 Node* value = NodeProperties::GetValueInput(node, 0); |
| 195 Node* effect = NodeProperties::GetEffectInput(node); |
| 196 Node* control = NodeProperties::GetControlInput(node); |
| 197 return Change(node, simplified()->LoadField(AccessBuilder::ForStringLength()), |
| 198 value, effect, control); |
| 199 } |
| 200 |
| 201 |
| 180 Reduction JSIntrinsicLowering::ReduceInlineValueOf(Node* node) { | 202 Reduction JSIntrinsicLowering::ReduceInlineValueOf(Node* node) { |
| 181 // if (%_IsSmi(value)) { | 203 // if (%_IsSmi(value)) { |
| 182 // return value; | 204 // return value; |
| 183 // } else if (%_GetInstanceType(%_GetMap(value)) == JS_VALUE_TYPE) { | 205 // } else if (%_GetInstanceType(%_GetMap(value)) == JS_VALUE_TYPE) { |
| 184 // return %_GetValue(value); | 206 // return %_GetValue(value); |
| 185 // } else { | 207 // } else { |
| 186 // return value; | 208 // return value; |
| 187 // } | 209 // } |
| 188 const Operator* const merge_op = common()->Merge(2); | 210 const Operator* const merge_op = common()->Merge(2); |
| 189 const Operator* const ephi_op = common()->EffectPhi(2); | 211 const Operator* const ephi_op = common()->EffectPhi(2); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 } | 273 } |
| 252 | 274 |
| 253 | 275 |
| 254 Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a, | 276 Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a, |
| 255 Node* b, Node* c) { | 277 Node* b, Node* c) { |
| 256 node->set_op(op); | 278 node->set_op(op); |
| 257 node->ReplaceInput(0, a); | 279 node->ReplaceInput(0, a); |
| 258 node->ReplaceInput(1, b); | 280 node->ReplaceInput(1, b); |
| 259 node->ReplaceInput(2, c); | 281 node->ReplaceInput(2, c); |
| 260 node->TrimInputCount(3); | 282 node->TrimInputCount(3); |
| 283 NodeProperties::ReplaceWithValue(node, node, node); |
| 261 return Changed(node); | 284 return Changed(node); |
| 262 } | 285 } |
| 263 | 286 |
| 264 | 287 |
| 265 Graph* JSIntrinsicLowering::graph() const { return jsgraph()->graph(); } | 288 Graph* JSIntrinsicLowering::graph() const { return jsgraph()->graph(); } |
| 266 | 289 |
| 267 | 290 |
| 268 CommonOperatorBuilder* JSIntrinsicLowering::common() const { | 291 CommonOperatorBuilder* JSIntrinsicLowering::common() const { |
| 269 return jsgraph()->common(); | 292 return jsgraph()->common(); |
| 270 } | 293 } |
| 271 | 294 |
| 272 | 295 |
| 273 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { | 296 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { |
| 274 return jsgraph()->machine(); | 297 return jsgraph()->machine(); |
| 275 } | 298 } |
| 276 | 299 |
| 277 } // namespace compiler | 300 } // namespace compiler |
| 278 } // namespace internal | 301 } // namespace internal |
| 279 } // namespace v8 | 302 } // namespace v8 |
| OLD | NEW |