OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 int32_t arg2, | 1242 int32_t arg2, |
1243 int32_t arg3); | 1243 int32_t arg3); |
1244 | 1244 |
1245 | 1245 |
1246 // Software interrupt instructions are used by the simulator to call into the | 1246 // Software interrupt instructions are used by the simulator to call into the |
1247 // C-based V8 runtime. | 1247 // C-based V8 runtime. |
1248 void Simulator::SoftwareInterrupt(Instr* instr) { | 1248 void Simulator::SoftwareInterrupt(Instr* instr) { |
1249 int swi = instr->SwiField(); | 1249 int swi = instr->SwiField(); |
1250 switch (swi) { | 1250 switch (swi) { |
1251 case call_rt_redirected: { | 1251 case call_rt_redirected: { |
| 1252 // Check if stack is aligned. Error if not aligned is reported below to |
| 1253 // include information on the function called. |
| 1254 bool stack_aligned = |
| 1255 (get_register(sp) |
| 1256 & (::v8::internal::FLAG_sim_stack_alignment - 1)) == 0; |
1252 Redirection* redirection = Redirection::FromSwiInstruction(instr); | 1257 Redirection* redirection = Redirection::FromSwiInstruction(instr); |
1253 int32_t arg0 = get_register(r0); | 1258 int32_t arg0 = get_register(r0); |
1254 int32_t arg1 = get_register(r1); | 1259 int32_t arg1 = get_register(r1); |
1255 int32_t arg2 = get_register(r2); | 1260 int32_t arg2 = get_register(r2); |
1256 int32_t arg3 = get_register(r3); | 1261 int32_t arg3 = get_register(r3); |
1257 // This is dodgy but it works because the C entry stubs are never moved. | 1262 // This is dodgy but it works because the C entry stubs are never moved. |
1258 // See comment in codegen-arm.cc and bug 1242173. | 1263 // See comment in codegen-arm.cc and bug 1242173. |
1259 int32_t saved_lr = get_register(lr); | 1264 int32_t saved_lr = get_register(lr); |
1260 if (redirection->fp_return()) { | 1265 if (redirection->fp_return()) { |
1261 intptr_t external = | 1266 intptr_t external = |
1262 reinterpret_cast<intptr_t>(redirection->external_function()); | 1267 reinterpret_cast<intptr_t>(redirection->external_function()); |
1263 SimulatorRuntimeFPCall target = | 1268 SimulatorRuntimeFPCall target = |
1264 reinterpret_cast<SimulatorRuntimeFPCall>(external); | 1269 reinterpret_cast<SimulatorRuntimeFPCall>(external); |
1265 if (::v8::internal::FLAG_trace_sim) { | 1270 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { |
1266 double x, y; | 1271 double x, y; |
1267 GetFpArgs(&x, &y); | 1272 GetFpArgs(&x, &y); |
1268 PrintF("Call to host function at %p with args %f, %f\n", | 1273 PrintF("Call to host function at %p with args %f, %f", |
1269 FUNCTION_ADDR(target), x, y); | 1274 FUNCTION_ADDR(target), x, y); |
| 1275 if (!stack_aligned) { |
| 1276 PrintF(" with unaligned stack %08x\n", get_register(sp)); |
| 1277 } |
| 1278 PrintF("\n"); |
1270 } | 1279 } |
| 1280 CHECK(stack_aligned); |
1271 double result = target(arg0, arg1, arg2, arg3); | 1281 double result = target(arg0, arg1, arg2, arg3); |
1272 SetFpResult(result); | 1282 SetFpResult(result); |
1273 } else { | 1283 } else { |
1274 intptr_t external = | 1284 intptr_t external = |
1275 reinterpret_cast<int32_t>(redirection->external_function()); | 1285 reinterpret_cast<int32_t>(redirection->external_function()); |
1276 SimulatorRuntimeCall target = | 1286 SimulatorRuntimeCall target = |
1277 reinterpret_cast<SimulatorRuntimeCall>(external); | 1287 reinterpret_cast<SimulatorRuntimeCall>(external); |
1278 if (::v8::internal::FLAG_trace_sim) { | 1288 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { |
1279 PrintF( | 1289 PrintF( |
1280 "Call to host function at %p with args %08x, %08x, %08x, %08x\n", | 1290 "Call to host function at %p with args %08x, %08x, %08x, %08x", |
1281 FUNCTION_ADDR(target), | 1291 FUNCTION_ADDR(target), |
1282 arg0, | 1292 arg0, |
1283 arg1, | 1293 arg1, |
1284 arg2, | 1294 arg2, |
1285 arg3); | 1295 arg3); |
| 1296 if (!stack_aligned) { |
| 1297 PrintF(" with unaligned stack %08x\n", get_register(sp)); |
| 1298 } |
| 1299 PrintF("\n"); |
1286 } | 1300 } |
| 1301 CHECK(stack_aligned); |
1287 int64_t result = target(arg0, arg1, arg2, arg3); | 1302 int64_t result = target(arg0, arg1, arg2, arg3); |
1288 int32_t lo_res = static_cast<int32_t>(result); | 1303 int32_t lo_res = static_cast<int32_t>(result); |
1289 int32_t hi_res = static_cast<int32_t>(result >> 32); | 1304 int32_t hi_res = static_cast<int32_t>(result >> 32); |
1290 if (::v8::internal::FLAG_trace_sim) { | 1305 if (::v8::internal::FLAG_trace_sim) { |
1291 PrintF("Returned %08x\n", lo_res); | 1306 PrintF("Returned %08x\n", lo_res); |
1292 } | 1307 } |
1293 set_register(r0, lo_res); | 1308 set_register(r0, lo_res); |
1294 set_register(r1, hi_res); | 1309 set_register(r1, hi_res); |
1295 } | 1310 } |
1296 set_register(lr, saved_lr); | 1311 set_register(lr, saved_lr); |
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2518 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp); | 2533 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp); |
2519 uintptr_t address = *stack_slot; | 2534 uintptr_t address = *stack_slot; |
2520 set_register(sp, current_sp + sizeof(uintptr_t)); | 2535 set_register(sp, current_sp + sizeof(uintptr_t)); |
2521 return address; | 2536 return address; |
2522 } | 2537 } |
2523 | 2538 |
2524 | 2539 |
2525 } } // namespace assembler::arm | 2540 } } // namespace assembler::arm |
2526 | 2541 |
2527 #endif // !defined(__arm__) | 2542 #endif // !defined(__arm__) |
OLD | NEW |