Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

View File

@ -0,0 +1,31 @@
// Copyright 2020 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.
d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
var builder = new WasmModuleBuilder();
builder
.addFunction('mul', kSig_i_ii)
// input is 2 args of type int and output is int
.addBody([
kExprLocalGet, 0, // local.get i0
kExprLocalGet, 1, // local.get i1
kExprI32Mul
]) // i32.mul i0 i1
.exportFunc();
const instance = builder.instantiate();
const wasm_f = instance.exports.mul;
function f() {
var result = wasm_f(21, 2);
return result;
}
try {
let val = f();
f();
} catch (e) {
print('*exception:* ' + e);
}

View File

@ -0,0 +1,23 @@
# Copyright 2020 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.
# 0x00 (module
# 0x08 [type]
# (type $type0 (func (param i32 i32) (result i32)))
# 0x11 [function]
# 0x15 (export "mul" (func $func0))
# 0x1e [code]
# 0x20 (func $func0 (param $var0 i32) (param $var1 i32) (result i32)
# 0x23 get_local $var0
# 0x25 get_local $var1
# 0x27 i32.mul
# )
# )
# 0x29 [name]
BREAK_ADDRESS_0 = 0x0023
BREAK_ADDRESS_1 = 0x0025
BREAK_ADDRESS_2 = 0x0027
ARG_0 = 21
ARG_1 = 2

View File

@ -0,0 +1,31 @@
// Copyright 2020 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.
d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
var builder = new WasmModuleBuilder();
builder
.addFunction('mul', kSig_f_ff)
// input is 2 args of type float and output is float
.addBody([
kExprLocalGet, 0, // local.get f0
kExprLocalGet, 1, // local.get f1
kExprF32Mul, // f32.mul i0 i1
])
.exportFunc();
const instance = builder.instantiate();
const wasm_f = instance.exports.mul;
function f() {
var result = wasm_f(12.0, 3.5);
return result;
}
try {
let val = f();
print('float result: ' + val);
} catch (e) {
print('*exception:* ' + e);
}

View File

@ -0,0 +1,21 @@
# Copyright 2020 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.
# 0x00 (module
# 0x08 [type]
# (type $type0 (func (param f32 f32) (result f32)))
# 0x11 [function]
# 0x15 (export "mul" (func $func0))
# 0x1e [code]
# 0x20 (func $func0 (param $var0 f32) (param $var1 f32) (result f32)
# 0x23 get_local $var0
# 0x25 get_local $var1
# 0x27 f32.mul
# )
# )
# 0x29 [name]
ARG_0 = 12.0
ARG_1 = 3.5
FUNC_START_ADDR = 0x23

View File

@ -0,0 +1,51 @@
// Copyright 2020 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.
d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
var builder = new WasmModuleBuilder();
builder.addGlobal(kWasmI32, false, false).exportAs('g_n');
builder.addMemory(32, 128);
builder.exportMemoryAs('mem', 0);
builder.addActiveDataSegment(0, [kExprI32Const, 0], [0x2a, 0x2b, 0x2c, 0x2d]);
var func_a_idx =
builder.addFunction('wasm_A', kSig_v_i).addBody([kExprNop, kExprNop]).index;
// wasm_B calls wasm_A <param0> times.
builder.addFunction('wasm_B', kSig_v_i)
.addBody([
kExprLoop,
kWasmVoid, // while
kExprLocalGet,
0, // -
kExprIf,
kWasmVoid, // if <param0> != 0
kExprLocalGet,
0, // -
kExprI32Const,
1, // -
kExprI32Sub, // -
kExprLocalSet,
0, // decrease <param0>
...wasmI32Const(1024), // some longer i32 const (2 byte imm)
kExprCallFunction,
func_a_idx, // -
kExprBr,
1, // continue
kExprEnd, // -
kExprEnd, // break
])
.exportAs('main');
const instance = builder.instantiate();
const wasm_main = instance.exports.main;
function f() {
wasm_main(42);
}
f();

View File

@ -0,0 +1,46 @@
# Copyright 2020 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.
# 0x00 (module
# 0x08 [type]
# 0x0a (type $type0 (func (param i32)))
# 0x0f (type $type1 (func (param i32)))
# 0x13 [function]
# 0x18 [memory]
# (memory (;0;) 32 128)
# 0x1f [global]
# 0x27 (global $global0 i32 (i32.const 0))
# 0x29 (export "g_n" (global $global0))
# 0x30 (export "mem" (memory 0))
# 0x36 (export "main" (func $func1))
# 0x3d [code]
# 0x3f (func $func0 (param $var0 i32)
# 0x42 nop
# 0x43 nop
# )
# 0x45 (func $func1 (param $var0 i32)
# 0x47 loop $label0
# 0x49 get_local $var0
# 0x4b if
# 0x4d get_local $var0
# 0x4f i32.const 1
# 0x51 i32.sub
# 0x52 set_local $var0
# 0x54 i32.const 1024
# 0x57 call $func0
# 0x59 br $label0
# 0x5b end
# 0x5c end $label0
# )
# )
# 0x5e [name]
MEM_MIN = 32
MEM_MAX = 128
FUNC0_START_ADDR = 0x42
FUNC1_RETURN_ADDR = 0x59
FUNC1_START_ADDR = 0x47
DATA_OFFSET = 0
DATA_SIZE = 4
DATA_CONTENT = 0x2d2c2b2a

View File

@ -0,0 +1,31 @@
// Copyright 2020 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.
d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
var builder = new WasmModuleBuilder();
builder.addMemory(32, 128).exportMemoryAs('mem')
var func_a_idx =
builder.addFunction('wasm_A', kSig_v_v).addBody([
kExprI32Const, 0, // i32.const 0
kExprI32Const, 42, // i32.const 42
kExprI32StoreMem, 0, 0xff, 0xff, 0xff, 0xff, 0x0f, // i32.store offset = -1
]).index;
builder.addFunction('main', kSig_i_v).addBody([
kExprCallFunction, func_a_idx, // call $wasm_A
kExprI32Const, 0 // i32.const 0
])
.exportFunc();
const instance = builder.instantiate();
const main_f = instance.exports.main;
function f() {
var result = main_f();
return result;
}
f();

View File

@ -0,0 +1,28 @@
# Copyright 2020 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.
# 0x00 (module
# 0x08 [type]
# 0x0a (type $type0 (func))
# 0x0e (type $type1 (func (result i32)))
# 0x12 [function]
# 0x17 [memory]
# 0x19 (memory $memory0 32 128)
# 0x1e [export]
# 0x20 (export "mem" (memory $memory0))
# 0x27 (export "main" (func $func1))
# 0x2e [code]
# 0x30 (func $func0
# 0x33 i32.const 0
# 0x35 i32.const 42
# 0x37 i32.store offset=-1 align=1
# 0x3e )
# 0x3f (func $func1 (result i32)
# 0x41 call $func0
# 0x43 i32.const 0
# 0x45 )
# 0x46 ...
# )
TRAP_ADDRESS = 0x0037