From c9fc0327b1f9c431c11672821a3eab41b326638f Mon Sep 17 00:00:00 2001 From: James Roseborough Date: Mon, 14 Jul 2008 17:57:44 +0000 Subject: [PATCH] Add tests for jit argument passing --- src/script/org/luaj/jit/LuaJit.java | 91 +++++++++++------- .../java/org/luaj/jit/LuaJitBasicTest.java | 11 +++ .../java/org/luaj/jit/LuaJitPerfTest.java | 92 +++++++++++++++++++ 3 files changed, 161 insertions(+), 33 deletions(-) create mode 100644 src/test/java/org/luaj/jit/LuaJitPerfTest.java diff --git a/src/script/org/luaj/jit/LuaJit.java b/src/script/org/luaj/jit/LuaJit.java index 178ad242..9d76c1c8 100644 --- a/src/script/org/luaj/jit/LuaJit.java +++ b/src/script/org/luaj/jit/LuaJit.java @@ -93,6 +93,15 @@ public class LuaJit extends Lua implements LuaCompiler { // instantiate, config and return if (success) { + // compile sub-prototypes + if ( p.p != null ) { + for ( int i=0, n=p.p.length; i 0) { // else use previous instruction set top for ( int j=1; j 0 ) for ( int j=0; j 0) { for ( int j=1; j plain ); + } + + private static int timeTrial(String type, LPrototype p) { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + BaseLib.redirectOutput(outputStream); + LuaState vm = Platform.newLuaState(); + LClosure c = p.newClosure(vm._G); + int globalCount = 0; + for ( int i=0; i<5; i++ ) { + int localCount = 0; + long t1 = System.currentTimeMillis() + 1000; + while ( t1 > System.currentTimeMillis() ) { + vm.pushlvalue(c); + vm.call(0, 0); + localCount++; + } + System.out.println(type+": "+(localCount)); + System.out.flush(); + globalCount += localCount; + } + return globalCount; + } +}