summaryrefslogtreecommitdiffstats
path: root/generic/tclAssembly.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2013-10-20 18:11:35 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2013-10-20 18:11:35 (GMT)
commit39e314ad912cdbd29ba3e01673b1097b40118f8b (patch)
tree8d2cc46c815847369fee10486b2370ab7340257f /generic/tclAssembly.c
parentacfb2a50369dae9afcf444519e5d3875812d5a3b (diff)
downloadtcl-39e314ad912cdbd29ba3e01673b1097b40118f8b.zip
tcl-39e314ad912cdbd29ba3e01673b1097b40118f8b.tar.gz
tcl-39e314ad912cdbd29ba3e01673b1097b40118f8b.tar.bz2
And the last bits that need fixing; the code is still less efficient than desired but should now not crash.dkf_loop_exception_range_work
Diffstat (limited to 'generic/tclAssembly.c')
-rw-r--r--generic/tclAssembly.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/generic/tclAssembly.c b/generic/tclAssembly.c
index 08da075..fc51457 100644
--- a/generic/tclAssembly.c
+++ b/generic/tclAssembly.c
@@ -246,6 +246,8 @@ static void BBEmitInstInt4(AssemblyEnv* assemEnvPtr, int tblIdx,
int opnd, int count);
static void BBEmitInst1or4(AssemblyEnv* assemEnvPtr, int tblIdx,
int param, int count);
+static void BBEmitInvoke1or4(AssemblyEnv* assemEnvPtr, int tblIdx,
+ int param, int count);
static void BBEmitOpcode(AssemblyEnv* assemEnvPtr, int tblIdx,
int count);
static int BuildExceptionRanges(AssemblyEnv* assemEnvPtr);
@@ -679,10 +681,13 @@ BBEmitInstInt4(
/*
*-----------------------------------------------------------------------------
*
- * BBEmitInst1or4 --
+ * BBEmitInst1or4, BBEmitInvoke1or4 --
*
* Emits a 1- or 4-byte operation according to the magnitude of the
- * operand
+ * operand. The Invoke variant generates wrapping stack-balance
+ * management if necessary (which is not normally required in assembled
+ * code, as loop exception ranges, expansions, breaks and continues can't
+ * be issued currently).
*
*-----------------------------------------------------------------------------
*/
@@ -714,6 +719,29 @@ BBEmitInst1or4(
TclUpdateAtCmdStart(op, envPtr);
BBUpdateStackReqs(bbPtr, tblIdx, count);
}
+
+static void
+BBEmitInvoke1or4(
+ AssemblyEnv* assemEnvPtr, /* Assembly environment */
+ int tblIdx, /* Index in TalInstructionTable of op */
+ int param, /* Variable-length parameter */
+ int count) /* Arity if variadic */
+{
+ CompileEnv* envPtr = assemEnvPtr->envPtr;
+ /* Compilation environment */
+ BasicBlock* bbPtr = assemEnvPtr->curr_bb;
+ /* Current basic block */
+ int op = TalInstructionTable[tblIdx].tclInstCode;
+
+ if (param <= 0xff) {
+ op >>= 8;
+ } else {
+ op &= 0xff;
+ }
+ TclEmitInvoke(envPtr, op, param);
+ TclUpdateAtCmdStart(op, envPtr);
+ BBUpdateStackReqs(bbPtr, tblIdx, count);
+}
/*
*-----------------------------------------------------------------------------
@@ -1450,8 +1478,7 @@ AssembleOneLine(
goto cleanup;
}
- // FIXME - use TclEmitInvoke
- BBEmitInst1or4(assemEnvPtr, tblIdx, opnd, opnd);
+ BBEmitInvoke1or4(assemEnvPtr, tblIdx, opnd, opnd);
break;
case ASSEM_JUMP: