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/ast/scopes.h" | 5 #include "src/ast/scopes.h" |
6 #include "src/compiler/code-generator.h" | 6 #include "src/compiler/code-generator.h" |
7 #include "src/compiler/code-generator-impl.h" | 7 #include "src/compiler/code-generator-impl.h" |
8 #include "src/compiler/gap-resolver.h" | 8 #include "src/compiler/gap-resolver.h" |
9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
10 #include "src/compiler/osr.h" | 10 #include "src/compiler/osr.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 public: | 217 public: |
218 OutOfLineRecordWrite(CodeGenerator* gen, Register object, Register index, | 218 OutOfLineRecordWrite(CodeGenerator* gen, Register object, Register index, |
219 Register value, Register scratch0, Register scratch1, | 219 Register value, Register scratch0, Register scratch1, |
220 RecordWriteMode mode) | 220 RecordWriteMode mode) |
221 : OutOfLineCode(gen), | 221 : OutOfLineCode(gen), |
222 object_(object), | 222 object_(object), |
223 index_(index), | 223 index_(index), |
224 value_(value), | 224 value_(value), |
225 scratch0_(scratch0), | 225 scratch0_(scratch0), |
226 scratch1_(scratch1), | 226 scratch1_(scratch1), |
227 mode_(mode) {} | 227 mode_(mode), |
| 228 must_save_lr_(!gen->frame_access_state()->has_frame()) {} |
228 | 229 |
229 void Generate() final { | 230 void Generate() final { |
230 if (mode_ > RecordWriteMode::kValueIsPointer) { | 231 if (mode_ > RecordWriteMode::kValueIsPointer) { |
231 __ JumpIfSmi(value_, exit()); | 232 __ JumpIfSmi(value_, exit()); |
232 } | 233 } |
233 __ CheckPageFlag(value_, scratch0_, | 234 __ CheckPageFlag(value_, scratch0_, |
234 MemoryChunk::kPointersToHereAreInterestingMask, eq, | 235 MemoryChunk::kPointersToHereAreInterestingMask, eq, |
235 exit()); | 236 exit()); |
236 RememberedSetAction const remembered_set_action = | 237 RememberedSetAction const remembered_set_action = |
237 mode_ > RecordWriteMode::kValueIsMap ? EMIT_REMEMBERED_SET | 238 mode_ > RecordWriteMode::kValueIsMap ? EMIT_REMEMBERED_SET |
238 : OMIT_REMEMBERED_SET; | 239 : OMIT_REMEMBERED_SET; |
239 SaveFPRegsMode const save_fp_mode = | 240 SaveFPRegsMode const save_fp_mode = |
240 frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs; | 241 frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs; |
241 if (!frame()->needs_frame()) { | 242 if (must_save_lr_) { |
242 // We need to save and restore ra if the frame was elided. | 243 // We need to save and restore ra if the frame was elided. |
243 __ Push(ra); | 244 __ Push(ra); |
244 } | 245 } |
245 RecordWriteStub stub(isolate(), object_, scratch0_, scratch1_, | 246 RecordWriteStub stub(isolate(), object_, scratch0_, scratch1_, |
246 remembered_set_action, save_fp_mode); | 247 remembered_set_action, save_fp_mode); |
247 __ Addu(scratch1_, object_, index_); | 248 __ Addu(scratch1_, object_, index_); |
248 __ CallStub(&stub); | 249 __ CallStub(&stub); |
249 if (!frame()->needs_frame()) { | 250 if (must_save_lr_) { |
250 __ Pop(ra); | 251 __ Pop(ra); |
251 } | 252 } |
252 } | 253 } |
253 | 254 |
254 private: | 255 private: |
255 Register const object_; | 256 Register const object_; |
256 Register const index_; | 257 Register const index_; |
257 Register const value_; | 258 Register const value_; |
258 Register const scratch0_; | 259 Register const scratch0_; |
259 Register const scratch1_; | 260 Register const scratch1_; |
260 RecordWriteMode const mode_; | 261 RecordWriteMode const mode_; |
| 262 bool must_save_lr_; |
261 }; | 263 }; |
262 | 264 |
263 | 265 |
264 Condition FlagsConditionToConditionCmp(FlagsCondition condition) { | 266 Condition FlagsConditionToConditionCmp(FlagsCondition condition) { |
265 switch (condition) { | 267 switch (condition) { |
266 case kEqual: | 268 case kEqual: |
267 return eq; | 269 return eq; |
268 case kNotEqual: | 270 case kNotEqual: |
269 return ne; | 271 return ne; |
270 case kSignedLessThan: | 272 case kSignedLessThan: |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 Operand(kFloat32ExponentBias + kFloat32MantissaBits)); \ | 465 Operand(kFloat32ExponentBias + kFloat32MantissaBits)); \ |
464 __ mov_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); \ | 466 __ mov_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); \ |
465 __ mode##_w_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); \ | 467 __ mode##_w_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); \ |
466 __ mfc1(at, i.OutputDoubleRegister()); \ | 468 __ mfc1(at, i.OutputDoubleRegister()); \ |
467 __ Branch(USE_DELAY_SLOT, ool->entry(), eq, at, Operand(zero_reg)); \ | 469 __ Branch(USE_DELAY_SLOT, ool->entry(), eq, at, Operand(zero_reg)); \ |
468 __ cvt_s_w(i.OutputDoubleRegister(), i.OutputDoubleRegister()); \ | 470 __ cvt_s_w(i.OutputDoubleRegister(), i.OutputDoubleRegister()); \ |
469 __ bind(ool->exit()); \ | 471 __ bind(ool->exit()); \ |
470 __ bind(&done); \ | 472 __ bind(&done); \ |
471 } | 473 } |
472 | 474 |
| 475 void CodeGenerator::AssembleDeconstructFrame() { |
| 476 __ mov(sp, fp); |
| 477 __ Pop(ra, fp); |
| 478 } |
| 479 |
| 480 void CodeGenerator::AssembleSetupStackPointer() {} |
| 481 |
473 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { | 482 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { |
474 int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta); | 483 int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta); |
475 if (sp_slot_delta > 0) { | 484 if (sp_slot_delta > 0) { |
476 __ addiu(sp, sp, sp_slot_delta * kPointerSize); | 485 __ addiu(sp, sp, sp_slot_delta * kPointerSize); |
477 } | 486 } |
478 frame_access_state()->SetFrameAccessToDefault(); | 487 frame_access_state()->SetFrameAccessToDefault(); |
479 } | 488 } |
480 | 489 |
481 | 490 |
482 void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) { | 491 void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) { |
483 int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta); | 492 int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta); |
484 if (sp_slot_delta < 0) { | 493 if (sp_slot_delta < 0) { |
485 __ Subu(sp, sp, Operand(-sp_slot_delta * kPointerSize)); | 494 __ Subu(sp, sp, Operand(-sp_slot_delta * kPointerSize)); |
486 frame_access_state()->IncreaseSPDelta(-sp_slot_delta); | 495 frame_access_state()->IncreaseSPDelta(-sp_slot_delta); |
487 } | 496 } |
488 if (frame()->needs_frame()) { | 497 if (frame_access_state()->has_frame()) { |
489 __ lw(ra, MemOperand(fp, StandardFrameConstants::kCallerPCOffset)); | 498 __ lw(ra, MemOperand(fp, StandardFrameConstants::kCallerPCOffset)); |
490 __ lw(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 499 __ lw(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
491 } | 500 } |
492 frame_access_state()->SetFrameAccessToSP(); | 501 frame_access_state()->SetFrameAccessToSP(); |
493 } | 502 } |
494 | 503 |
495 void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg, | 504 void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg, |
496 Register scratch1, | 505 Register scratch1, |
497 Register scratch2, | 506 Register scratch2, |
498 Register scratch3) { | 507 Register scratch3) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 case kArchRet: | 647 case kArchRet: |
639 AssembleReturn(); | 648 AssembleReturn(); |
640 break; | 649 break; |
641 case kArchStackPointer: | 650 case kArchStackPointer: |
642 __ mov(i.OutputRegister(), sp); | 651 __ mov(i.OutputRegister(), sp); |
643 break; | 652 break; |
644 case kArchFramePointer: | 653 case kArchFramePointer: |
645 __ mov(i.OutputRegister(), fp); | 654 __ mov(i.OutputRegister(), fp); |
646 break; | 655 break; |
647 case kArchParentFramePointer: | 656 case kArchParentFramePointer: |
648 if (frame_access_state()->frame()->needs_frame()) { | 657 if (frame_access_state()->has_frame()) { |
649 __ lw(i.OutputRegister(), MemOperand(fp, 0)); | 658 __ lw(i.OutputRegister(), MemOperand(fp, 0)); |
650 } else { | 659 } else { |
651 __ mov(i.OutputRegister(), fp); | 660 __ mov(i.OutputRegister(), fp); |
652 } | 661 } |
653 break; | 662 break; |
654 case kArchTruncateDoubleToI: | 663 case kArchTruncateDoubleToI: |
655 __ TruncateDoubleToI(i.OutputRegister(), i.InputDoubleRegister(0)); | 664 __ TruncateDoubleToI(i.OutputRegister(), i.InputDoubleRegister(0)); |
656 break; | 665 break; |
657 case kArchStoreWithWriteBarrier: { | 666 case kArchStoreWithWriteBarrier: { |
658 RecordWriteMode mode = | 667 RecordWriteMode mode = |
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1557 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { | 1566 int deoptimization_id, Deoptimizer::BailoutType bailout_type) { |
1558 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( | 1567 Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( |
1559 isolate(), deoptimization_id, bailout_type); | 1568 isolate(), deoptimization_id, bailout_type); |
1560 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); | 1569 __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); |
1561 } | 1570 } |
1562 | 1571 |
1563 | 1572 |
1564 void CodeGenerator::AssemblePrologue() { | 1573 void CodeGenerator::AssemblePrologue() { |
1565 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1574 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1566 int stack_shrink_slots = frame()->GetSpillSlotCount(); | 1575 int stack_shrink_slots = frame()->GetSpillSlotCount(); |
1567 if (frame()->needs_frame()) { | 1576 if (frame_access_state()->has_frame()) { |
1568 if (descriptor->IsCFunctionCall()) { | 1577 if (descriptor->IsCFunctionCall()) { |
1569 __ Push(ra, fp); | 1578 __ Push(ra, fp); |
1570 __ mov(fp, sp); | 1579 __ mov(fp, sp); |
1571 } else if (descriptor->IsJSFunctionCall()) { | 1580 } else if (descriptor->IsJSFunctionCall()) { |
1572 __ Prologue(this->info()->GeneratePreagedPrologue()); | 1581 __ Prologue(this->info()->GeneratePreagedPrologue()); |
1573 } else { | 1582 } else { |
1574 __ StubPrologue(info()->GetOutputStackFrameType()); | 1583 __ StubPrologue(info()->GetOutputStackFrameType()); |
1575 } | 1584 } |
1576 } else { | |
1577 frame()->SetElidedFrameSizeInSlots(0); | |
1578 } | 1585 } |
1579 frame_access_state()->SetFrameAccessToDefault(); | |
1580 | 1586 |
1581 if (info()->is_osr()) { | 1587 if (info()->is_osr()) { |
1582 // TurboFan OSR-compiled functions cannot be entered directly. | 1588 // TurboFan OSR-compiled functions cannot be entered directly. |
1583 __ Abort(kShouldNotDirectlyEnterOsrFunction); | 1589 __ Abort(kShouldNotDirectlyEnterOsrFunction); |
1584 | 1590 |
1585 // Unoptimized code jumps directly to this entrypoint while the unoptimized | 1591 // Unoptimized code jumps directly to this entrypoint while the unoptimized |
1586 // frame is still on the stack. Optimized code uses OSR values directly from | 1592 // frame is still on the stack. Optimized code uses OSR values directly from |
1587 // the unoptimized frame. Thus, all that needs to be done is to allocate the | 1593 // the unoptimized frame. Thus, all that needs to be done is to allocate the |
1588 // remaining stack slots. | 1594 // remaining stack slots. |
1589 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); | 1595 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1631 __ MultiPop(saves); | 1637 __ MultiPop(saves); |
1632 } | 1638 } |
1633 | 1639 |
1634 // Restore FPU registers. | 1640 // Restore FPU registers. |
1635 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); | 1641 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); |
1636 if (saves_fpu != 0) { | 1642 if (saves_fpu != 0) { |
1637 __ MultiPopFPU(saves_fpu); | 1643 __ MultiPopFPU(saves_fpu); |
1638 } | 1644 } |
1639 | 1645 |
1640 if (descriptor->IsCFunctionCall()) { | 1646 if (descriptor->IsCFunctionCall()) { |
1641 __ mov(sp, fp); | 1647 AssembleDeconstructFrame(); |
1642 __ Pop(ra, fp); | 1648 } else if (frame_access_state()->has_frame()) { |
1643 } else if (frame()->needs_frame()) { | |
1644 // Canonicalize JSFunction return sites for now. | 1649 // Canonicalize JSFunction return sites for now. |
1645 if (return_label_.is_bound()) { | 1650 if (return_label_.is_bound()) { |
1646 __ Branch(&return_label_); | 1651 __ Branch(&return_label_); |
1647 return; | 1652 return; |
1648 } else { | 1653 } else { |
1649 __ bind(&return_label_); | 1654 __ bind(&return_label_); |
1650 __ mov(sp, fp); | 1655 AssembleDeconstructFrame(); |
1651 __ Pop(ra, fp); | |
1652 } | 1656 } |
1653 } | 1657 } |
1654 if (pop_count != 0) { | 1658 if (pop_count != 0) { |
1655 __ DropAndRet(pop_count); | 1659 __ DropAndRet(pop_count); |
1656 } else { | 1660 } else { |
1657 __ Ret(); | 1661 __ Ret(); |
1658 } | 1662 } |
1659 } | 1663 } |
1660 | 1664 |
1661 | 1665 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1865 padding_size -= v8::internal::Assembler::kInstrSize; | 1869 padding_size -= v8::internal::Assembler::kInstrSize; |
1866 } | 1870 } |
1867 } | 1871 } |
1868 } | 1872 } |
1869 | 1873 |
1870 #undef __ | 1874 #undef __ |
1871 | 1875 |
1872 } // namespace compiler | 1876 } // namespace compiler |
1873 } // namespace internal | 1877 } // namespace internal |
1874 } // namespace v8 | 1878 } // namespace v8 |
OLD | NEW |