@@ -24,7 +24,7 @@ use crate::{
2424 js_string,
2525 vm:: {
2626 CallFrame , CodeBlock , CodeBlockFlags , Constant , GeneratorResumeKind , Handler , InlineCache ,
27- opcode:: { BindingOpcode , ByteCodeEmitter , VaryingOperand } ,
27+ opcode:: { Address , BindingOpcode , ByteCodeEmitter , VaryingOperand } ,
2828 source_info:: { SourceInfo , SourceMap , SourceMapBuilder , SourcePath } ,
2929 } ,
3030} ;
@@ -366,7 +366,7 @@ enum Literal {
366366#[ must_use]
367367#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
368368pub ( crate ) struct Label {
369- index : u32 ,
369+ index : Address ,
370370}
371371
372372#[ derive( Debug , Clone , Copy ) ]
@@ -536,8 +536,10 @@ pub(crate) enum BindingKind {
536536
537537impl < ' ctx > ByteCompiler < ' ctx > {
538538 /// Represents a placeholder address that will be patched later.
539- const DUMMY_ADDRESS : u32 = u32:: MAX ;
540- const DUMMY_LABEL : Label = Label { index : u32:: MAX } ;
539+ const DUMMY_ADDRESS : Address = Address :: new ( u32:: MAX ) ;
540+ const DUMMY_LABEL : Label = Label {
541+ index : Address :: new ( u32:: MAX ) ,
542+ } ;
541543
542544 /// Creates a new [`ByteCompiler`].
543545 #[ inline]
@@ -802,7 +804,7 @@ impl<'ctx> ByteCompiler<'ctx> {
802804 }
803805 }
804806
805- fn next_opcode_location ( & mut self ) -> u32 {
807+ fn next_opcode_location ( & mut self ) -> Address {
806808 self . bytecode . next_opcode_location ( )
807809 }
808810
@@ -819,12 +821,13 @@ impl<'ctx> ByteCompiler<'ctx> {
819821 {
820822 let start_pc = self . next_opcode_location ( ) ;
821823 self . source_map_builder
822- . push_source_position ( start_pc, position. into ( ) ) ;
824+ . push_source_position ( start_pc. as_u32 ( ) , position. into ( ) ) ;
823825 }
824826
825827 pub ( crate ) fn pop_source_position ( & mut self ) {
826828 let start_pc = self . next_opcode_location ( ) ;
827- self . source_map_builder . pop_source_position ( start_pc) ;
829+ self . source_map_builder
830+ . pop_source_position ( start_pc. as_u32 ( ) ) ;
828831 }
829832
830833 pub ( crate ) fn emit_get_function ( & mut self , dst : & Register , index : u32 ) {
@@ -1144,7 +1147,7 @@ impl<'ctx> ByteCompiler<'ctx> {
11441147 fn try_fused_comparison_branch ( & mut self , op : RelationalOp , binary : & Binary ) -> Option < Label > {
11451148 use crate :: vm:: opcode:: ByteCodeEmitter ;
11461149
1147- let emit_fn: fn ( & mut ByteCodeEmitter , u32 , VaryingOperand , VaryingOperand ) = match op {
1150+ let emit_fn: fn ( & mut ByteCodeEmitter , Address , VaryingOperand , VaryingOperand ) = match op {
11481151 RelationalOp :: LessThan => ByteCodeEmitter :: emit_jump_if_not_less_than,
11491152 RelationalOp :: LessThanOrEqual => ByteCodeEmitter :: emit_jump_if_not_less_than_or_equal,
11501153 RelationalOp :: GreaterThan => ByteCodeEmitter :: emit_jump_if_not_greater_than,
@@ -1153,7 +1156,7 @@ impl<'ctx> ByteCompiler<'ctx> {
11531156 }
11541157 _ => return None ,
11551158 } ;
1156- let mut label_index = 0u32 ;
1159+ let mut label_index = Address :: new ( 0 ) ;
11571160 self . compile_expr_operand ( binary. lhs ( ) , |compiler, lhs| {
11581161 compiler. compile_expr_operand ( binary. rhs ( ) , |compiler, rhs| {
11591162 label_index = compiler. next_opcode_location ( ) ;
@@ -1217,7 +1220,7 @@ impl<'ctx> ByteCompiler<'ctx> {
12171220 }
12181221
12191222 #[ track_caller]
1220- pub ( crate ) fn patch_jump_with_target ( & mut self , label : Label , target : u32 ) {
1223+ pub ( crate ) fn patch_jump_with_target ( & mut self , label : Label , target : Address ) {
12211224 self . bytecode . patch_jump ( label. index , target) ;
12221225 }
12231226
@@ -2397,7 +2400,7 @@ impl<'ctx> ByteCompiler<'ctx> {
23972400
23982401 let register_count = self . register_allocator . finish ( ) ;
23992402
2400- let source_map_entries = self . source_map_builder . build ( final_bytecode_len) ;
2403+ let source_map_entries = self . source_map_builder . build ( final_bytecode_len. as_u32 ( ) ) ;
24012404
24022405 CodeBlock {
24032406 length : self . length ,
0 commit comments