@@ -13,6 +13,7 @@ const Global = @import("store/global.zig").Global;
13
13
const Elem = @import ("store/elem.zig" ).Elem ;
14
14
const Data = @import ("store/data.zig" ).Data ;
15
15
const VirtualMachine = @import ("instance/vm.zig" ).VirtualMachine ;
16
+ const Instruction = VirtualMachine .Instruction ;
16
17
17
18
const VirtualMachineOptions = struct {
18
19
frame_stack_size : comptime_int = 1024 ,
@@ -348,7 +349,7 @@ pub const Instance = struct {
348
349
try vm .pushLabel (VirtualMachine.Label {
349
350
.return_arity = function .results .len ,
350
351
.op_stack_len = locals_start ,
351
- .branch_target = 0 ,
352
+ .branch_target = @as ([ * ] Instruction , @ptrCast ( & self . module . instructions . items [ 0 ])) ,
352
353
});
353
354
354
355
// 8. Execute our function
@@ -397,7 +398,7 @@ pub const Instance = struct {
397
398
try vm .pushLabel (VirtualMachine.Label {
398
399
.return_arity = 0 ,
399
400
.op_stack_len = locals_start ,
400
- .branch_target = 0 ,
401
+ .branch_target = @as ([ * ] Instruction , @ptrCast ( & self . module . instructions . items [ 0 ])) ,
401
402
});
402
403
403
404
try vm .invoke (f .start );
@@ -409,7 +410,7 @@ pub const Instance = struct {
409
410
}
410
411
}
411
412
412
- pub fn invokeExpression (self : * Instance , start : usize , comptime Result : type , comptime options : VirtualMachineOptions ) ! Result {
413
+ pub fn invokeExpression (self : * Instance , start : [ * ] Instruction , comptime Result : type , comptime options : VirtualMachineOptions ) ! Result {
413
414
var frame_stack : [options .frame_stack_size ]VirtualMachine.Frame = [_ ]VirtualMachine.Frame {undefined } ** options .frame_stack_size ;
414
415
var label_stack : [options .label_stack_size ]VirtualMachine.Label = [_ ]VirtualMachine.Label {undefined } ** options .label_stack_size ;
415
416
var op_stack : [options .operand_stack_size ]u64 = [_ ]u64 {0 } ** options .operand_stack_size ;
@@ -428,6 +429,7 @@ pub const Instance = struct {
428
429
try vm .pushLabel (VirtualMachine.Label {
429
430
.return_arity = 1 ,
430
431
.op_stack_len = locals_start ,
432
+ .branch_target = @as ([* ]Instruction , @ptrCast (& self .module .instructions .items [0 ])),
431
433
});
432
434
433
435
try vm .invoke (start );
0 commit comments