Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Start the VM before the MIDlet JAR and the filesystem are loaded #1201

Merged
merged 1 commit into from
Mar 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions jit/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module J2ME {
* at the right spots.
*/
export var yieldMap = {
"com/sun/midp/main/MIDletSuiteUtils.vmBeginStartUp.(I)V": YieldReason.Root,
"com/sun/midp/lcdui/DisplayDevice.gainedForeground0.(II)V": YieldReason.Root,
"com/sun/cdc/io/j2me/file/DefaultFileHandler.openForRead.()V": YieldReason.Root,
"com/sun/cdc/io/j2me/file/DefaultFileHandler.openForWrite.()V": YieldReason.Root,
Expand Down
10 changes: 6 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ var getMobileInfo = new Promise(function(resolve, reject) {
});
});

var loadingPromises = [initFS, getMobileInfo];
var loadingMIDletPromises = [initFS, getMobileInfo];

var loadingPromises = [];

loadingPromises.push(load("java/classes.jar", "arraybuffer").then(function(data) {
JARStore.addBuiltIn("java/classes.jar", data);
CLASSES.initializeBuiltinClasses();
}));

jars.forEach(function(jar) {
loadingPromises.push(load(jar, "arraybuffer").then(function(data) {
loadingMIDletPromises.push(load(jar, "arraybuffer").then(function(data) {
JARStore.addBuiltIn(jar, data);
}));
});
Expand All @@ -67,7 +69,7 @@ function processJAD(data) {
}

if (config.jad) {
loadingPromises.push(load(config.jad, "text").then(processJAD).then(backgroundCheck));
loadingMIDletPromises.push(load(config.jad, "text").then(processJAD).then(backgroundCheck));
}

function performDownload(url, dialog, callback) {
Expand Down Expand Up @@ -118,7 +120,7 @@ function performDownload(url, dialog, callback) {
}

if (config.downloadJAD) {
loadingPromises.push(new Promise(function(resolve, reject) {
loadingMIDletPromises.push(new Promise(function(resolve, reject) {
JARStore.loadJAR("midlet.jar").then(function(loaded) {
if (loaded) {
processJAD(JARStore.getJAD());
Expand Down
3 changes: 3 additions & 0 deletions midp/midp.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,16 @@ var MIDP = (function() {
return AMSIsolateId == $.ctx.runtime.isolate.id ? 1 : 0;
};

// This function is called before a MIDlet is created (in MIDletStateListener::midletPreStart).
Native["com/sun/midp/main/MIDletSuiteUtils.vmBeginStartUp.(I)V"] = function(midletIsolateId) {
// See DisplayContainer::createDisplayId, called by the LCDUIEnvironment constructor,
// called by CldcMIDletSuiteLoader::createSuiteEnvironment.
// The formula depens on the ID of the isolate that calls createDisplayId, that is
// the same isolate that calls vmBeginStartUp. So this is a good place to calculate
// the display ID.
displayId = ((midletIsolateId & 0xff)<<24) | (1 & 0x00ffffff);

asyncImpl("V", Promise.all(loadingMIDletPromises));
};

Native["com/sun/midp/main/MIDletSuiteUtils.vmEndStartUp.(I)V"] = function(midletIsolateId) {
Expand Down