[aarch64-port-dev ] Simulator: support buffered memory
Andrew Haley
aph at redhat.com
Fri Jul 19 04:37:19 PDT 2013
This adds support for buffered memory to the simulator. You'll
need to rebuild HotSpot.
Andrew.
comparing with http://hg.code.sf.net/p/smallaarch64sim/code
searching for changes
changeset: 201:cfb5b9b2a78d
tag: tip
user: aph
date: Fri Jul 19 12:35:09 2013 +0100
summary: Buffered memory support
diff -r 810fe3c0aba0 -r cfb5b9b2a78d simgdbinit
--- a/simgdbinit Thu Jul 04 18:20:11 2013 +0100
+++ b/simgdbinit Fri Jul 19 12:35:09 2013 +0100
@@ -105,6 +105,14 @@
# commands from now on are documneted using the gdb document command
# which makes the documenation available from gdb itself.
+define simstop
+ call 'AArch64Simulator::stopped'++
+end
+
+define simstart
+ call 'AArch64Simulator::stopped'--
+end
+
define simstep
if $argc == 0
set 'AArch64Simulator::current'()->debugState.stepCount = 1
@@ -878,7 +886,9 @@
define simpf
+ simstop
call pf('AArch64Simulator::current'()->cpuState.gr[31].value.u64, 'AArch64Simulator::current'()->cpuState.gr[rfp].value.u64, 'AArch64Simulator::current'()->cpuState.pc, 'AArch64Simulator::current'()->cpuState.gr[22].value.u64, 'AArch64Simulator::current'()->cpuState.gr[28].value.u64)
+ simstart
end
document simpf
diff -r 810fe3c0aba0 -r cfb5b9b2a78d simulator.cpp
--- a/simulator.cpp Thu Jul 04 18:20:11 2013 +0100
+++ b/simulator.cpp Fri Jul 19 12:35:09 2013 +0100
@@ -71,9 +71,7 @@
"ERROR_EXCEPTION"
};
-int AArch64Simulator::useCache = 0;
-
-AArch64Simulator::AArch64Simulator() : memory((useCache ? (Memory *)new CacheMemory(&debugState) : (Memory *)new DirectMemory()))
+AArch64Simulator::AArch64Simulator(bool useCache) : memory((useCache ? (Memory *)new CacheMemory(&debugState) : (Memory *)new DirectMemory()))
{
// set up callbacks into JVM
initCallbacks();
@@ -179,10 +177,10 @@
static __thread AArch64Simulator *sim = 0;
static __thread u_int64_t stack = 0;
-AArch64Simulator *AArch64Simulator::current()
+AArch64Simulator *AArch64Simulator::get_current(bool buffered)
{
if (sim == 0) {
- sim = new AArch64Simulator();
+ sim = new AArch64Simulator(buffered);
} else {
assert(sim->debugState.tid == syscall(__NR_gettid));
}
@@ -192,6 +190,11 @@
return sim;
}
+AArch64Simulator *AArch64Simulator::current()
+{
+ return get_current(false);
+}
+
extern "C" void stop();
extern "C" void start();
@@ -294,7 +297,7 @@
return;
}
-bool AArch64Simulator::stopped;
+int AArch64Simulator::stopped;
extern "C" void stop() { AArch64Simulator::stopped = true; }
extern "C" void start() { AArch64Simulator::stopped = false; }
@@ -3757,8 +3760,29 @@
// data synchronization barrier
+enum barrier {OSHLD = 0b0001, OSHST, OSH, NSHLD=0b0101, NSHST, NSH,
+ ISHLD = 0b1001, ISHST, ISH, LD=0b1101, ST, SY};
+
void AArch64Simulator::dsb()
{
+ barrier kind = (barrier)uimm(instr, 11, 8);
+ switch (kind) {
+ case ST:
+ memory->flush_all(false);
+ asm("sfence");
+ break;
+ case LD:
+ memory->flush_all(true);
+ asm("lfence");
+ break;
+ case SY:
+ memory->flush_all(true);
+ asm("mfence");
+ break;
+ default:
+ abort();
+ break;
+ }
}
// data memory barrier
diff -r 810fe3c0aba0 -r cfb5b9b2a78d simulator.hpp
--- a/simulator.hpp Thu Jul 04 18:20:11 2013 +0100
+++ b/simulator.hpp Fri Jul 19 12:35:09 2013 +0100
@@ -104,15 +104,14 @@
// allow memory to be supplied at create so we can support
// alternative memory models
- AArch64Simulator();
+ AArch64Simulator(bool useCache = true);
AArch64Simulator(Memory *m);
void initCallbacks();
- // configure use of memory
- static int useCache;
// retrieve the simulator associated with the current thread
+ static AArch64Simulator *get_current(bool useCache);
static AArch64Simulator *current();
// retrieve the alternative stack on which we should
@@ -294,7 +293,7 @@
return errorCodeText[errorCode];
}
- static bool stopped;
+ static int stopped;
// used by exception handler
More information about the aarch64-port-dev
mailing list