Mon, 07 Dec 2015 13:15:47 -0800
Merge
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. |
attila@962 | 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. |
attila@962 | 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). |
attila@962 | 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. |
attila@962 | 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 | /** |
attila@963 | 25 | * Make sure that we run with the class cache off to so that every |
attila@963 | 26 | * run produces compile time and with optimistic type info caching |
attila@963 | 27 | * and persistent code store off, for the same reasons. These last two |
attila@963 | 28 | * are currently default, but this is not guaranteed to be the case |
attila@963 | 29 | * forever, so make this test future safe, we specify them explicitly |
attila@963 | 30 | * |
attila@963 | 31 | * This means that if you use this subtest as a compilation test |
attila@963 | 32 | * harness, pass the arguments: |
attila@963 | 33 | * |
attila@963 | 34 | * -scripting -Dnashorn.typeInfo.disabled=true --class-cache-size=0 |
attila@963 | 35 | * --persistent-code-cache=false |
attila@963 | 36 | * |
attila@963 | 37 | * @subtest |
attila@962 | 38 | */ |
jlaskey@3 | 39 | |
attila@963 | 40 | load(__DIR__ + 'octane-payload.js'); |
attila@963 | 41 | |
attila@963 | 42 | var DEFAULT_ITERS = 1; //default is one iteration through each benchmark |
attila@963 | 43 | var iters = DEFAULT_ITERS; |
attila@963 | 44 | var args = []; |
attila@963 | 45 | |
attila@963 | 46 | if (typeof $ARGS !== 'undefined') { |
attila@963 | 47 | args = $ARGS; |
attila@963 | 48 | } else if (typeof arguments !== 'undefined' && arguments.length != 0) { |
attila@963 | 49 | args = arguments; |
attila@963 | 50 | } |
attila@963 | 51 | |
attila@963 | 52 | var onlyTheseTests = []; |
attila@963 | 53 | var verbose = false; |
attila@963 | 54 | |
attila@963 | 55 | for (var i = 0; i < args.length; ) { |
attila@963 | 56 | var arg = args[i]; |
attila@963 | 57 | if (arg === '--iterations') { |
attila@963 | 58 | iters = +args[++i]; |
attila@963 | 59 | } else if (arg === '--verbose') { |
attila@963 | 60 | verbose = true; |
attila@963 | 61 | } else { |
attila@963 | 62 | onlyTheseTests.push(arg); |
attila@963 | 63 | } |
attila@963 | 64 | i++; |
attila@963 | 65 | } |
attila@963 | 66 | |
attila@963 | 67 | if (isNaN(iters)) { |
attila@963 | 68 | iters = DEFAULT_ITERS; |
attila@963 | 69 | } |
attila@963 | 70 | |
attila@963 | 71 | if (iters != DEFAULT_ITERS) { |
attila@963 | 72 | print("Running " + iters + " iterations of each compilation."); |
attila@963 | 73 | } |
attila@963 | 74 | |
attila@963 | 75 | function print_if_verbose(x) { |
attila@963 | 76 | if (verbose) { |
attila@963 | 77 | print(x); |
attila@963 | 78 | } |
attila@963 | 79 | } |
attila@963 | 80 | |
attila@963 | 81 | function contains(a, obj) { |
attila@963 | 82 | for (var i = 0; i < a.length; i++) { |
attila@963 | 83 | if (a[i] === obj) { |
attila@963 | 84 | return true; |
attila@963 | 85 | } |
attila@963 | 86 | } |
attila@963 | 87 | return false; |
attila@963 | 88 | } |
attila@963 | 89 | |
attila@963 | 90 | var testsCompiled = []; |
attila@963 | 91 | |
attila@963 | 92 | for (var j in tests) { |
attila@963 | 93 | var test_name = tests[j].name; |
attila@963 | 94 | var files = tests[j].files; |
attila@963 | 95 | |
attila@963 | 96 | if (onlyTheseTests.length > 0 && !contains(onlyTheseTests, test_name)) { |
attila@963 | 97 | print_if_verbose("Skipping " + test_name); |
attila@963 | 98 | continue; |
attila@963 | 99 | } |
attila@963 | 100 | |
attila@963 | 101 | if (!contains(testsCompiled, test_name)) { |
attila@963 | 102 | testsCompiled.push(test_name); |
attila@963 | 103 | } |
attila@963 | 104 | |
attila@963 | 105 | var str = "Compiling '" + test_name + "'..."; |
attila@963 | 106 | if (files.length > 1) { |
attila@963 | 107 | str += " (" + files.length + " files)"; |
attila@963 | 108 | } |
attila@963 | 109 | if (iters != 1) { |
attila@963 | 110 | str += " (" + iters + " times)"; |
attila@963 | 111 | } |
attila@963 | 112 | str + "..."; |
attila@963 | 113 | print(str); |
attila@963 | 114 | |
attila@963 | 115 | for (var iteration = 0; iteration < iters; iteration++) { |
attila@963 | 116 | |
attila@963 | 117 | //get a new global to avoid symbol pollution and reloads of base |
attila@963 | 118 | //in the same namespace |
attila@963 | 119 | var newGlobal = loadWithNewGlobal({script:'this', name:'test'}); |
attila@963 | 120 | |
attila@963 | 121 | //load base into the new global so we get BenchmarkSuite etc |
attila@963 | 122 | newGlobal.load(base); |
attila@963 | 123 | |
attila@963 | 124 | //load all files in the single benchmark |
attila@963 | 125 | for (var k in files) { |
attila@963 | 126 | var file = files[k]; |
attila@963 | 127 | if (iteration >= 0) { //only display message on first iteration |
attila@963 | 128 | var str2 = "\t"; |
attila@963 | 129 | if (iters > 1) { |
attila@963 | 130 | str2 += " [iteration " + (iteration + 1) + "]"; |
attila@963 | 131 | } |
attila@963 | 132 | str2 += " processing file: " + file + "..."; |
attila@963 | 133 | print_if_verbose(str2); |
attila@963 | 134 | } |
slugovoy@1106 | 135 | newGlobal.load(new java.io.File(path + file).toURL()); |
attila@963 | 136 | } |
attila@963 | 137 | } |
attila@963 | 138 | print("Done."); |
attila@963 | 139 | } |
attila@963 | 140 | |
attila@963 | 141 | if (testsCompiled.length == 0) { |
attila@963 | 142 | print("Error: no tests given to compile"); |
attila@963 | 143 | } |