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

Side by Side Diff: runtime/vm/simulator_arm.cc

Issue 12439005: Implement leaf runtime call stub on ARM and corresponding call redirection (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 months 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 | « runtime/vm/simulator_arm.h ('k') | runtime/vm/stub_code_arm_test.cc » ('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 (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <math.h> // for isnan. 5 #include <math.h> // for isnan.
6 #include <setjmp.h> 6 #include <setjmp.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #if defined(TARGET_ARCH_ARM) 10 #if defined(TARGET_ARCH_ARM)
(...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 rlist >>= 1; 1294 rlist >>= 1;
1295 } 1295 }
1296 ASSERT(end_address == address); 1296 ASSERT(end_address == address);
1297 } 1297 }
1298 } 1298 }
1299 1299
1300 1300
1301 // Calls into the Dart runtime are based on this interface. 1301 // Calls into the Dart runtime are based on this interface.
1302 typedef void (*SimulatorRuntimeCall)(NativeArguments arguments); 1302 typedef void (*SimulatorRuntimeCall)(NativeArguments arguments);
1303 1303
1304 // Calls to leaf Dart runtime functions are based on this interface.
1305 typedef int32_t (*SimulatorLeafRuntimeCall)(
1306 int32_t r0, int32_t r1, int32_t r2, int32_t r3);
1304 1307
1305 // Calls to native Dart functions are based on this interface. 1308 // Calls to native Dart functions are based on this interface.
1306 typedef void (*SimulatorNativeCall)(NativeArguments* arguments); 1309 typedef void (*SimulatorNativeCall)(NativeArguments* arguments);
1307 1310
1308 1311
1309 void Simulator::SupervisorCall(Instr* instr) { 1312 void Simulator::SupervisorCall(Instr* instr) {
1310 int svc = instr->SvcField(); 1313 int svc = instr->SvcField();
1311 switch (svc) { 1314 switch (svc) {
1312 case kRedirectionSvcCode: { 1315 case kRedirectionSvcCode: {
1313 SimulatorSetjmpBuffer buffer(this); 1316 SimulatorSetjmpBuffer buffer(this);
1314 1317
1315 if (!setjmp(buffer.buffer_)) { 1318 if (!setjmp(buffer.buffer_)) {
1316 int32_t saved_lr = get_register(LR); 1319 int32_t saved_lr = get_register(LR);
1317 Redirection* redirection = Redirection::FromSvcInstruction(instr); 1320 Redirection* redirection = Redirection::FromSvcInstruction(instr);
1318 uword external = redirection->external_function(); 1321 uword external = redirection->external_function();
1319 if (FLAG_trace_sim) { 1322 if (FLAG_trace_sim) {
1320 OS::Print("Call to host function at 0x%d\n", external); 1323 OS::Print("Call to host function at 0x%d\n", external);
1321 } 1324 }
1322 if (redirection->call_kind() == kRuntimeCall) { 1325 if (redirection->call_kind() == kRuntimeCall) {
1323 NativeArguments arguments; 1326 NativeArguments arguments;
1324 ASSERT(sizeof(NativeArguments) == 4*kWordSize); 1327 ASSERT(sizeof(NativeArguments) == 4*kWordSize);
1325 arguments.isolate_ = reinterpret_cast<Isolate*>(get_register(R0)); 1328 arguments.isolate_ = reinterpret_cast<Isolate*>(get_register(R0));
1326 arguments.argc_tag_ = get_register(R1); 1329 arguments.argc_tag_ = get_register(R1);
1327 arguments.argv_ = reinterpret_cast<RawObject*(*)[]>(get_register(R2)); 1330 arguments.argv_ = reinterpret_cast<RawObject*(*)[]>(get_register(R2));
1328 arguments.retval_ = reinterpret_cast<RawObject**>(get_register(R3)); 1331 arguments.retval_ = reinterpret_cast<RawObject**>(get_register(R3));
1329 SimulatorRuntimeCall target = 1332 SimulatorRuntimeCall target =
1330 reinterpret_cast<SimulatorRuntimeCall>(external); 1333 reinterpret_cast<SimulatorRuntimeCall>(external);
1331 target(arguments); 1334 target(arguments);
1335 set_register(R0, icount_); // Zap result register from void function.
1336 } else if (redirection->call_kind() == kLeafRuntimeCall) {
1337 int32_t r0 = get_register(R0);
1338 int32_t r1 = get_register(R1);
1339 int32_t r2 = get_register(R2);
1340 int32_t r3 = get_register(R3);
1341 SimulatorLeafRuntimeCall target =
1342 reinterpret_cast<SimulatorLeafRuntimeCall>(external);
1343 r0 = target(r0, r1, r2, r3);
1344 set_register(R0, r0); // Set returned result from function.
1332 } else { 1345 } else {
1333 ASSERT(redirection->call_kind() == kNativeCall); 1346 ASSERT(redirection->call_kind() == kNativeCall);
1334 NativeArguments* arguments; 1347 NativeArguments* arguments;
1335 arguments = reinterpret_cast<NativeArguments*>(get_register(R0)); 1348 arguments = reinterpret_cast<NativeArguments*>(get_register(R0));
1336 SimulatorNativeCall target = 1349 SimulatorNativeCall target =
1337 reinterpret_cast<SimulatorNativeCall>(external); 1350 reinterpret_cast<SimulatorNativeCall>(external);
1338 target(arguments); 1351 target(arguments);
1352 set_register(R0, icount_); // Zap result register from void function.
1339 } 1353 }
1340 1354
1341 // Zap caller-saved registers, since the actual runtime call could have 1355 // Zap caller-saved registers, since the actual runtime call could have
1342 // used them. 1356 // used them.
1357 set_register(R1, icount_);
1343 set_register(R2, icount_); 1358 set_register(R2, icount_);
1344 set_register(R3, icount_); 1359 set_register(R3, icount_);
1345 set_register(IP, icount_); 1360 set_register(IP, icount_);
1346 set_register(LR, icount_); 1361 set_register(LR, icount_);
1347 float zap_fvalue = static_cast<float>(icount_); 1362 float zap_fvalue = static_cast<float>(icount_);
1348 for (int i = S0; i <= S15; i++) { 1363 for (int i = S0; i <= S15; i++) {
1349 set_sregister(static_cast<SRegister>(i), zap_fvalue); 1364 set_sregister(static_cast<SRegister>(i), zap_fvalue);
1350 } 1365 }
1351 #ifdef VFPv3_D32 1366 #ifdef VFPv3_D32
1352 double zap_dvalue = static_cast<double>(icount_); 1367 double zap_dvalue = static_cast<double>(icount_);
1353 for (int i = D16; i <= D31; i++) { 1368 for (int i = D16; i <= D31; i++) {
1354 set_dregister(static_cast<DRegister>(i), zap_dvalue); 1369 set_dregister(static_cast<DRegister>(i), zap_dvalue);
1355 } 1370 }
1356 #endif // VFPv3_D32 1371 #endif // VFPv3_D32
1357 1372
1358 // Zap result register pair R0:R1 and return. 1373 // Return.
1359 set_register(R0, icount_);
1360 set_register(R1, icount_);
1361 set_pc(saved_lr); 1374 set_pc(saved_lr);
1362 } 1375 }
1363 1376
1364 break; 1377 break;
1365 } 1378 }
1366 case kBreakpointSvcCode: { 1379 case kBreakpointSvcCode: {
1367 SimulatorDebugger dbg(this); 1380 SimulatorDebugger dbg(this);
1368 dbg.Stop(instr, "breakpoint"); 1381 dbg.Stop(instr, "breakpoint");
1369 break; 1382 break;
1370 } 1383 }
(...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after
2844 // isolate->ChangeStateToGeneratedCode(); 2857 // isolate->ChangeStateToGeneratedCode();
2845 set_register(kExceptionObjectReg, bit_cast<int32_t>(object.raw())); 2858 set_register(kExceptionObjectReg, bit_cast<int32_t>(object.raw()));
2846 buf->Longjmp(); 2859 buf->Longjmp();
2847 } 2860 }
2848 2861
2849 } // namespace dart 2862 } // namespace dart
2850 2863
2851 #endif // !defined(HOST_ARCH_ARM) 2864 #endif // !defined(HOST_ARCH_ARM)
2852 2865
2853 #endif // defined TARGET_ARCH_ARM 2866 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/simulator_arm.h ('k') | runtime/vm/stub_code_arm_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698