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/compiler/access-builder.h" | 9 #include "src/compiler/access-builder.h" |
10 #include "src/compiler/js-graph.h" | 10 #include "src/compiler/js-graph.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 case Runtime::kInlineStringGetLength: | 67 case Runtime::kInlineStringGetLength: |
68 return ReduceStringGetLength(node); | 68 return ReduceStringGetLength(node); |
69 case Runtime::kInlineTwoByteSeqStringGetChar: | 69 case Runtime::kInlineTwoByteSeqStringGetChar: |
70 return ReduceSeqStringGetChar(node, String::TWO_BYTE_ENCODING); | 70 return ReduceSeqStringGetChar(node, String::TWO_BYTE_ENCODING); |
71 case Runtime::kInlineTwoByteSeqStringSetChar: | 71 case Runtime::kInlineTwoByteSeqStringSetChar: |
72 return ReduceSeqStringSetChar(node, String::TWO_BYTE_ENCODING); | 72 return ReduceSeqStringSetChar(node, String::TWO_BYTE_ENCODING); |
73 case Runtime::kInlineUnlikely: | 73 case Runtime::kInlineUnlikely: |
74 return ReduceUnLikely(node, BranchHint::kFalse); | 74 return ReduceUnLikely(node, BranchHint::kFalse); |
75 case Runtime::kInlineValueOf: | 75 case Runtime::kInlineValueOf: |
76 return ReduceValueOf(node); | 76 return ReduceValueOf(node); |
| 77 case Runtime::kInlineIsMinusZero: |
| 78 return ReduceIsMinusZero(node); |
| 79 case Runtime::kInlineFixedArraySet: |
| 80 return ReduceFixedArraySet(node); |
| 81 case Runtime::kInlineGetTypeFeedbackVector: |
| 82 return ReduceGetTypeFeedbackVector(node); |
77 default: | 83 default: |
78 break; | 84 break; |
79 } | 85 } |
80 return NoChange(); | 86 return NoChange(); |
81 } | 87 } |
82 | 88 |
83 | 89 |
84 Reduction JSIntrinsicLowering::ReduceConstructDouble(Node* node) { | 90 Reduction JSIntrinsicLowering::ReduceConstructDouble(Node* node) { |
85 Node* high = NodeProperties::GetValueInput(node, 0); | 91 Node* high = NodeProperties::GetValueInput(node, 0); |
86 Node* low = NodeProperties::GetValueInput(node, 1); | 92 Node* low = NodeProperties::GetValueInput(node, 1); |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 // Replace all effect uses of {node} with the effect dependency. | 397 // Replace all effect uses of {node} with the effect dependency. |
392 NodeProperties::ReplaceWithValue(node, node); | 398 NodeProperties::ReplaceWithValue(node, node); |
393 // Remove the inputs corresponding to context, effect and control. | 399 // Remove the inputs corresponding to context, effect and control. |
394 NodeProperties::RemoveNonValueInputs(node); | 400 NodeProperties::RemoveNonValueInputs(node); |
395 // Finally update the operator to the new one. | 401 // Finally update the operator to the new one. |
396 node->set_op(op); | 402 node->set_op(op); |
397 return Changed(node); | 403 return Changed(node); |
398 } | 404 } |
399 | 405 |
400 | 406 |
| 407 Reduction JSIntrinsicLowering::ReduceIsMinusZero(Node* node) { |
| 408 Node* value = NodeProperties::GetValueInput(node, 0); |
| 409 Node* effect = NodeProperties::GetEffectInput(node); |
| 410 |
| 411 Node* double_lo = |
| 412 graph()->NewNode(machine()->Float64ExtractLowWord32(), value); |
| 413 Node* check1 = graph()->NewNode(machine()->Word32Equal(), double_lo, |
| 414 jsgraph()->ZeroConstant()); |
| 415 |
| 416 Node* double_hi = |
| 417 graph()->NewNode(machine()->Float64ExtractHighWord32(), value); |
| 418 Node* check2 = graph()->NewNode( |
| 419 machine()->Word32Equal(), double_hi, |
| 420 jsgraph()->Int32Constant(static_cast<int32_t>(0x80000000))); |
| 421 |
| 422 NodeProperties::ReplaceWithValue(node, node, effect); |
| 423 |
| 424 Node* and_result = graph()->NewNode(machine()->Word32And(), check1, check2); |
| 425 |
| 426 return Change(node, machine()->Word32Equal(), and_result, |
| 427 jsgraph()->Int32Constant(1)); |
| 428 } |
| 429 |
| 430 |
| 431 Reduction JSIntrinsicLowering::ReduceFixedArraySet(Node* node) { |
| 432 Node* base = node->InputAt(0); |
| 433 Node* index = node->InputAt(1); |
| 434 Node* value = node->InputAt(2); |
| 435 Node* effect = NodeProperties::GetEffectInput(node); |
| 436 Node* control = NodeProperties::GetControlInput(node); |
| 437 Node* store = (graph()->NewNode( |
| 438 simplified()->StoreElement(AccessBuilder::ForFixedArrayElement()), base, |
| 439 index, value, effect, control)); |
| 440 NodeProperties::ReplaceWithValue(node, value, store); |
| 441 return Changed(store); |
| 442 } |
| 443 |
| 444 |
| 445 Reduction JSIntrinsicLowering::ReduceGetTypeFeedbackVector(Node* node) { |
| 446 Node* func = node->InputAt(0); |
| 447 Node* effect = NodeProperties::GetEffectInput(node); |
| 448 Node* control = NodeProperties::GetControlInput(node); |
| 449 FieldAccess access = AccessBuilder::ForJSFunctionSharedFunctionInfo(); |
| 450 Node* load = |
| 451 graph()->NewNode(simplified()->LoadField(access), func, effect, control); |
| 452 access = AccessBuilder::ForSharedFunctionInfoTypeFeedbackVector(); |
| 453 return Change(node, simplified()->LoadField(access), load, load, control); |
| 454 } |
| 455 |
| 456 |
| 457 Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a, |
| 458 Node* b) { |
| 459 node->set_op(op); |
| 460 node->ReplaceInput(0, a); |
| 461 node->ReplaceInput(1, b); |
| 462 node->TrimInputCount(2); |
| 463 NodeProperties::ReplaceWithValue(node, node, node); |
| 464 return Changed(node); |
| 465 } |
| 466 |
| 467 |
401 Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a, | 468 Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a, |
402 Node* b, Node* c) { | 469 Node* b, Node* c) { |
403 node->set_op(op); | 470 node->set_op(op); |
404 node->ReplaceInput(0, a); | 471 node->ReplaceInput(0, a); |
405 node->ReplaceInput(1, b); | 472 node->ReplaceInput(1, b); |
406 node->ReplaceInput(2, c); | 473 node->ReplaceInput(2, c); |
407 node->TrimInputCount(3); | 474 node->TrimInputCount(3); |
408 NodeProperties::ReplaceWithValue(node, node, node); | 475 NodeProperties::ReplaceWithValue(node, node, node); |
409 return Changed(node); | 476 return Changed(node); |
410 } | 477 } |
(...skipping 14 matching lines...) Expand all Loading... |
425 } | 492 } |
426 | 493 |
427 | 494 |
428 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { | 495 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { |
429 return jsgraph()->machine(); | 496 return jsgraph()->machine(); |
430 } | 497 } |
431 | 498 |
432 } // namespace compiler | 499 } // namespace compiler |
433 } // namespace internal | 500 } // namespace internal |
434 } // namespace v8 | 501 } // namespace v8 |
OLD | NEW |