| 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 <stack> | 7 #include <stack> |
| 8 | 8 |
| 9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
| 10 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 case Runtime::kInlineDoubleLo: | 46 case Runtime::kInlineDoubleLo: |
| 47 return ReduceDoubleLo(node); | 47 return ReduceDoubleLo(node); |
| 48 case Runtime::kInlineIncrementStatsCounter: | 48 case Runtime::kInlineIncrementStatsCounter: |
| 49 return ReduceIncrementStatsCounter(node); | 49 return ReduceIncrementStatsCounter(node); |
| 50 case Runtime::kInlineIsArray: | 50 case Runtime::kInlineIsArray: |
| 51 return ReduceIsInstanceType(node, JS_ARRAY_TYPE); | 51 return ReduceIsInstanceType(node, JS_ARRAY_TYPE); |
| 52 case Runtime::kInlineIsDate: | 52 case Runtime::kInlineIsDate: |
| 53 return ReduceIsInstanceType(node, JS_DATE_TYPE); | 53 return ReduceIsInstanceType(node, JS_DATE_TYPE); |
| 54 case Runtime::kInlineIsTypedArray: | 54 case Runtime::kInlineIsTypedArray: |
| 55 return ReduceIsInstanceType(node, JS_TYPED_ARRAY_TYPE); | 55 return ReduceIsInstanceType(node, JS_TYPED_ARRAY_TYPE); |
| 56 case Runtime::kInlineIsFunction: | |
| 57 return ReduceIsFunction(node); | |
| 58 case Runtime::kInlineIsRegExp: | 56 case Runtime::kInlineIsRegExp: |
| 59 return ReduceIsInstanceType(node, JS_REGEXP_TYPE); | 57 return ReduceIsInstanceType(node, JS_REGEXP_TYPE); |
| 60 case Runtime::kInlineIsJSReceiver: | 58 case Runtime::kInlineIsJSReceiver: |
| 61 return ReduceIsJSReceiver(node); | 59 return ReduceIsJSReceiver(node); |
| 62 case Runtime::kInlineIsSmi: | 60 case Runtime::kInlineIsSmi: |
| 63 return ReduceIsSmi(node); | 61 return ReduceIsSmi(node); |
| 64 case Runtime::kInlineJSValueGetValue: | 62 case Runtime::kInlineJSValueGetValue: |
| 65 return ReduceJSValueGetValue(node); | 63 return ReduceJSValueGetValue(node); |
| 66 case Runtime::kInlineMathClz32: | 64 case Runtime::kInlineMathClz32: |
| 67 return ReduceMathClz32(node); | 65 return ReduceMathClz32(node); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 // Replace all effect uses of {node} with the {ephi}. | 220 // Replace all effect uses of {node} with the {ephi}. |
| 223 Node* ephi = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, merge); | 221 Node* ephi = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, merge); |
| 224 ReplaceWithValue(node, node, ephi); | 222 ReplaceWithValue(node, node, ephi); |
| 225 | 223 |
| 226 // Turn the {node} into a Phi. | 224 // Turn the {node} into a Phi. |
| 227 return Change(node, common()->Phi(MachineRepresentation::kTagged, 2), vtrue, | 225 return Change(node, common()->Phi(MachineRepresentation::kTagged, 2), vtrue, |
| 228 vfalse, merge); | 226 vfalse, merge); |
| 229 } | 227 } |
| 230 | 228 |
| 231 | 229 |
| 232 Reduction JSIntrinsicLowering::ReduceIsFunction(Node* node) { | |
| 233 Node* value = NodeProperties::GetValueInput(node, 0); | |
| 234 Type* value_type = NodeProperties::GetType(value); | |
| 235 Node* effect = NodeProperties::GetEffectInput(node); | |
| 236 Node* control = NodeProperties::GetControlInput(node); | |
| 237 if (value_type->Is(Type::Function())) { | |
| 238 value = jsgraph()->TrueConstant(); | |
| 239 } else { | |
| 240 // if (%_IsSmi(value)) { | |
| 241 // return false; | |
| 242 // } else { | |
| 243 // return FIRST_FUNCTION_TYPE <= %_GetInstanceType(%_GetMap(value)) | |
| 244 // } | |
| 245 STATIC_ASSERT(LAST_TYPE == LAST_FUNCTION_TYPE); | |
| 246 | |
| 247 Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); | |
| 248 Node* branch = graph()->NewNode(common()->Branch(), check, control); | |
| 249 | |
| 250 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | |
| 251 Node* etrue = effect; | |
| 252 Node* vtrue = jsgraph()->FalseConstant(); | |
| 253 | |
| 254 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | |
| 255 Node* efalse = graph()->NewNode( | |
| 256 simplified()->LoadField(AccessBuilder::ForMapInstanceType()), | |
| 257 graph()->NewNode(simplified()->LoadField(AccessBuilder::ForMap()), | |
| 258 value, effect, if_false), | |
| 259 effect, if_false); | |
| 260 Node* vfalse = | |
| 261 graph()->NewNode(machine()->Uint32LessThanOrEqual(), | |
| 262 jsgraph()->Int32Constant(FIRST_FUNCTION_TYPE), efalse); | |
| 263 | |
| 264 control = graph()->NewNode(common()->Merge(2), if_true, if_false); | |
| 265 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); | |
| 266 value = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), | |
| 267 vtrue, vfalse, control); | |
| 268 } | |
| 269 ReplaceWithValue(node, node, effect, control); | |
| 270 return Replace(value); | |
| 271 } | |
| 272 | |
| 273 | |
| 274 Reduction JSIntrinsicLowering::ReduceIsJSReceiver(Node* node) { | 230 Reduction JSIntrinsicLowering::ReduceIsJSReceiver(Node* node) { |
| 275 Node* value = NodeProperties::GetValueInput(node, 0); | 231 Node* value = NodeProperties::GetValueInput(node, 0); |
| 276 Type* value_type = NodeProperties::GetType(value); | 232 Type* value_type = NodeProperties::GetType(value); |
| 277 Node* effect = NodeProperties::GetEffectInput(node); | 233 Node* effect = NodeProperties::GetEffectInput(node); |
| 278 Node* control = NodeProperties::GetControlInput(node); | 234 Node* control = NodeProperties::GetControlInput(node); |
| 279 if (value_type->Is(Type::Receiver())) { | 235 if (value_type->Is(Type::Receiver())) { |
| 280 value = jsgraph()->TrueConstant(); | 236 value = jsgraph()->TrueConstant(); |
| 281 } else if (!value_type->Maybe(Type::Receiver())) { | 237 } else if (!value_type->Maybe(Type::Receiver())) { |
| 282 value = jsgraph()->FalseConstant(); | 238 value = jsgraph()->FalseConstant(); |
| 283 } else { | 239 } else { |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 } | 680 } |
| 725 | 681 |
| 726 | 682 |
| 727 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { | 683 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { |
| 728 return jsgraph()->simplified(); | 684 return jsgraph()->simplified(); |
| 729 } | 685 } |
| 730 | 686 |
| 731 } // namespace compiler | 687 } // namespace compiler |
| 732 } // namespace internal | 688 } // namespace internal |
| 733 } // namespace v8 | 689 } // namespace v8 |
| OLD | NEW |