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/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
8 #include "src/arm64/macro-assembler-arm64.h" | 8 #include "src/arm64/macro-assembler-arm64.h" |
9 #include "src/compiler/code-generator-impl.h" | 9 #include "src/compiler/code-generator-impl.h" |
10 #include "src/compiler/gap-resolver.h" | 10 #include "src/compiler/gap-resolver.h" |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 uint32_t imm = \ | 443 uint32_t imm = \ |
444 static_cast<uint32_t>(i.InputOperand##width(1).ImmediateValue()); \ | 444 static_cast<uint32_t>(i.InputOperand##width(1).ImmediateValue()); \ |
445 __ asm_instr(i.OutputRegister##width(), i.InputRegister##width(0), \ | 445 __ asm_instr(i.OutputRegister##width(), i.InputRegister##width(0), \ |
446 imm % (width)); \ | 446 imm % (width)); \ |
447 } \ | 447 } \ |
448 } while (0) | 448 } while (0) |
449 | 449 |
450 | 450 |
451 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { | 451 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { |
452 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 452 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
453 int stack_slots = frame()->GetSpillSlotCount(); | 453 int spill_slots = frame()->GetSpillSlotCount(); |
454 if (descriptor->IsJSFunctionCall() || stack_slots > 0) { | 454 bool has_frame = descriptor->IsJSFunctionCall() || spill_slots > 0; |
455 __ Mov(jssp, fp); | 455 if (has_frame) { |
| 456 if (stack_param_delta != 0) { |
| 457 int total_discarded_slots = frame()->GetTotalFrameSlotCount(); |
| 458 // Leave the PC and saved frame pointer on the stack. |
| 459 total_discarded_slots -= |
| 460 StandardFrameConstants::kFixedFrameSizeFromFp / kPointerSize; |
| 461 // Discard only slots that won't be used by new parameters. |
| 462 total_discarded_slots -= stack_param_delta; |
| 463 if (total_discarded_slots > 0) { |
| 464 __ Add(jssp, jssp, Operand(total_discarded_slots * kPointerSize)); |
| 465 } |
| 466 } else { |
| 467 __ Mov(jssp, fp); |
| 468 } |
456 __ Pop(fp, lr); | 469 __ Pop(fp, lr); |
457 } | 470 } |
458 if (stack_param_delta < 0) { | |
459 int offset = -stack_param_delta * kPointerSize; | |
460 __ Add(jssp, jssp, Operand(offset)); | |
461 } | |
462 } | 471 } |
463 | 472 |
| 473 |
| 474 void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) { |
| 475 if (stack_param_delta > 0) { |
| 476 int total_discarded_slots = frame()->GetTotalFrameSlotCount(); |
| 477 // Leave the PC and saved frame pointer on the stack. |
| 478 total_discarded_slots -= |
| 479 StandardFrameConstants::kFixedFrameSizeFromFp / kPointerSize; |
| 480 // Discard only slots that won't be used by new parameters. |
| 481 total_discarded_slots -= stack_param_delta; |
| 482 if (total_discarded_slots < 0) { |
| 483 __ Sub(jssp, jssp, Operand(-total_discarded_slots * kPointerSize)); |
| 484 } |
| 485 } |
| 486 } |
| 487 |
464 | 488 |
465 // Assembles an instruction after register allocation, producing machine code. | 489 // Assembles an instruction after register allocation, producing machine code. |
466 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 490 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
467 Arm64OperandConverter i(this, instr); | 491 Arm64OperandConverter i(this, instr); |
468 InstructionCode opcode = instr->opcode(); | 492 InstructionCode opcode = instr->opcode(); |
469 switch (ArchOpcodeField::decode(opcode)) { | 493 switch (ArchOpcodeField::decode(opcode)) { |
470 case kArchCallCodeObject: { | 494 case kArchCallCodeObject: { |
471 EnsureSpaceForLazyDeopt(); | 495 EnsureSpaceForLazyDeopt(); |
472 if (instr->InputAt(0)->IsImmediate()) { | 496 if (instr->InputAt(0)->IsImmediate()) { |
473 __ Call(Handle<Code>::cast(i.InputHeapObject(0)), | 497 __ Call(Handle<Code>::cast(i.InputHeapObject(0)), |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 EnsureSpaceForLazyDeopt(); | 553 EnsureSpaceForLazyDeopt(); |
530 RecordCallPosition(instr); | 554 RecordCallPosition(instr); |
531 break; | 555 break; |
532 } | 556 } |
533 case kArchPrepareCallCFunction: | 557 case kArchPrepareCallCFunction: |
534 // We don't need kArchPrepareCallCFunction on arm64 as the instruction | 558 // We don't need kArchPrepareCallCFunction on arm64 as the instruction |
535 // selector already perform a Claim to reserve space on the stack and | 559 // selector already perform a Claim to reserve space on the stack and |
536 // guarantee correct alignment of stack pointer. | 560 // guarantee correct alignment of stack pointer. |
537 UNREACHABLE(); | 561 UNREACHABLE(); |
538 break; | 562 break; |
| 563 case kArchPrepareTailCall: |
| 564 AssemblePrepareTailCall(i.InputInt32(instr->InputCount() - 1)); |
| 565 break; |
539 case kArchCallCFunction: { | 566 case kArchCallCFunction: { |
540 int const num_parameters = MiscField::decode(instr->opcode()); | 567 int const num_parameters = MiscField::decode(instr->opcode()); |
541 if (instr->InputAt(0)->IsImmediate()) { | 568 if (instr->InputAt(0)->IsImmediate()) { |
542 ExternalReference ref = i.InputExternalReference(0); | 569 ExternalReference ref = i.InputExternalReference(0); |
543 __ CallCFunction(ref, num_parameters, 0); | 570 __ CallCFunction(ref, num_parameters, 0); |
544 } else { | 571 } else { |
545 Register func = i.InputRegister(0); | 572 Register func = i.InputRegister(0); |
546 __ CallCFunction(func, num_parameters, 0); | 573 __ CallCFunction(func, num_parameters, 0); |
547 } | 574 } |
548 break; | 575 break; |
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1520 padding_size -= kInstructionSize; | 1547 padding_size -= kInstructionSize; |
1521 } | 1548 } |
1522 } | 1549 } |
1523 } | 1550 } |
1524 | 1551 |
1525 #undef __ | 1552 #undef __ |
1526 | 1553 |
1527 } // namespace compiler | 1554 } // namespace compiler |
1528 } // namespace internal | 1555 } // namespace internal |
1529 } // namespace v8 | 1556 } // namespace v8 |
OLD | NEW |