diff Jint.Runtime/Main.cs @ 2:4aed85a1f558

implemented simple vm2
author cin
date Fri, 25 Oct 2013 15:52:16 +0400
parents e113095f1de0
children aced2ae9957f
line wrap: on
line diff
--- 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) {