Diff
Modified: trunk/PerformanceTests/ChangeLog (204881 => 204882)
--- trunk/PerformanceTests/ChangeLog 2016-08-24 02:36:40 UTC (rev 204881)
+++ trunk/PerformanceTests/ChangeLog 2016-08-24 03:39:33 UTC (rev 204882)
@@ -1,3 +1,47 @@
+2016-08-23 Saam Barati <[email protected]>
+
+ It should be easy to run ES6SampleBench from the jsc shell
+ https://bugs.webkit.org/show_bug.cgi?id=161085
+
+ Reviewed by Yusuke Suzuki.
+
+ This patch makes ES6 sample bench runnable through the `jsc` shell.
+ To do that, you need to be in the PerformanceTests/ES6SampleBench
+ directory and run `jsc cli.js`. To make this work, the benchmark
+ is now aware of being run in two modes: via the browser, and via
+ the shell. Each entry point will set a variable `isInBrowser`,
+ and the benchmark will do different things based on if that
+ variable is true or false.
+
+ * ES6SampleBench/Air/benchmark.js:
+ * ES6SampleBench/Air/stress-test.js:
+ * ES6SampleBench/Basic/benchmark.js:
+ (runBenchmark):
+ * ES6SampleBench/Basic/stress-test.js:
+ * ES6SampleBench/air_benchmark.js:
+ * ES6SampleBench/basic_benchmark.js:
+ * ES6SampleBench/cli.js: Added.
+ (return.doRun):
+ (makeBenchmarkRunner):
+ * ES6SampleBench/driver.js:
+ (Driver):
+ (Driver.prototype._recomputeSummary):
+ (Driver.prototype._iterate.window.setTimeout):
+ (Driver.prototype._iterate):
+ (Driver.prototype._updateIterations):
+ * ES6SampleBench/glue.js:
+ (reportResult):
+ * ES6SampleBench/index.html:
+ * ES6SampleBench/results.js:
+ (Results):
+ (Results.prototype.reportRunning):
+ (Results.prototype.reportDone):
+ (Results.prototype.reportError):
+ * ES6SampleBench/stats.js:
+ (Stats):
+ (Stats.prototype.toString):
+ (Stats.prototype._update):
+
2016-08-01 Said Abou-Hallawa <[email protected]>
Add an option to run the MotionMark tests with classic tile size (512x512)
Modified: trunk/PerformanceTests/ES6SampleBench/Air/benchmark.js (204881 => 204882)
--- trunk/PerformanceTests/ES6SampleBench/Air/benchmark.js 2016-08-24 02:36:40 UTC (rev 204881)
+++ trunk/PerformanceTests/ES6SampleBench/Air/benchmark.js 2016-08-24 03:39:33 UTC (rev 204882)
@@ -24,7 +24,7 @@
*/
"use strict";
-class Benchmark {
+class AirBenchmark {
constructor(verbose = 0)
{
this._verbose = verbose;
Modified: trunk/PerformanceTests/ES6SampleBench/Air/stress-test.js (204881 => 204882)
--- trunk/PerformanceTests/ES6SampleBench/Air/stress-test.js 2016-08-24 02:36:40 UTC (rev 204881)
+++ trunk/PerformanceTests/ES6SampleBench/Air/stress-test.js 2016-08-24 03:39:33 UTC (rev 204882)
@@ -31,7 +31,7 @@
load("payload-typescript-scanIdentifier.js");
load("benchmark.js");
-let benchmark = new Benchmark();
+let benchmark = new AirBenchmark();
let before = preciseTime();
// Run for at least 10 iterations.
Modified: trunk/PerformanceTests/ES6SampleBench/Basic/benchmark.js (204881 => 204882)
--- trunk/PerformanceTests/ES6SampleBench/Basic/benchmark.js 2016-08-24 02:36:40 UTC (rev 204881)
+++ trunk/PerformanceTests/ES6SampleBench/Basic/benchmark.js 2016-08-24 03:39:33 UTC (rev 204882)
@@ -24,7 +24,7 @@
*/
"use strict";
-class Benchmark {
+class BasicBenchmark {
constructor(verbose = 0)
{
this._verbose = verbose;
@@ -63,4 +63,3 @@
let after = currentTime();
return after - before;
}
-
Modified: trunk/PerformanceTests/ES6SampleBench/Basic/stress-test.js (204881 => 204882)
--- trunk/PerformanceTests/ES6SampleBench/Basic/stress-test.js 2016-08-24 02:36:40 UTC (rev 204881)
+++ trunk/PerformanceTests/ES6SampleBench/Basic/stress-test.js 2016-08-24 03:39:33 UTC (rev 204882)
@@ -35,7 +35,7 @@
load("util.js");
load("benchmark.js");
-let benchmark = new Benchmark();
+let benchmark = new BasicBenchmark();
let before = preciseTime();
// Run for at least 10 iterations.
Modified: trunk/PerformanceTests/ES6SampleBench/air_benchmark.js (204881 => 204882)
--- trunk/PerformanceTests/ES6SampleBench/air_benchmark.js 2016-08-24 02:36:40 UTC (rev 204881)
+++ trunk/PerformanceTests/ES6SampleBench/air_benchmark.js 2016-08-24 03:39:33 UTC (rev 204882)
@@ -48,7 +48,7 @@
<script src=""
<script>
var results = [];
-var benchmark = new Benchmark();
+var benchmark = new AirBenchmark();
var numIterations = 200;
for (var i = 0; i < numIterations; ++i) {
var before = currentTime();
@@ -59,13 +59,47 @@
reportResult(results);
</script>`;
-const AirBenchmark = {
+let runAirBenchmark = null;
+if (!isInBrowser) {
+ let sources = [
+ "Air/symbols.js"
+ , "Air/tmp_base.js"
+ , "Air/arg.js"
+ , "Air/basic_block.js"
+ , "Air/code.js"
+ , "Air/frequented_block.js"
+ , "Air/inst.js"
+ , "Air/opcode.js"
+ , "Air/reg.js"
+ , "Air/stack_slot.js"
+ , "Air/tmp.js"
+ , "Air/util.js"
+ , "Air/custom.js"
+ , "Air/liveness.js"
+ , "Air/insertion_set.js"
+ , "Air/allocate_stack.js"
+ , "Air/payload-gbemu-executeIteration.js"
+ , "Air/payload-imaging-gaussian-blur-gaussianBlur.js"
+ , "Air/payload-airjs-ACLj8C.js"
+ , "Air/payload-typescript-scanIdentifier.js"
+ , "Air/benchmark.js"
+ ];
+
+ runAirBenchmark = makeBenchmarkRunner(sources, "AirBenchmark");
+}
+
+const AirBenchmarkRunner = {
code: AirBenchmarkCode,
- cells: {
+ run: runAirBenchmark,
+ cells: { },
+ name: "Air"
+};
+
+if (isInBrowser) {
+ AirBenchmarkRunner.cells = {
firstIteration: document.getElementById("AirFirstIteration"),
averageWorstCase: document.getElementById("AirAverageWorstCase"),
steadyState: document.getElementById("AirSteadyState"),
message: document.getElementById("AirMessage")
}
-};
-
+}
Modified: trunk/PerformanceTests/ES6SampleBench/basic_benchmark.js (204881 => 204882)
--- trunk/PerformanceTests/ES6SampleBench/basic_benchmark.js 2016-08-24 02:36:40 UTC (rev 204881)
+++ trunk/PerformanceTests/ES6SampleBench/basic_benchmark.js 2016-08-24 03:39:33 UTC (rev 204882)
@@ -37,7 +37,7 @@
<script src=""
<script>
var results = [];
-var benchmark = new Benchmark();
+var benchmark = new BasicBenchmark();
var numIterations = 200;
for (var i = 0; i < numIterations; ++i) {
var before = currentTime();
@@ -48,12 +48,37 @@
reportResult(results);
</script>`;
-const BasicBenchmark = {
+
+let runBasicBenchmark = null;
+if (!isInBrowser) {
+ let sources = [
+ "Basic/ast.js"
+ , "Basic/basic.js"
+ , "Basic/caseless_map.js"
+ , "Basic/lexer.js"
+ , "Basic/number.js"
+ , "Basic/parser.js"
+ , "Basic/random.js"
+ , "Basic/state.js"
+ , "Basic/util.js"
+ , "Basic/benchmark.js"
+ ];
+
+ runBasicBenchmark = makeBenchmarkRunner(sources, "BasicBenchmark");
+}
+
+const BasicBenchmarkRunner = {
+ name: "Basic",
code: BasicBenchmarkCode,
- cells: {
+ run: runBasicBenchmark,
+ cells: {}
+};
+
+if (isInBrowser) {
+ BasicBenchmarkRunner.cells = {
firstIteration: document.getElementById("BasicFirstIteration"),
averageWorstCase: document.getElementById("BasicAverageWorstCase"),
steadyState: document.getElementById("BasicSteadyState"),
message: document.getElementById("BasicMessage")
- }
-};
+ };
+}
Added: trunk/PerformanceTests/ES6SampleBench/cli.js (0 => 204882)
--- trunk/PerformanceTests/ES6SampleBench/cli.js (rev 0)
+++ trunk/PerformanceTests/ES6SampleBench/cli.js 2016-08-24 03:39:33 UTC (rev 204882)
@@ -0,0 +1,33 @@
+const isInBrowser = false;
+
+function makeBenchmarkRunner(sources, benchmarkConstructor) {
+ let source = "'use strict';"
+ for (let file of sources) {
+ source += readFile(file);
+ }
+ source += `
+ this.results = [];
+ var benchmark = new ${benchmarkConstructor}();
+ var numIterations = 200;
+ for (var i = 0; i < numIterations; ++i) {
+ var before = currentTime();
+ benchmark.runIteration();
+ var after = currentTime();
+ results.push(after - before);
+ }
+ `;
+ return function doRun() {
+ let globalObjectOfScript = runString(source);
+ let results = globalObjectOfScript.results;
+ reportResult(results);
+ }
+}
+
+load("driver.js");
+load("results.js");
+load("stats.js");
+load("air_benchmark.js");
+load("basic_benchmark.js");
+load("glue.js");
+
+driver.start(10);
Modified: trunk/PerformanceTests/ES6SampleBench/driver.js (204881 => 204882)
--- trunk/PerformanceTests/ES6SampleBench/driver.js 2016-08-24 02:36:40 UTC (rev 204881)
+++ trunk/PerformanceTests/ES6SampleBench/driver.js 2016-08-24 03:39:33 UTC (rev 204882)
@@ -31,10 +31,11 @@
this._triggerCell = triggerCell;
this._triggerLink = triggerLink;
this._magicCell = magicCell;
- this._summary = new Stats(summaryCell);
+ this._summary = new Stats(summaryCell, "summary");
this._key = key;
this._hadErrors = false;
- window[key] = this;
+ if (isInBrowser)
+ window[key] = this;
}
addBenchmark(benchmark)
@@ -96,7 +97,7 @@
for (let subResult of Results.subResults)
statses.push(results[subResult]);
}
-
+
let numIterations = Math.min(...statses.map(stats => stats.numIterations));
let data = "" Array(numIterations);
for (let i = 0; i < data.length; ++i)
@@ -117,9 +118,12 @@
this._benchmark = this._iterator ? this._iterator.next().value : null;
if (!this._benchmark) {
if (!this._numIterations) {
- this._triggerCell.innerHTML =
- (this._hadErrors ? "Failures encountered!" : "Success!") +
- ` <a href="" Benchmark</a>`;
+ if (isInBrowser) {
+ this._triggerCell.innerHTML =
+ (this._hadErrors ? "Failures encountered!" : "Success!") +
+ ` <a href="" Benchmark</a>`;
+ } else
+ print(this._hadErrors ? "Failures encountered!" : "Success! Benchmark is now finished.");
return;
}
this._numIterations--;
@@ -130,31 +134,48 @@
this._benchmarks.get(this._benchmark).reportRunning();
- window.setTimeout(() => {
- if (!this._isRunning)
- return;
-
- this._magicCell.contentDocument.body.textContent = "";
- this._magicCell.contentDocument.body.innerHTML = "<iframe id=\"magicFrame\" frameborder=\"0\">";
-
- let magicFrame = this._magicCell.contentDocument.getElementById("magicFrame");
- magicFrame.contentDocument.open();
- magicFrame.contentDocument.write(
- `<!DOCTYPE html><head><title>benchmark payload</title></head><body><script>` +
- `window._onerror_ = top.${this._key}.reportError;\n` +
- `function reportResult()\n` +
- `{\n` +
- ` var driver = top.${this._key};\n` +
- ` driver.reportResult.apply(driver, arguments);\n` +
- `}\n` +
- `</script>\n` +
- `${this._benchmark.code}</body></html>`);
- }, 100);
+ let benchmark = this._benchmark;
+ if (isInBrowser) {
+ window.setTimeout(() => {
+ if (!this._isRunning)
+ return;
+
+ this._magicCell.contentDocument.body.textContent = "";
+ this._magicCell.contentDocument.body.innerHTML = "<iframe id=\"magicFrame\" frameborder=\"0\">";
+
+ let magicFrame = this._magicCell.contentDocument.getElementById("magicFrame");
+ magicFrame.contentDocument.open();
+ magicFrame.contentDocument.write(
+ `<!DOCTYPE html><head><title>benchmark payload</title></head><body><script>` +
+ `window._onerror_ = top.${this._key}.reportError;\n` +
+ `function reportResult()\n` +
+ `{\n` +
+ ` var driver = top.${this._key};\n` +
+ ` driver.reportResult.apply(driver, arguments);\n` +
+ `}\n` +
+ `</script>\n` +
+ `${this._benchmark.code}</body></html>`);
+ }, 100);
+ } else {
+ Promise.resolve(20).then(() => {
+ if (!this._isRunning)
+ return;
+
+ try {
+ print(`Running... ${this._benchmark.name} ( ${this._numIterations + 1} to go)`);
+ benchmark.run();
+ print("\n");
+ } catch(e) {
+ print(e);
+ print(e.stack);
+ }
+ });
+ }
}
_updateIterations()
{
- this._triggerCell.innerHTML = "Running... (" + (this._numIterations + 1) + " to go)";
+ if (isInBrowser)
+ this._triggerCell.innerHTML = "Running... (" + (this._numIterations + 1) + " to go)";
}
}
-
Modified: trunk/PerformanceTests/ES6SampleBench/glue.js (204881 => 204882)
--- trunk/PerformanceTests/ES6SampleBench/glue.js 2016-08-24 02:36:40 UTC (rev 204881)
+++ trunk/PerformanceTests/ES6SampleBench/glue.js 2016-08-24 03:39:33 UTC (rev 204882)
@@ -25,11 +25,15 @@
"use strict";
const driver = new Driver(
- document.getElementById("trigger"),
+ isInBrowser ? document.getElementById("trigger") : null,
"driver.start(10)",
- document.getElementById("magic"),
- document.getElementById("Geomean"),
+ isInBrowser ? document.getElementById("magic") : null,
+ isInBrowser ? document.getElementById("Geomean") : null,
"sampleBench");
-driver.addBenchmark(AirBenchmark);
-driver.addBenchmark(BasicBenchmark);
+function reportResult(...args) {
+ driver.reportResult(...args);
+}
+
+driver.addBenchmark(AirBenchmarkRunner);
+driver.addBenchmark(BasicBenchmarkRunner);
Modified: trunk/PerformanceTests/ES6SampleBench/index.html (204881 => 204882)
--- trunk/PerformanceTests/ES6SampleBench/index.html 2016-08-24 02:36:40 UTC (rev 204881)
+++ trunk/PerformanceTests/ES6SampleBench/index.html 2016-08-24 03:39:33 UTC (rev 204882)
@@ -8,6 +8,8 @@
{
document.getElementById("trigger").innerHTML = "ERROR: " + url + ":" + lineNumber + ": " + message;
}
+
+const isInBrowser = true;
</script>
<script src=""
<script src=""
Modified: trunk/PerformanceTests/ES6SampleBench/results.js (204881 => 204882)
--- trunk/PerformanceTests/ES6SampleBench/results.js 2016-08-24 02:36:40 UTC (rev 204881)
+++ trunk/PerformanceTests/ES6SampleBench/results.js 2016-08-24 03:39:33 UTC (rev 204882)
@@ -29,7 +29,7 @@
{
this._benchmark = benchmark;
for (let subResult of Results.subResults)
- this[subResult] = new Stats(benchmark.cells[subResult]);
+ this[subResult] = new Stats(benchmark.cells[subResult], subResult);
}
get benchmark() { return this._benchmark; }
@@ -42,12 +42,14 @@
reportRunning()
{
- this._benchmark.cells.message.innerHTML = "Running...";
+ if (isInBrowser)
+ this._benchmark.cells.message.innerHTML = "Running...";
}
reportDone()
{
- this._benchmark.cells.message.innerHTML = "";
+ if (isInBrowser)
+ this._benchmark.cells.message.innerHTML = "";
}
reportResult(times)
@@ -99,7 +101,8 @@
{
for (let subResult of Results.subResults)
this[subResult].reportResult(Stats.error);
- this._benchmark.cells.message.innerHTML = url + ":" + lineNumber + ": " + message;
+ if (isInBrowser)
+ this._benchmark.cells.message.innerHTML = url + ":" + lineNumber + ": " + message;
}
}
Modified: trunk/PerformanceTests/ES6SampleBench/stats.js (204881 => 204882)
--- trunk/PerformanceTests/ES6SampleBench/stats.js 2016-08-24 02:36:40 UTC (rev 204881)
+++ trunk/PerformanceTests/ES6SampleBench/stats.js 2016-08-24 03:39:33 UTC (rev 204882)
@@ -25,10 +25,16 @@
"use strict";
class Stats {
- constructor(cell)
+ constructor(cell, prefix)
{
this._cell = cell;
this._data = [];
+ this._prefix = "";
+ if (!isInBrowser && prefix) {
+ this._prefix = prefix + ": ";
+ if (this._prefix.length < 20)
+ this._prefix += " ".repeat(20 - this._prefix.length);
+ }
}
reset(...data)
@@ -91,15 +97,18 @@
return "ERROR";
if ("interval" in result)
- return `${result.mean.toFixed(2)} ms ± ${result.interval.toFixed(2)} ms`;
+ return `${this._prefix}${result.mean.toFixed(2)} ms +- ${result.interval.toFixed(2)} ms`;
- return `${result.mean.toFixed(2)} ms`;
+ return `${this._prefix}${result.mean.toFixed(2)} ms`;
}
_update()
{
- if (this._cell)
- this._cell.innerHTML = this.toString();
+ if (isInBrowser) {
+ if (this._cell)
+ this._cell.innerHTML = this.toString();
+ } else
+ print(this.toString());
}
}
Modified: trunk/Source/_javascript_Core/ChangeLog (204881 => 204882)
--- trunk/Source/_javascript_Core/ChangeLog 2016-08-24 02:36:40 UTC (rev 204881)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-08-24 03:39:33 UTC (rev 204882)
@@ -1,3 +1,20 @@
+2016-08-23 Saam Barati <[email protected]>
+
+ It should be easy to run ES6SampleBench from the jsc shell
+ https://bugs.webkit.org/show_bug.cgi?id=161085
+
+ Reviewed by Yusuke Suzuki.
+
+ This patch adds a new function called `runString` to the shell.
+ It takes in a string, and executes it in a new global object.
+ Then, it returns the global object it executed the code in.
+ This allows the code to stash some kind of a result on the global,
+ and then have the caller of `runString` extract the result.
+
+ * jsc.cpp:
+ (GlobalObject::finishCreation):
+ (functionRunString):
+
2016-08-23 Benjamin Poulain <[email protected]>
[JSC] Make ArithLog works with any type
Modified: trunk/Source/_javascript_Core/jsc.cpp (204881 => 204882)
--- trunk/Source/_javascript_Core/jsc.cpp 2016-08-24 02:36:40 UTC (rev 204881)
+++ trunk/Source/_javascript_Core/jsc.cpp 2016-08-24 03:39:33 UTC (rev 204882)
@@ -589,6 +589,7 @@
#endif
static EncodedJSValue JSC_HOST_CALL functionVersion(ExecState*);
static EncodedJSValue JSC_HOST_CALL functionRun(ExecState*);
+static EncodedJSValue JSC_HOST_CALL functionRunString(ExecState*);
static EncodedJSValue JSC_HOST_CALL functionLoad(ExecState*);
static EncodedJSValue JSC_HOST_CALL functionLoadString(ExecState*);
static EncodedJSValue JSC_HOST_CALL functionReadFile(ExecState*);
@@ -785,6 +786,7 @@
#endif
addFunction(vm, "version", functionVersion, 1);
addFunction(vm, "run", functionRun, 1);
+ addFunction(vm, "runString", functionRunString, 1);
addFunction(vm, "load", functionLoad, 1);
addFunction(vm, "loadString", functionLoadString, 1);
addFunction(vm, "readFile", functionReadFile, 1);
@@ -1443,6 +1445,31 @@
return JSValue::encode(jsNumber(stopWatch.getElapsedMS()));
}
+EncodedJSValue JSC_HOST_CALL functionRunString(ExecState* exec)
+{
+ String source = exec->argument(0).toWTFString(exec);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
+
+ GlobalObject* globalObject = GlobalObject::create(exec->vm(), GlobalObject::createStructure(exec->vm(), jsNull()), Vector<String>());
+
+ JSArray* array = constructEmptyArray(globalObject->globalExec(), 0);
+ for (unsigned i = 1; i < exec->argumentCount(); ++i)
+ array->putDirectIndex(globalObject->globalExec(), i - 1, exec->uncheckedArgument(i));
+ globalObject->putDirect(
+ exec->vm(), Identifier::fromString(globalObject->globalExec(), "arguments"), array);
+
+ NakedPtr<Exception> exception;
+ evaluate(globalObject->globalExec(), makeSource(source), JSValue(), exception);
+
+ if (exception) {
+ exec->vm().throwException(globalObject->globalExec(), exception);
+ return JSValue::encode(jsUndefined());
+ }
+
+ return JSValue::encode(globalObject);
+}
+
EncodedJSValue JSC_HOST_CALL functionLoad(ExecState* exec)
{
String fileName = exec->argument(0).toWTFString(exec);