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/arm/macro-assembler-arm.h" | 7 #include "src/arm/macro-assembler-arm.h" |
8 #include "src/assembler-inl.h" | 8 #include "src/assembler-inl.h" |
9 #include "src/compilation-info.h" | 9 #include "src/compilation-info.h" |
10 #include "src/compiler/code-generator-impl.h" | 10 #include "src/compiler/code-generator-impl.h" |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 DCHECK_EQ(LeaveCC, i.OutputSBit()); \ | 496 DCHECK_EQ(LeaveCC, i.OutputSBit()); \ |
497 } while (0) | 497 } while (0) |
498 | 498 |
499 void CodeGenerator::AssembleDeconstructFrame() { | 499 void CodeGenerator::AssembleDeconstructFrame() { |
500 __ LeaveFrame(StackFrame::MANUAL); | 500 __ LeaveFrame(StackFrame::MANUAL); |
501 unwinding_info_writer_.MarkFrameDeconstructed(__ pc_offset()); | 501 unwinding_info_writer_.MarkFrameDeconstructed(__ pc_offset()); |
502 } | 502 } |
503 | 503 |
504 void CodeGenerator::AssemblePrepareTailCall() { | 504 void CodeGenerator::AssemblePrepareTailCall() { |
505 if (frame_access_state()->has_frame()) { | 505 if (frame_access_state()->has_frame()) { |
506 if (FLAG_enable_embedded_constant_pool) { | |
507 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kConstantPoolOffset)); | |
508 } | |
509 __ ldr(lr, MemOperand(fp, StandardFrameConstants::kCallerPCOffset)); | 506 __ ldr(lr, MemOperand(fp, StandardFrameConstants::kCallerPCOffset)); |
510 __ ldr(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 507 __ ldr(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
511 } | 508 } |
512 frame_access_state()->SetFrameAccessToSP(); | 509 frame_access_state()->SetFrameAccessToSP(); |
513 } | 510 } |
514 | 511 |
515 void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg, | 512 void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg, |
516 Register scratch1, | 513 Register scratch1, |
517 Register scratch2, | 514 Register scratch2, |
518 Register scratch3) { | 515 Register scratch3) { |
(...skipping 1982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2501 | 2498 |
2502 if (saves_fp != 0) { | 2499 if (saves_fp != 0) { |
2503 // Save callee-saved FP registers. | 2500 // Save callee-saved FP registers. |
2504 STATIC_ASSERT(DwVfpRegister::kMaxNumRegisters == 32); | 2501 STATIC_ASSERT(DwVfpRegister::kMaxNumRegisters == 32); |
2505 uint32_t last = base::bits::CountLeadingZeros32(saves_fp) - 1; | 2502 uint32_t last = base::bits::CountLeadingZeros32(saves_fp) - 1; |
2506 uint32_t first = base::bits::CountTrailingZeros32(saves_fp); | 2503 uint32_t first = base::bits::CountTrailingZeros32(saves_fp); |
2507 DCHECK_EQ((last - first + 1), base::bits::CountPopulation32(saves_fp)); | 2504 DCHECK_EQ((last - first + 1), base::bits::CountPopulation32(saves_fp)); |
2508 frame->AllocateSavedCalleeRegisterSlots((last - first + 1) * | 2505 frame->AllocateSavedCalleeRegisterSlots((last - first + 1) * |
2509 (kDoubleSize / kPointerSize)); | 2506 (kDoubleSize / kPointerSize)); |
2510 } | 2507 } |
2511 const RegList saves = FLAG_enable_embedded_constant_pool | 2508 const RegList saves = descriptor->CalleeSavedRegisters(); |
2512 ? (descriptor->CalleeSavedRegisters() & ~pp.bit()) | |
2513 : descriptor->CalleeSavedRegisters(); | |
2514 if (saves != 0) { | 2509 if (saves != 0) { |
2515 // Save callee-saved registers. | 2510 // Save callee-saved registers. |
2516 frame->AllocateSavedCalleeRegisterSlots( | 2511 frame->AllocateSavedCalleeRegisterSlots( |
2517 base::bits::CountPopulation32(saves)); | 2512 base::bits::CountPopulation32(saves)); |
2518 } | 2513 } |
2519 } | 2514 } |
2520 | 2515 |
2521 void CodeGenerator::AssembleConstructFrame() { | 2516 void CodeGenerator::AssembleConstructFrame() { |
2522 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 2517 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
2523 if (frame_access_state()->has_frame()) { | 2518 if (frame_access_state()->has_frame()) { |
2524 if (descriptor->IsCFunctionCall()) { | 2519 if (descriptor->IsCFunctionCall()) { |
2525 if (FLAG_enable_embedded_constant_pool) { | 2520 __ Push(lr, fp); |
2526 __ Push(lr, fp, pp); | 2521 __ mov(fp, sp); |
2527 // Adjust FP to point to saved FP. | |
2528 __ sub(fp, sp, Operand(StandardFrameConstants::kConstantPoolOffset)); | |
2529 } else { | |
2530 __ Push(lr, fp); | |
2531 __ mov(fp, sp); | |
2532 } | |
2533 } else if (descriptor->IsJSFunctionCall()) { | 2522 } else if (descriptor->IsJSFunctionCall()) { |
2534 __ Prologue(this->info()->GeneratePreagedPrologue()); | 2523 __ Prologue(this->info()->GeneratePreagedPrologue()); |
2535 if (descriptor->PushArgumentCount()) { | 2524 if (descriptor->PushArgumentCount()) { |
2536 __ Push(kJavaScriptCallArgCountRegister); | 2525 __ Push(kJavaScriptCallArgCountRegister); |
2537 } | 2526 } |
2538 } else { | 2527 } else { |
2539 __ StubPrologue(info()->GetOutputStackFrameType()); | 2528 __ StubPrologue(info()->GetOutputStackFrameType()); |
2540 } | 2529 } |
2541 | 2530 |
2542 if (!info()->GeneratePreagedPrologue()) { | 2531 if (!info()->GeneratePreagedPrologue()) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2608 | 2597 |
2609 if (saves_fp != 0) { | 2598 if (saves_fp != 0) { |
2610 // Save callee-saved FP registers. | 2599 // Save callee-saved FP registers. |
2611 STATIC_ASSERT(DwVfpRegister::kMaxNumRegisters == 32); | 2600 STATIC_ASSERT(DwVfpRegister::kMaxNumRegisters == 32); |
2612 uint32_t last = base::bits::CountLeadingZeros32(saves_fp) - 1; | 2601 uint32_t last = base::bits::CountLeadingZeros32(saves_fp) - 1; |
2613 uint32_t first = base::bits::CountTrailingZeros32(saves_fp); | 2602 uint32_t first = base::bits::CountTrailingZeros32(saves_fp); |
2614 DCHECK_EQ((last - first + 1), base::bits::CountPopulation32(saves_fp)); | 2603 DCHECK_EQ((last - first + 1), base::bits::CountPopulation32(saves_fp)); |
2615 __ vstm(db_w, sp, DwVfpRegister::from_code(first), | 2604 __ vstm(db_w, sp, DwVfpRegister::from_code(first), |
2616 DwVfpRegister::from_code(last)); | 2605 DwVfpRegister::from_code(last)); |
2617 } | 2606 } |
2618 const RegList saves = FLAG_enable_embedded_constant_pool | 2607 const RegList saves = descriptor->CalleeSavedRegisters(); |
2619 ? (descriptor->CalleeSavedRegisters() & ~pp.bit()) | |
2620 : descriptor->CalleeSavedRegisters(); | |
2621 if (saves != 0) { | 2608 if (saves != 0) { |
2622 // Save callee-saved registers. | 2609 // Save callee-saved registers. |
2623 __ stm(db_w, sp, saves); | 2610 __ stm(db_w, sp, saves); |
2624 } | 2611 } |
2625 } | 2612 } |
2626 | 2613 |
2627 void CodeGenerator::AssembleReturn(InstructionOperand* pop) { | 2614 void CodeGenerator::AssembleReturn(InstructionOperand* pop) { |
2628 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 2615 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
2629 int pop_count = static_cast<int>(descriptor->StackParameterCount()); | 2616 int pop_count = static_cast<int>(descriptor->StackParameterCount()); |
2630 | 2617 |
2631 // Restore registers. | 2618 // Restore registers. |
2632 const RegList saves = FLAG_enable_embedded_constant_pool | 2619 const RegList saves = descriptor->CalleeSavedRegisters(); |
2633 ? (descriptor->CalleeSavedRegisters() & ~pp.bit()) | |
2634 : descriptor->CalleeSavedRegisters(); | |
2635 if (saves != 0) { | 2620 if (saves != 0) { |
2636 __ ldm(ia_w, sp, saves); | 2621 __ ldm(ia_w, sp, saves); |
2637 } | 2622 } |
2638 | 2623 |
2639 // Restore FP registers. | 2624 // Restore FP registers. |
2640 const RegList saves_fp = descriptor->CalleeSavedFPRegisters(); | 2625 const RegList saves_fp = descriptor->CalleeSavedFPRegisters(); |
2641 if (saves_fp != 0) { | 2626 if (saves_fp != 0) { |
2642 STATIC_ASSERT(DwVfpRegister::kMaxNumRegisters == 32); | 2627 STATIC_ASSERT(DwVfpRegister::kMaxNumRegisters == 32); |
2643 uint32_t last = base::bits::CountLeadingZeros32(saves_fp) - 1; | 2628 uint32_t last = base::bits::CountLeadingZeros32(saves_fp) - 1; |
2644 uint32_t first = base::bits::CountTrailingZeros32(saves_fp); | 2629 uint32_t first = base::bits::CountTrailingZeros32(saves_fp); |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2986 padding_size -= v8::internal::Assembler::kInstrSize; | 2971 padding_size -= v8::internal::Assembler::kInstrSize; |
2987 } | 2972 } |
2988 } | 2973 } |
2989 } | 2974 } |
2990 | 2975 |
2991 #undef __ | 2976 #undef __ |
2992 | 2977 |
2993 } // namespace compiler | 2978 } // namespace compiler |
2994 } // namespace internal | 2979 } // namespace internal |
2995 } // namespace v8 | 2980 } // namespace v8 |
OLD | NEW |