Skip to content

Commit

Permalink
remove slow identinicer
Browse files Browse the repository at this point in the history
  • Loading branch information
azakai committed Feb 22, 2011
1 parent cb0b00f commit b381f9f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 34 deletions.
19 changes: 3 additions & 16 deletions src/analyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
});
}
Expand All @@ -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');
}
});

Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
31 changes: 17 additions & 14 deletions src/intertyper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
}];
}
Expand All @@ -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');
Expand Down Expand Up @@ -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');
}
});
Expand All @@ -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');
}
Expand All @@ -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');
}
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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];
}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/jsifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions src/parseTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 == '{') {
Expand All @@ -317,7 +317,7 @@ function parseLLVMSegment(segment) {
} else {
return {
intertype: 'value',
ident: segment[1].text,
ident: toNiceIdent(segment[1].text),
type: segment[0].text
};
}
Expand Down

0 comments on commit b381f9f

Please sign in to comment.