c44228b78c
- Implement js-api changes for WebAssembly.Memory to accept a shared parameter - Update allocation to use SharedArrayBuffers BUG=v8:6532 R=binji@chromium.org, bradnelson@chromium.org Change-Id: I021491217568751b06fbd7b4b08b1dd88910e21d Reviewed-on: https://chromium-review.googlesource.com/564058 Commit-Queue: Deepti Gandluri <gdeepti@chromium.org> Reviewed-by: Brad Nelson <bradnelson@chromium.org> Reviewed-by: Ben Smith <binji@chromium.org> Cr-Commit-Position: refs/heads/master@{#46543}
53 lines
1.8 KiB
JavaScript
53 lines
1.8 KiB
JavaScript
// Copyright 2017 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// Flags: --experimental-wasm-threads
|
|
|
|
function assertMemoryIsValid(memory) {
|
|
assertSame(WebAssembly.Memory.prototype, memory.__proto__);
|
|
assertSame(WebAssembly.Memory, memory.constructor);
|
|
assertTrue(memory instanceof Object);
|
|
assertTrue(memory instanceof WebAssembly.Memory);
|
|
}
|
|
|
|
(function TestConstructorWithShared() {
|
|
print("TestConstructorWithShared");
|
|
let memory = new WebAssembly.Memory({
|
|
initial: 0, maximum: 10, shared: true});
|
|
assertMemoryIsValid(memory);
|
|
// Assert that the buffer is frozen when memory is shared.
|
|
assertTrue(Object.isFrozen(memory.buffer));
|
|
})();
|
|
|
|
(function TestConstructorWithUndefinedShared() {
|
|
print("TestConstructorWithUndefinedShared");
|
|
// Maximum = undefined, shared = undefined.
|
|
let memory = new WebAssembly.Memory({
|
|
initial: 0, maximum: undefined, shared: undefined});
|
|
assertMemoryIsValid(memory);
|
|
})();
|
|
|
|
(function TestConstructorWithNumericShared() {
|
|
print("TestConstructorWithNumericShared");
|
|
// For numeric values, shared = true.
|
|
let memory = new WebAssembly.Memory({
|
|
initial: 0, maximum: 10, shared: 2098665});
|
|
assertMemoryIsValid(memory);
|
|
})();
|
|
|
|
(function TestConstructorWithEmptyStringShared() {
|
|
print("TestConstructorWithEmptyStringShared");
|
|
// Maximum = undefined, shared = false.
|
|
let memory = new WebAssembly.Memory({
|
|
initial: 0, maximum: undefined, shared: ""});
|
|
assertMemoryIsValid(memory);
|
|
})();
|
|
|
|
(function TestConstructorWithUndefinedMaxShared() {
|
|
print("TestConstructorWithUndefinedMaxShared");
|
|
// New memory with Maximum = undefined, shared = true => TypeError.
|
|
assertThrows(() => new WebAssembly.Memory({initial: 0, shared: true}),
|
|
TypeError);
|
|
})();
|