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 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 mov(r0, Operand(0, RelocInfo::NONE)); | 1160 mov(r0, Operand(0, RelocInfo::NONE)); |
1161 mov(r1, Operand(ExternalReference(Runtime::kDebugBreak, isolate()))); | 1161 mov(r1, Operand(ExternalReference(Runtime::kDebugBreak, isolate()))); |
1162 CEntryStub ces(1); | 1162 CEntryStub ces(1); |
1163 ASSERT(AllowThisStubCall(&ces)); | 1163 ASSERT(AllowThisStubCall(&ces)); |
1164 Call(ces.GetCode(), RelocInfo::DEBUG_BREAK); | 1164 Call(ces.GetCode(), RelocInfo::DEBUG_BREAK); |
1165 } | 1165 } |
1166 #endif | 1166 #endif |
1167 | 1167 |
1168 | 1168 |
1169 void MacroAssembler::PushTryHandler(CodeLocation try_location, | 1169 void MacroAssembler::PushTryHandler(CodeLocation try_location, |
1170 HandlerType type) { | 1170 HandlerType type, |
| 1171 int handler_index) { |
1171 // Adjust this code if not the case. | 1172 // Adjust this code if not the case. |
1172 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); | 1173 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); |
1173 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); | 1174 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); |
1174 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 1 * kPointerSize); | 1175 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize); |
1175 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 2 * kPointerSize); | 1176 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize); |
1176 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 3 * kPointerSize); | 1177 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize); |
1177 STATIC_ASSERT(StackHandlerConstants::kPCOffset == 4 * kPointerSize); | 1178 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize); |
1178 | 1179 |
1179 // The pc (return address) is passed in register lr. | 1180 // For the JSEntry handler, we must preserve r0-r4, r5-r7 are available. |
| 1181 // We will build up the handler from the bottom by pushing on the stack. |
| 1182 // First compute the state. |
| 1183 unsigned state = StackHandler::OffsetField::encode(handler_index); |
1180 if (try_location == IN_JAVASCRIPT) { | 1184 if (try_location == IN_JAVASCRIPT) { |
1181 if (type == TRY_CATCH_HANDLER) { | 1185 state |= (type == TRY_CATCH_HANDLER) |
1182 mov(r3, Operand(StackHandler::TRY_CATCH)); | 1186 ? StackHandler::KindField::encode(StackHandler::TRY_CATCH) |
1183 } else { | 1187 : StackHandler::KindField::encode(StackHandler::TRY_FINALLY); |
1184 mov(r3, Operand(StackHandler::TRY_FINALLY)); | |
1185 } | |
1186 stm(db_w, sp, r3.bit() | cp.bit() | fp.bit() | lr.bit()); | |
1187 // Save the current handler as the next handler. | |
1188 mov(r3, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); | |
1189 ldr(r1, MemOperand(r3)); | |
1190 push(r1); | |
1191 // Link this handler as the new current one. | |
1192 str(sp, MemOperand(r3)); | |
1193 } else { | 1188 } else { |
1194 // Must preserve r0-r4, r5-r7 are available. | |
1195 ASSERT(try_location == IN_JS_ENTRY); | 1189 ASSERT(try_location == IN_JS_ENTRY); |
1196 // The frame pointer does not point to a JS frame so we save NULL | 1190 state |= StackHandler::KindField::encode(StackHandler::ENTRY); |
1197 // for fp. We expect the code throwing an exception to check fp | |
1198 // before dereferencing it to restore the context. | |
1199 mov(r5, Operand(StackHandler::ENTRY)); // State. | |
1200 mov(r6, Operand(Smi::FromInt(0))); // Indicates no context. | |
1201 mov(r7, Operand(0, RelocInfo::NONE)); // NULL frame pointer. | |
1202 stm(db_w, sp, r5.bit() | r6.bit() | r7.bit() | lr.bit()); | |
1203 // Save the current handler as the next handler. | |
1204 mov(r7, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); | |
1205 ldr(r6, MemOperand(r7)); | |
1206 push(r6); | |
1207 // Link this handler as the new current one. | |
1208 str(sp, MemOperand(r7)); | |
1209 } | 1191 } |
| 1192 |
| 1193 // Set up the code object (r5) and the state (r6) for pushing. |
| 1194 mov(r5, Operand(CodeObject())); |
| 1195 mov(r6, Operand(state)); |
| 1196 |
| 1197 // Push the frame pointer, context, state, and code object. |
| 1198 if (try_location == IN_JAVASCRIPT) { |
| 1199 stm(db_w, sp, r5.bit() | r6.bit() | cp.bit() | fp.bit()); |
| 1200 } else { |
| 1201 mov(r7, Operand(Smi::FromInt(0))); // Indicates no context. |
| 1202 mov(ip, Operand(0, RelocInfo::NONE)); // NULL frame pointer. |
| 1203 stm(db_w, sp, r5.bit() | r6.bit() | r7.bit() | ip.bit()); |
| 1204 } |
| 1205 |
| 1206 // Link the current handler as the next handler. |
| 1207 mov(r6, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); |
| 1208 ldr(r5, MemOperand(r6)); |
| 1209 push(r5); |
| 1210 // Set this new handler as the current one. |
| 1211 str(sp, MemOperand(r6)); |
1210 } | 1212 } |
1211 | 1213 |
1212 | 1214 |
1213 void MacroAssembler::PopTryHandler() { | 1215 void MacroAssembler::PopTryHandler() { |
1214 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); | 1216 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); |
1215 pop(r1); | 1217 pop(r1); |
1216 mov(ip, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); | 1218 mov(ip, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); |
1217 add(sp, sp, Operand(StackHandlerConstants::kSize - kPointerSize)); | 1219 add(sp, sp, Operand(StackHandlerConstants::kSize - kPointerSize)); |
1218 str(r1, MemOperand(ip)); | 1220 str(r1, MemOperand(ip)); |
1219 } | 1221 } |
1220 | 1222 |
1221 | 1223 |
| 1224 void MacroAssembler::JumpToHandlerEntry() { |
| 1225 // Compute the handler entry address and jump to it. The handler table is |
| 1226 // a fixed array of (smi-tagged) code offsets. |
| 1227 // r0 = exception, r1 = code object, r2 = state. |
| 1228 ldr(r3, FieldMemOperand(r1, Code::kHandlerTableOffset)); // Handler table. |
| 1229 add(r3, r3, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
| 1230 mov(r2, Operand(r2, LSR, StackHandler::kKindWidth)); // Handler index. |
| 1231 ldr(r2, MemOperand(r3, r2, LSL, kPointerSizeLog2)); // Smi-tagged offset. |
| 1232 add(r1, r1, Operand(Code::kHeaderSize - kHeapObjectTag)); // Code start. |
| 1233 add(pc, r1, Operand(r2, ASR, kSmiTagSize)); // Jump. |
| 1234 } |
| 1235 |
| 1236 |
1222 void MacroAssembler::Throw(Register value) { | 1237 void MacroAssembler::Throw(Register value) { |
1223 // Adjust this code if not the case. | 1238 // Adjust this code if not the case. |
1224 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); | 1239 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); |
1225 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); | 1240 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); |
1226 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 1 * kPointerSize); | 1241 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize); |
1227 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 2 * kPointerSize); | 1242 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize); |
1228 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 3 * kPointerSize); | 1243 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize); |
1229 STATIC_ASSERT(StackHandlerConstants::kPCOffset == 4 * kPointerSize); | 1244 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize); |
1230 // r0 is expected to hold the exception. | 1245 |
| 1246 // The exception is expected in r0. |
1231 if (!value.is(r0)) { | 1247 if (!value.is(r0)) { |
1232 mov(r0, value); | 1248 mov(r0, value); |
1233 } | 1249 } |
1234 | 1250 // Drop the stack pointer to the top of the top handler. |
1235 // Drop the sp to the top of the handler. | |
1236 mov(r3, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); | 1251 mov(r3, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); |
1237 ldr(sp, MemOperand(r3)); | 1252 ldr(sp, MemOperand(r3)); |
1238 | |
1239 // Restore the next handler. | 1253 // Restore the next handler. |
1240 pop(r2); | 1254 pop(r2); |
1241 str(r2, MemOperand(r3)); | 1255 str(r2, MemOperand(r3)); |
1242 | 1256 |
1243 // Restore context and frame pointer, discard state (r3). | 1257 // Get the code object (r1) and state (r2). Restore the context and frame |
1244 ldm(ia_w, sp, r3.bit() | cp.bit() | fp.bit()); | 1258 // pointer. |
| 1259 ldm(ia_w, sp, r1.bit() | r2.bit() | cp.bit() | fp.bit()); |
1245 | 1260 |
1246 // If the handler is a JS frame, restore the context to the frame. | 1261 // If the handler is a JS frame, restore the context to the frame. |
1247 // (r3 == ENTRY) == (fp == 0) == (cp == 0), so we could test any | 1262 // (kind == ENTRY) == (fp == 0) == (cp == 0), so we could test either fp |
1248 // of them. | 1263 // or cp. |
1249 cmp(r3, Operand(StackHandler::ENTRY)); | 1264 tst(cp, cp); |
1250 str(cp, MemOperand(fp, StandardFrameConstants::kContextOffset), ne); | 1265 str(cp, MemOperand(fp, StandardFrameConstants::kContextOffset), ne); |
1251 | 1266 |
1252 #ifdef DEBUG | 1267 JumpToHandlerEntry(); |
1253 if (emit_debug_code()) { | |
1254 mov(lr, Operand(pc)); | |
1255 } | |
1256 #endif | |
1257 pop(pc); | |
1258 } | 1268 } |
1259 | 1269 |
1260 | 1270 |
1261 void MacroAssembler::ThrowUncatchable(UncatchableExceptionType type, | 1271 void MacroAssembler::ThrowUncatchable(UncatchableExceptionType type, |
1262 Register value) { | 1272 Register value) { |
1263 // Adjust this code if not the case. | 1273 // Adjust this code if not the case. |
1264 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); | 1274 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); |
1265 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); | 1275 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); |
1266 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 1 * kPointerSize); | 1276 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize); |
1267 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 2 * kPointerSize); | 1277 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize); |
1268 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 3 * kPointerSize); | 1278 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize); |
1269 STATIC_ASSERT(StackHandlerConstants::kPCOffset == 4 * kPointerSize); | 1279 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize); |
1270 | 1280 |
1271 // The exception is expected in r0. | 1281 // The exception is expected in r0. |
1272 if (type == OUT_OF_MEMORY) { | 1282 if (type == OUT_OF_MEMORY) { |
1273 // Set external caught exception to false. | 1283 // Set external caught exception to false. |
1274 ExternalReference external_caught(Isolate::kExternalCaughtExceptionAddress, | 1284 ExternalReference external_caught(Isolate::kExternalCaughtExceptionAddress, |
1275 isolate()); | 1285 isolate()); |
1276 mov(r0, Operand(false, RelocInfo::NONE)); | 1286 mov(r0, Operand(false, RelocInfo::NONE)); |
1277 mov(r2, Operand(external_caught)); | 1287 mov(r2, Operand(external_caught)); |
1278 str(r0, MemOperand(r2)); | 1288 str(r0, MemOperand(r2)); |
1279 | 1289 |
1280 // Set pending exception and r0 to out of memory exception. | 1290 // Set pending exception and r0 to out of memory exception. |
1281 Failure* out_of_memory = Failure::OutOfMemoryException(); | 1291 Failure* out_of_memory = Failure::OutOfMemoryException(); |
1282 mov(r0, Operand(reinterpret_cast<int32_t>(out_of_memory))); | 1292 mov(r0, Operand(reinterpret_cast<int32_t>(out_of_memory))); |
1283 mov(r2, Operand(ExternalReference(Isolate::kPendingExceptionAddress, | 1293 mov(r2, Operand(ExternalReference(Isolate::kPendingExceptionAddress, |
1284 isolate()))); | 1294 isolate()))); |
1285 str(r0, MemOperand(r2)); | 1295 str(r0, MemOperand(r2)); |
1286 } else if (!value.is(r0)) { | 1296 } else if (!value.is(r0)) { |
1287 mov(r0, value); | 1297 mov(r0, value); |
1288 } | 1298 } |
1289 | 1299 |
1290 // Drop the stack pointer to the top of the top stack handler. | 1300 // Drop the stack pointer to the top of the top stack handler. |
1291 mov(r3, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); | 1301 mov(r3, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); |
1292 ldr(sp, MemOperand(r3)); | 1302 ldr(sp, MemOperand(r3)); |
1293 | 1303 |
1294 // Unwind the handlers until the top ENTRY handler is found. | 1304 // Unwind the handlers until the ENTRY handler is found. |
1295 Label fetch_next, check_kind; | 1305 Label fetch_next, check_kind; |
1296 jmp(&check_kind); | 1306 jmp(&check_kind); |
1297 bind(&fetch_next); | 1307 bind(&fetch_next); |
1298 ldr(sp, MemOperand(sp, StackHandlerConstants::kNextOffset)); | 1308 ldr(sp, MemOperand(sp, StackHandlerConstants::kNextOffset)); |
1299 | 1309 |
1300 bind(&check_kind); | 1310 bind(&check_kind); |
| 1311 STATIC_ASSERT(StackHandler::ENTRY == 0); |
1301 ldr(r2, MemOperand(sp, StackHandlerConstants::kStateOffset)); | 1312 ldr(r2, MemOperand(sp, StackHandlerConstants::kStateOffset)); |
1302 cmp(r2, Operand(StackHandler::ENTRY)); | 1313 tst(r2, Operand(StackHandler::KindField::kMask)); |
1303 b(ne, &fetch_next); | 1314 b(ne, &fetch_next); |
1304 | 1315 |
1305 // Set the top handler address to next handler past the top ENTRY handler. | 1316 // Set the top handler address to next handler past the top ENTRY handler. |
1306 pop(r2); | 1317 pop(r2); |
1307 str(r2, MemOperand(r3)); | 1318 str(r2, MemOperand(r3)); |
| 1319 // Get the code object (r1) and state (r2). Clear the context and frame |
| 1320 // pointer (0 was saved in the handler). |
| 1321 ldm(ia_w, sp, r1.bit() | r2.bit() | cp.bit() | fp.bit()); |
1308 | 1322 |
1309 // Clear the context and frame pointer (0 was saved in the handler), and | 1323 JumpToHandlerEntry(); |
1310 // discard the state (r2). | |
1311 ldm(ia_w, sp, r2.bit() | cp.bit() | fp.bit()); | |
1312 | |
1313 pop(pc); | |
1314 } | 1324 } |
1315 | 1325 |
1316 | 1326 |
1317 void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg, | 1327 void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg, |
1318 Register scratch, | 1328 Register scratch, |
1319 Label* miss) { | 1329 Label* miss) { |
1320 Label same_contexts; | 1330 Label same_contexts; |
1321 | 1331 |
1322 ASSERT(!holder_reg.is(scratch)); | 1332 ASSERT(!holder_reg.is(scratch)); |
1323 ASSERT(!holder_reg.is(ip)); | 1333 ASSERT(!holder_reg.is(ip)); |
(...skipping 2278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3602 void CodePatcher::EmitCondition(Condition cond) { | 3612 void CodePatcher::EmitCondition(Condition cond) { |
3603 Instr instr = Assembler::instr_at(masm_.pc_); | 3613 Instr instr = Assembler::instr_at(masm_.pc_); |
3604 instr = (instr & ~kCondMask) | cond; | 3614 instr = (instr & ~kCondMask) | cond; |
3605 masm_.emit(instr); | 3615 masm_.emit(instr); |
3606 } | 3616 } |
3607 | 3617 |
3608 | 3618 |
3609 } } // namespace v8::internal | 3619 } } // namespace v8::internal |
3610 | 3620 |
3611 #endif // V8_TARGET_ARCH_ARM | 3621 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |