| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 const int kNumberOfRegisters = Register::kNumRegisters; | 974 const int kNumberOfRegisters = Register::kNumRegisters; |
| 975 | 975 |
| 976 // Everything but pc, lr and ip which will be saved but not restored. | 976 // Everything but pc, lr and ip which will be saved but not restored. |
| 977 RegList restored_regs = kJSCallerSaved | kCalleeSaved | ip.bit(); | 977 RegList restored_regs = kJSCallerSaved | kCalleeSaved | ip.bit(); |
| 978 | 978 |
| 979 const int kDoubleRegsSize = | 979 const int kDoubleRegsSize = |
| 980 kDoubleSize * DwVfpRegister::kMaxNumAllocatableRegisters; | 980 kDoubleSize * DwVfpRegister::kMaxNumAllocatableRegisters; |
| 981 | 981 |
| 982 if (CpuFeatures::IsSupported(VFP2)) { | 982 if (CpuFeatures::IsSupported(VFP2)) { |
| 983 CpuFeatures::Scope scope(VFP2); | 983 CpuFeatures::Scope scope(VFP2); |
| 984 // Save all VFP registers before messing with them. | 984 // Save all allocatable VFP registers before messing with them. |
| 985 DwVfpRegister first = DwVfpRegister::FromAllocationIndex(0); | 985 ASSERT(kDoubleRegZero.code() == 14); |
| 986 DwVfpRegister last = | 986 ASSERT(kScratchDoubleReg.code() == 15); |
| 987 DwVfpRegister::FromAllocationIndex( | 987 |
| 988 DwVfpRegister::kMaxNumAllocatableRegisters - 1); | 988 // Check CPU flags for number of registers, setting the Z condition flag. |
| 989 ASSERT(last.code() > first.code()); | 989 __ CheckFor32DRegs(ip); |
| 990 ASSERT((last.code() - first.code()) == | 990 |
| 991 (DwVfpRegister::kMaxNumAllocatableRegisters - 1)); | 991 // Push registers d0-d13, and possibly d16-d31, on the stack. |
| 992 #ifdef DEBUG | 992 __ vstm(db_w, sp, d16, d31, ne); |
| 993 int max = DwVfpRegister::kMaxNumAllocatableRegisters - 1; | 993 __ sub(sp, sp, Operand(16 * kDoubleSize), LeaveCC, eq); |
| 994 for (int i = 0; i <= max; i++) { | 994 __ vstm(db_w, sp, d0, d13); |
| 995 ASSERT((DwVfpRegister::FromAllocationIndex(i).code() <= last.code()) && | |
| 996 (DwVfpRegister::FromAllocationIndex(i).code() >= first.code())); | |
| 997 } | |
| 998 #endif | |
| 999 __ vstm(db_w, sp, first, last); | |
| 1000 } else { | 995 } else { |
| 1001 __ sub(sp, sp, Operand(kDoubleRegsSize)); | 996 __ sub(sp, sp, Operand(kDoubleRegsSize)); |
| 1002 } | 997 } |
| 1003 | 998 |
| 1004 // Push all 16 registers (needed to populate FrameDescription::registers_). | 999 // Push all 16 registers (needed to populate FrameDescription::registers_). |
| 1005 // TODO(1588) Note that using pc with stm is deprecated, so we should perhaps | 1000 // TODO(1588) Note that using pc with stm is deprecated, so we should perhaps |
| 1006 // handle this a bit differently. | 1001 // handle this a bit differently. |
| 1007 __ stm(db_w, sp, restored_regs | sp.bit() | lr.bit() | pc.bit()); | 1002 __ stm(db_w, sp, restored_regs | sp.bit() | lr.bit() | pc.bit()); |
| 1008 | 1003 |
| 1009 const int kSavedRegistersAreaSize = | 1004 const int kSavedRegistersAreaSize = |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); | 1051 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); |
| 1057 __ ldr(r2, MemOperand(sp, i * kPointerSize)); | 1052 __ ldr(r2, MemOperand(sp, i * kPointerSize)); |
| 1058 __ str(r2, MemOperand(r1, offset)); | 1053 __ str(r2, MemOperand(r1, offset)); |
| 1059 } | 1054 } |
| 1060 | 1055 |
| 1061 if (CpuFeatures::IsSupported(VFP2)) { | 1056 if (CpuFeatures::IsSupported(VFP2)) { |
| 1062 CpuFeatures::Scope scope(VFP2); | 1057 CpuFeatures::Scope scope(VFP2); |
| 1063 // Copy VFP registers to | 1058 // Copy VFP registers to |
| 1064 // double_registers_[DoubleRegister::kMaxNumAllocatableRegisters] | 1059 // double_registers_[DoubleRegister::kMaxNumAllocatableRegisters] |
| 1065 int double_regs_offset = FrameDescription::double_registers_offset(); | 1060 int double_regs_offset = FrameDescription::double_registers_offset(); |
| 1066 for (int i = 0; i < DwVfpRegister::NumAllocatableRegisters(); ++i) { | 1061 for (int i = 0; i < DwVfpRegister::kMaxNumAllocatableRegisters; ++i) { |
| 1067 int dst_offset = i * kDoubleSize + double_regs_offset; | 1062 int dst_offset = i * kDoubleSize + double_regs_offset; |
| 1068 int src_offset = i * kDoubleSize + kNumberOfRegisters * kPointerSize; | 1063 int src_offset = i * kDoubleSize + kNumberOfRegisters * kPointerSize; |
| 1069 __ vldr(d0, sp, src_offset); | 1064 __ vldr(d0, sp, src_offset); |
| 1070 __ vstr(d0, r1, dst_offset); | 1065 __ vstr(d0, r1, dst_offset); |
| 1071 } | 1066 } |
| 1072 } | 1067 } |
| 1073 | 1068 |
| 1074 // Remove the bailout id, eventually return address, and the saved registers | 1069 // Remove the bailout id, eventually return address, and the saved registers |
| 1075 // from the stack. | 1070 // from the stack. |
| 1076 if (type() == EAGER || type() == OSR) { | 1071 if (type() == EAGER || type() == OSR) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1104 // r0: deoptimizer object; r1: scratch. | 1099 // r0: deoptimizer object; r1: scratch. |
| 1105 __ PrepareCallCFunction(1, r1); | 1100 __ PrepareCallCFunction(1, r1); |
| 1106 // Call Deoptimizer::ComputeOutputFrames(). | 1101 // Call Deoptimizer::ComputeOutputFrames(). |
| 1107 { | 1102 { |
| 1108 AllowExternalCallThatCantCauseGC scope(masm()); | 1103 AllowExternalCallThatCantCauseGC scope(masm()); |
| 1109 __ CallCFunction( | 1104 __ CallCFunction( |
| 1110 ExternalReference::compute_output_frames_function(isolate), 1); | 1105 ExternalReference::compute_output_frames_function(isolate), 1); |
| 1111 } | 1106 } |
| 1112 __ pop(r0); // Restore deoptimizer object (class Deoptimizer). | 1107 __ pop(r0); // Restore deoptimizer object (class Deoptimizer). |
| 1113 | 1108 |
| 1109 // TODO(hans): Change the code below to not clobber r0, so that it can be |
| 1110 // used in the "restore the d registers" code further down, making this mov |
| 1111 // redundant. |
| 1112 __ mov(r4, r0); |
| 1113 |
| 1114 // Replace the current (input) frame with the output frames. | 1114 // Replace the current (input) frame with the output frames. |
| 1115 Label outer_push_loop, inner_push_loop, | 1115 Label outer_push_loop, inner_push_loop, |
| 1116 outer_loop_header, inner_loop_header; | 1116 outer_loop_header, inner_loop_header; |
| 1117 // Outer loop state: r0 = current "FrameDescription** output_", | 1117 // Outer loop state: r0 = current "FrameDescription** output_", |
| 1118 // r1 = one past the last FrameDescription**. | 1118 // r1 = one past the last FrameDescription**. |
| 1119 __ ldr(r1, MemOperand(r0, Deoptimizer::output_count_offset())); | 1119 __ ldr(r1, MemOperand(r0, Deoptimizer::output_count_offset())); |
| 1120 __ ldr(r0, MemOperand(r0, Deoptimizer::output_offset())); // r0 is output_. | 1120 __ ldr(r0, MemOperand(r0, Deoptimizer::output_offset())); // r0 is output_. |
| 1121 __ add(r1, r0, Operand(r1, LSL, 2)); | 1121 __ add(r1, r0, Operand(r1, LSL, 2)); |
| 1122 __ jmp(&outer_loop_header); | 1122 __ jmp(&outer_loop_header); |
| 1123 __ bind(&outer_push_loop); | 1123 __ bind(&outer_push_loop); |
| 1124 // Inner loop state: r2 = current FrameDescription*, r3 = loop index. | 1124 // Inner loop state: r2 = current FrameDescription*, r3 = loop index. |
| 1125 __ ldr(r2, MemOperand(r0, 0)); // output_[ix] | 1125 __ ldr(r2, MemOperand(r0, 0)); // output_[ix] |
| 1126 __ ldr(r3, MemOperand(r2, FrameDescription::frame_size_offset())); | 1126 __ ldr(r3, MemOperand(r2, FrameDescription::frame_size_offset())); |
| 1127 __ jmp(&inner_loop_header); | 1127 __ jmp(&inner_loop_header); |
| 1128 __ bind(&inner_push_loop); | 1128 __ bind(&inner_push_loop); |
| 1129 __ sub(r3, r3, Operand(sizeof(uint32_t))); | 1129 __ sub(r3, r3, Operand(sizeof(uint32_t))); |
| 1130 __ add(r6, r2, Operand(r3)); | 1130 __ add(r6, r2, Operand(r3)); |
| 1131 __ ldr(r7, MemOperand(r6, FrameDescription::frame_content_offset())); | 1131 __ ldr(r7, MemOperand(r6, FrameDescription::frame_content_offset())); |
| 1132 __ push(r7); | 1132 __ push(r7); |
| 1133 __ bind(&inner_loop_header); | 1133 __ bind(&inner_loop_header); |
| 1134 __ cmp(r3, Operand::Zero()); | 1134 __ cmp(r3, Operand::Zero()); |
| 1135 __ b(ne, &inner_push_loop); // test for gt? | 1135 __ b(ne, &inner_push_loop); // test for gt? |
| 1136 __ add(r0, r0, Operand(kPointerSize)); | 1136 __ add(r0, r0, Operand(kPointerSize)); |
| 1137 __ bind(&outer_loop_header); | 1137 __ bind(&outer_loop_header); |
| 1138 __ cmp(r0, r1); | 1138 __ cmp(r0, r1); |
| 1139 __ b(lt, &outer_push_loop); | 1139 __ b(lt, &outer_push_loop); |
| 1140 | 1140 |
| 1141 if (CpuFeatures::IsSupported(VFP2)) { |
| 1142 CpuFeatures::Scope scope(VFP2); |
| 1143 // In case of OSR, we have to restore the d registers. |
| 1144 if (type() == OSR) { |
| 1145 // Check CPU flags for number of registers, setting the Z condition flag. |
| 1146 __ CheckFor32DRegs(ip); |
| 1147 |
| 1148 __ ldr(r1, MemOperand(r4, Deoptimizer::input_offset())); |
| 1149 int src_offset = FrameDescription::double_registers_offset(); |
| 1150 for (int i = 0; i < DwVfpRegister::kNumRegisters; ++i) { |
| 1151 if (i == kDoubleRegZero.code()) continue; |
| 1152 if (i == kScratchDoubleReg.code()) continue; |
| 1153 |
| 1154 const DwVfpRegister reg = DwVfpRegister::from_code(i); |
| 1155 __ vldr(reg, r1, src_offset, i < 16 ? al : ne); |
| 1156 src_offset += kDoubleSize; |
| 1157 } |
| 1158 } |
| 1159 } |
| 1160 |
| 1141 // Push state, pc, and continuation from the last output frame. | 1161 // Push state, pc, and continuation from the last output frame. |
| 1142 if (type() != OSR) { | 1162 if (type() != OSR) { |
| 1143 __ ldr(r6, MemOperand(r2, FrameDescription::state_offset())); | 1163 __ ldr(r6, MemOperand(r2, FrameDescription::state_offset())); |
| 1144 __ push(r6); | 1164 __ push(r6); |
| 1145 } | 1165 } |
| 1146 | 1166 |
| 1147 __ ldr(r6, MemOperand(r2, FrameDescription::pc_offset())); | 1167 __ ldr(r6, MemOperand(r2, FrameDescription::pc_offset())); |
| 1148 __ push(r6); | 1168 __ push(r6); |
| 1149 __ ldr(r6, MemOperand(r2, FrameDescription::continuation_offset())); | 1169 __ ldr(r6, MemOperand(r2, FrameDescription::continuation_offset())); |
| 1150 __ push(r6); | 1170 __ push(r6); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 __ push(ip); | 1208 __ push(ip); |
| 1189 __ b(&done); | 1209 __ b(&done); |
| 1190 ASSERT(masm()->pc_offset() - start == table_entry_size_); | 1210 ASSERT(masm()->pc_offset() - start == table_entry_size_); |
| 1191 } | 1211 } |
| 1192 __ bind(&done); | 1212 __ bind(&done); |
| 1193 } | 1213 } |
| 1194 | 1214 |
| 1195 #undef __ | 1215 #undef __ |
| 1196 | 1216 |
| 1197 } } // namespace v8::internal | 1217 } } // namespace v8::internal |
| OLD | NEW |