| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 ReduceIsInstanceType(node, JS_FUNCTION_TYPE); |
| 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::kInlineIsSpecObject: |
| 63 // TODO(bmeurer): Rename %_IsSpecObject to %_IsReceiver. |
| 64 return ReduceIsSpecObject(node); |
| 62 case Runtime::kInlineIsSmi: | 65 case Runtime::kInlineIsSmi: |
| 63 return ReduceIsSmi(node); | 66 return ReduceIsSmi(node); |
| 64 case Runtime::kInlineJSValueGetValue: | 67 case Runtime::kInlineJSValueGetValue: |
| 65 return ReduceJSValueGetValue(node); | 68 return ReduceJSValueGetValue(node); |
| 66 case Runtime::kInlineMapGetInstanceType: | 69 case Runtime::kInlineMapGetInstanceType: |
| 67 return ReduceMapGetInstanceType(node); | 70 return ReduceMapGetInstanceType(node); |
| 68 case Runtime::kInlineMathClz32: | 71 case Runtime::kInlineMathClz32: |
| 69 return ReduceMathClz32(node); | 72 return ReduceMathClz32(node); |
| 70 case Runtime::kInlineMathFloor: | 73 case Runtime::kInlineMathFloor: |
| 71 return ReduceMathFloor(node); | 74 return ReduceMathFloor(node); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 | 246 |
| 244 // Replace all effect uses of {node} with the {ephi}. | 247 // Replace all effect uses of {node} with the {ephi}. |
| 245 Node* ephi = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, merge); | 248 Node* ephi = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, merge); |
| 246 ReplaceWithValue(node, node, ephi); | 249 ReplaceWithValue(node, node, ephi); |
| 247 | 250 |
| 248 // Turn the {node} into a Phi. | 251 // Turn the {node} into a Phi. |
| 249 return Change(node, common()->Phi(type, 2), vtrue, vfalse, merge); | 252 return Change(node, common()->Phi(type, 2), vtrue, vfalse, merge); |
| 250 } | 253 } |
| 251 | 254 |
| 252 | 255 |
| 256 Reduction JSIntrinsicLowering::ReduceIsSpecObject(Node* node) { |
| 257 // if (%_IsSmi(value)) { |
| 258 // return false; |
| 259 // } else { |
| 260 // return FIRST_JS_RECEIVER_TYPE <= %_GetInstanceType(%_GetMap(value)) |
| 261 // } |
| 262 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE); |
| 263 MachineType const type = static_cast<MachineType>(kTypeBool | kRepTagged); |
| 264 |
| 265 Node* value = NodeProperties::GetValueInput(node, 0); |
| 266 Node* effect = NodeProperties::GetEffectInput(node); |
| 267 Node* control = NodeProperties::GetControlInput(node); |
| 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()), value, |
| 280 effect, if_false), |
| 281 effect, if_false); |
| 282 Node* vfalse = graph()->NewNode( |
| 283 machine()->Uint32LessThanOrEqual(), |
| 284 jsgraph()->Int32Constant(FIRST_JS_RECEIVER_TYPE), efalse); |
| 285 |
| 286 control = graph()->NewNode(common()->Merge(2), if_true, if_false); |
| 287 |
| 288 // Replace all effect uses of {node} with the {ephi}. |
| 289 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); |
| 290 ReplaceWithValue(node, node, effect, control); |
| 291 |
| 292 // Turn the {node} into a Phi. |
| 293 return Change(node, common()->Phi(type, 2), vtrue, vfalse, control); |
| 294 } |
| 295 |
| 296 |
| 253 Reduction JSIntrinsicLowering::ReduceIsSmi(Node* node) { | 297 Reduction JSIntrinsicLowering::ReduceIsSmi(Node* node) { |
| 254 return Change(node, simplified()->ObjectIsSmi()); | 298 return Change(node, simplified()->ObjectIsSmi()); |
| 255 } | 299 } |
| 256 | 300 |
| 257 | 301 |
| 258 Reduction JSIntrinsicLowering::ReduceJSValueGetValue(Node* node) { | 302 Reduction JSIntrinsicLowering::ReduceJSValueGetValue(Node* node) { |
| 259 Node* value = NodeProperties::GetValueInput(node, 0); | 303 Node* value = NodeProperties::GetValueInput(node, 0); |
| 260 Node* effect = NodeProperties::GetEffectInput(node); | 304 Node* effect = NodeProperties::GetEffectInput(node); |
| 261 Node* control = NodeProperties::GetControlInput(node); | 305 Node* control = NodeProperties::GetControlInput(node); |
| 262 return Change(node, simplified()->LoadField(AccessBuilder::ForValue()), value, | 306 return Change(node, simplified()->LoadField(AccessBuilder::ForValue()), value, |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 } | 719 } |
| 676 | 720 |
| 677 | 721 |
| 678 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { | 722 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { |
| 679 return jsgraph()->simplified(); | 723 return jsgraph()->simplified(); |
| 680 } | 724 } |
| 681 | 725 |
| 682 } // namespace compiler | 726 } // namespace compiler |
| 683 } // namespace internal | 727 } // namespace internal |
| 684 } // namespace v8 | 728 } // namespace v8 |
| OLD | NEW |