summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-09-13 10:01:09 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-09-13 10:01:09 (GMT)
commit3e0fcc904e48bc36c1fd51f24638a1227bec860a (patch)
tree04d410c166a55c263908db222b10263389583a95
parentacf652595c7df69adab683a5a9b29e3881cc42be (diff)
downloadpowder-3e0fcc904e48bc36c1fd51f24638a1227bec860a.zip
powder-3e0fcc904e48bc36c1fd51f24638a1227bec860a.tar.gz
Disable JIT for now
-rw-r--r--src/simulation/elements/TEST.cpp100
-rw-r--r--src/virtualmachine/VirtualMachine.h8
2 files changed, 106 insertions, 2 deletions
diff --git a/src/simulation/elements/TEST.cpp b/src/simulation/elements/TEST.cpp
new file mode 100644
index 0000000..25b8f64
--- /dev/null
+++ b/src/simulation/elements/TEST.cpp
@@ -0,0 +1,100 @@
+#include "simulation/Elements.h"
+#include "virtualmachine/VirtualMachine.h"
+//#TPT-Directive ElementClass Element_TEST PT_TEST 255
+static vm::VirtualMachine * vMachine;
+Element_TEST::Element_TEST()
+{
+ Identifier = "DEFAULT_PT_TEST";
+ Name = "TEST";
+ Colour = PIXPACK(0x407020);
+ MenuVisible = 1;
+ MenuSection = SC_POWDERS;
+ Enabled = 1;
+
+ Advection = 0.4f;
+ AirDrag = 0.01f * CFDS;
+ AirLoss = 0.99f;
+ Loss = 0.95f;
+ Collision = 0.0f;
+ Gravity = 0.4f;
+ Diffusion = 0.00f;
+ HotAir = 0.000f * CFDS;
+ Falldown = 1;
+
+ Flammable = 0;
+ Explosive = 0;
+ Meltable = 0;
+ Hardness = 0;
+
+ Weight = 90;
+
+ Temperature = R_TEMP+4.0f +273.15f;
+ HeatConduct = 251;
+ Description = "Heavy particles. Fissile. Generates neutrons under pressure.";
+
+ State = ST_SOLID;
+ Properties = TYPE_PART|PROP_NEUTPENETRATE|PROP_RADIOACTIVE;
+
+ LowPressure = IPL;
+ LowPressureTransition = NT;
+ HighPressure = IPH;
+ HighPressureTransition = NT;
+ LowTemperature = ITL;
+ LowTemperatureTransition = NT;
+ HighTemperature = ITH;
+ HighTemperatureTransition = NT;
+
+
+ vMachine = new vm::VirtualMachine(2);
+ vMachine->LoadProgram("test.qvm");
+ //if(vMachine->Compile())
+ /*{
+ Update = &Element_TEST::updateCompiled;
+ }
+ else*/
+ {
+ Update = &Element_TEST::updateInterpreted;
+ }
+}
+
+//#TPT-Directive ElementHeader Element_TEST static int updateCompiled(UPDATE_FUNC_ARGS)
+int Element_TEST::updateCompiled(UPDATE_FUNC_ARGS)
+{
+ //vMachine->CallCompiled(0);
+ return 0;
+}
+
+//#TPT-Directive ElementHeader Element_TEST static int updateInterpreted(UPDATE_FUNC_ARGS)
+int Element_TEST::updateInterpreted(UPDATE_FUNC_ARGS)
+{
+ vm::word w;
+ int argAddr = 0, argCount = 5;
+ vMachine->sim = sim;
+
+ /* Set up call. */
+ vMachine->OpPUSH(w); //Pointless null in stack
+ w.int4 = (argCount + 2) * sizeof(vm::word);
+ vMachine->OpENTER(w);
+ argAddr = 8;
+
+ //Arguments
+ w.int4 = i; vMachine->Marshal(argAddr, w); argAddr += 4;
+ w.int4 = x; vMachine->Marshal(argAddr, w); argAddr += 4;
+ w.int4 = y; vMachine->Marshal(argAddr, w); argAddr += 4;
+ w.int4 = nt; vMachine->Marshal(argAddr, w); argAddr += 4;
+ w.int4 = surround_space; vMachine->Marshal(argAddr, w); argAddr += 4;
+
+ w.int4 = 0;
+ vMachine->Push(w);
+
+ vMachine->OpCALL(w);
+ vMachine->Run();
+ w.int4 = (argCount + 2) * sizeof(vm::word);
+ vMachine->OpLEAVE(w);
+ vMachine->OpPOP(w); //Pop pointless null
+ vMachine->End();
+ return 0;
+}
+
+
+Element_TEST::~Element_TEST() {} \ No newline at end of file
diff --git a/src/virtualmachine/VirtualMachine.h b/src/virtualmachine/VirtualMachine.h
index 287e9aa..1f5b088 100644
--- a/src/virtualmachine/VirtualMachine.h
+++ b/src/virtualmachine/VirtualMachine.h
@@ -123,6 +123,7 @@ namespace vm
int syscall(int programCounter);
//Used by the JIT
+ #ifdef VMJIT
int constant4();
int constant1();
void emit1(int v);
@@ -133,9 +134,14 @@ namespace vm
void emitMovEAXEDI();
bool emitMovEBXEDI(int andit);
static int hex(int c);
+ #endif
public:
+ #ifdef VMJIT
static void callFromCompiled();
static void callSyscall();
+ bool Compile();
+ int CallCompiled(int address);
+ #endif
Simulation * sim;
Renderer * ren;
@@ -146,11 +152,9 @@ public:
VirtualMachine(int hunkMbytes);
virtual ~VirtualMachine();
- bool Compile();
int LoadProgram(char * filename);
int Run();
int CallInterpreted(int address);
- int CallCompiled(int address);
void End();
void Marshal(int address, word element)
{