clean up flattener code and remove unneeded flattener definitions; 3% speedup
This commit is contained in:
Родитель
ab097f0b3a
Коммит
5a4c4614b7
|
@ -172,9 +172,9 @@ function analyzer(data) {
|
|||
return;
|
||||
}
|
||||
type.flatSize = 0;
|
||||
var sizes = [];
|
||||
var diffs = [];
|
||||
var prev = -1;
|
||||
type.flatIndexes = type.fields.map(function(field) {
|
||||
var soFar = type.flatSize;
|
||||
var size;
|
||||
if (isNumberType(field) || isPointerType(field)) {
|
||||
size = getNativeFieldSize(field, true); // pack char; char; in structs, also char[X]s.
|
||||
|
@ -183,14 +183,20 @@ function analyzer(data) {
|
|||
} else {
|
||||
assert(0);
|
||||
}
|
||||
type.flatSize += size;
|
||||
sizes.push(size);
|
||||
return Runtime.alignMemory(soFar, Math.min(QUANTUM_SIZE, size)); // if necessary, place this on aligned memory
|
||||
var curr = Runtime.alignMemory(type.flatSize, Math.min(QUANTUM_SIZE, size)); // if necessary, place this on aligned memory
|
||||
type.flatSize = curr + size;
|
||||
if (prev >= 0) {
|
||||
diffs.push(curr-prev);
|
||||
}
|
||||
prev = curr;
|
||||
return curr;
|
||||
});
|
||||
type.flatSize = Runtime.alignMemory(type.flatSize); // padding at end
|
||||
if (dedup(sizes).length == 1) {
|
||||
type.flatFactor = sizes[0];
|
||||
if (diffs.length == 0) {
|
||||
type.flatFactor = type.flatSize;
|
||||
} else if (dedup(diffs).length == 1) {
|
||||
type.flatFactor = diffs[0];
|
||||
}
|
||||
type.flatSize = Runtime.alignMemory(type.flatSize); // final padding at end
|
||||
type.needsFlattening = (this.flatFactor != 1);
|
||||
dprint('types', 'type: ' + type.name_ + ' : ' + JSON.stringify(type.fields));
|
||||
dprint('types', ' has final size of ' + type.flatSize + ', flatting: ' + type.needsFlattening + ' ? ' + (type.flatFactor ? type.flatFactor : JSON.stringify(type.flatIndexes)));
|
||||
|
|
|
@ -9,7 +9,7 @@ function JSify(data) {
|
|||
substrate.addZyme('Type', {
|
||||
processItem: function(item) {
|
||||
var type = TYPES[item.name_];
|
||||
if (type.needsFlattening) {
|
||||
if (type.needsFlattening && !type.flatFactor) {
|
||||
item.JS = 'var ' + toNiceIdent(item.name_) + '___FLATTENER = ' + JSON.stringify(TYPES[item.name_].flatIndexes) + ';';
|
||||
} else {
|
||||
item.JS = '// type: ' + item.name_;
|
||||
|
|
|
@ -881,10 +881,13 @@ else:
|
|||
COMPILER = LLVM_GCC
|
||||
PARSER_ENGINE = V8_ENGINE
|
||||
JS_ENGINE = SPIDERMONKEY_ENGINE
|
||||
if JS_ENGINE == SPIDERMONKEY_ENGINE:
|
||||
JS_ENGINE_OPTS += ['-j', '-m'] # TODO: use this everywhere else
|
||||
|
||||
RELOOP = OPTIMIZE = 1
|
||||
GUARD_MEMORY = 0
|
||||
QUANTUM_SIZE = 1
|
||||
TEST_REPS = 10
|
||||
TEST_REPS = 20
|
||||
TOTAL_TESTS = 2
|
||||
|
||||
tests_done = 0
|
||||
|
@ -896,7 +899,7 @@ else:
|
|||
squared_times = map(lambda x: x*x, times)
|
||||
mean_of_squared = sum(squared_times)/len(times)
|
||||
std = math.sqrt(mean_of_squared - mean*mean)
|
||||
print ' mean: %.2f (+-%.2f) seconds (max: %.2f, min: %.2f, noise/signal: %.2f) (%d runs)' % (mean, std, max(times), min(times), std/mean, TEST_REPS)
|
||||
print ' mean: %.3f (+-%.3f) seconds (max: %.3f, min: %.3f, noise/signal: %.3f) (%d runs)' % (mean, std, max(times), min(times), std/mean, TEST_REPS)
|
||||
|
||||
def do_benchmark(self, src, args=[], main_file=None):
|
||||
print 'Running benchmark:', inspect.stack()[1][3].replace('test_', '')
|
||||
|
|
|
@ -33,16 +33,10 @@ V8_ENGINE=os.path.expanduser('~/Dev/v8/d8')
|
|||
#PARSER_ENGINE=SPIDERMONKEY_ENGINE
|
||||
PARSER_ENGINE=V8_ENGINE
|
||||
|
||||
#TODO
|
||||
#if PARSER_ENGINE == SPIDERMONKEY_ENGINE:
|
||||
# PARSER_ENGINE_OPS += ['-j', '-m']
|
||||
|
||||
JS_ENGINE=SPIDERMONKEY_ENGINE
|
||||
#JS_ENGINE=V8_ENGINE
|
||||
#JS_ENGINE=SPIDERMONKEY_ENGINE
|
||||
JS_ENGINE=V8_ENGINE
|
||||
|
||||
JS_ENGINE_OPTS=[]
|
||||
if JS_ENGINE == SPIDERMONKEY_ENGINE:
|
||||
JS_ENGINE_OPTS += ['-j', '-m']
|
||||
|
||||
OUTPUT_TO_SCREEN = 0 # useful for debugging specific tests, or for subjectively seeing what parts are slow
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче