aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@mozilla.com>2011-02-21 18:46:55 -0800
committerAlon Zakai <azakai@mozilla.com>2011-02-21 18:46:55 -0800
commitb381f9f375aa479dcbd4367af19cb698d4de1b43 (patch)
tree9fba1136be6390a51e170cac6b3331a27df15cf7 /src
parentcb0b00ff98ba99dd9661de4de89f3225caed766c (diff)
remove slow identinicer
Diffstat (limited to 'src')
-rw-r--r--src/analyzer.js19
-rw-r--r--src/framework.js3
-rw-r--r--src/intertyper.js31
-rw-r--r--src/jsifier.js5
-rw-r--r--src/parseTools.js6
5 files changed, 30 insertions, 34 deletions
diff --git a/src/analyzer.js b/src/analyzer.js
index b3d311d1..42654502 100644
--- a/src/analyzer.js
+++ b/src/analyzer.js
@@ -53,7 +53,7 @@ function analyzer(data, givenTypes) {
if (LLVM_STYLE == 'new' && item.items[i+1].intertype !== 'label') {
item.items.splice(i+1, 0, {
intertype: 'label',
- ident: '%entry',
+ ident: '_entry',
lineNum: subItem.lineNum + '.5'
});
}
@@ -79,20 +79,7 @@ function analyzer(data, givenTypes) {
}
}
delete item.items;
- this.forwardItem(item, 'Identinicer');
- }
- });
-
- // IdentiNicer
- substrate.addActor('Identinicer', {
- processItem: function(output) {
- walkJSON(output, function(item) {
- ['', '2', '3', '4', '5'].forEach(function(ext) {
- if (item && item['ident' + ext])
- item['ident' + ext] = toNiceIdent(item['ident' + ext]);
- });
- });
- this.forwardItem(output, 'Typevestigator');
+ this.forwardItem(item, 'Typevestigator');
}
});
@@ -930,7 +917,7 @@ function analyzer(data, givenTypes) {
['memset', 'malloc', 'free'].forEach(function(ident) {
ret.functionStubs.push({
intertype: 'functionStub',
- ident: '@' + ident
+ ident: '_' + ident
});
});
return ret;
diff --git a/src/framework.js b/src/framework.js
index 959d73fd..7873353b 100644
--- a/src/framework.js
+++ b/src/framework.js
@@ -101,7 +101,10 @@ Substrate.prototype = {
try {
dprint('framework', 'Processing using ' + actor.name_ + ': ' + inputs.length);
actor.items = []; // More may be added in process(); we'll get to them next time
+ //var t = Date.now();
outputs = actor.process(inputs);
+ //t = (Date.now()-t)/1000;
+ //dprint('framework', 'Took ' + t + ' seconds.');
dprint('framework', 'New results: ' + (outputs.length + that.results.length - currResultCount) + ' out of ' + (that.results.length + outputs.length));
} catch (e) {
//print("Exception, current selected are: " + inputs.map(dump).join('\n\n'));
diff --git a/src/intertyper.js b/src/intertyper.js
index 4316425e..33168e7d 100644
--- a/src/intertyper.js
+++ b/src/intertyper.js
@@ -443,7 +443,7 @@ function intertyper(data, parseFunctions, baseLineNum) {
}
var ret = {
intertype: 'globalVariable',
- ident: ident,
+ ident: toNiceIdent(ident),
type: item.tokens[2].text,
external: external,
lineNum: item.lineNum
@@ -481,7 +481,7 @@ function intertyper(data, parseFunctions, baseLineNum) {
});
var ret = {
intertype: 'function',
- ident: item.tokens[1].text,
+ ident: toNiceIdent(item.tokens[1].text),
returnType: item.tokens[0].text,
params: parseParamTokens(item.tokens[2].item.tokens),
lineNum: item.lineNum
@@ -502,9 +502,11 @@ function intertyper(data, parseFunctions, baseLineNum) {
processItem: function(item) {
return [{
intertype: 'label',
- ident: item.tokens[0].text.substr(-1) == ':' ?
- '%' + item.tokens[0].text.substr(0, item.tokens[0].text.length-1) :
- '%' + item.tokens[2].text.substr(1),
+ ident: toNiceIdent(
+ item.tokens[0].text.substr(-1) == ':' ?
+ '%' + item.tokens[0].text.substr(0, item.tokens[0].text.length-1) :
+ '%' + item.tokens[2].text.substr(1)
+ ),
lineNum: item.lineNum
}];
}
@@ -516,7 +518,7 @@ function intertyper(data, parseFunctions, baseLineNum) {
var opIndex = findTokenText(item, '=');
var pair = splitItem({
intertype: 'assign',
- ident: combineTokens(item.tokens.slice(0, opIndex)).text,
+ ident: toNiceIdent(combineTokens(item.tokens.slice(0, opIndex)).text),
lineNum: item.lineNum
}, 'value');
this.forwardItem(pair.parent, 'Reintegrator');
@@ -558,7 +560,7 @@ function intertyper(data, parseFunctions, baseLineNum) {
item.pointer = item.tokens[2].text;
}
}
- item.ident = item.pointer;
+ item.ident = toNiceIdent(item.pointer);
this.forwardItem(item, 'Reintegrator');
}
});
@@ -568,7 +570,7 @@ function intertyper(data, parseFunctions, baseLineNum) {
var last = getTokenIndexByText(item.tokens, ';');
item.intertype = 'extractvalue';
item.type = item.tokens[1].text; // Of the origin aggregate - not what we extract from it. For that, can only infer it later
- item.ident = item.tokens[2].text;
+ item.ident = toNiceIdent(item.tokens[2].text);
item.indexes = splitTokenList(item.tokens.slice(4, last));
this.forwardItem(item, 'Reintegrator');
}
@@ -578,7 +580,7 @@ function intertyper(data, parseFunctions, baseLineNum) {
processItem: function(item) {
item.intertype = 'bitcast';
item.type = item.tokens[1].text;
- item.ident = item.tokens[2].text;
+ item.ident = toNiceIdent(item.tokens[2].text);
item.type2 = item.tokens[4].text;
this.forwardItem(item, 'Reintegrator');
}
@@ -637,6 +639,7 @@ function intertyper(data, parseFunctions, baseLineNum) {
} else {
item.params = parseParamTokens(tokensLeft[0].item.tokens);
}
+ item.ident = toNiceIdent(item.ident);
if (item.indent == 2) {
// standalone call - not in assign
item.standalone = true;
@@ -657,7 +660,7 @@ function intertyper(data, parseFunctions, baseLineNum) {
}
cleanOutTokens(['alignstack', 'alwaysinline', 'inlinehint', 'naked', 'noimplicitfloat', 'noinline', 'alwaysinline attribute.', 'noredzone', 'noreturn', 'nounwind', 'optsize', 'readnone', 'readonly', 'ssp', 'sspreq'], item.tokens, 4);
item.type = item.tokens[1].text;
- item.ident = item.tokens[2].text;
+ item.ident = toNiceIdent(item.tokens[2].text);
item.params = parseParamTokens(item.tokens[3].item.tokens);
item.toLabel = toNiceIdent(item.tokens[6].text);
item.unwindLabel = toNiceIdent(item.tokens[9].text);
@@ -738,7 +741,7 @@ function intertyper(data, parseFunctions, baseLineNum) {
pointer: parseLLVMSegment(segments[1]),
lineNum: item.lineNum
};
- ret.ident = ret.pointer.ident;
+ ret.ident = toNiceIdent(ret.pointer.ident);
ret.pointerType = ret.pointer.type;
return [ret];
}
@@ -755,7 +758,7 @@ function intertyper(data, parseFunctions, baseLineNum) {
} else {
return [{
intertype: 'branch',
- ident: item.tokens[2].text,
+ ident: toNiceIdent(item.tokens[2].text),
labelTrue: toNiceIdent(item.tokens[5].text),
labelFalse: toNiceIdent(item.tokens[8].text),
lineNum: item.lineNum
@@ -792,7 +795,7 @@ function intertyper(data, parseFunctions, baseLineNum) {
return [{
intertype: 'switch',
type: item.tokens[1].text,
- ident: item.tokens[2].text,
+ ident: toNiceIdent(item.tokens[2].text),
defaultLabel: toNiceIdent(item.tokens[5].text),
switchLabels: parseSwitchLabels(item.tokens[6]),
lineNum: item.lineNum
@@ -816,7 +819,7 @@ function intertyper(data, parseFunctions, baseLineNum) {
}
return [{
intertype: 'functionStub',
- ident: item.tokens[2].text,
+ ident: toNiceIdent(item.tokens[2].text),
returnType: item.tokens[1],
params: item.tokens[3],
lineNum: item.lineNum
diff --git a/src/jsifier.js b/src/jsifier.js
index f4046423..3b054119 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -30,8 +30,11 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions, givenGlobalVaria
for (var i = 0; i < data.unparsedFunctions.length; i++) {
var func = data.unparsedFunctions[i];
- dprint('unparsedFunctions', 'processing |' + func.ident + '|, ' + i + '/' + data.unparsedFunctions.length);
+ dprint('unparsedFunctions', '====================\n// Processing |' + func.ident + '|, ' + i + '/' + data.unparsedFunctions.length);
+ //var t = Date.now();
func.JS = JSify(analyzer(intertyper(func.lines, true, func.lineNum-1), TYPES), true, TYPES, FUNCTIONS, GLOBAL_VARIABLES);
+ //t = (Date.now()-t)/1000;
+ //dprint('unparsedFunctions', 'unparsedFunction took ' + t + ' seconds.');
delete func.lines; // clean up memory as much as possible
}
diff --git a/src/parseTools.js b/src/parseTools.js
index 0990eb2f..6cf186d0 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -287,7 +287,7 @@ function parseParamTokens(params) {
intertype: 'value',
type: segment[0].text,
value: segment[1],
- ident: parseNumerical(segment[1].text)
+ ident: toNiceIdent(parseNumerical(segment[1].text))
});
// } else {
// throw "what is this params token? " + JSON.stringify(segment);
@@ -301,7 +301,7 @@ function parseLLVMSegment(segment) {
if (segment.length == 1) {
return {
intertype: 'value',
- ident: segment[0].text,
+ ident: toNiceIdent(segment[0].text),
type: isType(segment[0].text) ? segment[0].text : '?'
};
} else if (segment[1].type == '{') {
@@ -317,7 +317,7 @@ function parseLLVMSegment(segment) {
} else {
return {
intertype: 'value',
- ident: segment[1].text,
+ ident: toNiceIdent(segment[1].text),
type: segment[0].text
};
}