Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: src/arm/macro-assembler-arm.cc

Issue 8540005: Revert "Add a level of indirection to exception handler addresses." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/macro-assembler-arm.h ('k') | src/ast.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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) {
1172 // Adjust this code if not the case. 1171 // Adjust this code if not the case.
1173 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); 1172 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize);
1174 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); 1173 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize);
1175 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize); 1174 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 1 * kPointerSize);
1176 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize); 1175 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 2 * kPointerSize);
1177 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize); 1176 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 3 * kPointerSize);
1178 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize); 1177 STATIC_ASSERT(StackHandlerConstants::kPCOffset == 4 * kPointerSize);
1179 1178
1180 // For the JSEntry handler, we must preserve r0-r4, r5-r7 are available. 1179 // The pc (return address) is passed in register lr.
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);
1184 if (try_location == IN_JAVASCRIPT) { 1180 if (try_location == IN_JAVASCRIPT) {
1185 state |= (type == TRY_CATCH_HANDLER) 1181 if (type == TRY_CATCH_HANDLER) {
1186 ? StackHandler::KindField::encode(StackHandler::TRY_CATCH) 1182 mov(r3, Operand(StackHandler::TRY_CATCH));
1187 : StackHandler::KindField::encode(StackHandler::TRY_FINALLY); 1183 } else {
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));
1188 } else { 1193 } else {
1194 // Must preserve r0-r4, r5-r7 are available.
1189 ASSERT(try_location == IN_JS_ENTRY); 1195 ASSERT(try_location == IN_JS_ENTRY);
1190 state |= StackHandler::KindField::encode(StackHandler::ENTRY); 1196 // The frame pointer does not point to a JS frame so we save NULL
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));
1191 } 1209 }
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));
1212 } 1210 }
1213 1211
1214 1212
1215 void MacroAssembler::PopTryHandler() { 1213 void MacroAssembler::PopTryHandler() {
1216 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); 1214 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0);
1217 pop(r1); 1215 pop(r1);
1218 mov(ip, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); 1216 mov(ip, Operand(ExternalReference(Isolate::kHandlerAddress, isolate())));
1219 add(sp, sp, Operand(StackHandlerConstants::kSize - kPointerSize)); 1217 add(sp, sp, Operand(StackHandlerConstants::kSize - kPointerSize));
1220 str(r1, MemOperand(ip)); 1218 str(r1, MemOperand(ip));
1221 } 1219 }
1222 1220
1223 1221
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
1237 void MacroAssembler::Throw(Register value) { 1222 void MacroAssembler::Throw(Register value) {
1238 // Adjust this code if not the case. 1223 // Adjust this code if not the case.
1239 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); 1224 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize);
1240 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); 1225 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize);
1241 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize); 1226 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 1 * kPointerSize);
1242 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize); 1227 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 2 * kPointerSize);
1243 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize); 1228 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 3 * kPointerSize);
1244 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize); 1229 STATIC_ASSERT(StackHandlerConstants::kPCOffset == 4 * kPointerSize);
1245 1230 // r0 is expected to hold the exception.
1246 // The exception is expected in r0.
1247 if (!value.is(r0)) { 1231 if (!value.is(r0)) {
1248 mov(r0, value); 1232 mov(r0, value);
1249 } 1233 }
1250 // Drop the stack pointer to the top of the top handler. 1234
1235 // Drop the sp to the top of the handler.
1251 mov(r3, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); 1236 mov(r3, Operand(ExternalReference(Isolate::kHandlerAddress, isolate())));
1252 ldr(sp, MemOperand(r3)); 1237 ldr(sp, MemOperand(r3));
1238
1253 // Restore the next handler. 1239 // Restore the next handler.
1254 pop(r2); 1240 pop(r2);
1255 str(r2, MemOperand(r3)); 1241 str(r2, MemOperand(r3));
1256 1242
1257 // Get the code object (r1) and state (r2). Restore the context and frame 1243 // Restore context and frame pointer, discard state (r3).
1258 // pointer. 1244 ldm(ia_w, sp, r3.bit() | cp.bit() | fp.bit());
1259 ldm(ia_w, sp, r1.bit() | r2.bit() | cp.bit() | fp.bit());
1260 1245
1261 // If the handler is a JS frame, restore the context to the frame. 1246 // If the handler is a JS frame, restore the context to the frame.
1262 // (kind == ENTRY) == (fp == 0) == (cp == 0), so we could test either fp 1247 // (r3 == ENTRY) == (fp == 0) == (cp == 0), so we could test any
1263 // or cp. 1248 // of them.
1264 tst(cp, cp); 1249 cmp(r3, Operand(StackHandler::ENTRY));
1265 str(cp, MemOperand(fp, StandardFrameConstants::kContextOffset), ne); 1250 str(cp, MemOperand(fp, StandardFrameConstants::kContextOffset), ne);
1266 1251
1267 JumpToHandlerEntry(); 1252 #ifdef DEBUG
1253 if (emit_debug_code()) {
1254 mov(lr, Operand(pc));
1255 }
1256 #endif
1257 pop(pc);
1268 } 1258 }
1269 1259
1270 1260
1271 void MacroAssembler::ThrowUncatchable(UncatchableExceptionType type, 1261 void MacroAssembler::ThrowUncatchable(UncatchableExceptionType type,
1272 Register value) { 1262 Register value) {
1273 // Adjust this code if not the case. 1263 // Adjust this code if not the case.
1274 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); 1264 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize);
1275 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); 1265 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize);
1276 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize); 1266 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 1 * kPointerSize);
1277 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize); 1267 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 2 * kPointerSize);
1278 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize); 1268 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 3 * kPointerSize);
1279 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize); 1269 STATIC_ASSERT(StackHandlerConstants::kPCOffset == 4 * kPointerSize);
1280 1270
1281 // The exception is expected in r0. 1271 // The exception is expected in r0.
1282 if (type == OUT_OF_MEMORY) { 1272 if (type == OUT_OF_MEMORY) {
1283 // Set external caught exception to false. 1273 // Set external caught exception to false.
1284 ExternalReference external_caught(Isolate::kExternalCaughtExceptionAddress, 1274 ExternalReference external_caught(Isolate::kExternalCaughtExceptionAddress,
1285 isolate()); 1275 isolate());
1286 mov(r0, Operand(false, RelocInfo::NONE)); 1276 mov(r0, Operand(false, RelocInfo::NONE));
1287 mov(r2, Operand(external_caught)); 1277 mov(r2, Operand(external_caught));
1288 str(r0, MemOperand(r2)); 1278 str(r0, MemOperand(r2));
1289 1279
1290 // Set pending exception and r0 to out of memory exception. 1280 // Set pending exception and r0 to out of memory exception.
1291 Failure* out_of_memory = Failure::OutOfMemoryException(); 1281 Failure* out_of_memory = Failure::OutOfMemoryException();
1292 mov(r0, Operand(reinterpret_cast<int32_t>(out_of_memory))); 1282 mov(r0, Operand(reinterpret_cast<int32_t>(out_of_memory)));
1293 mov(r2, Operand(ExternalReference(Isolate::kPendingExceptionAddress, 1283 mov(r2, Operand(ExternalReference(Isolate::kPendingExceptionAddress,
1294 isolate()))); 1284 isolate())));
1295 str(r0, MemOperand(r2)); 1285 str(r0, MemOperand(r2));
1296 } else if (!value.is(r0)) { 1286 } else if (!value.is(r0)) {
1297 mov(r0, value); 1287 mov(r0, value);
1298 } 1288 }
1299 1289
1300 // Drop the stack pointer to the top of the top stack handler. 1290 // Drop the stack pointer to the top of the top stack handler.
1301 mov(r3, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); 1291 mov(r3, Operand(ExternalReference(Isolate::kHandlerAddress, isolate())));
1302 ldr(sp, MemOperand(r3)); 1292 ldr(sp, MemOperand(r3));
1303 1293
1304 // Unwind the handlers until the ENTRY handler is found. 1294 // Unwind the handlers until the top ENTRY handler is found.
1305 Label fetch_next, check_kind; 1295 Label fetch_next, check_kind;
1306 jmp(&check_kind); 1296 jmp(&check_kind);
1307 bind(&fetch_next); 1297 bind(&fetch_next);
1308 ldr(sp, MemOperand(sp, StackHandlerConstants::kNextOffset)); 1298 ldr(sp, MemOperand(sp, StackHandlerConstants::kNextOffset));
1309 1299
1310 bind(&check_kind); 1300 bind(&check_kind);
1311 STATIC_ASSERT(StackHandler::ENTRY == 0);
1312 ldr(r2, MemOperand(sp, StackHandlerConstants::kStateOffset)); 1301 ldr(r2, MemOperand(sp, StackHandlerConstants::kStateOffset));
1313 tst(r2, Operand(StackHandler::KindField::kMask)); 1302 cmp(r2, Operand(StackHandler::ENTRY));
1314 b(ne, &fetch_next); 1303 b(ne, &fetch_next);
1315 1304
1316 // Set the top handler address to next handler past the top ENTRY handler. 1305 // Set the top handler address to next handler past the top ENTRY handler.
1317 pop(r2); 1306 pop(r2);
1318 str(r2, MemOperand(r3)); 1307 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());
1322 1308
1323 JumpToHandlerEntry(); 1309 // Clear the context and frame pointer (0 was saved in the handler), and
1310 // discard the state (r2).
1311 ldm(ia_w, sp, r2.bit() | cp.bit() | fp.bit());
1312
1313 pop(pc);
1324 } 1314 }
1325 1315
1326 1316
1327 void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg, 1317 void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg,
1328 Register scratch, 1318 Register scratch,
1329 Label* miss) { 1319 Label* miss) {
1330 Label same_contexts; 1320 Label same_contexts;
1331 1321
1332 ASSERT(!holder_reg.is(scratch)); 1322 ASSERT(!holder_reg.is(scratch));
1333 ASSERT(!holder_reg.is(ip)); 1323 ASSERT(!holder_reg.is(ip));
(...skipping 2278 matching lines...) Expand 10 before | Expand all | Expand 10 after
3612 void CodePatcher::EmitCondition(Condition cond) { 3602 void CodePatcher::EmitCondition(Condition cond) {
3613 Instr instr = Assembler::instr_at(masm_.pc_); 3603 Instr instr = Assembler::instr_at(masm_.pc_);
3614 instr = (instr & ~kCondMask) | cond; 3604 instr = (instr & ~kCondMask) | cond;
3615 masm_.emit(instr); 3605 masm_.emit(instr);
3616 } 3606 }
3617 3607
3618 3608
3619 } } // namespace v8::internal 3609 } } // namespace v8::internal
3620 3610
3621 #endif // V8_TARGET_ARCH_ARM 3611 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/macro-assembler-arm.h ('k') | src/ast.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698