More reliable detection of when we're at a native/Lua call boundary

Fri, 28 May 2010 02:20:35 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 28 May 2010 02:20:35 +0100
changeset 51
b429e7a73de7
parent 50
4612c85cdc01
child 52
cae5ea4e3321

More reliable detection of when we're at a native/Lua call boundary

lvm.js file | annotate | diff | comparison | revisions
--- a/lvm.js	Fri May 28 02:19:34 2010 +0100
+++ b/lvm.js	Fri May 28 02:20:35 2010 +0100
@@ -299,7 +299,7 @@
 LVM.prototype = {
 	call: function (lfFunction)
 	{
-		var frame = {f:lfFunction,pc:0,reg:[]};
+		var frame = {f:lfFunction,pc:0,reg:[],entry:true};
 		this.callstack.push(frame);
 		for(var i=0;i<lfFunction.maxStackSize;i++)
 			frame.reg[i] = new LValue("nil", null);
@@ -386,7 +386,8 @@
 				{
 					// Lua function
 					frame = {f:f,pc:0,reg:args,
-						retAt:INS_A(instruction),retCount:INS_C(instruction)};
+						retAt:INS_A(instruction),retCount:INS_C(instruction),
+						entry:false};
 					this.callstack.push(frame);
 				}
 				break;
@@ -419,7 +420,7 @@
 					rets = oldFrame.reg.slice(INS_A(instruction));
 				else
 					rets = oldFrame.reg.slice(INS_A(instruction),INS_A(instruction)+(INS_B(instruction)-1));
-				if(frame)
+				if(!oldFrame.entry)
 				{
 					var i;
 					for(i=0;(oldFrame.retCount == 0||i<oldFrame.retCount)&&i<rets.length;i++)

mercurial