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. |
989 ASSERT(last.code() > first.code()); | 989 // 16 regs => Z==1, 32 regs => Z==0. |
990 ASSERT((last.code() - first.code()) == | 990 __ mov(ip, Operand(ExternalReference::cpu_features())); |
991 (DwVfpRegister::kMaxNumAllocatableRegisters - 1)); | 991 __ ldr(ip, MemOperand(ip)); |
992 #ifdef DEBUG | 992 __ and_(ip, ip, Operand(1u << VFP32DREGS), SetCC); |
993 int max = DwVfpRegister::kMaxNumAllocatableRegisters - 1; | 993 |
994 for (int i = 0; i <= max; i++) { | 994 // Push registers d0-d13, and possibly d16-d31, on the stack. |
995 ASSERT((DwVfpRegister::FromAllocationIndex(i).code() <= last.code()) && | 995 __ vstm(db_w, sp, d16, d31, ne); |
996 (DwVfpRegister::FromAllocationIndex(i).code() >= first.code())); | 996 __ add(sp, sp, Operand(16 * kDoubleSize), LeaveCC, eq); |
997 } | 997 __ vstm(db_w, sp, d0, d13); |
998 #endif | |
999 __ vstm(db_w, sp, first, last); | |
1000 } else { | 998 } else { |
1001 __ sub(sp, sp, Operand(kDoubleRegsSize)); | 999 __ sub(sp, sp, Operand(kDoubleRegsSize)); |
1002 } | 1000 } |
1003 | 1001 |
1004 // Push all 16 registers (needed to populate FrameDescription::registers_). | 1002 // Push all 16 registers (needed to populate FrameDescription::registers_). |
1005 // TODO(1588) Note that using pc with stm is deprecated, so we should perhaps | 1003 // TODO(1588) Note that using pc with stm is deprecated, so we should perhaps |
1006 // handle this a bit differently. | 1004 // handle this a bit differently. |
1007 __ stm(db_w, sp, restored_regs | sp.bit() | lr.bit() | pc.bit()); | 1005 __ stm(db_w, sp, restored_regs | sp.bit() | lr.bit() | pc.bit()); |
1008 | 1006 |
1009 const int kSavedRegistersAreaSize = | 1007 const int kSavedRegistersAreaSize = |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); | 1054 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); |
1057 __ ldr(r2, MemOperand(sp, i * kPointerSize)); | 1055 __ ldr(r2, MemOperand(sp, i * kPointerSize)); |
1058 __ str(r2, MemOperand(r1, offset)); | 1056 __ str(r2, MemOperand(r1, offset)); |
1059 } | 1057 } |
1060 | 1058 |
1061 if (CpuFeatures::IsSupported(VFP2)) { | 1059 if (CpuFeatures::IsSupported(VFP2)) { |
1062 CpuFeatures::Scope scope(VFP2); | 1060 CpuFeatures::Scope scope(VFP2); |
1063 // Copy VFP registers to | 1061 // Copy VFP registers to |
1064 // double_registers_[DoubleRegister::kMaxNumAllocatableRegisters] | 1062 // double_registers_[DoubleRegister::kMaxNumAllocatableRegisters] |
1065 int double_regs_offset = FrameDescription::double_registers_offset(); | 1063 int double_regs_offset = FrameDescription::double_registers_offset(); |
1066 for (int i = 0; i < DwVfpRegister::NumAllocatableRegisters(); ++i) { | 1064 for (int i = 0; i < DwVfpRegister::kMaxNumAllocatableRegisters; ++i) { |
1067 int dst_offset = i * kDoubleSize + double_regs_offset; | 1065 int dst_offset = i * kDoubleSize + double_regs_offset; |
1068 int src_offset = i * kDoubleSize + kNumberOfRegisters * kPointerSize; | 1066 int src_offset = i * kDoubleSize + kNumberOfRegisters * kPointerSize; |
1069 __ vldr(d0, sp, src_offset); | 1067 __ vldr(d0, sp, src_offset); |
1070 __ vstr(d0, r1, dst_offset); | 1068 __ vstr(d0, r1, dst_offset); |
1071 } | 1069 } |
1072 } | 1070 } |
1073 | 1071 |
1074 // Remove the bailout id, eventually return address, and the saved registers | 1072 // Remove the bailout id, eventually return address, and the saved registers |
1075 // from the stack. | 1073 // from the stack. |
1076 if (type() == EAGER || type() == OSR) { | 1074 if (type() == EAGER || type() == OSR) { |
(...skipping 27 matching lines...) Expand all Loading... |
1104 // r0: deoptimizer object; r1: scratch. | 1102 // r0: deoptimizer object; r1: scratch. |
1105 __ PrepareCallCFunction(1, r1); | 1103 __ PrepareCallCFunction(1, r1); |
1106 // Call Deoptimizer::ComputeOutputFrames(). | 1104 // Call Deoptimizer::ComputeOutputFrames(). |
1107 { | 1105 { |
1108 AllowExternalCallThatCantCauseGC scope(masm()); | 1106 AllowExternalCallThatCantCauseGC scope(masm()); |
1109 __ CallCFunction( | 1107 __ CallCFunction( |
1110 ExternalReference::compute_output_frames_function(isolate), 1); | 1108 ExternalReference::compute_output_frames_function(isolate), 1); |
1111 } | 1109 } |
1112 __ pop(r0); // Restore deoptimizer object (class Deoptimizer). | 1110 __ pop(r0); // Restore deoptimizer object (class Deoptimizer). |
1113 | 1111 |
| 1112 // TODO(hans): Change the code below to not clobber r0, so that it can be |
| 1113 // used in the "restore the d registers" code further down, making this mov |
| 1114 // redundant. |
| 1115 __ mov(r4, r0); |
| 1116 |
1114 // Replace the current (input) frame with the output frames. | 1117 // Replace the current (input) frame with the output frames. |
1115 Label outer_push_loop, inner_push_loop, | 1118 Label outer_push_loop, inner_push_loop, |
1116 outer_loop_header, inner_loop_header; | 1119 outer_loop_header, inner_loop_header; |
1117 // Outer loop state: r0 = current "FrameDescription** output_", | 1120 // Outer loop state: r0 = current "FrameDescription** output_", |
1118 // r1 = one past the last FrameDescription**. | 1121 // r1 = one past the last FrameDescription**. |
1119 __ ldr(r1, MemOperand(r0, Deoptimizer::output_count_offset())); | 1122 __ ldr(r1, MemOperand(r0, Deoptimizer::output_count_offset())); |
1120 __ ldr(r0, MemOperand(r0, Deoptimizer::output_offset())); // r0 is output_. | 1123 __ ldr(r0, MemOperand(r0, Deoptimizer::output_offset())); // r0 is output_. |
1121 __ add(r1, r0, Operand(r1, LSL, 2)); | 1124 __ add(r1, r0, Operand(r1, LSL, 2)); |
1122 __ jmp(&outer_loop_header); | 1125 __ jmp(&outer_loop_header); |
1123 __ bind(&outer_push_loop); | 1126 __ bind(&outer_push_loop); |
1124 // Inner loop state: r2 = current FrameDescription*, r3 = loop index. | 1127 // Inner loop state: r2 = current FrameDescription*, r3 = loop index. |
1125 __ ldr(r2, MemOperand(r0, 0)); // output_[ix] | 1128 __ ldr(r2, MemOperand(r0, 0)); // output_[ix] |
1126 __ ldr(r3, MemOperand(r2, FrameDescription::frame_size_offset())); | 1129 __ ldr(r3, MemOperand(r2, FrameDescription::frame_size_offset())); |
1127 __ jmp(&inner_loop_header); | 1130 __ jmp(&inner_loop_header); |
1128 __ bind(&inner_push_loop); | 1131 __ bind(&inner_push_loop); |
1129 __ sub(r3, r3, Operand(sizeof(uint32_t))); | 1132 __ sub(r3, r3, Operand(sizeof(uint32_t))); |
1130 __ add(r6, r2, Operand(r3)); | 1133 __ add(r6, r2, Operand(r3)); |
1131 __ ldr(r7, MemOperand(r6, FrameDescription::frame_content_offset())); | 1134 __ ldr(r7, MemOperand(r6, FrameDescription::frame_content_offset())); |
1132 __ push(r7); | 1135 __ push(r7); |
1133 __ bind(&inner_loop_header); | 1136 __ bind(&inner_loop_header); |
1134 __ cmp(r3, Operand::Zero()); | 1137 __ cmp(r3, Operand::Zero()); |
1135 __ b(ne, &inner_push_loop); // test for gt? | 1138 __ b(ne, &inner_push_loop); // test for gt? |
1136 __ add(r0, r0, Operand(kPointerSize)); | 1139 __ add(r0, r0, Operand(kPointerSize)); |
1137 __ bind(&outer_loop_header); | 1140 __ bind(&outer_loop_header); |
1138 __ cmp(r0, r1); | 1141 __ cmp(r0, r1); |
1139 __ b(lt, &outer_push_loop); | 1142 __ b(lt, &outer_push_loop); |
1140 | 1143 |
| 1144 if (CpuFeatures::IsSupported(VFP2)) { |
| 1145 CpuFeatures::Scope scope(VFP2); |
| 1146 // In case of OSR, we have to restore the d registers. |
| 1147 if (type() == OSR) { |
| 1148 // Check CPU flags for number of registers. |
| 1149 // 16 regs => Z==1, 32 regs => Z==0. |
| 1150 __ mov(ip, Operand(ExternalReference::cpu_features())); |
| 1151 __ ldr(ip, MemOperand(ip)); |
| 1152 __ and_(ip, ip, Operand(1u << VFP32DREGS), SetCC); |
| 1153 |
| 1154 __ ldr(r1, MemOperand(r4, Deoptimizer::input_offset())); |
| 1155 int src_offset = FrameDescription::double_registers_offset(); |
| 1156 for (int i = 0; i < DwVfpRegister::kNumRegisters; ++i) { |
| 1157 if (i == kDoubleRegZero.code()) continue; |
| 1158 if (i == kScratchDoubleReg.code()) continue; |
| 1159 |
| 1160 const DwVfpRegister reg = DwVfpRegister::from_code(i); |
| 1161 __ vldr(reg, r1, src_offset, i < 16 ? al : ne); |
| 1162 src_offset += kDoubleSize; |
| 1163 } |
| 1164 } |
| 1165 } |
| 1166 |
1141 // Push state, pc, and continuation from the last output frame. | 1167 // Push state, pc, and continuation from the last output frame. |
1142 if (type() != OSR) { | 1168 if (type() != OSR) { |
1143 __ ldr(r6, MemOperand(r2, FrameDescription::state_offset())); | 1169 __ ldr(r6, MemOperand(r2, FrameDescription::state_offset())); |
1144 __ push(r6); | 1170 __ push(r6); |
1145 } | 1171 } |
1146 | 1172 |
1147 __ ldr(r6, MemOperand(r2, FrameDescription::pc_offset())); | 1173 __ ldr(r6, MemOperand(r2, FrameDescription::pc_offset())); |
1148 __ push(r6); | 1174 __ push(r6); |
1149 __ ldr(r6, MemOperand(r2, FrameDescription::continuation_offset())); | 1175 __ ldr(r6, MemOperand(r2, FrameDescription::continuation_offset())); |
1150 __ push(r6); | 1176 __ push(r6); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 __ push(ip); | 1214 __ push(ip); |
1189 __ b(&done); | 1215 __ b(&done); |
1190 ASSERT(masm()->pc_offset() - start == table_entry_size_); | 1216 ASSERT(masm()->pc_offset() - start == table_entry_size_); |
1191 } | 1217 } |
1192 __ bind(&done); | 1218 __ bind(&done); |
1193 } | 1219 } |
1194 | 1220 |
1195 #undef __ | 1221 #undef __ |
1196 | 1222 |
1197 } } // namespace v8::internal | 1223 } } // namespace v8::internal |
OLD | NEW |