Commit c066623e authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[wasm] Fix the regression-680683 test.

The test was out-dated. The wasm bytes still had the version 0xd, and
no END instruction at the end of the function. In addition, the test
used asynchronous compilation but did not wait for the promise to
resolve.

R=clemensh@chromium.org

Change-Id: Ib01f47ac8f668401ed14470af7100e990e5bbd94
Reviewed-on: https://chromium-review.googlesource.com/463286Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44276}
parent fa314341
......@@ -120,6 +120,9 @@ var assertContains;
// Assert that a string matches a given regex.
var assertMatches;
// Assert the result of a promise.
var assertPromiseResult;
// These bits must be in sync with bits defined in Runtime_GetOptimizationStatus
var V8OptimizationStatus = {
kIsFunction: 1 << 0,
......@@ -490,6 +493,30 @@ var failWithMessage;
}
};
assertPromiseResult = function(promise, success, fail) {
// Use --allow-natives-syntax to use this function. Note that this function
// overwrites {failWithMessage} permanently with %AbortJS.
// We have to patch mjsunit because normal assertion failures just throw
// exceptions which are swallowed in a then clause.
// We use eval here to avoid parsing issues with the natives syntax.
failWithMessage = (msg) => eval("%AbortJS(msg)");
if (!fail)
fail = result => failWithMessage("assertPromiseResult failed: " + result);
eval("%IncrementWaitCount()");
promise.then(
result => {
eval("%DecrementWaitCount()");
success(result);
},
result => {
eval("%DecrementWaitCount()");
fail(result);
}
);
};
var OptimizationStatusImpl = undefined;
var OptimizationStatus = function(fun, sync_opt) {
......
......@@ -2,16 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-wasm
// Flags: --expose-wasm --allow-natives-syntax
const bytes = new Uint8Array([
0x00, 0x61, 0x73, 0x6d, 0x0d, 0x00, 0x00, 0x00,
0x01, 0x05, 0x01, 0x60, 0x00, 0x01, 0x7f, 0x03,
0x02, 0x01, 0x00, 0x05, 0x03, 0x01, 0x00, 0x01,
0x07, 0x11, 0x02, 0x04, 0x67, 0x72, 0x6f, 0x77,
0x00, 0x00, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72,
0x79, 0x02, 0x00, 0x0a, 0x07, 0x01, 0x05, 0x00,
0x41, 0x01, 0x40, 0x00]);
0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x05, 0x01,
0x60, 0x00, 0x01, 0x7f, 0x03, 0x02, 0x01, 0x00, 0x05, 0x03, 0x01,
0x00, 0x01, 0x07, 0x11, 0x02, 0x04, 0x67, 0x72, 0x6f, 0x77, 0x00,
0x00, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x02, 0x00, 0x0a,
0x08, 0x01, 0x06, 0x00, 0x41, 0x01, 0x40, 0x00, 0x0b
]);
WebAssembly.compile(bytes).then(
m => new WebAssembly.Instance(m).exports.grow());
assertPromiseResult(
WebAssembly.compile(bytes),
module => {
print('promise resolved: ' + module);
new WebAssembly.Instance(module).exports.grow();
});
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