Added trampolines for global trait methods.

This commit is contained in:
Michael Bebenita 2012-07-19 17:39:33 -07:00
Родитель 3e89afd2c4
Коммит add85c3102
2 изменённых файлов: 34 добавлений и 3 удалений

Просмотреть файл

@ -123,8 +123,9 @@ var Verifier = (function() {
} else if (name.getQualifiedName() === "public$Object") {
return type.Atom.Object;
}
print(name);
return type.fromReference(domain.getProperty(name, false, false));
var ty = domain.getProperty(name, false, false);
assert (ty, name + " not found");
return type.fromReference(ty);
};
type.fromReference = function fromReference(value) {

Просмотреть файл

@ -855,7 +855,37 @@ var Runtime = (function () {
// FIXME: Breaking compat with AS and using .bind here instead of the
// MethodClosure class to work around a SpiderMonkey bug 771871.
const MethodClosureClass = domain.system.MethodClosureClass;
var closure = makeClosure(trait);
var closure;
// FIXME: There are some regressions because of this, but leave it in
// place for now to help the work on the verifier progress.
// Here we're creating a trampoline that triggers compilation when the
// method is first executed and not when the trait is applied. This
// helps ensure that types are initialized by the time the verifier
// gets to work.
// TODO: It may be that the verifier can work with non-initialized types.
// It can probably find the class traits manually, so that may be worth
// looking into.
if (obj instanceof Global && this.domain.mode !== ALWAYS_INTERPRET) {
closure = (function (trait, obj, qn) {
return (function () {
var executed = false;
var mc = undefined;
return function () {
if (!executed) {
mc = makeClosure(trait);
defineNonEnumerableProperty(obj, qn, mc);
executed = true;
}
return mc.apply(this, arguments);
};
})();
})(trait, obj, qn);
} else {
closure = makeClosure(trait);
}
var mc;
if (delayBinding) {
var memoizeMethodClosure = (function (closure, qn) {