| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/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" | |
| 11 #include "src/ia32/assembler-ia32.h" | 10 #include "src/ia32/assembler-ia32.h" |
| 12 #include "src/ia32/macro-assembler-ia32.h" | 11 #include "src/ia32/macro-assembler-ia32.h" |
| 13 #include "src/scopes.h" | 12 #include "src/scopes.h" |
| 14 | 13 |
| 15 namespace v8 { | 14 namespace v8 { |
| 16 namespace internal { | 15 namespace internal { |
| 17 namespace compiler { | 16 namespace compiler { |
| 18 | 17 |
| 19 #define __ masm()-> | 18 #define __ masm()-> |
| 20 | 19 |
| (...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 // | FP | RET | args | caller frame | | 966 // | FP | RET | args | caller frame | |
| 968 // ^ esp,ebp | 967 // ^ esp,ebp |
| 969 | 968 |
| 970 // --{ pop ebp }---------------------------------------------------------------- | 969 // --{ pop ebp }---------------------------------------------------------------- |
| 971 // | RET | args | caller frame | | 970 // | RET | args | caller frame | |
| 972 // ^ esp ^ ebp | 971 // ^ esp ^ ebp |
| 973 | 972 |
| 974 | 973 |
| 975 void CodeGenerator::AssemblePrologue() { | 974 void CodeGenerator::AssemblePrologue() { |
| 976 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 975 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
| 977 Frame* frame = this->frame(); | 976 int stack_slots = frame()->GetSpillSlotCount(); |
| 978 int stack_slots = frame->GetSpillSlotCount(); | |
| 979 if (descriptor->kind() == CallDescriptor::kCallAddress) { | 977 if (descriptor->kind() == CallDescriptor::kCallAddress) { |
| 980 // Assemble a prologue similar the to cdecl calling convention. | 978 // Assemble a prologue similar the to cdecl calling convention. |
| 981 __ push(ebp); | 979 __ push(ebp); |
| 982 __ mov(ebp, esp); | 980 __ mov(ebp, esp); |
| 983 const RegList saves = descriptor->CalleeSavedRegisters(); | 981 const RegList saves = descriptor->CalleeSavedRegisters(); |
| 984 if (saves != 0) { // Save callee-saved registers. | 982 if (saves != 0) { // Save callee-saved registers. |
| 985 int register_save_area_size = 0; | 983 int register_save_area_size = 0; |
| 986 for (int i = Register::kNumRegisters - 1; i >= 0; i--) { | 984 for (int i = Register::kNumRegisters - 1; i >= 0; i--) { |
| 987 if (!((1 << i) & saves)) continue; | 985 if (!((1 << i) & saves)) continue; |
| 988 __ push(Register::from_code(i)); | 986 __ push(Register::from_code(i)); |
| 989 register_save_area_size += kPointerSize; | 987 register_save_area_size += kPointerSize; |
| 990 } | 988 } |
| 991 frame->SetRegisterSaveAreaSize(register_save_area_size); | 989 frame()->SetRegisterSaveAreaSize(register_save_area_size); |
| 992 } | 990 } |
| 993 } else if (descriptor->IsJSFunctionCall()) { | 991 } else if (descriptor->IsJSFunctionCall()) { |
| 994 // TODO(turbofan): this prologue is redundant with OSR, but needed for | 992 // TODO(turbofan): this prologue is redundant with OSR, but needed for |
| 995 // code aging. | 993 // code aging. |
| 996 CompilationInfo* info = this->info(); | 994 CompilationInfo* info = this->info(); |
| 997 __ Prologue(info->IsCodePreAgingActive()); | 995 __ Prologue(info->IsCodePreAgingActive()); |
| 998 frame->SetRegisterSaveAreaSize( | 996 frame()->SetRegisterSaveAreaSize( |
| 999 StandardFrameConstants::kFixedFrameSizeFromFp); | 997 StandardFrameConstants::kFixedFrameSizeFromFp); |
| 1000 } else { | 998 } else { |
| 1001 __ StubPrologue(); | 999 __ StubPrologue(); |
| 1002 frame->SetRegisterSaveAreaSize( | 1000 frame()->SetRegisterSaveAreaSize( |
| 1003 StandardFrameConstants::kFixedFrameSizeFromFp); | 1001 StandardFrameConstants::kFixedFrameSizeFromFp); |
| 1004 } | 1002 } |
| 1005 | 1003 |
| 1006 if (info()->is_osr()) { | 1004 if (info()->is_osr()) { |
| 1007 // TurboFan OSR-compiled functions cannot be entered directly. | 1005 // TurboFan OSR-compiled functions cannot be entered directly. |
| 1008 __ Abort(kShouldNotDirectlyEnterOsrFunction); | 1006 __ Abort(kShouldNotDirectlyEnterOsrFunction); |
| 1009 | 1007 |
| 1010 // Unoptimized code jumps directly to this entrypoint while the unoptimized | 1008 // Unoptimized code jumps directly to this entrypoint while the unoptimized |
| 1011 // frame is still on the stack. Optimized code uses OSR values directly from | 1009 // frame is still on the stack. Optimized code uses OSR values directly from |
| 1012 // the unoptimized frame. Thus, all that needs to be done is to allocate the | 1010 // the unoptimized frame. Thus, all that needs to be done is to allocate the |
| 1013 // remaining stack slots. | 1011 // remaining stack slots. |
| 1014 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); | 1012 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); |
| 1015 osr_pc_offset_ = __ pc_offset(); | 1013 osr_pc_offset_ = __ pc_offset(); |
| 1016 int unoptimized_slots = | 1014 DCHECK(stack_slots >= frame()->GetOsrStackSlotCount()); |
| 1017 static_cast<int>(OsrHelper(info()).UnoptimizedFrameSlots()); | 1015 stack_slots -= frame()->GetOsrStackSlotCount(); |
| 1018 DCHECK(stack_slots >= unoptimized_slots); | |
| 1019 stack_slots -= unoptimized_slots; | |
| 1020 } | 1016 } |
| 1021 | 1017 |
| 1022 if (stack_slots > 0) { | 1018 if (stack_slots > 0) { |
| 1023 // Allocate the stack slots used by this frame. | 1019 // Allocate the stack slots used by this frame. |
| 1024 __ sub(esp, Immediate(stack_slots * kPointerSize)); | 1020 __ sub(esp, Immediate(stack_slots * kPointerSize)); |
| 1025 } | 1021 } |
| 1026 } | 1022 } |
| 1027 | 1023 |
| 1028 | 1024 |
| 1029 void CodeGenerator::AssembleReturn() { | 1025 void CodeGenerator::AssembleReturn() { |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 } | 1229 } |
| 1234 } | 1230 } |
| 1235 MarkLazyDeoptSite(); | 1231 MarkLazyDeoptSite(); |
| 1236 } | 1232 } |
| 1237 | 1233 |
| 1238 #undef __ | 1234 #undef __ |
| 1239 | 1235 |
| 1240 } // namespace compiler | 1236 } // namespace compiler |
| 1241 } // namespace internal | 1237 } // namespace internal |
| 1242 } // namespace v8 | 1238 } // namespace v8 |
| OLD | NEW |