From: John Hodge Date: Wed, 21 Sep 2011 08:37:51 +0000 (+0800) Subject: SpiderScript - Speedup fixes to bytecode X-Git-Tag: rel0.11~86 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=5473eb360038564028bd9afa0193f5841ab628cd;p=tpg%2Facess2.git SpiderScript - Speedup fixes to bytecode --- diff --git a/Usermode/Libraries/libspiderscript.so_src/exec_bytecode.c b/Usermode/Libraries/libspiderscript.so_src/exec_bytecode.c index 9dabeff6..780bee55 100644 --- a/Usermode/Libraries/libspiderscript.so_src/exec_bytecode.c +++ b/Usermode/Libraries/libspiderscript.so_src/exec_bytecode.c @@ -612,6 +612,32 @@ int Bytecode_int_ExecuteFunction(tSpiderScript *Script, tScript_Function *Fcn, t GET_STACKVAL(val2); // Right GET_STACKVAL(val1); // Left + + #define PERFORM_NUM_OP(_type, _field) if(val1.Type == _type && val1.Type == val2.Type) { \ + switch(op->Operation) { \ + case BC_OP_ADD: val1._field = val1._field + val2._field; break; \ + case BC_OP_SUBTRACT: val1._field = val1._field - val2._field; break; \ + case BC_OP_MULTIPLY: val1._field = val1._field * val2._field; break; \ + case BC_OP_DIVIDE: val1._field = val1._field / val2._field; break; \ + case BC_OP_EQUALS: val1._field = val1._field == val2._field; break; \ + case BC_OP_LESSTHAN: val1._field = val1._field < val2._field; break; \ + case BC_OP_LESSTHANOREQUAL: val1._field = val1._field <= val2._field; break; \ + case BC_OP_GREATERTHAN: val1._field = val1._field > val2._field; break; \ + case BC_OP_GREATERTHANOREQUAL: val1._field = val1._field >= val2._field; break; \ + \ + case BC_OP_BITAND: val1._field = (int64_t)val1._field & (int64_t)val2._field; break; \ + case BC_OP_BITOR: val1._field = (int64_t)val1._field | (int64_t)val2._field; break; \ + case BC_OP_BITXOR: val1._field = (int64_t)val1._field ^ (int64_t)val2._field; break; \ + case BC_OP_MODULO: val1._field = (int64_t)val1._field % (int64_t)val2._field; break; \ + default: AST_RuntimeError(NULL, "Invalid operation on datatype %i", _type); nextop = NULL; break;\ + }\ + PUT_STACKVAL(val1);\ + break;\ + } + + PERFORM_NUM_OP(SS_DATATYPE_INTEGER, Integer); + PERFORM_NUM_OP(SS_DATATYPE_REAL, Real); + pval1 = Bytecode_int_GetSpiderValue(&val1, &tmpVal1); pval2 = Bytecode_int_GetSpiderValue(&val2, &tmpVal2); Bytecode_int_DerefStackValue(&val1); diff --git a/Usermode/Libraries/libspiderscript.so_src/main.c b/Usermode/Libraries/libspiderscript.so_src/main.c index e2f846a9..bd292805 100644 --- a/Usermode/Libraries/libspiderscript.so_src/main.c +++ b/Usermode/Libraries/libspiderscript.so_src/main.c @@ -73,6 +73,7 @@ tSpiderScript *SpiderScript_ParseFile(tSpiderVariant *Variant, const char *Filen // HACK!! + #if 1 // - Save AST to a file { char cacheFilename[strlen(Filename)+6+1]; @@ -81,6 +82,7 @@ tSpiderScript *SpiderScript_ParseFile(tSpiderVariant *Variant, const char *Filen SpiderScript_SaveAST(ret, cacheFilename); } + #endif // - Save Bytecode too { char cacheFilename[strlen(Filename)+6+1];