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

Side by Side Diff: src/x87/macro-assembler-x87.cc

Issue 2120873002: X87: [builtins] New frame type for exits to C++ builtins. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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/x87/macro-assembler-x87.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 #if V8_TARGET_ARCH_X87 5 #if V8_TARGET_ARCH_X87
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/base/division-by-constant.h" 8 #include "src/base/division-by-constant.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 1071
1072 void MacroAssembler::LeaveFrame(StackFrame::Type type) { 1072 void MacroAssembler::LeaveFrame(StackFrame::Type type) {
1073 if (emit_debug_code()) { 1073 if (emit_debug_code()) {
1074 cmp(Operand(ebp, CommonFrameConstants::kContextOrFrameTypeOffset), 1074 cmp(Operand(ebp, CommonFrameConstants::kContextOrFrameTypeOffset),
1075 Immediate(Smi::FromInt(type))); 1075 Immediate(Smi::FromInt(type)));
1076 Check(equal, kStackFrameTypesMustMatch); 1076 Check(equal, kStackFrameTypesMustMatch);
1077 } 1077 }
1078 leave(); 1078 leave();
1079 } 1079 }
1080 1080
1081 void MacroAssembler::EnterExitFramePrologue(StackFrame::Type frame_type) {
1082 DCHECK(frame_type == StackFrame::EXIT ||
1083 frame_type == StackFrame::BUILTIN_EXIT);
1081 1084
1082 void MacroAssembler::EnterExitFramePrologue() {
1083 // Set up the frame structure on the stack. 1085 // Set up the frame structure on the stack.
1084 DCHECK_EQ(+2 * kPointerSize, ExitFrameConstants::kCallerSPDisplacement); 1086 DCHECK_EQ(+2 * kPointerSize, ExitFrameConstants::kCallerSPDisplacement);
1085 DCHECK_EQ(+1 * kPointerSize, ExitFrameConstants::kCallerPCOffset); 1087 DCHECK_EQ(+1 * kPointerSize, ExitFrameConstants::kCallerPCOffset);
1086 DCHECK_EQ(0 * kPointerSize, ExitFrameConstants::kCallerFPOffset); 1088 DCHECK_EQ(0 * kPointerSize, ExitFrameConstants::kCallerFPOffset);
1087 push(ebp); 1089 push(ebp);
1088 mov(ebp, esp); 1090 mov(ebp, esp);
1089 1091
1090 // Reserve room for entry stack pointer and push the code object. 1092 // Reserve room for entry stack pointer and push the code object.
1091 push(Immediate(Smi::FromInt(StackFrame::EXIT))); 1093 push(Immediate(Smi::FromInt(frame_type)));
1092 DCHECK_EQ(-2 * kPointerSize, ExitFrameConstants::kSPOffset); 1094 DCHECK_EQ(-2 * kPointerSize, ExitFrameConstants::kSPOffset);
1093 push(Immediate(0)); // Saved entry sp, patched before call. 1095 push(Immediate(0)); // Saved entry sp, patched before call.
1094 DCHECK_EQ(-3 * kPointerSize, ExitFrameConstants::kCodeOffset); 1096 DCHECK_EQ(-3 * kPointerSize, ExitFrameConstants::kCodeOffset);
1095 push(Immediate(CodeObject())); // Accessed from ExitFrame::code_slot. 1097 push(Immediate(CodeObject())); // Accessed from ExitFrame::code_slot.
1096 1098
1097 // Save the frame pointer and the context in top. 1099 // Save the frame pointer and the context in top.
1098 ExternalReference c_entry_fp_address(Isolate::kCEntryFPAddress, isolate()); 1100 ExternalReference c_entry_fp_address(Isolate::kCEntryFPAddress, isolate());
1099 ExternalReference context_address(Isolate::kContextAddress, isolate()); 1101 ExternalReference context_address(Isolate::kContextAddress, isolate());
1100 ExternalReference c_function_address(Isolate::kCFunctionAddress, isolate()); 1102 ExternalReference c_function_address(Isolate::kCFunctionAddress, isolate());
1101 mov(Operand::StaticVariable(c_entry_fp_address), ebp); 1103 mov(Operand::StaticVariable(c_entry_fp_address), ebp);
(...skipping 18 matching lines...) Expand all
1120 const int kFrameAlignment = base::OS::ActivationFrameAlignment(); 1122 const int kFrameAlignment = base::OS::ActivationFrameAlignment();
1121 if (kFrameAlignment > 0) { 1123 if (kFrameAlignment > 0) {
1122 DCHECK(base::bits::IsPowerOfTwo32(kFrameAlignment)); 1124 DCHECK(base::bits::IsPowerOfTwo32(kFrameAlignment));
1123 and_(esp, -kFrameAlignment); 1125 and_(esp, -kFrameAlignment);
1124 } 1126 }
1125 1127
1126 // Patch the saved entry sp. 1128 // Patch the saved entry sp.
1127 mov(Operand(ebp, ExitFrameConstants::kSPOffset), esp); 1129 mov(Operand(ebp, ExitFrameConstants::kSPOffset), esp);
1128 } 1130 }
1129 1131
1130 1132 void MacroAssembler::EnterExitFrame(int argc, bool save_doubles,
1131 void MacroAssembler::EnterExitFrame(int argc, bool save_doubles) { 1133 StackFrame::Type frame_type) {
1132 EnterExitFramePrologue(); 1134 EnterExitFramePrologue(frame_type);
1133 1135
1134 // Set up argc and argv in callee-saved registers. 1136 // Set up argc and argv in callee-saved registers.
1135 int offset = StandardFrameConstants::kCallerSPOffset - kPointerSize; 1137 int offset = StandardFrameConstants::kCallerSPOffset - kPointerSize;
1136 mov(edi, eax); 1138 mov(edi, eax);
1137 lea(esi, Operand(ebp, eax, times_4, offset)); 1139 lea(esi, Operand(ebp, eax, times_4, offset));
1138 1140
1139 // Reserve space for argc, argv and isolate. 1141 // Reserve space for argc, argv and isolate.
1140 EnterExitFrameEpilogue(argc, save_doubles); 1142 EnterExitFrameEpilogue(argc, save_doubles);
1141 } 1143 }
1142 1144
1143 1145
1144 void MacroAssembler::EnterApiExitFrame(int argc) { 1146 void MacroAssembler::EnterApiExitFrame(int argc) {
1145 EnterExitFramePrologue(); 1147 EnterExitFramePrologue(StackFrame::EXIT);
1146 EnterExitFrameEpilogue(argc, false); 1148 EnterExitFrameEpilogue(argc, false);
1147 } 1149 }
1148 1150
1149 1151
1150 void MacroAssembler::LeaveExitFrame(bool save_doubles, bool pop_arguments) { 1152 void MacroAssembler::LeaveExitFrame(bool save_doubles, bool pop_arguments) {
1151 // Optionally restore FPU state. 1153 // Optionally restore FPU state.
1152 if (save_doubles) { 1154 if (save_doubles) {
1153 const int offset = -ExitFrameConstants::kFixedFrameSizeFromFp; 1155 const int offset = -ExitFrameConstants::kFixedFrameSizeFromFp;
1154 frstor(MemOperand(ebp, offset - 108)); 1156 frstor(MemOperand(ebp, offset - 108));
1155 } 1157 }
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
2134 if (function->nargs >= 0) { 2136 if (function->nargs >= 0) {
2135 // TODO(1236192): Most runtime routines don't need the number of 2137 // TODO(1236192): Most runtime routines don't need the number of
2136 // arguments passed in because it is constant. At some point we 2138 // arguments passed in because it is constant. At some point we
2137 // should remove this need and make the runtime routine entry code 2139 // should remove this need and make the runtime routine entry code
2138 // smarter. 2140 // smarter.
2139 mov(eax, Immediate(function->nargs)); 2141 mov(eax, Immediate(function->nargs));
2140 } 2142 }
2141 JumpToExternalReference(ExternalReference(fid, isolate())); 2143 JumpToExternalReference(ExternalReference(fid, isolate()));
2142 } 2144 }
2143 2145
2144 2146 void MacroAssembler::JumpToExternalReference(const ExternalReference& ext,
2145 void MacroAssembler::JumpToExternalReference(const ExternalReference& ext) { 2147 bool builtin_exit_frame) {
2146 // Set the entry point and jump to the C entry runtime stub. 2148 // Set the entry point and jump to the C entry runtime stub.
2147 mov(ebx, Immediate(ext)); 2149 mov(ebx, Immediate(ext));
2148 CEntryStub ces(isolate(), 1); 2150 CEntryStub ces(isolate(), 1, kDontSaveFPRegs, kArgvOnStack,
2151 builtin_exit_frame);
2149 jmp(ces.GetCode(), RelocInfo::CODE_TARGET); 2152 jmp(ces.GetCode(), RelocInfo::CODE_TARGET);
2150 } 2153 }
2151 2154
2152 void MacroAssembler::PrepareForTailCall( 2155 void MacroAssembler::PrepareForTailCall(
2153 const ParameterCount& callee_args_count, Register caller_args_count_reg, 2156 const ParameterCount& callee_args_count, Register caller_args_count_reg,
2154 Register scratch0, Register scratch1, ReturnAddressState ra_state, 2157 Register scratch0, Register scratch1, ReturnAddressState ra_state,
2155 int number_of_temp_values_after_return_address) { 2158 int number_of_temp_values_after_return_address) {
2156 #if DEBUG 2159 #if DEBUG
2157 if (callee_args_count.is_reg()) { 2160 if (callee_args_count.is_reg()) {
2158 DCHECK(!AreAliased(callee_args_count.reg(), caller_args_count_reg, scratch0, 2161 DCHECK(!AreAliased(callee_args_count.reg(), caller_args_count_reg, scratch0,
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
3281 mov(eax, dividend); 3284 mov(eax, dividend);
3282 shr(eax, 31); 3285 shr(eax, 31);
3283 add(edx, eax); 3286 add(edx, eax);
3284 } 3287 }
3285 3288
3286 3289
3287 } // namespace internal 3290 } // namespace internal
3288 } // namespace v8 3291 } // namespace v8
3289 3292
3290 #endif // V8_TARGET_ARCH_X87 3293 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « src/x87/macro-assembler-x87.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698