OLD | NEW |
---|---|
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_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
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 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1024 void MacroAssembler::EnterFrame(StackFrame::Type type, | 1024 void MacroAssembler::EnterFrame(StackFrame::Type type, |
1025 bool load_constant_pool_pointer_reg) { | 1025 bool load_constant_pool_pointer_reg) { |
1026 // Out-of-line constant pool not implemented on ia32. | 1026 // Out-of-line constant pool not implemented on ia32. |
1027 UNREACHABLE(); | 1027 UNREACHABLE(); |
1028 } | 1028 } |
1029 | 1029 |
1030 | 1030 |
1031 void MacroAssembler::EnterFrame(StackFrame::Type type) { | 1031 void MacroAssembler::EnterFrame(StackFrame::Type type) { |
1032 push(ebp); | 1032 push(ebp); |
1033 mov(ebp, esp); | 1033 mov(ebp, esp); |
1034 push(esi); | |
1035 push(Immediate(Smi::FromInt(type))); | 1034 push(Immediate(Smi::FromInt(type))); |
1036 push(Immediate(CodeObject())); | 1035 if (type == StackFrame::INTERNAL) { |
1036 push(Immediate(CodeObject())); | |
1037 } | |
1037 if (emit_debug_code()) { | 1038 if (emit_debug_code()) { |
1038 cmp(Operand(esp, 0), Immediate(isolate()->factory()->undefined_value())); | 1039 cmp(Operand(esp, 0), Immediate(isolate()->factory()->undefined_value())); |
1039 Check(not_equal, kCodeObjectNotProperlyPatched); | 1040 Check(not_equal, kCodeObjectNotProperlyPatched); |
1040 } | 1041 } |
1041 } | 1042 } |
1042 | 1043 |
1043 | 1044 |
1044 void MacroAssembler::LeaveFrame(StackFrame::Type type) { | 1045 void MacroAssembler::LeaveFrame(StackFrame::Type type) { |
1045 if (emit_debug_code()) { | 1046 if (emit_debug_code()) { |
1046 cmp(Operand(ebp, StandardFrameConstants::kMarkerOffset), | 1047 cmp(Operand(ebp, CommonFrameConstants::kContextOrFrameTypeOffset), |
1047 Immediate(Smi::FromInt(type))); | 1048 Immediate(Smi::FromInt(type))); |
1048 Check(equal, kStackFrameTypesMustMatch); | 1049 Check(equal, kStackFrameTypesMustMatch); |
1049 } | 1050 } |
1050 leave(); | 1051 leave(); |
1051 } | 1052 } |
1052 | 1053 |
1053 | 1054 |
1054 void MacroAssembler::EnterExitFramePrologue() { | 1055 void MacroAssembler::EnterExitFramePrologue() { |
1055 // Set up the frame structure on the stack. | 1056 // Set up the frame structure on the stack. |
1056 DCHECK(ExitFrameConstants::kCallerSPDisplacement == +2 * kPointerSize); | 1057 DCHECK(ExitFrameConstants::kCallerSPDisplacement == +2 * kPointerSize); |
1057 DCHECK(ExitFrameConstants::kCallerPCOffset == +1 * kPointerSize); | 1058 DCHECK(ExitFrameConstants::kCallerPCOffset == +1 * kPointerSize); |
1058 DCHECK(ExitFrameConstants::kCallerFPOffset == 0 * kPointerSize); | 1059 DCHECK(ExitFrameConstants::kCallerFPOffset == 0 * kPointerSize); |
1059 push(ebp); | 1060 push(ebp); |
1060 mov(ebp, esp); | 1061 mov(ebp, esp); |
1061 | 1062 |
1062 // Reserve room for entry stack pointer and push the code object. | 1063 // Reserve room for entry stack pointer and push the code object. |
1063 DCHECK(ExitFrameConstants::kSPOffset == -1 * kPointerSize); | 1064 push(Immediate(Smi::FromInt(StackFrame::EXIT))); |
1065 DCHECK_EQ(-2 * kPointerSize, ExitFrameConstants::kSPOffset); | |
1064 push(Immediate(0)); // Saved entry sp, patched before call. | 1066 push(Immediate(0)); // Saved entry sp, patched before call. |
1067 DCHECK(ExitFrameConstants::kCodeOffset == -3 * kPointerSize); | |
Michael Starzinger
2016/02/23 10:57:33
nit: DCHECK_EQ
danno
2016/03/07 09:33:38
Done.
| |
1065 push(Immediate(CodeObject())); // Accessed from ExitFrame::code_slot. | 1068 push(Immediate(CodeObject())); // Accessed from ExitFrame::code_slot. |
1066 | 1069 |
1067 // Save the frame pointer and the context in top. | 1070 // Save the frame pointer and the context in top. |
1068 ExternalReference c_entry_fp_address(Isolate::kCEntryFPAddress, isolate()); | 1071 ExternalReference c_entry_fp_address(Isolate::kCEntryFPAddress, isolate()); |
1069 ExternalReference context_address(Isolate::kContextAddress, isolate()); | 1072 ExternalReference context_address(Isolate::kContextAddress, isolate()); |
1070 ExternalReference c_function_address(Isolate::kCFunctionAddress, isolate()); | 1073 ExternalReference c_function_address(Isolate::kCFunctionAddress, isolate()); |
1071 mov(Operand::StaticVariable(c_entry_fp_address), ebp); | 1074 mov(Operand::StaticVariable(c_entry_fp_address), ebp); |
1072 mov(Operand::StaticVariable(context_address), esi); | 1075 mov(Operand::StaticVariable(context_address), esi); |
1073 mov(Operand::StaticVariable(c_function_address), ebx); | 1076 mov(Operand::StaticVariable(c_function_address), ebx); |
1074 } | 1077 } |
1075 | 1078 |
1076 | 1079 |
1077 void MacroAssembler::EnterExitFrameEpilogue(int argc, bool save_doubles) { | 1080 void MacroAssembler::EnterExitFrameEpilogue(int argc, bool save_doubles) { |
1078 // Optionally save all XMM registers. | 1081 // Optionally save all XMM registers. |
1079 if (save_doubles) { | 1082 if (save_doubles) { |
1080 int space = XMMRegister::kMaxNumRegisters * kDoubleSize + | 1083 int space = XMMRegister::kMaxNumRegisters * kDoubleSize + |
1081 argc * kPointerSize; | 1084 argc * kPointerSize; |
1082 sub(esp, Immediate(space)); | 1085 sub(esp, Immediate(space)); |
1083 const int offset = -2 * kPointerSize; | 1086 const int offset = -ExitFrameConstants::kFixedFrameSizeFromFp; |
1084 for (int i = 0; i < XMMRegister::kMaxNumRegisters; i++) { | 1087 for (int i = 0; i < XMMRegister::kMaxNumRegisters; i++) { |
1085 XMMRegister reg = XMMRegister::from_code(i); | 1088 XMMRegister reg = XMMRegister::from_code(i); |
1086 movsd(Operand(ebp, offset - ((i + 1) * kDoubleSize)), reg); | 1089 movsd(Operand(ebp, offset - ((i + 1) * kDoubleSize)), reg); |
1087 } | 1090 } |
1088 } else { | 1091 } else { |
1089 sub(esp, Immediate(argc * kPointerSize)); | 1092 sub(esp, Immediate(argc * kPointerSize)); |
1090 } | 1093 } |
1091 | 1094 |
1092 // Get the required frame alignment for the OS. | 1095 // Get the required frame alignment for the OS. |
1093 const int kFrameAlignment = base::OS::ActivationFrameAlignment(); | 1096 const int kFrameAlignment = base::OS::ActivationFrameAlignment(); |
(...skipping 22 matching lines...) Expand all Loading... | |
1116 | 1119 |
1117 void MacroAssembler::EnterApiExitFrame(int argc) { | 1120 void MacroAssembler::EnterApiExitFrame(int argc) { |
1118 EnterExitFramePrologue(); | 1121 EnterExitFramePrologue(); |
1119 EnterExitFrameEpilogue(argc, false); | 1122 EnterExitFrameEpilogue(argc, false); |
1120 } | 1123 } |
1121 | 1124 |
1122 | 1125 |
1123 void MacroAssembler::LeaveExitFrame(bool save_doubles, bool pop_arguments) { | 1126 void MacroAssembler::LeaveExitFrame(bool save_doubles, bool pop_arguments) { |
1124 // Optionally restore all XMM registers. | 1127 // Optionally restore all XMM registers. |
1125 if (save_doubles) { | 1128 if (save_doubles) { |
1126 const int offset = -2 * kPointerSize; | 1129 const int offset = -ExitFrameConstants::kFixedFrameSizeFromFp; |
1127 for (int i = 0; i < XMMRegister::kMaxNumRegisters; i++) { | 1130 for (int i = 0; i < XMMRegister::kMaxNumRegisters; i++) { |
1128 XMMRegister reg = XMMRegister::from_code(i); | 1131 XMMRegister reg = XMMRegister::from_code(i); |
1129 movsd(reg, Operand(ebp, offset - ((i + 1) * kDoubleSize))); | 1132 movsd(reg, Operand(ebp, offset - ((i + 1) * kDoubleSize))); |
1130 } | 1133 } |
1131 } | 1134 } |
1132 | 1135 |
1133 if (pop_arguments) { | 1136 if (pop_arguments) { |
1134 // Get the return address from the stack and restore the frame pointer. | 1137 // Get the return address from the stack and restore the frame pointer. |
1135 mov(ecx, Operand(ebp, 1 * kPointerSize)); | 1138 mov(ecx, Operand(ebp, 1 * kPointerSize)); |
1136 mov(ebp, Operand(ebp, 0 * kPointerSize)); | 1139 mov(ebp, Operand(ebp, 0 * kPointerSize)); |
(...skipping 2093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3230 mov(eax, dividend); | 3233 mov(eax, dividend); |
3231 shr(eax, 31); | 3234 shr(eax, 31); |
3232 add(edx, eax); | 3235 add(edx, eax); |
3233 } | 3236 } |
3234 | 3237 |
3235 | 3238 |
3236 } // namespace internal | 3239 } // namespace internal |
3237 } // namespace v8 | 3240 } // namespace v8 |
3238 | 3241 |
3239 #endif // V8_TARGET_ARCH_IA32 | 3242 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |