| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 mov(r1, Operand(ExternalReference(Runtime::kDebugBreak, isolate()))); | 1095 mov(r1, Operand(ExternalReference(Runtime::kDebugBreak, isolate()))); |
| 1096 CEntryStub ces(1); | 1096 CEntryStub ces(1); |
| 1097 Call(ces.GetCode(), RelocInfo::DEBUG_BREAK); | 1097 Call(ces.GetCode(), RelocInfo::DEBUG_BREAK); |
| 1098 } | 1098 } |
| 1099 #endif | 1099 #endif |
| 1100 | 1100 |
| 1101 | 1101 |
| 1102 void MacroAssembler::PushTryHandler(CodeLocation try_location, | 1102 void MacroAssembler::PushTryHandler(CodeLocation try_location, |
| 1103 HandlerType type) { | 1103 HandlerType type) { |
| 1104 // Adjust this code if not the case. | 1104 // Adjust this code if not the case. |
| 1105 ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); | 1105 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); |
| 1106 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); |
| 1107 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 1 * kPointerSize); |
| 1108 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 2 * kPointerSize); |
| 1109 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 3 * kPointerSize); |
| 1110 STATIC_ASSERT(StackHandlerConstants::kPCOffset == 4 * kPointerSize); |
| 1111 |
| 1106 // The pc (return address) is passed in register lr. | 1112 // The pc (return address) is passed in register lr. |
| 1107 if (try_location == IN_JAVASCRIPT) { | 1113 if (try_location == IN_JAVASCRIPT) { |
| 1108 if (type == TRY_CATCH_HANDLER) { | 1114 if (type == TRY_CATCH_HANDLER) { |
| 1109 mov(r3, Operand(StackHandler::TRY_CATCH)); | 1115 mov(r3, Operand(StackHandler::TRY_CATCH)); |
| 1110 } else { | 1116 } else { |
| 1111 mov(r3, Operand(StackHandler::TRY_FINALLY)); | 1117 mov(r3, Operand(StackHandler::TRY_FINALLY)); |
| 1112 } | 1118 } |
| 1113 ASSERT(StackHandlerConstants::kStateOffset == 1 * kPointerSize | 1119 stm(db_w, sp, r3.bit() | cp.bit() | fp.bit() | lr.bit()); |
| 1114 && StackHandlerConstants::kFPOffset == 2 * kPointerSize | |
| 1115 && StackHandlerConstants::kPCOffset == 3 * kPointerSize); | |
| 1116 stm(db_w, sp, r3.bit() | fp.bit() | lr.bit()); | |
| 1117 // Save the current handler as the next handler. | 1120 // Save the current handler as the next handler. |
| 1118 mov(r3, Operand(ExternalReference(Isolate::k_handler_address, isolate()))); | 1121 mov(r3, Operand(ExternalReference(Isolate::k_handler_address, isolate()))); |
| 1119 ldr(r1, MemOperand(r3)); | 1122 ldr(r1, MemOperand(r3)); |
| 1120 ASSERT(StackHandlerConstants::kNextOffset == 0); | |
| 1121 push(r1); | 1123 push(r1); |
| 1122 // Link this handler as the new current one. | 1124 // Link this handler as the new current one. |
| 1123 str(sp, MemOperand(r3)); | 1125 str(sp, MemOperand(r3)); |
| 1124 } else { | 1126 } else { |
| 1125 // Must preserve r0-r4, r5-r7 are available. | 1127 // Must preserve r0-r4, r5-r7 are available. |
| 1126 ASSERT(try_location == IN_JS_ENTRY); | 1128 ASSERT(try_location == IN_JS_ENTRY); |
| 1127 // The frame pointer does not point to a JS frame so we save NULL | 1129 // The frame pointer does not point to a JS frame so we save NULL |
| 1128 // for fp. We expect the code throwing an exception to check fp | 1130 // for fp. We expect the code throwing an exception to check fp |
| 1129 // before dereferencing it to restore the context. | 1131 // before dereferencing it to restore the context. |
| 1130 mov(ip, Operand(0, RelocInfo::NONE)); // To save a NULL frame pointer. | 1132 mov(r5, Operand(StackHandler::ENTRY)); // State. |
| 1131 mov(r6, Operand(StackHandler::ENTRY)); | 1133 mov(r6, Operand(Smi::FromInt(0))); // Indicates no context. |
| 1132 ASSERT(StackHandlerConstants::kStateOffset == 1 * kPointerSize | 1134 mov(r7, Operand(0, RelocInfo::NONE)); // NULL frame pointer. |
| 1133 && StackHandlerConstants::kFPOffset == 2 * kPointerSize | 1135 stm(db_w, sp, r5.bit() | r6.bit() | r7.bit() | lr.bit()); |
| 1134 && StackHandlerConstants::kPCOffset == 3 * kPointerSize); | |
| 1135 stm(db_w, sp, r6.bit() | ip.bit() | lr.bit()); | |
| 1136 // Save the current handler as the next handler. | 1136 // Save the current handler as the next handler. |
| 1137 mov(r7, Operand(ExternalReference(Isolate::k_handler_address, isolate()))); | 1137 mov(r7, Operand(ExternalReference(Isolate::k_handler_address, isolate()))); |
| 1138 ldr(r6, MemOperand(r7)); | 1138 ldr(r6, MemOperand(r7)); |
| 1139 ASSERT(StackHandlerConstants::kNextOffset == 0); | |
| 1140 push(r6); | 1139 push(r6); |
| 1141 // Link this handler as the new current one. | 1140 // Link this handler as the new current one. |
| 1142 str(sp, MemOperand(r7)); | 1141 str(sp, MemOperand(r7)); |
| 1143 } | 1142 } |
| 1144 } | 1143 } |
| 1145 | 1144 |
| 1146 | 1145 |
| 1147 void MacroAssembler::PopTryHandler() { | 1146 void MacroAssembler::PopTryHandler() { |
| 1148 ASSERT_EQ(0, StackHandlerConstants::kNextOffset); | 1147 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); |
| 1149 pop(r1); | 1148 pop(r1); |
| 1150 mov(ip, Operand(ExternalReference(Isolate::k_handler_address, isolate()))); | 1149 mov(ip, Operand(ExternalReference(Isolate::k_handler_address, isolate()))); |
| 1151 add(sp, sp, Operand(StackHandlerConstants::kSize - kPointerSize)); | 1150 add(sp, sp, Operand(StackHandlerConstants::kSize - kPointerSize)); |
| 1152 str(r1, MemOperand(ip)); | 1151 str(r1, MemOperand(ip)); |
| 1153 } | 1152 } |
| 1154 | 1153 |
| 1155 | 1154 |
| 1156 void MacroAssembler::Throw(Register value) { | 1155 void MacroAssembler::Throw(Register value) { |
| 1156 // Adjust this code if not the case. |
| 1157 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); |
| 1158 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); |
| 1159 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 1 * kPointerSize); |
| 1160 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 2 * kPointerSize); |
| 1161 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 3 * kPointerSize); |
| 1162 STATIC_ASSERT(StackHandlerConstants::kPCOffset == 4 * kPointerSize); |
| 1157 // r0 is expected to hold the exception. | 1163 // r0 is expected to hold the exception. |
| 1158 if (!value.is(r0)) { | 1164 if (!value.is(r0)) { |
| 1159 mov(r0, value); | 1165 mov(r0, value); |
| 1160 } | 1166 } |
| 1161 | 1167 |
| 1162 // Adjust this code if not the case. | |
| 1163 STATIC_ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); | |
| 1164 | |
| 1165 // Drop the sp to the top of the handler. | 1168 // Drop the sp to the top of the handler. |
| 1166 mov(r3, Operand(ExternalReference(Isolate::k_handler_address, isolate()))); | 1169 mov(r3, Operand(ExternalReference(Isolate::k_handler_address, isolate()))); |
| 1167 ldr(sp, MemOperand(r3)); | 1170 ldr(sp, MemOperand(r3)); |
| 1168 | 1171 |
| 1169 // Restore the next handler and frame pointer, discard handler state. | 1172 // Restore the next handler. |
| 1170 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); | |
| 1171 pop(r2); | 1173 pop(r2); |
| 1172 str(r2, MemOperand(r3)); | 1174 str(r2, MemOperand(r3)); |
| 1173 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 2 * kPointerSize); | |
| 1174 ldm(ia_w, sp, r3.bit() | fp.bit()); // r3: discarded state. | |
| 1175 | 1175 |
| 1176 // Before returning we restore the context from the frame pointer if | 1176 // Restore context and frame pointer, discard state (r3). |
| 1177 // not NULL. The frame pointer is NULL in the exception handler of a | 1177 ldm(ia_w, sp, r3.bit() | cp.bit() | fp.bit()); |
| 1178 // JS entry frame. | 1178 |
| 1179 cmp(fp, Operand(0, RelocInfo::NONE)); | |
| 1180 // Set cp to NULL if fp is NULL. | |
| 1181 mov(cp, Operand(0, RelocInfo::NONE), LeaveCC, eq); | |
| 1182 // Restore cp otherwise. | |
| 1183 ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset), ne); | |
| 1184 #ifdef DEBUG | 1179 #ifdef DEBUG |
| 1185 if (emit_debug_code()) { | 1180 if (emit_debug_code()) { |
| 1186 mov(lr, Operand(pc)); | 1181 mov(lr, Operand(pc)); |
| 1187 } | 1182 } |
| 1188 #endif | 1183 #endif |
| 1189 STATIC_ASSERT(StackHandlerConstants::kPCOffset == 3 * kPointerSize); | |
| 1190 pop(pc); | 1184 pop(pc); |
| 1191 } | 1185 } |
| 1192 | 1186 |
| 1193 | 1187 |
| 1194 void MacroAssembler::ThrowUncatchable(UncatchableExceptionType type, | 1188 void MacroAssembler::ThrowUncatchable(UncatchableExceptionType type, |
| 1195 Register value) { | 1189 Register value) { |
| 1196 // Adjust this code if not the case. | 1190 // Adjust this code if not the case. |
| 1197 STATIC_ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); | 1191 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); |
| 1198 | 1192 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); |
| 1193 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 1 * kPointerSize); |
| 1194 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 2 * kPointerSize); |
| 1195 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 3 * kPointerSize); |
| 1196 STATIC_ASSERT(StackHandlerConstants::kPCOffset == 4 * kPointerSize); |
| 1199 // r0 is expected to hold the exception. | 1197 // r0 is expected to hold the exception. |
| 1200 if (!value.is(r0)) { | 1198 if (!value.is(r0)) { |
| 1201 mov(r0, value); | 1199 mov(r0, value); |
| 1202 } | 1200 } |
| 1203 | 1201 |
| 1204 // Drop sp to the top stack handler. | 1202 // Drop sp to the top stack handler. |
| 1205 mov(r3, Operand(ExternalReference(Isolate::k_handler_address, isolate()))); | 1203 mov(r3, Operand(ExternalReference(Isolate::k_handler_address, isolate()))); |
| 1206 ldr(sp, MemOperand(r3)); | 1204 ldr(sp, MemOperand(r3)); |
| 1207 | 1205 |
| 1208 // Unwind the handlers until the ENTRY handler is found. | 1206 // Unwind the handlers until the ENTRY handler is found. |
| 1209 Label loop, done; | 1207 Label loop, done; |
| 1210 bind(&loop); | 1208 bind(&loop); |
| 1211 // Load the type of the current stack handler. | 1209 // Load the type of the current stack handler. |
| 1212 const int kStateOffset = StackHandlerConstants::kStateOffset; | 1210 const int kStateOffset = StackHandlerConstants::kStateOffset; |
| 1213 ldr(r2, MemOperand(sp, kStateOffset)); | 1211 ldr(r2, MemOperand(sp, kStateOffset)); |
| 1214 cmp(r2, Operand(StackHandler::ENTRY)); | 1212 cmp(r2, Operand(StackHandler::ENTRY)); |
| 1215 b(eq, &done); | 1213 b(eq, &done); |
| 1216 // Fetch the next handler in the list. | 1214 // Fetch the next handler in the list. |
| 1217 const int kNextOffset = StackHandlerConstants::kNextOffset; | 1215 const int kNextOffset = StackHandlerConstants::kNextOffset; |
| 1218 ldr(sp, MemOperand(sp, kNextOffset)); | 1216 ldr(sp, MemOperand(sp, kNextOffset)); |
| 1219 jmp(&loop); | 1217 jmp(&loop); |
| 1220 bind(&done); | 1218 bind(&done); |
| 1221 | 1219 |
| 1222 // Set the top handler address to next handler past the current ENTRY handler. | 1220 // Set the top handler address to next handler past the current ENTRY handler. |
| 1223 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); | |
| 1224 pop(r2); | 1221 pop(r2); |
| 1225 str(r2, MemOperand(r3)); | 1222 str(r2, MemOperand(r3)); |
| 1226 | 1223 |
| 1227 if (type == OUT_OF_MEMORY) { | 1224 if (type == OUT_OF_MEMORY) { |
| 1228 // Set external caught exception to false. | 1225 // Set external caught exception to false. |
| 1229 ExternalReference external_caught( | 1226 ExternalReference external_caught( |
| 1230 Isolate::k_external_caught_exception_address, isolate()); | 1227 Isolate::k_external_caught_exception_address, isolate()); |
| 1231 mov(r0, Operand(false, RelocInfo::NONE)); | 1228 mov(r0, Operand(false, RelocInfo::NONE)); |
| 1232 mov(r2, Operand(external_caught)); | 1229 mov(r2, Operand(external_caught)); |
| 1233 str(r0, MemOperand(r2)); | 1230 str(r0, MemOperand(r2)); |
| 1234 | 1231 |
| 1235 // Set pending exception and r0 to out of memory exception. | 1232 // Set pending exception and r0 to out of memory exception. |
| 1236 Failure* out_of_memory = Failure::OutOfMemoryException(); | 1233 Failure* out_of_memory = Failure::OutOfMemoryException(); |
| 1237 mov(r0, Operand(reinterpret_cast<int32_t>(out_of_memory))); | 1234 mov(r0, Operand(reinterpret_cast<int32_t>(out_of_memory))); |
| 1238 mov(r2, Operand(ExternalReference(Isolate::k_pending_exception_address, | 1235 mov(r2, Operand(ExternalReference(Isolate::k_pending_exception_address, |
| 1239 isolate()))); | 1236 isolate()))); |
| 1240 str(r0, MemOperand(r2)); | 1237 str(r0, MemOperand(r2)); |
| 1241 } | 1238 } |
| 1242 | 1239 |
| 1243 // Stack layout at this point. See also StackHandlerConstants. | 1240 // Stack layout at this point. See also StackHandlerConstants. |
| 1244 // sp -> state (ENTRY) | 1241 // sp -> state (ENTRY) |
| 1242 // cp |
| 1245 // fp | 1243 // fp |
| 1246 // lr | 1244 // lr |
| 1247 | 1245 |
| 1248 // Discard handler state (r2 is not used) and restore frame pointer. | 1246 // Restore context and frame pointer, discard state (r2). |
| 1249 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 2 * kPointerSize); | 1247 ldm(ia_w, sp, r2.bit() | cp.bit() | fp.bit()); |
| 1250 ldm(ia_w, sp, r2.bit() | fp.bit()); // r2: discarded state. | |
| 1251 // Before returning we restore the context from the frame pointer if | |
| 1252 // not NULL. The frame pointer is NULL in the exception handler of a | |
| 1253 // JS entry frame. | |
| 1254 cmp(fp, Operand(0, RelocInfo::NONE)); | |
| 1255 // Set cp to NULL if fp is NULL. | |
| 1256 mov(cp, Operand(0, RelocInfo::NONE), LeaveCC, eq); | |
| 1257 // Restore cp otherwise. | |
| 1258 ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset), ne); | |
| 1259 #ifdef DEBUG | 1248 #ifdef DEBUG |
| 1260 if (emit_debug_code()) { | 1249 if (emit_debug_code()) { |
| 1261 mov(lr, Operand(pc)); | 1250 mov(lr, Operand(pc)); |
| 1262 } | 1251 } |
| 1263 #endif | 1252 #endif |
| 1264 STATIC_ASSERT(StackHandlerConstants::kPCOffset == 3 * kPointerSize); | |
| 1265 pop(pc); | 1253 pop(pc); |
| 1266 } | 1254 } |
| 1267 | 1255 |
| 1268 | 1256 |
| 1269 void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg, | 1257 void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg, |
| 1270 Register scratch, | 1258 Register scratch, |
| 1271 Label* miss) { | 1259 Label* miss) { |
| 1272 Label same_contexts; | 1260 Label same_contexts; |
| 1273 | 1261 |
| 1274 ASSERT(!holder_reg.is(scratch)); | 1262 ASSERT(!holder_reg.is(scratch)); |
| (...skipping 1960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3235 void CodePatcher::EmitCondition(Condition cond) { | 3223 void CodePatcher::EmitCondition(Condition cond) { |
| 3236 Instr instr = Assembler::instr_at(masm_.pc_); | 3224 Instr instr = Assembler::instr_at(masm_.pc_); |
| 3237 instr = (instr & ~kCondMask) | cond; | 3225 instr = (instr & ~kCondMask) | cond; |
| 3238 masm_.emit(instr); | 3226 masm_.emit(instr); |
| 3239 } | 3227 } |
| 3240 | 3228 |
| 3241 | 3229 |
| 3242 } } // namespace v8::internal | 3230 } } // namespace v8::internal |
| 3243 | 3231 |
| 3244 #endif // V8_TARGET_ARCH_ARM | 3232 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |