| 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 #include "src/compiler/code-generator-impl.h" | 6 #include "src/compiler/code-generator-impl.h" |
| 7 #include "src/compiler/gap-resolver.h" | 7 #include "src/compiler/gap-resolver.h" |
| 8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
| 9 #include "src/compiler/osr.h" | 9 #include "src/compiler/osr.h" |
| 10 #include "src/mips/macro-assembler-mips.h" | 10 #include "src/mips/macro-assembler-mips.h" |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 __ or_(at, at, kScratchReg2); \ | 448 __ or_(at, at, kScratchReg2); \ |
| 449 __ Branch(USE_DELAY_SLOT, ool->entry(), eq, at, Operand(zero_reg)); \ | 449 __ Branch(USE_DELAY_SLOT, ool->entry(), eq, at, Operand(zero_reg)); \ |
| 450 __ cvt_d_l(i.OutputDoubleRegister(), i.OutputDoubleRegister()); \ | 450 __ cvt_d_l(i.OutputDoubleRegister(), i.OutputDoubleRegister()); \ |
| 451 __ bind(ool->exit()); \ | 451 __ bind(ool->exit()); \ |
| 452 __ bind(&done); \ | 452 __ bind(&done); \ |
| 453 } while (0) | 453 } while (0) |
| 454 | 454 |
| 455 | 455 |
| 456 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { | 456 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { |
| 457 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 457 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
| 458 int stack_slots = frame()->GetSpillSlotCount(); | 458 int spill_slots = frame()->GetSpillSlotCount(); |
| 459 int stack_pointer_delta = 0; | 459 bool has_frame = descriptor->IsJSFunctionCall() || spill_slots > 0; |
| 460 if (descriptor->IsJSFunctionCall() || stack_slots > 0) { | 460 if (has_frame) { |
| 461 __ mov(sp, fp); | 461 if (stack_param_delta != 0) { |
| 462 __ lw(fp, MemOperand(sp, 0 * kPointerSize)); | 462 int total_discarded_slots = frame()->GetTotalFrameSlotCount(); |
| 463 __ lw(ra, MemOperand(sp, 1 * kPointerSize)); | 463 // Leave the PC and saved frame pointer on the stack. |
| 464 stack_pointer_delta = 2 * kPointerSize; | 464 total_discarded_slots -= |
| 465 } | 465 StandardFrameConstants::kFixedFrameSizeFromFp / kPointerSize; |
| 466 if (stack_param_delta < 0) { | 466 // Discard only slots that won't be used by new parameters. |
| 467 stack_pointer_delta += -stack_param_delta * kPointerSize; | 467 total_discarded_slots -= stack_param_delta; |
| 468 } | 468 if (total_discarded_slots > 0) { |
| 469 if (stack_pointer_delta != 0) { | 469 __ addiu(sp, sp, total_discarded_slots * kPointerSize); |
| 470 __ addiu(sp, sp, stack_pointer_delta); | 470 } |
| 471 } else { |
| 472 __ mov(sp, fp); |
| 473 } |
| 474 __ Pop(ra, fp); |
| 471 } | 475 } |
| 472 } | 476 } |
| 473 | 477 |
| 478 |
| 479 void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) { |
| 480 if (stack_param_delta > 0) { |
| 481 int total_discarded_slots = frame()->GetTotalFrameSlotCount(); |
| 482 // Leave the PC and saved frame pointer on the stack. |
| 483 total_discarded_slots -= |
| 484 StandardFrameConstants::kFixedFrameSizeFromFp / kPointerSize; |
| 485 // Discard only slots that won't be used by new parameters. |
| 486 total_discarded_slots -= stack_param_delta; |
| 487 if (total_discarded_slots < 0) { |
| 488 __ Subu(sp, sp, Operand(-total_discarded_slots * kPointerSize)); |
| 489 } |
| 490 } |
| 491 } |
| 492 |
| 474 | 493 |
| 475 // Assembles an instruction after register allocation, producing machine code. | 494 // Assembles an instruction after register allocation, producing machine code. |
| 476 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 495 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
| 477 MipsOperandConverter i(this, instr); | 496 MipsOperandConverter i(this, instr); |
| 478 InstructionCode opcode = instr->opcode(); | 497 InstructionCode opcode = instr->opcode(); |
| 479 | 498 |
| 480 switch (ArchOpcodeField::decode(opcode)) { | 499 switch (ArchOpcodeField::decode(opcode)) { |
| 481 case kArchCallCodeObject: { | 500 case kArchCallCodeObject: { |
| 482 EnsureSpaceForLazyDeopt(); | 501 EnsureSpaceForLazyDeopt(); |
| 483 if (instr->InputAt(0)->IsImmediate()) { | 502 if (instr->InputAt(0)->IsImmediate()) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 case kArchLazyBailout: { | 552 case kArchLazyBailout: { |
| 534 EnsureSpaceForLazyDeopt(); | 553 EnsureSpaceForLazyDeopt(); |
| 535 RecordCallPosition(instr); | 554 RecordCallPosition(instr); |
| 536 break; | 555 break; |
| 537 } | 556 } |
| 538 case kArchPrepareCallCFunction: { | 557 case kArchPrepareCallCFunction: { |
| 539 int const num_parameters = MiscField::decode(instr->opcode()); | 558 int const num_parameters = MiscField::decode(instr->opcode()); |
| 540 __ PrepareCallCFunction(num_parameters, kScratchReg); | 559 __ PrepareCallCFunction(num_parameters, kScratchReg); |
| 541 break; | 560 break; |
| 542 } | 561 } |
| 562 case kArchPrepareTailCall: |
| 563 AssemblePrepareTailCall(i.InputInt32(instr->InputCount() - 1)); |
| 564 break; |
| 543 case kArchCallCFunction: { | 565 case kArchCallCFunction: { |
| 544 int const num_parameters = MiscField::decode(instr->opcode()); | 566 int const num_parameters = MiscField::decode(instr->opcode()); |
| 545 if (instr->InputAt(0)->IsImmediate()) { | 567 if (instr->InputAt(0)->IsImmediate()) { |
| 546 ExternalReference ref = i.InputExternalReference(0); | 568 ExternalReference ref = i.InputExternalReference(0); |
| 547 __ CallCFunction(ref, num_parameters); | 569 __ CallCFunction(ref, num_parameters); |
| 548 } else { | 570 } else { |
| 549 Register func = i.InputRegister(0); | 571 Register func = i.InputRegister(0); |
| 550 __ CallCFunction(func, num_parameters); | 572 __ CallCFunction(func, num_parameters); |
| 551 } | 573 } |
| 552 break; | 574 break; |
| (...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1591 padding_size -= v8::internal::Assembler::kInstrSize; | 1613 padding_size -= v8::internal::Assembler::kInstrSize; |
| 1592 } | 1614 } |
| 1593 } | 1615 } |
| 1594 } | 1616 } |
| 1595 | 1617 |
| 1596 #undef __ | 1618 #undef __ |
| 1597 | 1619 |
| 1598 } // namespace compiler | 1620 } // namespace compiler |
| 1599 } // namespace internal | 1621 } // namespace internal |
| 1600 } // namespace v8 | 1622 } // namespace v8 |
| OLD | NEW |