Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: src/compiler/ia32/code-generator-ia32.cc

Issue 933603002: Build stack frames for stubs only when needed. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: MIPS ports Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/arm64/code-generator-arm64.cc ('k') | src/compiler/mips/code-generator-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ia32/assembler-ia32.h" 10 #include "src/ia32/assembler-ia32.h"
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 } 1003 }
1004 frame()->SetRegisterSaveAreaSize(register_save_area_size); 1004 frame()->SetRegisterSaveAreaSize(register_save_area_size);
1005 } 1005 }
1006 } else if (descriptor->IsJSFunctionCall()) { 1006 } else if (descriptor->IsJSFunctionCall()) {
1007 // TODO(turbofan): this prologue is redundant with OSR, but needed for 1007 // TODO(turbofan): this prologue is redundant with OSR, but needed for
1008 // code aging. 1008 // code aging.
1009 CompilationInfo* info = this->info(); 1009 CompilationInfo* info = this->info();
1010 __ Prologue(info->IsCodePreAgingActive()); 1010 __ Prologue(info->IsCodePreAgingActive());
1011 frame()->SetRegisterSaveAreaSize( 1011 frame()->SetRegisterSaveAreaSize(
1012 StandardFrameConstants::kFixedFrameSizeFromFp); 1012 StandardFrameConstants::kFixedFrameSizeFromFp);
1013 } else { 1013 } else if (stack_slots > 0) {
1014 __ StubPrologue(); 1014 __ StubPrologue();
1015 frame()->SetRegisterSaveAreaSize( 1015 frame()->SetRegisterSaveAreaSize(
1016 StandardFrameConstants::kFixedFrameSizeFromFp); 1016 StandardFrameConstants::kFixedFrameSizeFromFp);
1017 } 1017 }
1018 1018
1019 if (info()->is_osr()) { 1019 if (info()->is_osr()) {
1020 // TurboFan OSR-compiled functions cannot be entered directly. 1020 // TurboFan OSR-compiled functions cannot be entered directly.
1021 __ Abort(kShouldNotDirectlyEnterOsrFunction); 1021 __ Abort(kShouldNotDirectlyEnterOsrFunction);
1022 1022
1023 // Unoptimized code jumps directly to this entrypoint while the unoptimized 1023 // Unoptimized code jumps directly to this entrypoint while the unoptimized
1024 // frame is still on the stack. Optimized code uses OSR values directly from 1024 // frame is still on the stack. Optimized code uses OSR values directly from
1025 // the unoptimized frame. Thus, all that needs to be done is to allocate the 1025 // the unoptimized frame. Thus, all that needs to be done is to allocate the
1026 // remaining stack slots. 1026 // remaining stack slots.
1027 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); 1027 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --");
1028 osr_pc_offset_ = __ pc_offset(); 1028 osr_pc_offset_ = __ pc_offset();
1029 DCHECK(stack_slots >= frame()->GetOsrStackSlotCount()); 1029 DCHECK(stack_slots >= frame()->GetOsrStackSlotCount());
1030 stack_slots -= frame()->GetOsrStackSlotCount(); 1030 stack_slots -= frame()->GetOsrStackSlotCount();
1031 } 1031 }
1032 1032
1033 if (stack_slots > 0) { 1033 if (stack_slots > 0) {
1034 // Allocate the stack slots used by this frame. 1034 // Allocate the stack slots used by this frame.
1035 __ sub(esp, Immediate(stack_slots * kPointerSize)); 1035 __ sub(esp, Immediate(stack_slots * kPointerSize));
1036 } 1036 }
1037 } 1037 }
1038 1038
1039 1039
1040 void CodeGenerator::AssembleReturn() { 1040 void CodeGenerator::AssembleReturn() {
1041 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); 1041 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
1042 int stack_slots = frame()->GetSpillSlotCount();
1042 if (descriptor->kind() == CallDescriptor::kCallAddress) { 1043 if (descriptor->kind() == CallDescriptor::kCallAddress) {
1043 const RegList saves = descriptor->CalleeSavedRegisters(); 1044 const RegList saves = descriptor->CalleeSavedRegisters();
1044 if (frame()->GetRegisterSaveAreaSize() > 0) { 1045 if (frame()->GetRegisterSaveAreaSize() > 0) {
1045 // Remove this frame's spill slots first. 1046 // Remove this frame's spill slots first.
1046 int stack_slots = frame()->GetSpillSlotCount();
1047 if (stack_slots > 0) { 1047 if (stack_slots > 0) {
1048 __ add(esp, Immediate(stack_slots * kPointerSize)); 1048 __ add(esp, Immediate(stack_slots * kPointerSize));
1049 } 1049 }
1050 // Restore registers. 1050 // Restore registers.
1051 if (saves != 0) { 1051 if (saves != 0) {
1052 for (int i = 0; i < Register::kNumRegisters; i++) { 1052 for (int i = 0; i < Register::kNumRegisters; i++) {
1053 if (!((1 << i) & saves)) continue; 1053 if (!((1 << i) & saves)) continue;
1054 __ pop(Register::from_code(i)); 1054 __ pop(Register::from_code(i));
1055 } 1055 }
1056 } 1056 }
1057 __ pop(ebp); // Pop caller's frame pointer. 1057 __ pop(ebp); // Pop caller's frame pointer.
1058 __ ret(0); 1058 __ ret(0);
1059 } else { 1059 } else {
1060 // No saved registers. 1060 // No saved registers.
1061 __ mov(esp, ebp); // Move stack pointer back to frame pointer. 1061 __ mov(esp, ebp); // Move stack pointer back to frame pointer.
1062 __ pop(ebp); // Pop caller's frame pointer. 1062 __ pop(ebp); // Pop caller's frame pointer.
1063 __ ret(0); 1063 __ ret(0);
1064 } 1064 }
1065 } else { 1065 } else if (descriptor->IsJSFunctionCall() || stack_slots > 0) {
1066 __ mov(esp, ebp); // Move stack pointer back to frame pointer. 1066 __ mov(esp, ebp); // Move stack pointer back to frame pointer.
1067 __ pop(ebp); // Pop caller's frame pointer. 1067 __ pop(ebp); // Pop caller's frame pointer.
1068 int pop_count = descriptor->IsJSFunctionCall() 1068 int pop_count = descriptor->IsJSFunctionCall()
1069 ? static_cast<int>(descriptor->JSParameterCount()) 1069 ? static_cast<int>(descriptor->JSParameterCount())
1070 : 0; 1070 : 0;
1071 __ ret(pop_count * kPointerSize); 1071 __ ret(pop_count * kPointerSize);
1072 } else {
1073 __ ret(0);
1072 } 1074 }
1073 } 1075 }
1074 1076
1075 1077
1076 void CodeGenerator::AssembleMove(InstructionOperand* source, 1078 void CodeGenerator::AssembleMove(InstructionOperand* source,
1077 InstructionOperand* destination) { 1079 InstructionOperand* destination) {
1078 IA32OperandConverter g(this, NULL); 1080 IA32OperandConverter g(this, NULL);
1079 // Dispatch on the source and destination operand kinds. Not all 1081 // Dispatch on the source and destination operand kinds. Not all
1080 // combinations are possible. 1082 // combinations are possible.
1081 if (source->IsRegister()) { 1083 if (source->IsRegister()) {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 } 1253 }
1252 } 1254 }
1253 MarkLazyDeoptSite(); 1255 MarkLazyDeoptSite();
1254 } 1256 }
1255 1257
1256 #undef __ 1258 #undef __
1257 1259
1258 } // namespace compiler 1260 } // namespace compiler
1259 } // namespace internal 1261 } // namespace internal
1260 } // namespace v8 1262 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/arm64/code-generator-arm64.cc ('k') | src/compiler/mips/code-generator-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698