test/script/basic/run-octane.js

Wed, 30 Jan 2013 12:26:45 +0100

author
lagergren
date
Wed, 30 Jan 2013 12:26:45 +0100
changeset 57
59970b70ebb5
parent 19
4cd65798ec70
child 139
390d44ba90cf
permissions
-rw-r--r--

8007062: Split Lower up into Lower/Attr/FinalizeTypes. Integrate AccessSpecalizer into FinalizeTypes.
Summary: Lower suffered from being a "God class" trying to do everything at once. As Nashorn code generation has grown, so has Lower. It does several post processing passes, tries to do several things at once even though all type information isn't in place, adjusting state afterwards and so on. It also performs control flow analysis, type attribution and constant folding, and everything else code generation related before byte code emission. I have now separated the compilation process into Lower (create low level nodes from high level ones, copy code such as finally block inlining etc), Attr (assign types and symbols to all nodes - freeze slot and scope information) and FinalizeTypes (insert explicit casts, specialize invoke dynamic types for scope accesses). I've removed the kludgy AccessSpecializer, as this now integrates naturally with typing. Everything is now much easier to read and each module performs only one thing. I have added separate loggers for the separate tiers. In the process I have also fixed: (1) problems with type coercion (see test/script/basic/typecoercion.js, basically our coercion was too late and our symbol inference was erroneous. This only manifested itself in very rare occasions where toNumber coercion has side effects, such as for example when valueOf is overridden) (2) copying literal nodes (literal copy did not use the superclass copy, which made all the Node specific fields not to be copied (3) erroneous literal tokenization (literals shouldn't always just inherit token information from whatever node that creates them) (4) splitter weighnodes - unary nodes were considered weightless (4) removed the hateful and kludgy "VarNode.shouldAppend", which really isn't needed when we have an attribution phase that determines self reference symbols (the only thing it was used for) (5) duplicate line number issues in the parser (6) convert bug in CodeGenerator for intermediate results of scope accesses (see test/script/basic/access-specializer.js) ... Several of these things just stopped being problems with the new architecture "can't happen anymore" and are not bug fixes per se. All tests run. No performance regressions exist that I've been able to measure. Some increases in performance were measured, but in the statistical margin of error (which is very wide as HotSpot currently has warmup issues with LambdaForms/invoke dynamic). Compile speed has not measurably increased.
Reviewed-by: jlaskey, attila

jlaskey@3 1 /*
jlaskey@7 2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
jlaskey@3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jlaskey@3 4 *
jlaskey@3 5 * This code is free software; you can redistribute it and/or modify it
jlaskey@3 6 * under the terms of the GNU General Public License version 2 only, as
jlaskey@3 7 * published by the Free Software Foundation.
jlaskey@3 8 *
jlaskey@3 9 * This code is distributed in the hope that it will be useful, but WITHOUT
jlaskey@3 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jlaskey@3 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jlaskey@3 12 * version 2 for more details (a copy is included in the LICENSE file that
jlaskey@3 13 * accompanied this code).
jlaskey@3 14 *
jlaskey@3 15 * You should have received a copy of the GNU General Public License version
jlaskey@3 16 * 2 along with this work; if not, write to the Free Software Foundation,
jlaskey@3 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jlaskey@3 18 *
jlaskey@3 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jlaskey@3 20 * or visit www.oracle.com if you need additional information or have any
jlaskey@3 21 * questions.
jlaskey@3 22 */
jlaskey@3 23
jlaskey@3 24 /**
jlaskey@3 25 * @subtest
jlaskey@3 26 */
jlaskey@3 27
jlaskey@3 28 var tests = [
jlaskey@3 29 "box2d.js",
jlaskey@3 30 "code-load.js",
jlaskey@3 31 "crypto.js",
jlaskey@3 32 "deltablue.js",
jlaskey@3 33 "earley-boyer.js",
jlaskey@3 34 "gbemu.js",
jlaskey@3 35 "navier-stokes.js",
jlaskey@3 36 "pdfjs.js",
jlaskey@3 37 "raytrace.js",
jlaskey@3 38 "regexp.js",
jlaskey@3 39 "richards.js",
jlaskey@3 40 "splay.js"
jlaskey@3 41 ];
jlaskey@3 42
jlaskey@3 43 // hack, teardown breaks things defined in the global space, making it impossible
jlaskey@3 44 // to do multiple consecutive benchmark runs with the same harness. I think it's a bug
jlaskey@3 45 // that the setup and teardown aren't each others constructor and destructor but rather
jlaskey@3 46 // that the benchmarks rely on partial global state. For shame, Octane!
jlaskey@3 47 var ignoreTeardown = [
jlaskey@3 48 { name: "box2d.js" },
jlaskey@3 49 { name: "gbemu.js" },
jlaskey@3 50 ];
jlaskey@3 51
jlaskey@3 52 var dir = (typeof(__DIR__) == 'undefined') ? "test/script/basic/" : __DIR__;
jlaskey@3 53
jlaskey@3 54 // TODO: why is this path hard coded when it's defined in project properties?
sundar@19 55 var path = dir + "../external/octane/";
jlaskey@3 56
jlaskey@3 57 var runtime = "";
jlaskey@3 58 var verbose = false;
jlaskey@3 59
jlaskey@3 60 var numberOfIterations = 5;
jlaskey@3 61
jlaskey@3 62 function endsWith(str, suffix) {
jlaskey@3 63 return str.indexOf(suffix, str.length - suffix.length) !== -1;
jlaskey@3 64 }
jlaskey@3 65
jlaskey@3 66 function run_one_benchmark(arg, iters) {
jlaskey@3 67
jlaskey@3 68 var file_name;
jlaskey@3 69 var file = arg.split('/');
jlaskey@3 70 if (file.length == 1) {
jlaskey@3 71 file = arg.split('\\');
jlaskey@3 72 }
jlaskey@3 73
jlaskey@3 74 //trim off trailing path separators
jlaskey@3 75 while (file[file.length - 1].indexOf(".js") == -1) {
jlaskey@3 76 file.pop();
jlaskey@3 77 }
jlaskey@3 78 file_name = file[file.length - 1];
lagergren@57 79
lagergren@57 80 if (typeof compile_only !== 'undefined') {
lagergren@57 81 print("Compiling... " + file_name);
lagergren@57 82 }
lagergren@57 83
lagergren@57 84 load(path + 'base.js');
lagergren@57 85 load(arg);
jlaskey@3 86
jlaskey@3 87 if (typeof compile_only !== 'undefined') {
jlaskey@3 88 print("Compiled OK: " + file_name);
lagergren@57 89 print("");
jlaskey@3 90 return;
jlaskey@3 91 }
jlaskey@3 92
jlaskey@3 93 var success = true;
jlaskey@3 94 var hiscore = 0;
jlaskey@3 95 var loscore = 10e8;
jlaskey@3 96 var current_name;
jlaskey@3 97
jlaskey@3 98 function PrintResult(name, result) {
jlaskey@3 99 current_name = name;
jlaskey@3 100 }
jlaskey@3 101
jlaskey@3 102 function PrintError(name, error) {
jlaskey@3 103 current_name = name;
jlaskey@3 104 PrintResult(name, error);
jlaskey@3 105 success = false;
jlaskey@3 106 }
jlaskey@3 107
jlaskey@3 108 function PrintScore(score) {
jlaskey@3 109 if (success) {
jlaskey@3 110 if (+score >= hiscore) {
jlaskey@3 111 hiscore = +score;
jlaskey@3 112 }
jlaskey@3 113 if (+score <= loscore) {
jlaskey@3 114 loscore = +score;
jlaskey@3 115 }
jlaskey@3 116 }
jlaskey@3 117
jlaskey@3 118 if (verbose) {
jlaskey@3 119 print("Score: " + score);
jlaskey@3 120 }
jlaskey@3 121 }
jlaskey@3 122
jlaskey@3 123 if (iters == undefined) {
jlaskey@3 124 iters = numberOfIterations;
jlaskey@3 125 } else {
jlaskey@3 126 numberOfIterations = iters;
jlaskey@3 127 }
jlaskey@3 128
jlaskey@3 129 print(runtime + ": running " + file_name + "...");
jlaskey@3 130
jlaskey@3 131 for (var i = 0; i < numberOfIterations; i++) {
jlaskey@3 132 var callbacks =
jlaskey@3 133 { NotifyResult: PrintResult,
jlaskey@3 134 NotifyError: PrintError,
jlaskey@3 135 NotifyScore: PrintScore };
jlaskey@3 136
jlaskey@3 137 for (j in ignoreTeardown) {
jlaskey@3 138 var ignore = ignoreTeardown[j];
jlaskey@3 139 if (endsWith(arg, ignore.name)) {
jlaskey@3 140 var teardownOverride = ignore.teardown;
jlaskey@3 141 if (!teardownOverride) {
jlaskey@3 142 teardownOverride = function() {};
jlaskey@3 143 }
jlaskey@3 144
jlaskey@3 145 for (k in BenchmarkSuite.suites) {
jlaskey@3 146 var benchmarks = BenchmarkSuite.suites[k].benchmarks;
jlaskey@3 147 for (l in benchmarks) {
jlaskey@3 148 benchmarks[l].TearDown = teardownOverride;
jlaskey@3 149 }
jlaskey@3 150 }
jlaskey@3 151 break;
jlaskey@3 152 }
jlaskey@3 153 }
jlaskey@3 154
jlaskey@3 155 BenchmarkSuite.RunSuites(callbacks);
jlaskey@3 156 }
jlaskey@3 157
jlaskey@3 158 var start = "Score: ";
jlaskey@3 159 if (runtime != "") {
jlaskey@3 160 start = runtime + ": ";
jlaskey@3 161 }
jlaskey@3 162 print(start + current_name + ' (version ' + BenchmarkSuite.version + '): ' + loscore + '-' + hiscore);
jlaskey@3 163 }
jlaskey@3 164
jlaskey@3 165 function run_suite(tests, iters) {
jlaskey@3 166 for (var idx = 0; idx < tests.length; idx++) {
jlaskey@3 167 run_one_benchmark(tests[idx], iters, false);
jlaskey@3 168 }
jlaskey@3 169 }
jlaskey@3 170
jlaskey@3 171 runtime = "command line";
jlaskey@3 172
jlaskey@3 173 var args = [];
jlaskey@3 174 if (typeof $ARGS !== 'undefined') {
jlaskey@3 175 args = $ARGS;
jlaskey@3 176 } else if (typeof arguments !== 'undefined' && arguments.length != 0) {
jlaskey@3 177 args = arguments;
jlaskey@3 178 }
jlaskey@3 179
jlaskey@3 180 var new_args = [];
jlaskey@3 181 for (i in args) {
jlaskey@3 182 if (args[i].toString().indexOf(' ') != -1) {
jlaskey@3 183 args[i] = args[i].replace(/\/$/, '');
jlaskey@3 184 var s = args[i].split(' ');
jlaskey@3 185 for (j in s) {
jlaskey@3 186 new_args.push(s[j]);
jlaskey@3 187 }
jlaskey@3 188 } else {
jlaskey@3 189 new_args.push(args[i]);
jlaskey@3 190 }
jlaskey@3 191 }
jlaskey@3 192
jlaskey@3 193 if (new_args.length != 0) {
jlaskey@3 194 args = new_args;
jlaskey@3 195 }
jlaskey@3 196
jlaskey@3 197 var tests_found = [];
jlaskey@3 198 var iters = undefined;
jlaskey@3 199
jlaskey@3 200 for (var i = 0; i < args.length; i++) {
jlaskey@3 201 arg = args[i];
jlaskey@3 202 if (arg == "--iterations") {
jlaskey@3 203 iters = +args[++i];
jlaskey@3 204 } else if (arg == "--runtime") {
jlaskey@3 205 runtime = args[++i];
jlaskey@3 206 } else if (arg == "--verbose") {
jlaskey@3 207 verbose = true;
jlaskey@3 208 } else if (arg == "") {
jlaskey@3 209 continue; //skip
jlaskey@3 210 } else {
jlaskey@3 211 tests_found.push(arg);
jlaskey@3 212 }
jlaskey@3 213 }
jlaskey@3 214
jlaskey@3 215 if (tests_found.length == 0) {
jlaskey@3 216 for (i in tests) {
jlaskey@3 217 tests_found.push(path + tests[i]);
jlaskey@3 218 }
jlaskey@3 219 }
jlaskey@3 220
jlaskey@3 221 tests_found.sort();
jlaskey@3 222
jlaskey@3 223 run_suite(tests_found, iters);
jlaskey@3 224
jlaskey@3 225
jlaskey@3 226

mercurial