Skip to content
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.

Commit

Permalink
Merge pull request #215 from mbebenita/master
Browse files Browse the repository at this point in the history
Perf updates.
  • Loading branch information
mbebenita committed Apr 7, 2013
2 parents 4c1e5bb + 0e25180 commit 2e610cd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/avm2/compiler/inferrer.js
Expand Up @@ -86,7 +86,7 @@ var Type = (function () {
};

type.prototype.isNumeric = function () {
return this === Type.Int || this === Type.Number;
return this === Type.Int || this === Type.Uint || this === Type.Number;
};

type.prototype.isParameterizedType = function () {
Expand Down
27 changes: 12 additions & 15 deletions src/avm2/parser.js
Expand Up @@ -327,7 +327,7 @@ var ShumwayNamespace = (function () {
}
} else if (this.isUnique()) {
// Make a psuedo unique id by concatenating current milliseconds to original uri
this.uri = String(this.uri+Date.now());
this.uri = String(this.uri + Date.now());
}
this.uri = mangleNamespaceString(this.uri);
release || assert(kinds[this.kind]);
Expand All @@ -341,22 +341,17 @@ var ShumwayNamespace = (function () {
return str;
}

function mangleNamespaceString(strIn) {
var perfectNamespaceHash = Object.create(null);
var perfectNamespaceHashCount = 0;

function mangleNamespaceString(str) {
if (!release) {
return escapeString(strIn);
}
var buf = str2ab(strIn);
var strOut = base64ArrayBuffer(buf).replace(/=/g, ""); // Erase padding
return strOut;

function str2ab(str) {
var buf = new ArrayBuffer(str.length);
var bufView = new Uint8Array(buf);
for (var i=0, strLen=str.length; i<strLen; i++) {
bufView[i] = str.charCodeAt(i);
}
return buf;
return escapeString(str);
}
if (str === "") {
return "";
}
return perfectNamespaceHash[str] || (perfectNamespaceHash[str] = "N" + perfectNamespaceHashCount++);
}

namespace.kindFromString = function kindFromString(str) {
Expand Down Expand Up @@ -1182,6 +1177,7 @@ var ClassInfo = (function () {
function classInfo(abc, instanceInfo, stream) {
this.id = nextID ++;
this.init = abc.methods[stream.readU30()];
this.init.isClassInitializer = true;
attachHolder(this.init, this);
this.traits = parseTraits(abc, stream, this);
this.instanceInfo = instanceInfo;
Expand All @@ -1201,6 +1197,7 @@ var ScriptInfo = (function scriptInfo() {
this.abc = abc;
this.name = abc.name + "$script" + idx;
this.init = abc.methods[stream.readU30()];
this.init.isScriptInitializer = true;
attachHolder(this.init, this);
this.traits = parseTraits(abc, stream, this);
this.traits.verified = true;
Expand Down
4 changes: 4 additions & 0 deletions src/avm2/runtime.js
Expand Up @@ -883,6 +883,10 @@ var Runtime = (function () {
} else if (mi.code.length > compilerMaximumMethodSize.value) {
return false;
}
// Don't compile class and script initializers since they only run once.
if (mi.isClassInitializer || mi.isScriptInitializer) {
return false;
}
return true;
}

Expand Down

0 comments on commit 2e610cd

Please sign in to comment.