2dd28df97a
This moves all tests that construct a wasm module (and load wasm-module-builder.js) from test/regress to the test/regress/wasm directory. This will make it easier to skip them all in the v8_enable_webassembly=false configuration. R=ahaas@chromium.org Bug: v8:11238 Change-Id: Ib22b0fb40a58f213182e68b78b34041651c436d1 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2712243 Reviewed-by: Andreas Haas <ahaas@chromium.org> Commit-Queue: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#72942}
113 lines
2.4 KiB
JavaScript
113 lines
2.4 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.
|
|
|
|
// This example crashes if the AllocationSites have not been properly added to
|
|
// the allocation_sites_list.
|
|
|
|
// Flags: --expose-gc
|
|
|
|
function __getProperties() {
|
|
return [];
|
|
let properties = [];
|
|
for (let name of Object.getOwnPropertyNames()) {;
|
|
}
|
|
return properties;
|
|
}
|
|
|
|
function __getRandomProperty() {
|
|
let properties = __getProperties();
|
|
if (!properties.length)
|
|
return undefined;
|
|
return properties[seed % properties.length];
|
|
}
|
|
var kWasmH0 = 0;
|
|
var kWasmH1 = 0x61;
|
|
var kWasmH2 = 0x73;
|
|
var kWasmH3 = 0x6d;
|
|
var kWasmV0 = 0x1;
|
|
var kWasmV1 = 0;
|
|
var kWasmV2 = 0;
|
|
var kWasmV3 = 0;
|
|
class Binary extends Array {
|
|
emit_header() {
|
|
this.push(kWasmH0, kWasmH1, kWasmH2, kWasmH3,
|
|
kWasmV0, kWasmV1, kWasmV2, kWasmV3);
|
|
}
|
|
}
|
|
class WasmModuleBuilder {
|
|
constructor() {
|
|
this.exports = [];
|
|
}
|
|
addImportedMemory() {}
|
|
setFunctionTableLength() {}
|
|
toArray() {
|
|
let binary = new Binary;
|
|
let wasm = this;
|
|
binary.emit_header();
|
|
"emitting imports @ " + binary.length;
|
|
section => {};
|
|
var mem_export = (wasm.memory !== undefined && wasm.memory.exp);
|
|
var exports_count = wasm.exports.length + (mem_export ? 1 : 0);
|
|
return binary;
|
|
}
|
|
toBuffer() {
|
|
let bytes = this.toArray();
|
|
let buffer = new ArrayBuffer(bytes.length);
|
|
let view = new Uint8Array(buffer);
|
|
for (let i = 0; i < bytes.length; i++) {
|
|
let val = bytes[i];
|
|
view[i] = val | 0;
|
|
}
|
|
return buffer;
|
|
}
|
|
instantiate(ffi) {
|
|
let module = new WebAssembly.Module(this.toBuffer());
|
|
let instance = new WebAssembly.Instance(module);
|
|
}
|
|
}
|
|
|
|
var v_40 = 0;
|
|
var v_43 = NaN;
|
|
|
|
try {
|
|
v_23 = new WasmModuleBuilder();
|
|
} catch (e) {
|
|
print("Caught: " + e);
|
|
}
|
|
|
|
try {
|
|
v_31 = [0xff];
|
|
v_29 = [v_31];
|
|
} catch (e) {
|
|
print("Caught: " + e);
|
|
}
|
|
|
|
try {
|
|
v_25 = ["main"];
|
|
gc();
|
|
} catch (e) {
|
|
print("Caught: " + e);
|
|
}
|
|
for (var v_28 of [[2]]) {
|
|
try {
|
|
gc();
|
|
} catch (e) {
|
|
print("Caught: " + e);
|
|
}
|
|
}
|
|
try {
|
|
module = v_23.instantiate();
|
|
} catch (e) {
|
|
print("Caught: " + e);
|
|
}
|
|
try {
|
|
v_41 = [];
|
|
} catch (e) {;
|
|
}
|
|
for (var v_43 = 0; v_43 < 100000; v_43++) try {
|
|
v_41[v_43] = [];
|
|
} catch (e) {
|
|
"Caught: " + e;
|
|
}
|