| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 49       return ReduceDoubleLo(node); | 49       return ReduceDoubleLo(node); | 
| 50     case Runtime::kInlineIncrementStatsCounter: | 50     case Runtime::kInlineIncrementStatsCounter: | 
| 51       return ReduceIncrementStatsCounter(node); | 51       return ReduceIncrementStatsCounter(node); | 
| 52     case Runtime::kInlineIsArray: | 52     case Runtime::kInlineIsArray: | 
| 53       return ReduceIsInstanceType(node, JS_ARRAY_TYPE); | 53       return ReduceIsInstanceType(node, JS_ARRAY_TYPE); | 
| 54     case Runtime::kInlineIsDate: | 54     case Runtime::kInlineIsDate: | 
| 55       return ReduceIsInstanceType(node, JS_DATE_TYPE); | 55       return ReduceIsInstanceType(node, JS_DATE_TYPE); | 
| 56     case Runtime::kInlineIsTypedArray: | 56     case Runtime::kInlineIsTypedArray: | 
| 57       return ReduceIsInstanceType(node, JS_TYPED_ARRAY_TYPE); | 57       return ReduceIsInstanceType(node, JS_TYPED_ARRAY_TYPE); | 
| 58     case Runtime::kInlineIsFunction: | 58     case Runtime::kInlineIsFunction: | 
| 59       return ReduceIsInstanceType(node, JS_FUNCTION_TYPE); | 59       return ReduceIsFunction(node); | 
| 60     case Runtime::kInlineIsRegExp: | 60     case Runtime::kInlineIsRegExp: | 
| 61       return ReduceIsInstanceType(node, JS_REGEXP_TYPE); | 61       return ReduceIsInstanceType(node, JS_REGEXP_TYPE); | 
| 62     case Runtime::kInlineIsJSReceiver: | 62     case Runtime::kInlineIsJSReceiver: | 
| 63       return ReduceIsJSReceiver(node); | 63       return ReduceIsJSReceiver(node); | 
| 64     case Runtime::kInlineIsSmi: | 64     case Runtime::kInlineIsSmi: | 
| 65       return ReduceIsSmi(node); | 65       return ReduceIsSmi(node); | 
| 66     case Runtime::kInlineJSValueGetValue: | 66     case Runtime::kInlineJSValueGetValue: | 
| 67       return ReduceJSValueGetValue(node); | 67       return ReduceJSValueGetValue(node); | 
| 68     case Runtime::kInlineMathClz32: | 68     case Runtime::kInlineMathClz32: | 
| 69       return ReduceMathClz32(node); | 69       return ReduceMathClz32(node); | 
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 244   // Replace all effect uses of {node} with the {ephi}. | 244   // Replace all effect uses of {node} with the {ephi}. | 
| 245   Node* ephi = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, merge); | 245   Node* ephi = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, merge); | 
| 246   ReplaceWithValue(node, node, ephi); | 246   ReplaceWithValue(node, node, ephi); | 
| 247 | 247 | 
| 248   // Turn the {node} into a Phi. | 248   // Turn the {node} into a Phi. | 
| 249   return Change(node, common()->Phi(MachineRepresentation::kTagged, 2), vtrue, | 249   return Change(node, common()->Phi(MachineRepresentation::kTagged, 2), vtrue, | 
| 250                 vfalse, merge); | 250                 vfalse, merge); | 
| 251 } | 251 } | 
| 252 | 252 | 
| 253 | 253 | 
|  | 254 Reduction JSIntrinsicLowering::ReduceIsFunction(Node* node) { | 
|  | 255   Node* value = NodeProperties::GetValueInput(node, 0); | 
|  | 256   Type* value_type = NodeProperties::GetType(value); | 
|  | 257   Node* effect = NodeProperties::GetEffectInput(node); | 
|  | 258   Node* control = NodeProperties::GetControlInput(node); | 
|  | 259   if (value_type->Is(Type::Function())) { | 
|  | 260     value = jsgraph()->TrueConstant(); | 
|  | 261   } else { | 
|  | 262     // if (%_IsSmi(value)) { | 
|  | 263     //   return false; | 
|  | 264     // } else { | 
|  | 265     //   return FIRST_FUNCTION_TYPE <= %_GetInstanceType(%_GetMap(value)) | 
|  | 266     // } | 
|  | 267     STATIC_ASSERT(LAST_TYPE == LAST_FUNCTION_TYPE); | 
|  | 268 | 
|  | 269     Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); | 
|  | 270     Node* branch = graph()->NewNode(common()->Branch(), check, control); | 
|  | 271 | 
|  | 272     Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 
|  | 273     Node* etrue = effect; | 
|  | 274     Node* vtrue = jsgraph()->FalseConstant(); | 
|  | 275 | 
|  | 276     Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 
|  | 277     Node* efalse = graph()->NewNode( | 
|  | 278         simplified()->LoadField(AccessBuilder::ForMapInstanceType()), | 
|  | 279         graph()->NewNode(simplified()->LoadField(AccessBuilder::ForMap()), | 
|  | 280                          value, effect, if_false), | 
|  | 281         effect, if_false); | 
|  | 282     Node* vfalse = | 
|  | 283         graph()->NewNode(machine()->Uint32LessThanOrEqual(), | 
|  | 284                          jsgraph()->Int32Constant(FIRST_FUNCTION_TYPE), efalse); | 
|  | 285 | 
|  | 286     control = graph()->NewNode(common()->Merge(2), if_true, if_false); | 
|  | 287     effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); | 
|  | 288     value = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), | 
|  | 289                              vtrue, vfalse, control); | 
|  | 290   } | 
|  | 291   ReplaceWithValue(node, node, effect, control); | 
|  | 292   return Replace(value); | 
|  | 293 } | 
|  | 294 | 
|  | 295 | 
| 254 Reduction JSIntrinsicLowering::ReduceIsJSReceiver(Node* node) { | 296 Reduction JSIntrinsicLowering::ReduceIsJSReceiver(Node* node) { | 
| 255   Node* value = NodeProperties::GetValueInput(node, 0); | 297   Node* value = NodeProperties::GetValueInput(node, 0); | 
| 256   Type* value_type = NodeProperties::GetType(value); | 298   Type* value_type = NodeProperties::GetType(value); | 
| 257   Node* effect = NodeProperties::GetEffectInput(node); | 299   Node* effect = NodeProperties::GetEffectInput(node); | 
| 258   Node* control = NodeProperties::GetControlInput(node); | 300   Node* control = NodeProperties::GetControlInput(node); | 
| 259   if (value_type->Is(Type::Receiver())) { | 301   if (value_type->Is(Type::Receiver())) { | 
| 260     value = jsgraph()->TrueConstant(); | 302     value = jsgraph()->TrueConstant(); | 
| 261   } else if (!value_type->Maybe(Type::Receiver())) { | 303   } else if (!value_type->Maybe(Type::Receiver())) { | 
| 262     value = jsgraph()->FalseConstant(); | 304     value = jsgraph()->FalseConstant(); | 
| 263   } else { | 305   } else { | 
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 691 } | 733 } | 
| 692 | 734 | 
| 693 | 735 | 
| 694 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { | 736 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { | 
| 695   return jsgraph()->simplified(); | 737   return jsgraph()->simplified(); | 
| 696 } | 738 } | 
| 697 | 739 | 
| 698 }  // namespace compiler | 740 }  // namespace compiler | 
| 699 }  // namespace internal | 741 }  // namespace internal | 
| 700 }  // namespace v8 | 742 }  // namespace v8 | 
| OLD | NEW | 
|---|