From 395a8766bdb9d5af98893b7036d14238647e896b Mon Sep 17 00:00:00 2001 From: Myk Melez Date: Wed, 21 Jan 2015 14:13:19 -0800 Subject: [PATCH 01/17] move urlparams library and midlet config file to better locations --- README.md | 2 +- midlet.js => config/midlet.js | 0 index.html | 4 ++-- libs/{urlparams.js => config.js} | 0 main.html | 4 ++-- 5 files changed, 5 insertions(+), 5 deletions(-) rename midlet.js => config/midlet.js (100%) rename libs/{urlparams.js => config.js} (100%) diff --git a/README.md b/README.md index f13f0c6c..34a3de99 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ index.html is a webapp that runs j2me.js. The URL parameters you pass to index.h ### URL parameters -See full list at libs/urlparams.js +See full list at libs/config.js * `main` - default is `com/sun/midp/main/MIDletSuiteLoader` * `midletClassName` - must be set to the main class to run. Only valid when default `main` parameter is used. Defaults to `RunTests` diff --git a/midlet.js b/config/midlet.js similarity index 100% rename from midlet.js rename to config/midlet.js diff --git a/index.html b/index.html index 888d43e7..b14cdbac 100644 --- a/index.html +++ b/index.html @@ -7,8 +7,8 @@ - - + + diff --git a/libs/urlparams.js b/libs/config.js similarity index 100% rename from libs/urlparams.js rename to libs/config.js diff --git a/main.html b/main.html index 2f9eb9ca..9c6fc379 100644 --- a/main.html +++ b/main.html @@ -10,11 +10,11 @@ - + - + From da902e19a6ed05764df37f459cf333363199450c Mon Sep 17 00:00:00 2001 From: Myk Melez Date: Wed, 21 Jan 2015 14:48:48 -0800 Subject: [PATCH 02/17] split config between default, midlet-specific, and urlparam-overrides --- config/default.js | 13 +++++++++++++ config/midlet.js | 14 ++++---------- libs/config.js => config/urlparams.js | 4 +--- index.html | 3 ++- main.html | 3 ++- midp/gfx.js | 2 +- 6 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 config/default.js rename libs/config.js => config/urlparams.js (95%) diff --git a/config/default.js b/config/default.js new file mode 100644 index 00000000..56645db6 --- /dev/null +++ b/config/default.js @@ -0,0 +1,13 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ + +'use strict'; + +var config = { +}; + +// The base directory of the app, relative to the current page. Normally this +// is the directory from which the page was loaded, but some test pages load +// from a subdirectory, like tests/fs/, and they set this accordingly such that +// code loads files, like libs/fs-init.js, can load them from the right place. +var APP_BASE_DIR = "./"; diff --git a/config/midlet.js b/config/midlet.js index e1697d81..2b8c1acc 100644 --- a/config/midlet.js +++ b/config/midlet.js @@ -1,4 +1,7 @@ -// Midlet-specific customization code. +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ + +'use strict'; var MIDlet = { name: "aMIDlet", @@ -10,12 +13,3 @@ var MIDlet = { return message; }, }; - -var config = { -}; - -// The base directory of the app, relative to the current page. Normally this -// is the directory from which the page was loaded, but some test pages load -// from a subdirectory, like tests/fs/, and they set this accordingly such that -// code loads files, like libs/fs-init.js, can load them from the right place. -var APP_BASE_DIR = "./"; diff --git a/libs/config.js b/config/urlparams.js similarity index 95% rename from libs/config.js rename to config/urlparams.js index d1a9690f..8cebade6 100644 --- a/libs/config.js +++ b/config/urlparams.js @@ -31,7 +31,7 @@ * Keep this list up-to-date! */ -var urlParams = (function() { +(function() { var params = {}; location.search.substring(1).split("&").forEach(function (param) { @@ -46,6 +46,4 @@ var urlParams = (function() { for (var name in params) { config[name] = params[name]; } - - return params; })(); diff --git a/index.html b/index.html index b14cdbac..4129613c 100644 --- a/index.html +++ b/index.html @@ -7,8 +7,9 @@ + - + diff --git a/main.html b/main.html index 9c6fc379..2bf45d00 100644 --- a/main.html +++ b/main.html @@ -10,11 +10,12 @@ + + - diff --git a/midp/gfx.js b/midp/gfx.js index 5e5b11a9..f2abb3fe 100644 --- a/midp/gfx.js +++ b/midp/gfx.js @@ -1068,7 +1068,7 @@ var currentlyFocusedTextEditor; }; Native["com/nokia/mid/ui/CanvasItem.setPosition0.(II)V"] = function(x, y) { - var headerHeight = (!urlParams.nativeMenu) ? 0 : document.getElementById("drawer").querySelector("header").offsetHeight; + var headerHeight = (!config.nativeMenu) ? 0 : document.getElementById("drawer").querySelector("header").offsetHeight; this.textEditor.setStyle("left", x + "px"); this.textEditor.setStyle("top", (headerHeight + y) + "px"); }; From f5cf02ec93dc68014a3dfd54da96ac22a9f565c8 Mon Sep 17 00:00:00 2001 From: Myk Melez Date: Wed, 21 Jan 2015 14:55:07 -0800 Subject: [PATCH 03/17] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 34a3de99..a2d0123f 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ index.html is a webapp that runs j2me.js. The URL parameters you pass to index.h ### URL parameters -See full list at libs/config.js +You can specify URL parameters to override the configuration. See the full list of parameters at config/urlparams.js. * `main` - default is `com/sun/midp/main/MIDletSuiteLoader` * `midletClassName` - must be set to the main class to run. Only valid when default `main` parameter is used. Defaults to `RunTests` From da9aab9da67b200a5e0d53dadef3390d63a259c3 Mon Sep 17 00:00:00 2001 From: Myk Melez Date: Wed, 21 Jan 2015 14:57:43 -0800 Subject: [PATCH 04/17] move default midlet config to config/default.js --- config/default.js | 17 ++++++++++++++--- config/midlet.js | 10 ---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/config/default.js b/config/default.js index 56645db6..33d4e728 100644 --- a/config/default.js +++ b/config/default.js @@ -3,11 +3,22 @@ 'use strict'; -var config = { -}; - // The base directory of the app, relative to the current page. Normally this // is the directory from which the page was loaded, but some test pages load // from a subdirectory, like tests/fs/, and they set this accordingly such that // code loads files, like libs/fs-init.js, can load them from the right place. var APP_BASE_DIR = "./"; + +var config = { +}; + +var MIDlet = { + name: "aMIDlet", + + SMSDialogVerificationText: "This app sent you an SMS. Type the message you received here:", + SMSDialogTimeout: 300000, // Five minutes + SMSDialogTimeoutText: "left", + SMSDialogReceiveFilter: function(message) { + return message; + }, +}; diff --git a/config/midlet.js b/config/midlet.js index 2b8c1acc..e609960e 100644 --- a/config/midlet.js +++ b/config/midlet.js @@ -3,13 +3,3 @@ 'use strict'; -var MIDlet = { - name: "aMIDlet", - - SMSDialogVerificationText: "This app sent you an SMS. Type the message you received here:", - SMSDialogTimeout: 300000, // Five minutes - SMSDialogTimeoutText: "left", - SMSDialogReceiveFilter: function(message) { - return message; - }, -}; From fafa530c424a778ded1d59b3675a9d98b6379694 Mon Sep 17 00:00:00 2001 From: Myk Melez Date: Wed, 21 Jan 2015 14:58:45 -0800 Subject: [PATCH 05/17] minimize irrelevant changes --- config/default.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/config/default.js b/config/default.js index 33d4e728..abe75996 100644 --- a/config/default.js +++ b/config/default.js @@ -3,15 +3,6 @@ 'use strict'; -// The base directory of the app, relative to the current page. Normally this -// is the directory from which the page was loaded, but some test pages load -// from a subdirectory, like tests/fs/, and they set this accordingly such that -// code loads files, like libs/fs-init.js, can load them from the right place. -var APP_BASE_DIR = "./"; - -var config = { -}; - var MIDlet = { name: "aMIDlet", @@ -22,3 +13,12 @@ var MIDlet = { return message; }, }; + +var config = { +}; + +// The base directory of the app, relative to the current page. Normally this +// is the directory from which the page was loaded, but some test pages load +// from a subdirectory, like tests/fs/, and they set this accordingly such that +// code loads files, like libs/fs-init.js, can load them from the right place. +var APP_BASE_DIR = "./"; From a7508c00cc5a10ac516c0ecf66ac2a77dd1eff17 Mon Sep 17 00:00:00 2001 From: Myk Melez Date: Wed, 21 Jan 2015 15:19:35 -0800 Subject: [PATCH 06/17] set midletClassName in config file --- config/default.js | 1 + config/urlparams.js | 4 ++++ index.js | 3 +-- libs/fs-init.js | 4 ++-- main.js | 4 ++-- midp/midp.js | 8 +++----- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/config/default.js b/config/default.js index abe75996..e42f9386 100644 --- a/config/default.js +++ b/config/default.js @@ -15,6 +15,7 @@ var MIDlet = { }; var config = { + midletClassName: "RunTests", }; // The base directory of the app, relative to the current page. Normally this diff --git a/config/urlparams.js b/config/urlparams.js index 8cebade6..f75c40e0 100644 --- a/config/urlparams.js +++ b/config/urlparams.js @@ -43,6 +43,10 @@ params.args = (params.args || "").split(","); + if ("midletClassName" in params) { + params.midletClassName = params.midletClassName.replace(/\//g, '.'); + } + for (var name in params) { config[name] = params[name]; } diff --git a/index.js b/index.js index 51cc276b..64716206 100644 --- a/index.js +++ b/index.js @@ -7,9 +7,8 @@ * Pre-load dependencies and then load the main page. */ (function() { - var midletClassName = config.midletClassName ? config.midletClassName.replace(/\//g, '.') : "RunTests"; var loadingPromises = []; - if (midletClassName == "RunTests") { + if (config.midletClassName == "RunTests") { loadingPromises.push(loadScript("tests/contacts.js"), loadScript("tests/index.js")); } diff --git a/libs/fs-init.js b/libs/fs-init.js index 6ecddf42..1b0451da 100644 --- a/libs/fs-init.js +++ b/libs/fs-init.js @@ -25,7 +25,7 @@ var initialFiles = [ var initFS = new Promise(function(resolve, reject) { fs.init(resolve); }).then(function() { - if (typeof MIDP !== "undefined" && MIDP.midletClassName == "RunTests") { + if (typeof config !== "undefined" && config.midletClassName == "RunTests") { initialDirs.push("/tcktestdir"); } @@ -43,7 +43,7 @@ var initFS = new Promise(function(resolve, reject) { }).then(function() { var filePromises = []; - if (typeof MIDP !== "undefined" && MIDP.midletClassName == "RunTests") { + if (typeof config !== "undefined" && config.midletClassName == "RunTests") { initialFiles.push({ sourcePath: "certs/_test.ks", targetPath: "/_test.ks" }); } diff --git a/main.js b/main.js index 86e2a8d9..84adb08b 100644 --- a/main.js +++ b/main.js @@ -17,7 +17,7 @@ if ("gamepad" in config && !/no|0/.test(config.gamepad)) { var jars = ["java/classes.jar"]; -if (MIDP.midletClassName == "RunTests") { +if (config.midletClassName == "RunTests") { jars.push("tests/tests.jar"); } @@ -171,7 +171,7 @@ if (config.downloadJAD) { })); } -if (MIDP.midletClassName == "RunTests") { +if (config.midletClassName == "RunTests") { loadingPromises.push(loadScript("tests/native.js"), loadScript("tests/override.js"), loadScript("tests/mozactivitymock.js")); diff --git a/midp/midp.js b/midp/midp.js index d4466806..6d1ee9bf 100644 --- a/midp/midp.js +++ b/midp/midp.js @@ -8,8 +8,6 @@ var MIDP = { MIDP.manifest = {}; -MIDP.midletClassName = config.midletClassName ? config.midletClassName.replace(/\//g, '.') : "RunTests"; - Native["com/sun/midp/jarutil/JarReader.readJarEntry0.(Ljava/lang/String;Ljava/lang/String;)[B"] = function(jar, entryName) { var bytes = CLASSES.loadFileFromJar(util.fromJavaString(jar), util.fromJavaString(entryName)); if (!bytes) @@ -280,9 +278,9 @@ Native["com/sun/midp/main/CldcPlatformRequest.dispatchPlatformRequest.(Ljava/lan }; Native["com/sun/midp/main/CommandState.restoreCommandState.(Lcom/sun/midp/main/CommandState;)V"] = function(state) { - var suiteId = (MIDP.midletClassName === "internal") ? -1 : 1; + var suiteId = (config.midletClassName === "internal") ? -1 : 1; state.klass.classInfo.getField("I.suiteId.I").set(state, suiteId); - state.klass.classInfo.getField("I.midletClassName.Ljava/lang/String;").set(state, J2ME.newString(MIDP.midletClassName)); + state.klass.classInfo.getField("I.midletClassName.Ljava/lang/String;").set(state, J2ME.newString(config.midletClassName)); var args = config.args; state.klass.classInfo.getField("I.arg0.Ljava/lang/String;").set(state, J2ME.newString((args.length > 0) ? args[0] : "")); state.klass.classInfo.getField("I.arg1.Ljava/lang/String;").set(state, J2ME.newString((args.length > 1) ? args[1] : "")); @@ -426,7 +424,7 @@ Native["com/sun/midp/main/Configuration.getProperty0.(Ljava/lang/String;)Ljava/l var value; switch (util.fromJavaString(key)) { case "com.sun.midp.publickeystore.WebPublicKeyStore": - if (MIDP.midletClassName == "RunTests") { + if (config.midletClassName == "RunTests") { value = "_test.ks"; } else { value = "_main.ks"; From 92f7aa18ee96116f8eb55c9eacc1b55425def783 Mon Sep 17 00:00:00 2001 From: Myk Melez Date: Wed, 21 Jan 2015 15:53:38 -0800 Subject: [PATCH 07/17] remove obsolete recommendations --- main.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/main.js b/main.js index 84adb08b..3e461ecf 100644 --- a/main.js +++ b/main.js @@ -3,10 +3,6 @@ 'use strict'; -// To launch the unit tests: ?main=RunTests -// To launch the MIDP demo: ?main=com/sun/midp/main/MIDletSuiteLoader&midletClassName=HelloCommandMIDlet -// To launch a JAR file: ?main=com/sun/midp/main/MIDletSuiteLoader&args=app.jar - var jvm = new JVM(); var main = config.main || "com/sun/midp/main/MIDletSuiteLoader"; From b6fd50d6886b325833600af518b2f70b4fb1ff93 Mon Sep 17 00:00:00 2001 From: Myk Melez Date: Wed, 21 Jan 2015 16:10:41 -0800 Subject: [PATCH 08/17] move main parameter to config --- config/default.js | 1 + main.js | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/config/default.js b/config/default.js index e42f9386..1c13945b 100644 --- a/config/default.js +++ b/config/default.js @@ -15,6 +15,7 @@ var MIDlet = { }; var config = { + main: "com/sun/midp/main/MIDletSuiteLoader", midletClassName: "RunTests", }; diff --git a/main.js b/main.js index 3e461ecf..0b1605f1 100644 --- a/main.js +++ b/main.js @@ -5,8 +5,6 @@ var jvm = new JVM(); -var main = config.main || "com/sun/midp/main/MIDletSuiteLoader"; - if ("gamepad" in config && !/no|0/.test(config.gamepad)) { document.documentElement.classList.add('gamepad'); } @@ -190,7 +188,7 @@ function start() { CLASSES.initializeBuiltinClasses(); profiler && profiler.start(2000, false); bigBang = performance.now(); - jvm.startIsolate0(main, config.args); + jvm.startIsolate0(config.main, config.args); } Promise.all(loadingPromises).then(start); From 60a0f672ae0ba3396e3379d6d61f397fc6cf77b7 Mon Sep 17 00:00:00 2001 From: Myk Melez Date: Wed, 21 Jan 2015 16:26:16 -0800 Subject: [PATCH 09/17] re-enable app-specific configuration --- config/app.js | 9 +++++++++ tools/package.sh | 6 ++++++ 2 files changed, 15 insertions(+) create mode 100644 config/app.js diff --git a/config/app.js b/config/app.js new file mode 100644 index 00000000..49109215 --- /dev/null +++ b/config/app.js @@ -0,0 +1,9 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ + +// Instead of being loaded directly, this is appended to config/midlet.js +// by package.sh at `make app` build time, so it only applies when the app +// is loaded as an open web app. + +config.autosize = "1"; +config.logConsole = "web"; diff --git a/tools/package.sh b/tools/package.sh index 2988d7e9..77f04c0d 100755 --- a/tools/package.sh +++ b/tools/package.sh @@ -31,6 +31,12 @@ cp -R classfile $PACKAGE_DIR/. # copy entire contents of libs dir cp -R libs $PACKAGE_DIR/. +# copy entire contents of config dir +cp -R config $PACKAGE_DIR/. + +# Merge app.js into a config file that gets loaded. +cat $PACKAGE_DIR/config/app.js >> $PACKAGE_DIR/config/midlet.js && rm $PACKAGE_DIR/config/app.js + # copy entire contents of midp dir cp -R midp $PACKAGE_DIR/. From 620970cf2e7be28b490e446d5302d865694b3e89 Mon Sep 17 00:00:00 2001 From: Myk Melez Date: Wed, 21 Jan 2015 16:46:42 -0800 Subject: [PATCH 10/17] add build-time RELEASE flag that disables much logging --- .gitignore | 1 + Makefile | 9 +++++++-- index.html | 1 + libs/console.js | 2 +- main.html | 1 + 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index fbfe0f13..7d2be9ca 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ certs/j2se_test.ks tests/Testlets.java output/ build/ +config/build.js # These are generated by the Java pre-processor. They're generated from # their *.jpp equivalents. Keep them up-to-date when you add *.jpp files! diff --git a/Makefile b/Makefile index 5cbe0274..5ecf8c6c 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,9 @@ BASIC_SRCS=$(shell find . -maxdepth 2 -name "*.ts" -not -path "./build/*") JIT_SRCS=$(shell find jit -name "*.ts" -not -path "./build/*") SHUMWAY_SRCS=$(shell find shumway -name "*.ts") +RELEASE ?= 0 -all: java jasmin tests j2me shumway +all: build java jasmin tests j2me shumway test: all tests/runtests.py @@ -47,6 +48,9 @@ closure: build/j2me.js aot shumway: $(SHUMWAY_SRCS) node tools/tsc.js --sourcemap --target ES5 shumway/references.ts --out build/shumway.js +build: + echo "config.release = ${RELEASE};" > config/build.js + tests: make -C tests @@ -57,12 +61,13 @@ certs: make -C certs # Makes an output/ directory containing the packaged open web app files. -app: java certs +app: build java certs tools/package.sh clean: rm -f j2me.js `find . -name "*~"` rm -rf build + rm -f config/build.js make -C tools/jasmin-2.4 clean make -C tests clean make -C java clean diff --git a/index.html b/index.html index 4129613c..f1b14a2a 100644 --- a/index.html +++ b/index.html @@ -9,6 +9,7 @@ + diff --git a/libs/console.js b/libs/console.js index 118eb86d..a8a8979a 100644 --- a/libs/console.js +++ b/libs/console.js @@ -24,7 +24,7 @@ * terminal: a faster canvas based console if Shumway.js is included. */ var ENABLED_CONSOLE_TYPES = (config.logConsole || "page").split(","); - var minLogLevel = LOG_LEVELS[config.logLevel || "log"]; + var minLogLevel = LOG_LEVELS[config.logLevel || (config.release ? "error" : "log")]; //================================================================ diff --git a/main.html b/main.html index 2bf45d00..51a3accd 100644 --- a/main.html +++ b/main.html @@ -12,6 +12,7 @@ + From 2b393a44dd9b2cc43fbaa0c346672c8f8305b50c Mon Sep 17 00:00:00 2001 From: Myk Melez Date: Thu, 22 Jan 2015 17:12:05 -0800 Subject: [PATCH 11/17] rename config-build target to avoid conflict with directory; add to phony targets --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 5ecf8c6c..ae7d8486 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ -.PHONY: all test tests j2me java certs app clean jasmin aot shumway +.PHONY: all test tests j2me java certs app clean jasmin aot shumway config-build BASIC_SRCS=$(shell find . -maxdepth 2 -name "*.ts" -not -path "./build/*") JIT_SRCS=$(shell find jit -name "*.ts" -not -path "./build/*") SHUMWAY_SRCS=$(shell find shumway -name "*.ts") RELEASE ?= 0 -all: build java jasmin tests j2me shumway +all: config-build java jasmin tests j2me shumway test: all tests/runtests.py @@ -48,7 +48,7 @@ closure: build/j2me.js aot shumway: $(SHUMWAY_SRCS) node tools/tsc.js --sourcemap --target ES5 shumway/references.ts --out build/shumway.js -build: +config-build: echo "config.release = ${RELEASE};" > config/build.js tests: From 3d85ec442dad6b76711b360006f4d2ab30c6f8e6 Mon Sep 17 00:00:00 2001 From: Yuan Xulei Date: Fri, 23 Jan 2015 13:46:15 +0800 Subject: [PATCH 12/17] Fix a typo of #903 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ae7d8486..a7b7a699 100644 --- a/Makefile +++ b/Makefile @@ -61,7 +61,7 @@ certs: make -C certs # Makes an output/ directory containing the packaged open web app files. -app: build java certs +app: config-build java certs tools/package.sh clean: From fc01375eb083c454a0bd171992ba23f378ac5edd Mon Sep 17 00:00:00 2001 From: Yuan Xulei Date: Fri, 23 Jan 2015 17:56:54 +0800 Subject: [PATCH 13/17] Remove drawString, drawSubstring and drawChars from yield map. --- jit/analyze.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/jit/analyze.ts b/jit/analyze.ts index 35be7e89..ee52012a 100644 --- a/jit/analyze.ts +++ b/jit/analyze.ts @@ -70,9 +70,6 @@ module J2ME { "java/lang/Class.invoke_clinit.()V": YieldReason.Root, "java/lang/Class.newInstance.()Ljava/lang/Object;": YieldReason.Root, "java/lang/Thread.yield.()V": YieldReason.Root, - "javax/microedition/lcdui/Graphics.drawString.(Ljava/lang/String;III)V": YieldReason.Root, - "javax/microedition/lcdui/Graphics.drawSubstring.(Ljava/lang/String;IIIII)V": YieldReason.Root, - "javax/microedition/lcdui/Graphics.drawChars.([CIIIII)V": YieldReason.Root, // Test Files: "gnu/testlet/vm/NativeTest.throwExceptionAfterPause.()V": YieldReason.Root, "gnu/testlet/vm/NativeTest.returnAfterPause.()I": YieldReason.Root, From bee04a120a234f5a9e53c8c7a463001c674294b9 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Fri, 23 Jan 2015 12:27:48 +0100 Subject: [PATCH 14/17] Print implKey for missing natives instead of name --- runtime.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime.ts b/runtime.ts index 0668cf93..61a93087 100644 --- a/runtime.ts +++ b/runtime.ts @@ -1171,7 +1171,7 @@ module J2ME { // Some Native MethodInfos are constructed but never called; // that's fine, unless we actually try to call them. return function missingImplementation() { - stderrWriter.errorLn("implKey " + methodInfo.name + " is native but does not have an implementation."); + stderrWriter.errorLn("implKey " + methodInfo.implKey + " is native but does not have an implementation."); } } } else if (implKey in Override) { From a92cb4ceb35412faad4e87b20874c11e12336fbf Mon Sep 17 00:00:00 2001 From: Michael Bebenita Date: Fri, 23 Jan 2015 12:28:58 -0800 Subject: [PATCH 15/17] Add license. --- utilities.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/utilities.ts b/utilities.ts index e2b47092..e27891f3 100644 --- a/utilities.ts +++ b/utilities.ts @@ -965,6 +965,27 @@ module J2ME { } export module HashUtilities { + // Copyright (c) 2011 Gary Court + // + // Permission is hereby granted, free of charge, to any person obtaining + // a copy of this software and associated documentation files (the + // "Software"), to deal in the Software without restriction, including + // without limitation the rights to use, copy, modify, merge, publish, + // distribute, sublicense, and/or sell copies of the Software, and to + // permit persons to whom the Software is furnished to do so, subject to + // the following conditions: + // + // The above copyright notice and this permission notice shall be + // included in all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + // https://github.com/garycourt/murmurhash-js export function hashBytesTo32BitsMurmur(data: Uint8Array, offset: number, length: number) { var l = length, h = 0x12345678 ^ l, i = offset, k; @@ -992,6 +1013,7 @@ module J2ME { h ^= h >>> 15; return h >>> 0; } + // end of imported section export function hashBytesTo32BitsAdler(data: Uint8Array, offset: number, length: number): number { var a = 1; From e19edb2c99cd531aab499c83d637316b114ca2a5 Mon Sep 17 00:00:00 2001 From: Michael Bebenita Date: Thu, 22 Jan 2015 18:14:58 -0800 Subject: [PATCH 16/17] Git push add aot-methods filter and use it by default in the make target. --- Makefile | 8 ++++---- aot-methods.txt | 1 + jit/compiler.ts | 14 +++++++++++++- jsc.ts | 3 +++ main.html | 2 +- 5 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 aot-methods.txt diff --git a/Makefile b/Makefile index a7b7a699..bb466f20 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ JIT_SRCS=$(shell find jit -name "*.ts" -not -path "./build/*") SHUMWAY_SRCS=$(shell find shumway -name "*.ts") RELEASE ?= 0 -all: config-build java jasmin tests j2me shumway +all: config-build java jasmin tests j2me shumway aot test: all tests/runtests.py @@ -28,10 +28,10 @@ j2me: build/j2me.js build/jsc.js aot: java j2me @echo "Compiling ..." - js build/jsc.js -cp java/classes.jar -d -jf java/classes.jar > build/classes.jar.js - js build/jsc.js -cp java/classes.jar tests/tests.jar -d -jf tests/tests.jar > build/tests.jar.js + js build/jsc.js -cp java/classes.jar -d -jf java/classes.jar -mff aot-methods.txt > build/classes.jar.js + js build/jsc.js -cp java/classes.jar tests/tests.jar -d -jf tests/tests.jar -mff aot-methods.txt > build/tests.jar.js if test -f program.jar; then \ - js build/jsc.js -cp java/classes.jar program.jar -d -jf program.jar > build/program.jar.js; \ + js build/jsc.js -cp java/classes.jar program.jar -d -jf program.jar -mff aot-methods.txt > build/program.jar.js; \ fi @echo "Done" diff --git a/aot-methods.txt b/aot-methods.txt new file mode 100644 index 00000000..c616db30 --- /dev/null +++ b/aot-methods.txt @@ -0,0 +1 @@ +java/util/Vector.elementAt.(I)Ljava/lang/Object; diff --git a/jit/compiler.ts b/jit/compiler.ts index a15d9f63..dba44cc4 100644 --- a/jit/compiler.ts +++ b/jit/compiler.ts @@ -432,10 +432,22 @@ module J2ME { } } + var filteredClassInfoList: ClassInfo [] = []; for (var i = 0; i < orderedClassInfoList.length; i++) { var classInfo = orderedClassInfoList[i]; + var methods = classInfo.methods; + for (var j = 0; j < methods.length; j++) { + var method = methods[j]; + if (methodFilter(method)) { + // If at least one method is found, compile the class. + filteredClassInfoList.push(classInfo); + break; + } + } + } - writer.writeLn("//// " + classInfo.className); + for (var i = 0; i < filteredClassInfoList.length; i++) { + var classInfo = filteredClassInfoList[i]; if (emitter.debugInfo) { writer.writeLn("// " + classInfo.className + (classInfo.superClass ? " extends " + classInfo.superClass.className : "")); diff --git a/jsc.ts b/jsc.ts index 0246f917..08c3c81c 100644 --- a/jsc.ts +++ b/jsc.ts @@ -218,6 +218,9 @@ module J2ME { } if (file) { methodNameList = file.replace(/\r?\n/g, "\n").split("\n"); + + // Trim Whitespace + methodNameList = methodNameList.map(x => x.replace(/^\s+|\s+$/g, "")); } } diff --git a/main.html b/main.html index 3c118782..365ef817 100644 --- a/main.html +++ b/main.html @@ -60,7 +60,7 @@ - + From bf62372057d8d30e324989699e0927bfb514c017 Mon Sep 17 00:00:00 2001 From: Brendan Dahl Date: Fri, 23 Jan 2015 11:45:19 -0800 Subject: [PATCH 17/17] Use real targets and only compile classes.jar by default. . Updated method list. Log failed/missing compiled methods. --- .travis.yml | 3 + Makefile | 27 ++-- aot-methods.txt | 348 ++++++++++++++++++++++++++++++++++++++++++++++++ jit/compiler.ts | 13 +- jsc.ts | 35 +++-- 5 files changed, 395 insertions(+), 31 deletions(-) diff --git a/.travis.yml b/.travis.yml index cd262462..64986f1a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,9 @@ before_script: - wget -P /tmp/j2me.js -N https://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases/31.0/runtimes/xulrunner-31.0.en-US.linux-x86_64.tar.bz2 - tar x -C /tmp -f /tmp/j2me.js/xulrunner-31.0.en-US.linux-x86_64.tar.bz2 - export SLIMERJSLAUNCHER=/tmp/xulrunner/xulrunner + - wget -P /tmp/j2me.js -N http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/36.0b1-candidates/build1/jsshell-linux-x86_64.zip + - unzip -d /tmp/js /tmp/j2me.js/jsshell-linux-x86_64.zip + - export PATH=$PATH:/tmp/js script: - make test sudo: false diff --git a/Makefile b/Makefile index bb466f20..e9df7bf4 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ build/j2me.js: $(BASIC_SRCS) $(JIT_SRCS) node tools/tsc.js --sourcemap --target ES5 references.ts -d --out build/j2me.js build/j2me-jsc.js: $(BASIC_SRCS) $(JIT_SRCS) - @echo "Building J2ME JSC" + @echo "Building J2ME AOT Compiler" node tools/tsc.js --sourcemap --target ES5 references-jsc.ts -d --out build/j2me-jsc.js build/jsc.js: jsc.ts build/j2me-jsc.js @@ -26,34 +26,35 @@ build/jsc.js: jsc.ts build/j2me-jsc.js j2me: build/j2me.js build/jsc.js -aot: java j2me +aot: build/classes.jar.js +build/classes.jar.js: java/classes.jar build/jsc.js aot-methods.txt @echo "Compiling ..." js build/jsc.js -cp java/classes.jar -d -jf java/classes.jar -mff aot-methods.txt > build/classes.jar.js - js build/jsc.js -cp java/classes.jar tests/tests.jar -d -jf tests/tests.jar -mff aot-methods.txt > build/tests.jar.js - if test -f program.jar; then \ - js build/jsc.js -cp java/classes.jar program.jar -d -jf program.jar -mff aot-methods.txt > build/program.jar.js; \ - fi - @echo "Done" -closure: build/j2me.js aot +build/tests.jar.js: tests/tests.jar build/jsc.js aot-methods.txt + js build/jsc.js -cp java/classes.jar tests/tests.jar -d -jf tests/tests.jar -mff aot-methods.txt > build/tests.jar.js + +build/program.jar.js: program.jar build/jsc.js aot-methods.txt + js build/jsc.js -cp java/classes.jar program.jar -d -jf program.jar -mff aot-methods.txt > build/program.jar.js + +closure: build/classes.jar.js build/j2me.js java -jar tools/closure.jar --language_in ECMASCRIPT5 -O SHUMWAY_OPTIMIZATIONS build/j2me.js > build/j2me.cc.js \ && mv build/j2me.cc.js build/j2me.js java -jar tools/closure.jar --language_in ECMASCRIPT5 -O SIMPLE build/classes.jar.js > build/classes.jar.cc.js \ && mv build/classes.jar.cc.js build/classes.jar.js - if test -f build/program.jar.js; then \ - java -jar tools/closure.jar --language_in ECMASCRIPT5 -O SIMPLE build/program.jar.js > build/program.jar.cc.js \ - && mv build/program.jar.cc.js build/program.jar.js; \ - fi -shumway: $(SHUMWAY_SRCS) +shumway: build/shumway.js +build/shumway.js: $(SHUMWAY_SRCS) node tools/tsc.js --sourcemap --target ES5 shumway/references.ts --out build/shumway.js config-build: echo "config.release = ${RELEASE};" > config/build.js +tests/tests.jar: tests tests: make -C tests +java/classes.jar: java java: make -C java diff --git a/aot-methods.txt b/aot-methods.txt index c616db30..72031e24 100644 --- a/aot-methods.txt +++ b/aot-methods.txt @@ -1 +1,349 @@ +java/util/Vector.indexOf.(Ljava/lang/Object;I)I +java/util/PropertyPermission.getActions.(I)Ljava/lang/String; +java/util/Vector.addElement.(Ljava/lang/Object;)V +java/util/Vector.size.()I java/util/Vector.elementAt.(I)Ljava/lang/Object; +java/util/Vector.ensureCapacityHelper.(I)V +javax/microedition/lcdui/Graphics.getClipX.()I +javax/microedition/lcdui/Graphics.getClipY.()I +javax/microedition/lcdui/Graphics.getClipWidth.()I +javax/microedition/lcdui/Graphics.getClipHeight.()I +java/io/DataInputStream.read.()I +javax/microedition/lcdui/Graphics.setClip.(IIII)V +java/lang/Math.max.(II)I +javax/microedition/lcdui/Graphics.clipRect.(IIII)V +com/sun/cldc/i18n/uclc/DefaultCaseConverter.isDigit.(C)Z +com/nokia/mid/ui/DirectUtils.getDirectGraphics.(Ljavax/microedition/lcdui/Graphics;)Lcom/nokia/mid/ui/DirectGraphics; +com/nokia/mid/ui/DirectGraphicsImp..(Ljavax/microedition/lcdui/Graphics;)V +javax/microedition/lcdui/Font.getHeight.()I +java/security/Permission..(Ljava/lang/String;)V +java/security/BasicPermission.init.(Ljava/lang/String;)V +java/security/AccessController.checkPermission.(Ljava/security/Permission;)V +java/lang/Character.digit.(CI)I +com/sun/cldc/i18n/uclc/DefaultCaseConverter.digit.(CI)I +java/util/PropertyPermission.getMask.(Ljava/lang/String;)I +java/lang/System.getProperty.(Ljava/lang/String;)Ljava/lang/String; +java/util/PropertyPermission..(Ljava/lang/String;Ljava/lang/String;)V +java/security/BasicPermission..(Ljava/lang/String;Ljava/lang/String;)V +java/util/PropertyPermission.init.(I)V +java/security/Permission.getName.()Ljava/lang/String; +javax/microedition/lcdui/Graphics.setColor.(I)V +javax/microedition/lcdui/Graphics.getFont.()Ljavax/microedition/lcdui/Font; +javax/microedition/lcdui/Graphics.getColor.()I +java/util/Vector..(II)V +java/util/Vector..(I)V +javax/microedition/lcdui/Graphics.setFont.(Ljavax/microedition/lcdui/Font;)V +java/util/Vector..()V +javax/microedition/lcdui/Graphics.grayVal.(III)I +java/util/Vector.copyInto.([Ljava/lang/Object;)V +com/sun/midp/events/Event.getType.()I +java/lang/Integer.parseInt.(Ljava/lang/String;I)I +java/lang/Integer.parseInt.(Ljava/lang/String;)I +java/lang/Integer..(I)V +java/io/DataInputStream.readInt.()I +java/io/DataOutputStream.write.(I)V +javax/microedition/lcdui/Canvas.repaint.(IIII)V +java/util/Vector.removeAllElements.()V +com/sun/midp/events/EventQueue.post.(Lcom/sun/midp/events/Event;)V +javax/microedition/lcdui/Font.getDefaultFont.()Ljavax/microedition/lcdui/Font; +javax/microedition/lcdui/Graphics.resetGC.()V +javax/microedition/lcdui/DisplayableLFImpl.lIsShown.()Z +javax/microedition/lcdui/DisplayableLFImpl.lRequestPaint.(IIIILjava/lang/Object;)V +javax/microedition/lcdui/Display.isShown.(Ljavax/microedition/lcdui/DisplayableLF;)Z +com/sun/midp/lcdui/RepaintEvent.setRepaintFields.(Lcom/sun/midp/lcdui/DisplayEventConsumer;IIIILjava/lang/Object;)V +javax/microedition/lcdui/Display.repaintImpl.(Ljavax/microedition/lcdui/DisplayableLF;IIIILjava/lang/Object;)V +com/sun/midp/lcdui/RepaintEventProducer.scheduleRepaint.(Lcom/sun/midp/lcdui/DisplayEventConsumer;IIIILjava/lang/Object;)V +javax/microedition/lcdui/Font.getBaselinePosition.()I +javax/microedition/lcdui/CanvasLFImpl.lRepaint.(IIIILjava/lang/Object;)V +java/util/Hashtable.put.(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; +java/util/HashtableEntry..()V +java/lang/Integer.hashCode.()I +java/io/DataInputStream.readFully.([BII)V +java/io/DataInputStream.read.([BII)I +javax/microedition/lcdui/ImageData.getWidth.()I +javax/microedition/lcdui/ImageData.getHeight.()I +java/lang/String.valueOf.(Ljava/lang/Object;)Ljava/lang/String; +com/nokia/mid/ui/CanvasItem.getParent.()Ljava/lang/Object; +java/util/Vector.removeElementAt.(I)V +java/lang/ref/WeakReference..(Ljava/lang/Object;)V +java/lang/ref/Reference..(Ljava/lang/Object;)V +javax/microedition/lcdui/ImageDataFactory.getImageDataFactory.()Ljavax/microedition/lcdui/AbstractImageDataFactory; +javax/microedition/lcdui/Image..(Ljavax/microedition/lcdui/ImageData;)V +javax/microedition/lcdui/ImageData..(IIZ)V +com/sun/midp/events/Event..(I)V +javax/microedition/lcdui/Displayable.getHeight.()I +javax/microedition/lcdui/DisplayableLFImpl.lGetHeight.()I +javax/microedition/lcdui/Displayable.getWidth.()I +javax/microedition/lcdui/DisplayableLFImpl.lGetWidth.()I +java/lang/Object.wait.()V +java/lang/Boolean.booleanValue.()Z +com/sun/midp/rms/RecordStoreUtil.getInt.([BI)I +com/sun/midp/events/EventQueue.run.()V +com/sun/midp/lcdui/LCDUIEvent..(I)V +com/sun/midp/lcdui/LCDUIEventListener.preprocess.(Lcom/sun/midp/events/Event;Lcom/sun/midp/events/Event;)Z +java/util/Stack.empty.()Z +java/io/OutputStream.write.([B)V +com/sun/midp/lcdui/LCDUIEvent.createBasicEvent.(Lcom/sun/midp/lcdui/DisplayEventConsumer;I)Lcom/sun/midp/lcdui/LCDUIEvent; +com/sun/midp/lcdui/LCDUIEventListener.preprocessAllowOnlyOneEvent.(Lcom/sun/midp/events/Event;Lcom/sun/midp/events/Event;)Z +javax/microedition/lcdui/Display.callSerially.(Ljava/lang/Runnable;)V +com/sun/midp/lcdui/DisplayEventProducer.sendCallSeriallyEvent.(Lcom/sun/midp/lcdui/DisplayEventConsumer;)V +javax/microedition/lcdui/Display.getCallSerially.()V +java/util/Vector.elements.()Ljava/util/Enumeration; +java/util/VectorEnumerator..(Ljava/util/Vector;)V +java/util/VectorEnumerator.hasMoreElements.()Z +com/sun/midp/lcdui/LCDUIEventListener.process.(Lcom/sun/midp/events/Event;)V +javax/microedition/lcdui/Graphics.reset.(IIII)V +javax/microedition/lcdui/Display.callPaint.(IIIILjava/lang/Object;)V +javax/microedition/lcdui/DisplayableLFImpl.uIsScrollNative.()Z +javax/microedition/lcdui/CanvasLFImpl.uCallPaint.(Ljavax/microedition/lcdui/Graphics;Ljava/lang/Object;)V +javax/microedition/lcdui/DisplayableLFImpl.uCallPaint.(Ljavax/microedition/lcdui/Graphics;Ljava/lang/Object;)V +com/sun/midp/lcdui/DisplayDevice.refresh.(IIIII)V +javax/microedition/lcdui/Display$DisplayEventConsumerImpl.handleCallSeriallyEvent.()V +javax/microedition/lcdui/Display.access$700.(Ljavax/microedition/lcdui/Display;)V +com/sun/midp/lcdui/RepaintEventProducer.preprocess.(Lcom/sun/midp/events/Event;Lcom/sun/midp/events/Event;)Z +com/sun/midp/lcdui/RepaintEventProducer.process.(Lcom/sun/midp/events/Event;)V +javax/microedition/lcdui/Display$DisplayEventConsumerImpl.handleRepaintEvent.(IIIILjava/lang/Object;)V +java/io/OutputStream.write.([BII)V +com/sun/midp/events/NativeEventPool.get.()Lcom/sun/midp/events/NativeEvent; +com/sun/midp/events/NativeEventPool.putBack.(Lcom/sun/midp/events/NativeEvent;)V +com/sun/midp/events/NativeEvent.clear.()V +com/sun/midp/lcdui/DisplayContainer.findDisplayById.(I)Lcom/sun/midp/lcdui/DisplayAccess; +javax/microedition/lcdui/Display.access$200.(Ljavax/microedition/lcdui/Display;)Ljavax/microedition/lcdui/DisplayableLF; +javax/microedition/lcdui/Display$DisplayAccessImpl.getDisplayId.()I +com/sun/midp/lcdui/DisplayEventListener.preprocess.(Lcom/sun/midp/events/Event;Lcom/sun/midp/events/Event;)Z +com/sun/midp/lcdui/DisplayEventListener.process.(Lcom/sun/midp/events/Event;)V +com/sun/midp/lcdui/DisplayContainer.findDisplayEventConsumer.(I)Lcom/sun/midp/lcdui/DisplayEventConsumer; +javax/microedition/lcdui/Display$DisplayAccessImpl.getDisplayEventConsumer.()Lcom/sun/midp/lcdui/DisplayEventConsumer; +java/lang/Character.isDigit.(C)Z +com/nokia/mid/ui/CanvasItem.setPosition.(II)V +com/nokia/mid/ui/gestures/GestureEventImpl.getStartX.()I +com/nokia/mid/ui/gestures/GestureEventImpl.getStartY.()I +com/nokia/mid/ui/gestures/GestureEventImpl.getType.()I +com/sun/midp/events/NativeEventMonitor.run.()V +javax/microedition/lcdui/Image.getWidth.()I +java/util/Hashtable.get.(Ljava/lang/Object;)Ljava/lang/Object; +javax/microedition/lcdui/Image.getHeight.()I +java/lang/Object.equals.(Ljava/lang/Object;)Z +java/io/PrintStream.ensureOpen.()V +java/io/OutputStreamWriter.ensureOpen.()V +com/sun/cldc/i18n/j2me/UTF_8_Writer.write.([CII)V +javax/microedition/lcdui/Image.getRGB.([IIIIIII)V +javax/microedition/lcdui/Graphics.setDimensions.(II)V +javax/microedition/lcdui/Graphics..()V +com/nokia/mid/ui/DirectUtils.createImage.(III)Ljavax/microedition/lcdui/Image; +javax/microedition/lcdui/Image.createImage.(II)Ljavax/microedition/lcdui/Image; +javax/microedition/lcdui/ImageDataFactory.createOffScreenImageData.(II)Ljavax/microedition/lcdui/ImageData; +javax/microedition/lcdui/Image.getGraphics.()Ljavax/microedition/lcdui/Graphics; +javax/microedition/lcdui/Image.isMutable.()Z +javax/microedition/lcdui/ImageData.isMutable.()Z +javax/microedition/lcdui/Graphics.getImageGraphics.(Ljavax/microedition/lcdui/Image;)Ljavax/microedition/lcdui/Graphics; +java/lang/Math.abs.(I)I +javax/microedition/lcdui/Graphics.translate.(II)V +javax/microedition/lcdui/Image.createRGBImage.([IIIZ)Ljavax/microedition/lcdui/Image; +javax/microedition/lcdui/ImageDataFactory.createImmutableImageData.([IIIZ)Ljavax/microedition/lcdui/ImageData; +java/util/Vector.setElementAt.(Ljava/lang/Object;I)V +com/sun/midp/rms/RecordStoreFile.read.([B)I +com/sun/midp/rms/RecordStoreFile.read.([BII)I +com/sun/midp/rms/RecordStoreFile.seek.(I)V +com/nokia/mid/ui/TextEditor.isMultiline.()Z +java/io/DataOutputStream.writeLong.(J)V +java/lang/Integer.toString.(II)Ljava/lang/String; +java/lang/Integer.toString.(I)Ljava/lang/String; +javax/microedition/rms/RecordStore.isOpen.()Z +javax/microedition/lcdui/Display$DisplayEventConsumerImpl.handlePointerEvent.(III)V +javax/microedition/lcdui/DisplayableLFImpl.uCallPointerEvent.(III)V +com/nokia/mid/ui/gestures/GestureRegistrationManager.callListener.(Lcom/nokia/mid/ui/gestures/GestureEvent;)V +com/nokia/mid/ui/gestures/GestureEventImpl..(IIIIIFIIIIIIIIII)V +javax/microedition/lcdui/Display$DisplayEventConsumerImpl.handleGestureEvent.(Lcom/nokia/mid/ui/gestures/GestureEvent;)V +com/nokia/mid/ui/gestures/GestureInteractiveZone.contains.(II)Z +com/nokia/mid/ui/gestures/GestureInteractiveZone.supports.(I)Z +java/lang/Long..(J)V +com/sun/midp/rms/RecordStoreUtil.calculateBlockSize.(I)I +javax/microedition/lcdui/CanvasLFImpl.uCallPointerDragged.(II)V +com/sun/cldc/io/ResourceInputStream.read.([BII)I +com/nokia/mid/ui/gestures/GestureEventImpl.getDragDistanceX.()I +com/nokia/mid/ui/gestures/GestureEventImpl.getDragDistanceY.()I +java/io/PrintStream.println.(Ljava/lang/String;)V +java/io/PrintStream.print.(Ljava/lang/String;)V +java/io/PrintStream.write.(Ljava/lang/String;)V +java/io/Writer.write.(Ljava/lang/String;)V +java/io/OutputStreamWriter.write.(Ljava/lang/String;II)V +java/io/Writer.write.(Ljava/lang/String;II)V +java/io/PrintStream.newLine.()V +java/io/OutputStreamWriter.write.(I)V +java/io/Writer.write.(I)V +com/nokia/mid/ui/TextEditor.getFont.()Ljavax/microedition/lcdui/Font; +com/nokia/mid/ui/TextEditor.getVisibleContentPosition.()I +com/sun/midp/rms/RecordStoreSharedDBHeader.getHeaderData.()[B +java/util/Vector.indexOf.(Ljava/lang/Object;)I +java/lang/Long.longValue.()J +java/lang/Long.hashCode.()I +java/util/Hashtable.containsKey.(Ljava/lang/Object;)Z +javax/microedition/rms/RecordStore.checkOpen.()V +java/lang/Long.equals.(Ljava/lang/Object;)Z +javax/microedition/rms/RecordEnumerationImpl.checkDestroyed.()V +java/io/DataOutputStream.flush.()V +com/sun/midp/midletsuite/MIDletSuiteImpl.guaranteeMIDletSuiteLocked.(Ljava/lang/String;)V +com/sun/cldc/i18n/j2me/UTF_8_Reader.read.([CII)I +java/io/DataOutputStream.write.([BII)V +com/sun/midp/rms/IntToIntMapper.setElementAt.(II)V +java/io/DataOutputStream.writeUTF.(Ljava/lang/String;)V +java/io/DataOutputStream.writeUTF.(Ljava/lang/String;Ljava/io/DataOutput;)I +java/io/InputStream..()V +java/lang/Character..(C)V +java/io/InputStream.read.([B)I +com/sun/midp/midlet/MIDletStateHandler.getMIDletSuite.()Lcom/sun/midp/midlet/MIDletSuite; +java/io/Reader.read.([C)I +java/io/InputStreamReader.read.([CII)I +java/io/InputStreamReader.ensureOpen.()V +java/io/DataOutputStream.writeByte.(I)V +java/io/ByteArrayOutputStream.toByteArray.()[B +java/lang/Integer.intValue.()I +java/io/OutputStream..()V +java/lang/Character.toString.()Ljava/lang/String; +com/sun/midp/security/SecurityToken.checkIfPermissionAllowed.(I)V +com/sun/midp/security/SecurityToken.checkIfPermissionAllowed.(ILjava/lang/String;)V +com/sun/midp/events/EventQueue.registerEventListener.(ILcom/sun/midp/events/EventListener;)V +com/sun/midp/midletsuite/MIDletSuiteImpl.getID.()I +com/sun/midp/midlet/MIDletStateHandler.getMidletStateHandler.()Lcom/sun/midp/midlet/MIDletStateHandler; +com/sun/midp/events/DispatchData..(Lcom/sun/midp/events/EventListener;)V +java/lang/Integer.toUnsignedString.(II)Ljava/lang/String; +com/ibm/oti/connection/file/FCOutputStream.flush.()V +com/ibm/oti/connection/file/FCOutputStream.write.([BII)V +javax/microedition/lcdui/Canvas.repaint.()V +javax/microedition/lcdui/CanvasLFImpl.lRepaint.()V +javax/microedition/lcdui/DisplayableLFImpl.lRequestPaintContents.()V +com/sun/midp/util/isolate/InterIsolateMutex.lock.()V +com/sun/midp/rms/RecordStoreSharedDBHeader.updateCachedData.()V +java/io/ByteArrayOutputStream.reset.()V +com/sun/midp/rms/RecordStoreLock.obtain.()V +java/io/DataInputStream..(Ljava/io/InputStream;)V +com/sun/midp/rms/RecordStoreLock.release.()V +com/sun/midp/util/isolate/InterIsolateMutex.unlock.()V +com/ibm/oti/connection/file/Connection.isOpen.()Z +com/sun/midp/rms/RecordStoreImpl.getVersion.()I +java/lang/Object.toString.()Ljava/lang/String; +java/lang/Integer.toHexString.(I)Ljava/lang/String; +com/sun/midp/rms/RecordStoreIndex.getRecordHeader_SearchFromTo.(I[BII)I +com/sun/midp/rms/RecordStoreImpl.lockRecordStore.()V +com/sun/midp/rms/RecordStoreSharedDBHeader.recordStoreLocked.()V +com/sun/midp/rms/RecordStoreImpl.unlockRecordStore.()V +com/sun/midp/rms/RecordStoreSharedDBHeader.recordStoreAboutToBeUnlocked.()V +java/lang/StringBuffer.append.(Ljava/lang/Object;)Ljava/lang/StringBuffer; +com/sun/midp/rms/IntToIntMapper.elementAt.(I)I +javax/microedition/io/Connector.checkProtocolName.(Ljava/lang/String;)V +javax/microedition/rms/RecordStore.openRecordStore.(Ljava/lang/String;Z)Ljavax/microedition/rms/RecordStore; +javax/microedition/rms/RecordStore.doOpen.(ILjava/lang/String;Z)Ljavax/microedition/rms/RecordStore; +javax/microedition/rms/RecordStore.closeRecordStore.()V +com/sun/midp/rms/RecordStoreImpl.getSize.()I +javax/microedition/rms/RecordEnumerationImpl.hasNextElement.()Z +java/util/Hashtable..(I)V +javax/microedition/rms/RecordEnumerationImpl.nextRecordId.()I +javax/microedition/rms/RecordStore.getRecord.(I)[B +com/sun/midp/rms/RecordStoreImpl.getRecord.(I)[B +com/sun/midp/rms/RecordStoreIndex.getRecordHeader.(I[B)I +com/sun/midp/rms/RecordStoreIndex.ensureIndexValidity.()V +com/sun/midp/rms/RecordStoreIndex.getRecordHeader_NoCache.(I[B)I +com/sun/midp/rms/IntToIntMapper.addElement.(II)V +com/sun/midp/util/Properties.setProperty.(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; +java/lang/Thread.init.(Ljava/lang/Runnable;Ljava/lang/String;)V +java/lang/Thread.getPriority.()I +java/lang/Thread.setPriority.(I)V +java/lang/Thread.checkAccess.()V +java/lang/RuntimePermission..(Ljava/lang/String;)V +java/security/BasicPermission..(Ljava/lang/String;)V +java/util/Vector.setSize.(I)V +java/io/ByteArrayOutputStream.size.()I +java/lang/Thread.nextThreadNum.()I +com/sun/cldc/io/ResourceInputStream.fixResourceName.(Ljava/lang/String;)Ljava/lang/String; +java/lang/Thread.start.()V +java/lang/Thread.start.(Ljava/lang/Thread;)V +com/ibm/oti/connection/file/Connection.checkRead.()V +com/ibm/oti/connection/file/Connection.checkRead.(Ljava/lang/String;)V +java/util/Hashtable..()V +com/ibm/oti/connection/file/Connection.parseDirectory.()V +javax/microedition/io/Connector.open.(Ljava/lang/String;I)Ljavax/microedition/io/Connection; +javax/microedition/io/Connector.open.(Ljava/lang/String;IZ)Ljavax/microedition/io/Connection; +javax/microedition/io/Connector.openPrim.(Ljava/lang/String;IZ)Ljavax/microedition/io/Connection; +com/ibm/oti/connection/file/Connection.existsInternal.()Z +javax/microedition/lcdui/Display$DisplayEventConsumerImpl.handleKeyEvent.(II)V +javax/microedition/lcdui/DisplayableLFImpl.uCallKeyEvent.(II)V +javax/microedition/lcdui/CanvasLFImpl.allowKey.(I)Z +com/ibm/oti/connection/file/Connection.isDirectoryInternal.()Z +java/util/Vector.isEmpty.()Z +java/util/Hashtable.rehash.()V +java/lang/Class.getResourceAsStream.(Ljava/lang/String;)Ljava/io/InputStream; +com/sun/cldc/io/ResourceInputStream..(Ljava/lang/String;)V +com/sun/midp/io/j2me/file/Protocol..()V +com/sun/midp/io/j2me/file/Protocol.openPrim.(Ljava/lang/String;IZ)Ljavax/microedition/io/Connection; +com/ibm/oti/connection/file/Connection..()V +com/ibm/oti/connection/file/Connection.setParameters2.(Ljava/lang/String;IZ)Ljavax/microedition/io/Connection; +com/ibm/oti/connection/file/Connection.setParameters.(Ljava/lang/String;IZ)V +com/ibm/oti/connection/file/Connection.validateSpec.(Ljava/lang/String;)Ljava/lang/String; +com/ibm/oti/connection/file/Connection.setPaths.(Ljava/lang/String;)V +com/ibm/oti/connection/file/Connection.getPlatformPath.(Ljava/lang/String;)Ljava/lang/String; +com/ibm/oti/connection/file/Connection.checkSecurity.(Ljava/lang/String;)V +java/lang/Thread..()V +java/lang/Boolean.equals.(Ljava/lang/Object;)Z +com/ibm/oti/connection/file/Connection.close.()V +java/lang/Integer.equals.(Ljava/lang/Object;)Z +com/sun/cldc/io/ResourceInputStream.close.()V +java/io/DataInputStream.readByte.()B +java/io/OutputStream.close.()V +com/nokia/mid/ui/TextEditorThread.run.()V +java/util/Vector.insertElementAt.(Ljava/lang/Object;I)V +java/io/ByteArrayOutputStream.close.()V +java/util/Hashtable$HashtableEnumerator.hasMoreElements.()Z +com/ibm/oti/connection/file/Connection.fileSize.()J +java/lang/Exception..()V +java/lang/Throwable..()V +java/io/ByteArrayOutputStream..(I)V +javax/microedition/lcdui/ImageDataFactory.getImageDataFromStream.(Ljavax/microedition/lcdui/ImageData;Ljava/io/InputStream;)V +javax/microedition/lcdui/CanvasLFImpl.uCallKeyReleased.(I)V +javax/microedition/lcdui/Canvas.keyReleased.(I)V +com/ibm/oti/connection/file/Connection.exists.()Z +com/sun/midp/security/SecurityInitializer.requestToken.(Lcom/sun/midp/security/ImplicitlyTrustedClass;)Lcom/sun/midp/security/SecurityToken; +com/sun/midp/security/SecurityInitializerImpl.requestToken.(Lcom/sun/midp/security/ImplicitlyTrustedClass;)Lcom/sun/midp/security/SecurityToken; +com/sun/midp/security/SecurityInitializerImpl.isTrusted.(Ljava/lang/Object;)Z +java/io/DataOutputStream..(Ljava/io/OutputStream;)V +java/io/DataOutputStream.close.()V +javax/microedition/lcdui/CanvasLFImpl.uCallKeyPressed.(I)V +javax/microedition/lcdui/Canvas.keyPressed.(I)V +com/sun/midp/events/NativeEvent..(I)V +com/ibm/oti/connection/file/Connection.openOutputStream.(J)Ljava/io/OutputStream; +com/ibm/oti/connection/file/FCOutputStream..([BJLcom/ibm/oti/connection/file/Connection;)V +com/sun/midp/rms/RecordStoreImpl..(Lcom/sun/midp/security/SecurityToken;ILjava/lang/String;Z)V +java/lang/Character.toUpperCase.(C)C +com/sun/midp/events/NativeEvent..()V +java/util/Hashtable.clear.()V +com/sun/cldc/util/j2me/CalendarImpl.floorDivide.(II[I)I +java/io/ByteArrayInputStream.close.()V +com/sun/cldc/i18n/Helper.normalizeEncodingName.(Ljava/lang/String;)Ljava/lang/String; +com/sun/midp/midletsuite/MIDletSuiteImpl.getProperty.(Ljava/lang/String;)Ljava/lang/String; +com/sun/midp/midletsuite/SuiteProperties.getProperty.(Ljava/lang/String;)Ljava/lang/String; +com/sun/midp/util/Properties.getProperty.(Ljava/lang/String;)Ljava/lang/String; +com/ibm/oti/connection/file/Connection.checkWrite.()V +javax/microedition/lcdui/DisplayableLFImpl.lGetDisplayable.()Ljavax/microedition/lcdui/Displayable; +com/sun/midp/security/SecurityInitializerImpl..(Lcom/sun/midp/security/SecurityToken;[Ljava/lang/String;)V +com/sun/midp/midletsuite/SuiteProperties.loadProperties.()V +com/sun/midp/rms/RecordStoreIndex.getRecordIDs.()[I +java/io/DataInputStream.readLong.()J +com/sun/midp/main/MIDletProxyList.notifyListenersOfProxyUpdate.(Lcom/sun/midp/main/MIDletProxy;I)V +com/nokia/mid/s40/codec/DataEncoder..(Ljava/lang/String;)V +java/lang/Exception..(Ljava/lang/String;)V +java/lang/Throwable..(Ljava/lang/String;)V +java/util/Vector.removeElement.(Ljava/lang/Object;)Z +com/ibm/oti/connection/file/FCOutputStream.close.()V +com/ibm/oti/connection/file/Connection.notifyOutputStreamClosed.()V +javax/microedition/lcdui/Display.getCurrent.()Ljavax/microedition/lcdui/Displayable; +javax/microedition/lcdui/Image.createImage.(Ljava/lang/String;)Ljavax/microedition/lcdui/Image; +javax/microedition/lcdui/ImageDataFactory.createResourceImageData.(Ljava/lang/String;)Ljavax/microedition/lcdui/ImageData; +javax/microedition/lcdui/ImageData..()V +javax/microedition/lcdui/ImageDataFactory.loadAndCreateImmutableImageDataFromCache.(Ljavax/microedition/lcdui/ImageData;Ljava/lang/String;)Z +javax/microedition/lcdui/SuiteImageCacheImpl.loadAndCreateImmutableImageData.(Ljavax/microedition/lcdui/ImageData;Ljava/lang/String;)Z +com/sun/midp/io/Util.toJavaString.([B)Ljava/lang/String; +java/util/Hashtable$HashtableEnumerator.nextElement.()Ljava/lang/Object; +com/sun/midp/lcdui/DisplayDevice.isPrimaryDisplay.()Z +com/sun/midp/main/MIDletProxy.getClassName.()Ljava/lang/String; +com/sun/midp/rms/RmsEnvironment.getSecureFilenameBase.(I)Ljava/lang/String; +com/sun/midp/midletsuite/SuiteContainerAdapter.getSecureFilenameBase.(I)Ljava/lang/String; diff --git a/jit/compiler.ts b/jit/compiler.ts index dba44cc4..e3714d78 100644 --- a/jit/compiler.ts +++ b/jit/compiler.ts @@ -237,7 +237,7 @@ module J2ME { var failedCompilations = 0; function compileClassInfo(emitter: Emitter, classInfo: ClassInfo, - methodFilter: (methodInfo: MethodInfo) => boolean, + methodFilterList: string[], ctx: Context): CompiledMethodInfo [] { var writer = emitter.writer; var mangledClassName = classInfo.mangledName; @@ -273,7 +273,7 @@ module J2ME { if (!method.code) { continue; } - if (!methodFilter(method)) { + if (methodFilterList !== null && methodFilterList.indexOf(method.implKey) < 0) { continue; } var mangledMethodName = method.mangledName; @@ -297,6 +297,9 @@ module J2ME { failedCompilations ++; } if (compiledMethod && compiledMethod.body) { + if (methodFilterList) { + methodFilterList.splice(methodFilterList.indexOf(method.implKey), 1); + } var compiledMethodName = mangledClassAndMethodName; writer.enter("function " + compiledMethodName + "(" + compiledMethod.args.join(",") + ") {"); writer.writeLns(compiledMethod.body); @@ -354,7 +357,7 @@ module J2ME { export function compile(jvm: any, jarFilter: (jarFile: string) => boolean, classFilter: (classInfo: ClassInfo) => boolean, - methodFilter: (methodInfo: MethodInfo) => boolean, + methodFilterList: string[], fileFilter: string, debugInfo: boolean, tsDefinitions: boolean) { var runtime = new Runtime(jvm); var jarFiles = CLASSES.jarFiles; @@ -438,7 +441,7 @@ module J2ME { var methods = classInfo.methods; for (var j = 0; j < methods.length; j++) { var method = methods[j]; - if (methodFilter(method)) { + if (methodFilterList === null || methodFilterList.indexOf(method.implKey) >= 0) { // If at least one method is found, compile the class. filteredClassInfoList.push(classInfo); break; @@ -456,7 +459,7 @@ module J2ME { if (classInfo.isInterface) { continue; } - ArrayUtilities.pushMany(compiledMethods, compileClassInfo(emitter, classInfo, methodFilter, ctx)); + ArrayUtilities.pushMany(compiledMethods, compileClassInfo(emitter, classInfo, methodFilterList, ctx)); } var color = failedCompilations ? IndentingWriter.YELLOW : IndentingWriter.GREEN; diff --git a/jsc.ts b/jsc.ts index 08c3c81c..d7b597b7 100644 --- a/jsc.ts +++ b/jsc.ts @@ -208,7 +208,7 @@ module J2ME { classNameList = file.replace(/\r?\n/g, "\n").split("\n"); } } - var methodNameList; + var methodFilterList = null; if (methodFileFilterOption.value) { var file; try { @@ -217,10 +217,16 @@ module J2ME { } if (file) { - methodNameList = file.replace(/\r?\n/g, "\n").split("\n"); - - // Trim Whitespace - methodNameList = methodNameList.map(x => x.replace(/^\s+|\s+$/g, "")); + methodFilterList = []; + var lines = file.replace(/\r?\n/g, "\n").split("\n"); + for (var i = 0; i < lines.length; i++) { + // Trim Whitespace + var line = lines[i].replace(/^\s+|\s+$/g, ""); + if (line === "") { + continue; + } + methodFilterList.push(line); + } } } @@ -238,17 +244,20 @@ module J2ME { } return false; } - function methodFilter(methodInfo: MethodInfo): boolean { - if (methodNameList) { - return methodNameList.indexOf(methodInfo.implKey) >= 0; - } else if (!methodFilterOption.value) { - return true; - } - return methodInfo.implKey === methodFilterOption.value; + if (methodFilterOption.value) { + methodFilterList = [methodFilterOption.value]; } + stdoutWriter.writeLn("var start = performance.now();"); - compile(jvm, jarFilter, classFilter, methodFilter, fileFilterOption.value, debuggerOption.value, definitionOption.value); + compile(jvm, jarFilter, classFilter, methodFilterList, fileFilterOption.value, debuggerOption.value, definitionOption.value); stdoutWriter.writeLn("console.log(\"Loaded " + jarFileFilterOption.value + " in \" + (performance.now() - start).toFixed(2) + \" ms.\");"); + if (methodFilterList !== null && methodFilterList.length) { + stderrWriter.enter("The following method(s) in the method filter list failed to compile or were not found:"); + for (var i = 0; i < methodFilterList.length; i++) { + stderrWriter.errorLn(methodFilterList[i]); + } + stderrWriter.leave(""); + } if (verboseOption.value) { // ... }