From 4736c6c09d90162a112c17fc82bfc75da8efc4e2 Mon Sep 17 00:00:00 2001 From: Adrian Thurston Date: Sun, 5 Apr 2015 17:24:50 -0400 Subject: add destroy2 to unwind code for user iters Will likely need to distinguish between a destroy and unwind for user iterators. Destroy is akin to the return, wheres unwind forces unwinding of the called iterator's stack. --- src/bytecode.c | 11 +++++++++++ src/bytecode.h | 2 +- src/synthesis.cc | 5 ++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/bytecode.c b/src/bytecode.c index 3a8cfcc9..ed51f8f0 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -3511,6 +3511,17 @@ again: break; } + case IN_UITER_DESTROY2: { + short field; + read_half( field ); + + debug( prg, REALM_BYTECODE, "IN_UITER_DESTROY %hd\n", field ); + + UserIter *uiter = (UserIter*) vm_get_local(exec, field); + userIterDestroy2( prg, &sp, uiter ); + break; + } + case IN_RET: { FrameInfo *fi = &prg->rtd->frameInfo[exec->frameId]; downref_local_trees( prg, sp, exec, fi->locals, fi->localsLen ); diff --git a/src/bytecode.h b/src/bytecode.h index 8b1ab496..2b4cb5b9 100644 --- a/src/bytecode.h +++ b/src/bytecode.h @@ -168,6 +168,7 @@ typedef unsigned long colm_value_t; #define IN_REV_TRITER_PREV_CHILD 0x4c #define IN_UITER_DESTROY 0x4d +#define IN_UITER_DESTROY2 0x71 #define IN_UITER_CREATE_WV 0x4e #define IN_UITER_CREATE_WC 0x4f #define IN_UITER_ADVANCE 0x50 @@ -209,7 +210,6 @@ typedef unsigned long colm_value_t; #define IN_GET_VLIST_MEM_WV 0x70 #define IN_GET_VLIST_MEM_BKT 0x5c -// 0x71 // 0x73 // 0x74 // 0x75 diff --git a/src/synthesis.cc b/src/synthesis.cc index f90005c4..7210d2ff 100644 --- a/src/synthesis.cc +++ b/src/synthesis.cc @@ -2204,7 +2204,10 @@ void LangStmt::compileForIterBody( Compiler *pd, /* Add the cleanup for the current loop. */ int lcLen = pd->unwindCode.length(); pd->unwindCode.insertHalf( 0, objField->offset ); - pd->unwindCode.insert( 0, objField->iterImpl->inDestroy ); + int c = objField->iterImpl->inDestroy; + if ( c == IN_UITER_DESTROY ) + c = IN_UITER_DESTROY2; + pd->unwindCode.insert( 0, c ); //objField->iterImpl->inDestroy ); /* Compile the contents. */ for ( StmtList::Iter stmt = *stmtList; stmt.lte(); stmt++ ) -- cgit v1.2.1