| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/base/adapters.h" | 5 #include "src/base/adapters.h" |
| 6 #include "src/base/bits.h" | 6 #include "src/base/bits.h" |
| 7 #include "src/compiler/instruction-selector-impl.h" | 7 #include "src/compiler/instruction-selector-impl.h" |
| 8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
| 9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
| 10 | 10 |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 FrameStateDescriptor* frame_state_descriptor = nullptr; | 518 FrameStateDescriptor* frame_state_descriptor = nullptr; |
| 519 if (descriptor->NeedsFrameState()) { | 519 if (descriptor->NeedsFrameState()) { |
| 520 frame_state_descriptor = | 520 frame_state_descriptor = |
| 521 GetFrameStateDescriptor(node->InputAt(descriptor->InputCount())); | 521 GetFrameStateDescriptor(node->InputAt(descriptor->InputCount())); |
| 522 } | 522 } |
| 523 | 523 |
| 524 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); | 524 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); |
| 525 | 525 |
| 526 // Compute InstructionOperands for inputs and outputs. | 526 // Compute InstructionOperands for inputs and outputs. |
| 527 InitializeCallBuffer(node, &buffer, true, false); | 527 InitializeCallBuffer(node, &buffer, true, false); |
| 528 // Possibly align stack here for functions. | 528 |
| 529 int push_count = buffer.pushed_nodes.size(); | 529 // Prepare for C function call. |
| 530 if (push_count > 0) { | 530 if (descriptor->IsCFunctionCall()) { |
| 531 Emit(kMipsStackClaim, g.NoOutput(), | 531 Emit(kArchPrepareCallCFunction | |
| 532 g.TempImmediate(push_count << kPointerSizeLog2)); | 532 MiscField::encode(static_cast<int>(descriptor->CParameterCount())), |
| 533 } | 533 0, nullptr, 0, nullptr); |
| 534 int slot = buffer.pushed_nodes.size() - 1; | 534 |
| 535 for (Node* node : base::Reversed(buffer.pushed_nodes)) { | 535 // Poke any stack arguments. |
| 536 Emit(kMipsStoreToStackSlot, g.NoOutput(), g.UseRegister(node), | 536 int slot = kCArgSlotCount; |
| 537 g.TempImmediate(slot << kPointerSizeLog2)); | 537 for (Node* node : buffer.pushed_nodes) { |
| 538 slot--; | 538 Emit(kMipsStoreToStackSlot, g.NoOutput(), g.UseRegister(node), |
| 539 g.TempImmediate(slot << kPointerSizeLog2)); |
| 540 ++slot; |
| 541 } |
| 542 } else { |
| 543 // Possibly align stack here for functions. |
| 544 int push_count = buffer.pushed_nodes.size(); |
| 545 if (push_count > 0) { |
| 546 Emit(kMipsStackClaim, g.NoOutput(), |
| 547 g.TempImmediate(push_count << kPointerSizeLog2)); |
| 548 } |
| 549 int slot = buffer.pushed_nodes.size() - 1; |
| 550 for (Node* node : base::Reversed(buffer.pushed_nodes)) { |
| 551 Emit(kMipsStoreToStackSlot, g.NoOutput(), g.UseRegister(node), |
| 552 g.TempImmediate(slot << kPointerSizeLog2)); |
| 553 slot--; |
| 554 } |
| 539 } | 555 } |
| 540 | 556 |
| 541 // Pass label of exception handler block. | 557 // Pass label of exception handler block. |
| 542 CallDescriptor::Flags flags = descriptor->flags(); | 558 CallDescriptor::Flags flags = descriptor->flags(); |
| 543 if (handler) { | 559 if (handler) { |
| 544 DCHECK_EQ(IrOpcode::kIfException, handler->front()->opcode()); | 560 DCHECK_EQ(IrOpcode::kIfException, handler->front()->opcode()); |
| 545 IfExceptionHint hint = OpParameter<IfExceptionHint>(handler->front()); | 561 IfExceptionHint hint = OpParameter<IfExceptionHint>(handler->front()); |
| 546 if (hint == IfExceptionHint::kLocallyCaught) { | 562 if (hint == IfExceptionHint::kLocallyCaught) { |
| 547 flags |= CallDescriptor::kHasLocalCatchHandler; | 563 flags |= CallDescriptor::kHasLocalCatchHandler; |
| 548 } | 564 } |
| 549 flags |= CallDescriptor::kHasExceptionHandler; | 565 flags |= CallDescriptor::kHasExceptionHandler; |
| 550 buffer.instruction_args.push_back(g.Label(handler)); | 566 buffer.instruction_args.push_back(g.Label(handler)); |
| 551 } | 567 } |
| 552 | 568 |
| 553 // Select the appropriate opcode based on the call type. | 569 // Select the appropriate opcode based on the call type. |
| 554 InstructionCode opcode; | 570 InstructionCode opcode; |
| 555 switch (descriptor->kind()) { | 571 switch (descriptor->kind()) { |
| 556 case CallDescriptor::kCallCodeObject: { | 572 case CallDescriptor::kCallAddress: |
| 557 opcode = kArchCallCodeObject; | 573 opcode = |
| 574 kArchCallCFunction | |
| 575 MiscField::encode(static_cast<int>(descriptor->CParameterCount())); |
| 558 break; | 576 break; |
| 559 } | 577 case CallDescriptor::kCallCodeObject: |
| 578 opcode = kArchCallCodeObject | MiscField::encode(flags); |
| 579 break; |
| 560 case CallDescriptor::kCallJSFunction: | 580 case CallDescriptor::kCallJSFunction: |
| 561 opcode = kArchCallJSFunction; | 581 opcode = kArchCallJSFunction | MiscField::encode(flags); |
| 562 break; | 582 break; |
| 563 default: | 583 default: |
| 564 UNREACHABLE(); | 584 UNREACHABLE(); |
| 565 return; | 585 return; |
| 566 } | 586 } |
| 567 opcode |= MiscField::encode(flags); | |
| 568 | 587 |
| 569 // Emit the call instruction. | 588 // Emit the call instruction. |
| 570 size_t const output_count = buffer.outputs.size(); | 589 size_t const output_count = buffer.outputs.size(); |
| 571 auto* outputs = output_count ? &buffer.outputs.front() : nullptr; | 590 auto* outputs = output_count ? &buffer.outputs.front() : nullptr; |
| 572 Emit(opcode, output_count, outputs, buffer.instruction_args.size(), | 591 Emit(opcode, output_count, outputs, buffer.instruction_args.size(), |
| 573 &buffer.instruction_args.front())->MarkAsCall(); | 592 &buffer.instruction_args.front())->MarkAsCall(); |
| 574 } | 593 } |
| 575 | 594 |
| 576 | 595 |
| 577 void InstructionSelector::VisitTailCall(Node* node) { | 596 void InstructionSelector::VisitTailCall(Node* node) { |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 IsFp64Mode()) { | 1105 IsFp64Mode()) { |
| 1087 flags |= MachineOperatorBuilder::kFloat64RoundDown | | 1106 flags |= MachineOperatorBuilder::kFloat64RoundDown | |
| 1088 MachineOperatorBuilder::kFloat64RoundTruncate; | 1107 MachineOperatorBuilder::kFloat64RoundTruncate; |
| 1089 } | 1108 } |
| 1090 return flags; | 1109 return flags; |
| 1091 } | 1110 } |
| 1092 | 1111 |
| 1093 } // namespace compiler | 1112 } // namespace compiler |
| 1094 } // namespace internal | 1113 } // namespace internal |
| 1095 } // namespace v8 | 1114 } // namespace v8 |
| OLD | NEW |