jlaskey@3: /* jlaskey@7: * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. jlaskey@3: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. attila@962: * jlaskey@3: * This code is free software; you can redistribute it and/or modify it jlaskey@3: * under the terms of the GNU General Public License version 2 only, as jlaskey@3: * published by the Free Software Foundation. attila@962: * jlaskey@3: * This code is distributed in the hope that it will be useful, but WITHOUT jlaskey@3: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jlaskey@3: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jlaskey@3: * version 2 for more details (a copy is included in the LICENSE file that jlaskey@3: * accompanied this code). attila@962: * jlaskey@3: * You should have received a copy of the GNU General Public License version jlaskey@3: * 2 along with this work; if not, write to the Free Software Foundation, jlaskey@3: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. attila@962: * jlaskey@3: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA jlaskey@3: * or visit www.oracle.com if you need additional information or have any jlaskey@3: * questions. jlaskey@3: */ jlaskey@3: jlaskey@3: /** attila@963: * Make sure that we run with the class cache off to so that every attila@963: * run produces compile time and with optimistic type info caching attila@963: * and persistent code store off, for the same reasons. These last two attila@963: * are currently default, but this is not guaranteed to be the case attila@963: * forever, so make this test future safe, we specify them explicitly attila@963: * attila@963: * This means that if you use this subtest as a compilation test attila@963: * harness, pass the arguments: attila@963: * attila@963: * -scripting -Dnashorn.typeInfo.disabled=true --class-cache-size=0 attila@963: * --persistent-code-cache=false attila@963: * attila@963: * @subtest attila@962: */ jlaskey@3: attila@963: load(__DIR__ + 'octane-payload.js'); attila@963: attila@963: var DEFAULT_ITERS = 1; //default is one iteration through each benchmark attila@963: var iters = DEFAULT_ITERS; attila@963: var args = []; attila@963: attila@963: if (typeof $ARGS !== 'undefined') { attila@963: args = $ARGS; attila@963: } else if (typeof arguments !== 'undefined' && arguments.length != 0) { attila@963: args = arguments; attila@963: } attila@963: attila@963: var onlyTheseTests = []; attila@963: var verbose = false; attila@963: attila@963: for (var i = 0; i < args.length; ) { attila@963: var arg = args[i]; attila@963: if (arg === '--iterations') { attila@963: iters = +args[++i]; attila@963: } else if (arg === '--verbose') { attila@963: verbose = true; attila@963: } else { attila@963: onlyTheseTests.push(arg); attila@963: } attila@963: i++; attila@963: } attila@963: attila@963: if (isNaN(iters)) { attila@963: iters = DEFAULT_ITERS; attila@963: } attila@963: attila@963: if (iters != DEFAULT_ITERS) { attila@963: print("Running " + iters + " iterations of each compilation."); attila@963: } attila@963: attila@963: function print_if_verbose(x) { attila@963: if (verbose) { attila@963: print(x); attila@963: } attila@963: } attila@963: attila@963: function contains(a, obj) { attila@963: for (var i = 0; i < a.length; i++) { attila@963: if (a[i] === obj) { attila@963: return true; attila@963: } attila@963: } attila@963: return false; attila@963: } attila@963: attila@963: var testsCompiled = []; attila@963: attila@963: for (var j in tests) { attila@963: var test_name = tests[j].name; attila@963: var files = tests[j].files; attila@963: attila@963: if (onlyTheseTests.length > 0 && !contains(onlyTheseTests, test_name)) { attila@963: print_if_verbose("Skipping " + test_name); attila@963: continue; attila@963: } attila@963: attila@963: if (!contains(testsCompiled, test_name)) { attila@963: testsCompiled.push(test_name); attila@963: } attila@963: attila@963: var str = "Compiling '" + test_name + "'..."; attila@963: if (files.length > 1) { attila@963: str += " (" + files.length + " files)"; attila@963: } attila@963: if (iters != 1) { attila@963: str += " (" + iters + " times)"; attila@963: } attila@963: str + "..."; attila@963: print(str); attila@963: attila@963: for (var iteration = 0; iteration < iters; iteration++) { attila@963: attila@963: //get a new global to avoid symbol pollution and reloads of base attila@963: //in the same namespace attila@963: var newGlobal = loadWithNewGlobal({script:'this', name:'test'}); attila@963: attila@963: //load base into the new global so we get BenchmarkSuite etc attila@963: newGlobal.load(base); attila@963: attila@963: //load all files in the single benchmark attila@963: for (var k in files) { attila@963: var file = files[k]; attila@963: if (iteration >= 0) { //only display message on first iteration attila@963: var str2 = "\t"; attila@963: if (iters > 1) { attila@963: str2 += " [iteration " + (iteration + 1) + "]"; attila@963: } attila@963: str2 += " processing file: " + file + "..."; attila@963: print_if_verbose(str2); attila@963: } attila@963: newGlobal.load("file://" + path + file); attila@963: } attila@963: } attila@963: print("Done."); attila@963: } attila@963: attila@963: if (testsCompiled.length == 0) { attila@963: print("Error: no tests given to compile"); attila@963: }