Commit a4eb80f7 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Fix runtime call syntax

This is to avoid ClusterFuzz picking up and using those calls.
With the proper syntax (no whitespace), they are recognized as runtime
calls and will be checked against a whitelist.

R=mstarzinger@chromium.org
BUG=chromium:724459

Change-Id: I5533f066feeb66f622230b12f79f9d227e2b2465
Reviewed-on: https://chromium-review.googlesource.com/509575Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45475}
parent c4b187ba
...@@ -39,7 +39,7 @@ load('test/mjsunit/wasm/wasm-module-builder.js'); ...@@ -39,7 +39,7 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
// Initially, we can load from offset 12, but not OOB. // Initially, we can load from offset 12, but not OOB.
var oob_index = kNumPages * kPageSize; var oob_index = kNumPages * kPageSize;
var initial_interpreted = % WasmNumInterpretedCalls(instance); var initial_interpreted = %WasmNumInterpretedCalls(instance);
assertEquals(0, exp.load(12)); assertEquals(0, exp.load(12));
assertEquals(0, exp.load_interpreted(12)); assertEquals(0, exp.load_interpreted(12));
assertTraps(kTrapMemOutOfBounds, () => exp.load(oob_index)); assertTraps(kTrapMemOutOfBounds, () => exp.load(oob_index));
...@@ -74,5 +74,5 @@ load('test/mjsunit/wasm/wasm-module-builder.js'); ...@@ -74,5 +74,5 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
assertEquals(-1, exp.grow_memory(kMaxPages - kNumPages + 1)); assertEquals(-1, exp.grow_memory(kMaxPages - kNumPages + 1));
assertEquals(-1, exp.grow_memory_interpreted(kMaxPages - kNumPages + 1)); assertEquals(-1, exp.grow_memory_interpreted(kMaxPages - kNumPages + 1));
// Overall, we executed 9 functions in the interpreter. // Overall, we executed 9 functions in the interpreter.
assertEquals(initial_interpreted + 9, % WasmNumInterpretedCalls(instance)); assertEquals(initial_interpreted + 9, %WasmNumInterpretedCalls(instance));
})(); })();
...@@ -33,9 +33,9 @@ function checkStack(stack, expected_lines) { ...@@ -33,9 +33,9 @@ function checkStack(stack, expected_lines) {
var instance = builder.instantiate({mod: {func: func}}); var instance = builder.instantiate({mod: {func: func}});
// Test that this does not mess up internal state by executing it three times. // Test that this does not mess up internal state by executing it three times.
for (var i = 0; i < 3; ++i) { for (var i = 0; i < 3; ++i) {
var interpreted_before = % WasmNumInterpretedCalls(instance); var interpreted_before = %WasmNumInterpretedCalls(instance);
instance.exports.main(); instance.exports.main();
assertEquals(interpreted_before + 1, % WasmNumInterpretedCalls(instance)); assertEquals(interpreted_before + 1, %WasmNumInterpretedCalls(instance));
checkStack(stripPath(stack), [ checkStack(stripPath(stack), [
'Error: test imported stack', // - 'Error: test imported stack', // -
/^ at func \(interpreter.js:\d+:28\)$/, // - /^ at func \(interpreter.js:\d+:28\)$/, // -
...@@ -69,10 +69,10 @@ function checkStack(stack, expected_lines) { ...@@ -69,10 +69,10 @@ function checkStack(stack, expected_lines) {
]) ])
.exportFunc(); .exportFunc();
var instance = builder.instantiate({mod: {func1: func1, func2: func2}}); var instance = builder.instantiate({mod: {func1: func1, func2: func2}});
var interpreted_before = % WasmNumInterpretedCalls(instance); var interpreted_before = %WasmNumInterpretedCalls(instance);
var args = [11, 0.3]; var args = [11, 0.3];
var ret = instance.exports.main(...args); var ret = instance.exports.main(...args);
assertEquals(interpreted_before + 1, % WasmNumInterpretedCalls(instance)); assertEquals(interpreted_before + 1, %WasmNumInterpretedCalls(instance));
var passed_test_args = [...passed_args]; var passed_test_args = [...passed_args];
var expected = func1(args[0], args[0] + 1) + func2(args[1]) | 0; var expected = func1(args[0], args[0] + 1) + func2(args[1]) | 0;
assertEquals(expected, ret); assertEquals(expected, ret);
...@@ -90,7 +90,7 @@ function checkStack(stack, expected_lines) { ...@@ -90,7 +90,7 @@ function checkStack(stack, expected_lines) {
var instance = builder.instantiate(); var instance = builder.instantiate();
// Test that this does not mess up internal state by executing it three times. // Test that this does not mess up internal state by executing it three times.
for (var i = 0; i < 3; ++i) { for (var i = 0; i < 3; ++i) {
var interpreted_before = % WasmNumInterpretedCalls(instance); var interpreted_before = %WasmNumInterpretedCalls(instance);
var stack; var stack;
try { try {
instance.exports.main(); instance.exports.main();
...@@ -98,7 +98,7 @@ function checkStack(stack, expected_lines) { ...@@ -98,7 +98,7 @@ function checkStack(stack, expected_lines) {
} catch (e) { } catch (e) {
stack = e.stack; stack = e.stack;
} }
assertEquals(interpreted_before + 2, % WasmNumInterpretedCalls(instance)); assertEquals(interpreted_before + 2, %WasmNumInterpretedCalls(instance));
checkStack(stripPath(stack), [ checkStack(stripPath(stack), [
'RuntimeError: unreachable', // - 'RuntimeError: unreachable', // -
' at foo (<WASM>[0]+3)', // - ' at foo (<WASM>[0]+3)', // -
...@@ -121,7 +121,7 @@ function checkStack(stack, expected_lines) { ...@@ -121,7 +121,7 @@ function checkStack(stack, expected_lines) {
var instance = builder.instantiate({mod: {func: func}}); var instance = builder.instantiate({mod: {func: func}});
// Test that this does not mess up internal state by executing it three times. // Test that this does not mess up internal state by executing it three times.
for (var i = 0; i < 3; ++i) { for (var i = 0; i < 3; ++i) {
var interpreted_before = % WasmNumInterpretedCalls(instance); var interpreted_before = %WasmNumInterpretedCalls(instance);
var stack; var stack;
try { try {
instance.exports.main(); instance.exports.main();
...@@ -129,7 +129,7 @@ function checkStack(stack, expected_lines) { ...@@ -129,7 +129,7 @@ function checkStack(stack, expected_lines) {
} catch (e) { } catch (e) {
stack = e.stack; stack = e.stack;
} }
assertEquals(interpreted_before + 1, % WasmNumInterpretedCalls(instance)); assertEquals(interpreted_before + 1, %WasmNumInterpretedCalls(instance));
checkStack(stripPath(stack), [ checkStack(stripPath(stack), [
'Error: thrown from imported function', // - 'Error: thrown from imported function', // -
/^ at func \(interpreter.js:\d+:11\)$/, // - /^ at func \(interpreter.js:\d+:11\)$/, // -
...@@ -205,10 +205,10 @@ function checkStack(stack, expected_lines) { ...@@ -205,10 +205,10 @@ function checkStack(stack, expected_lines) {
instance = builder.instantiate({mod: {func: func}}); instance = builder.instantiate({mod: {func: func}});
// Test that this does not mess up internal state by executing it three times. // Test that this does not mess up internal state by executing it three times.
for (var i = 0; i < 3; ++i) { for (var i = 0; i < 3; ++i) {
var interpreted_before = % WasmNumInterpretedCalls(instance); var interpreted_before = %WasmNumInterpretedCalls(instance);
stacks = []; stacks = [];
instance.exports.main(0); instance.exports.main(0);
assertEquals(interpreted_before + 3, % WasmNumInterpretedCalls(instance)); assertEquals(interpreted_before + 3, %WasmNumInterpretedCalls(instance));
assertEquals(3, stacks.length); assertEquals(3, stacks.length);
for (var e = 0; e < stacks.length; ++e) { for (var e = 0; e < stacks.length; ++e) {
expected = ['Error: reentrant interpreter test #' + e]; expected = ['Error: reentrant interpreter test #' + e];
...@@ -361,9 +361,9 @@ function checkStack(stack, expected_lines) { ...@@ -361,9 +361,9 @@ function checkStack(stack, expected_lines) {
.exportFunc(); .exportFunc();
var instance = builder.instantiate({mod: {func1: func1, func2: func2}}); var instance = builder.instantiate({mod: {func1: func1, func2: func2}});
var interpreted_before = % WasmNumInterpretedCalls(instance); var interpreted_before = %WasmNumInterpretedCalls(instance);
assertEquals(2 * (11 + 2), instance.exports.main()); assertEquals(2 * (11 + 2), instance.exports.main());
assertEquals(interpreted_before + 2, % WasmNumInterpretedCalls(instance)); assertEquals(interpreted_before + 2, %WasmNumInterpretedCalls(instance));
})(); })();
(function testInterpreterGC() { (function testInterpreterGC() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment