# HG changeset patch
# User cin
# Date 1382701936 -14400
# Node ID 4aed85a1f558da528b5d4939e534a60495297e2e
# Parent 033ebe7432d5dfb0a8eae9e22b0551e77b846111
implemented simple vm2
diff -r 033ebe7432d5 -r 4aed85a1f558 Jint.Runtime/Jint.Runtime.csproj
--- a/Jint.Runtime/Jint.Runtime.csproj Thu Oct 24 19:45:57 2013 +0400
+++ b/Jint.Runtime/Jint.Runtime.csproj Fri Oct 25 15:52:16 2013 +0400
@@ -55,8 +55,8 @@
-
+
diff -r 033ebe7432d5 -r 4aed85a1f558 Jint.Runtime/Main.cs
--- a/Jint.Runtime/Main.cs Thu Oct 24 19:45:57 2013 +0400
+++ b/Jint.Runtime/Main.cs Fri Oct 25 15:52:16 2013 +0400
@@ -34,6 +34,19 @@
count = OpAdd(count,inc);
Console.WriteLine ("reference results: {0}, int {1} ms", count, Environment.TickCount - t );
+
+ var code = new VM2.Instruction[10000000];
+
+ for (int i = 0; i < code.Length; i++)
+ code[i] = new VM2.Instruction(){ code = VM2.OpCodes.Codes.Add, dest = 0, args = new int[] {0,1} };
+ var machine = new VM2.Machine ();
+
+ t = Environment.TickCount;
+
+ machine.InitFrame (new object[] { 0, 1 });
+ machine.Execute (code);
+
+ Console.WriteLine ("vm2: {0}, int {1} ms", machine.Get(0), Environment.TickCount - t );
}
public static object OpAdd(object arg1, object arg2) {
diff -r 033ebe7432d5 -r 4aed85a1f558 Jint.Runtime/VM2/Box.cs
--- a/Jint.Runtime/VM2/Box.cs Thu Oct 24 19:45:57 2013 +0400
+++ b/Jint.Runtime/VM2/Box.cs Fri Oct 25 15:52:16 2013 +0400
@@ -9,6 +9,11 @@
public Operation[] impl;
public object value;
+ public Box(object boxValue,Operation[] opImpl) {
+ value = boxValue;
+ impl = opImpl;
+ }
+
public Type HoldingType {
get {
return value == null ? null : value.GetType ();
diff -r 033ebe7432d5 -r 4aed85a1f558 Jint.Runtime/VM2/Instruction.cs
--- a/Jint.Runtime/VM2/Instruction.cs Thu Oct 24 19:45:57 2013 +0400
+++ b/Jint.Runtime/VM2/Instruction.cs Fri Oct 25 15:52:16 2013 +0400
@@ -2,6 +2,7 @@
namespace Jint.Runtime.VM2
{
+ using OpCodes;
public struct Instruction
{
public Codes code;
diff -r 033ebe7432d5 -r 4aed85a1f558 Jint.Runtime/VM2/Machine.cs
--- a/Jint.Runtime/VM2/Machine.cs Thu Oct 24 19:45:57 2013 +0400
+++ b/Jint.Runtime/VM2/Machine.cs Fri Oct 25 15:52:16 2013 +0400
@@ -6,24 +6,36 @@
public class Machine
{
RuntimeContext m_context;
- Stack