зеркало из https://github.com/mozilla/pluotsorbet.git
Use a different object for locks so we don't trigger class initialization while getting the class object while pushing a class initialization frame.
This commit is contained in:
Родитель
79e3d9ad8e
Коммит
ebb5229397
|
@ -295,6 +295,15 @@ module J2ME {
|
|||
return CLASSES.getField(this, fieldKey);
|
||||
}
|
||||
|
||||
getClassInitLockObject(ctx: Context) {
|
||||
if (!(this.className in ctx.runtime.classInitLockObjects)) {
|
||||
ctx.runtime.classInitLockObjects[this.className] = {
|
||||
classInfo: this
|
||||
};
|
||||
}
|
||||
return ctx.runtime.classInitLockObjects[this.className];
|
||||
}
|
||||
|
||||
toString() {
|
||||
return "[class " + this.className + "]";
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ module J2ME {
|
|||
0xb1, // return
|
||||
])
|
||||
});
|
||||
return new Frame(syntheticMethod, [classInfo.getClassObject(this)], 0);
|
||||
return new Frame(syntheticMethod, [classInfo.getClassInitLockObject(this)], 0);
|
||||
}
|
||||
|
||||
pushClassInitFrame(classInfo: ClassInfo) {
|
||||
|
|
|
@ -254,7 +254,7 @@ Native.create("java/lang/Object.notifyAll.()V", function(ctx) {
|
|||
});
|
||||
|
||||
Native.create("java/lang/Class.invoke_clinit.()V", function(ctx) {
|
||||
var classInfo = this.runtimeKlass.templateKlass.classInfo;
|
||||
var classInfo = this.classInfo;
|
||||
var className = classInfo.className;
|
||||
var runtime = ctx.runtime;
|
||||
if (runtime.initialized[className] || runtime.pending[className])
|
||||
|
@ -263,7 +263,8 @@ Native.create("java/lang/Class.invoke_clinit.()V", function(ctx) {
|
|||
if (className === "com/sun/cldc/isolate/Isolate") {
|
||||
// The very first isolate is granted access to the isolate API.
|
||||
// ctx.runtime.setStatic(CLASSES.getField(classInfo, "S._API_access_ok.I"), 1);
|
||||
CLASSES.getField(classInfo, "S._API_access_ok.I").set(this, 1);
|
||||
var isolate = classInfo.getClassObject(ctx).classObject;
|
||||
CLASSES.getField(classInfo, "S._API_access_ok.I").set(isolate, 1);
|
||||
}
|
||||
var clinit = CLASSES.getMethod(classInfo, "S.<clinit>.()V");
|
||||
var frames = [];
|
||||
|
@ -282,7 +283,7 @@ Native.create("java/lang/Class.invoke_clinit.()V", function(ctx) {
|
|||
});
|
||||
|
||||
Native.create("java/lang/Class.init9.()V", function(ctx) {
|
||||
var classInfo = this.runtimeKlass.templateKlass.classInfo;
|
||||
var classInfo = this.classInfo;
|
||||
var className = classInfo.className;
|
||||
var runtime = ctx.runtime;
|
||||
if (runtime.initialized[className])
|
||||
|
|
|
@ -129,6 +129,7 @@ module J2ME {
|
|||
pending: any;
|
||||
staticFields: any;
|
||||
classObjects: any;
|
||||
classInitLockObjects: any;
|
||||
ctx: Context;
|
||||
|
||||
isolate: com.sun.cldc.isolate.Isolate;
|
||||
|
@ -148,6 +149,7 @@ module J2ME {
|
|||
this.staticFields = {};
|
||||
this.classObjects = {};
|
||||
this.ctx = null;
|
||||
this.classInitLockObjects = {};
|
||||
this._runtimeId = RuntimeTemplate._nextRuntimeId ++;
|
||||
this._nextHashCode = this._runtimeId << 24;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче