-
-
Save MasterDuke17/9114bd5da9d63a02bfac635e3da1fc0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
indx = 0, new size = 150 | |
indx = 150, mbc = 150 | |
indx = 150, new size = 222 | |
indx = 216, mbc = 222 | |
indx = 222, new size = 412 | |
indx = 388, mbc = 412 | |
indx = 412, new size = 478 | |
indx = 478, mbc = 478 | |
indx = 478, new size = 660 | |
indx = 642, mbc = 660 | |
indx = 660, new size = 726 | |
indx = 726, mbc = 726 | |
indx = 726, new size = 908 | |
indx = 890, mbc = 908 | |
indx = 908, new size = 974 | |
indx = 974, mbc = 974 | |
indx = 974, new size = 1158 | |
indx = 1140, mbc = 1158 | |
indx = 1158, new size = 1224 | |
indx = 1224, mbc = 1224 | |
indx = 1224, new size = 1358 | |
indx = 1358, mbc = 1358 | |
indx = 1358, new size = 1704 | |
indx = 1686, mbc = 1704 | |
indx = 1704, new size = 1882 | |
indx = 1852, mbc = 1882 | |
indx = 1882, new size = 1948 | |
indx = 1948, mbc = 1948 | |
indx = 1948, new size = 2020 | |
indx = 2020, mbc = 2020 | |
indx = 2020, new size = 2238 | |
indx = 2220, mbc = 2238 | |
indx = 2238, new size = 2392 | |
indx = 2380, mbc = 2392 | |
indx = 2392, new size = 2458 | |
indx = 2458, mbc = 2458 | |
indx = 2458, new size = 2548 | |
indx = 2548, mbc = 2548 | |
indx = 2548, new size = 2706 | |
indx = 2700, mbc = 2706 | |
indx = 2706, new size = 2862 | |
indx = 2850, mbc = 2862 | |
indx = 2862, new size = 2928 | |
indx = 2928, mbc = 2928 | |
indx = 2928, new size = 3002 | |
indx = 3002, mbc = 3002 | |
indx = 3002, new size = 3062 | |
indx = 3062, mbc = 3062 | |
indx = 3062, new size = 3120 | |
indx = 3120, mbc = 3120 | |
indx = 3120, new size = 3180 | |
indx = 3180, mbc = 3180 | |
indx = 3180, new size = 3240 | |
indx = 3240, mbc = 3240 | |
indx = 0, new size = 378 | |
indx = 372, mbc = 378 | |
indx = 378, new size = 496 | |
indx = 496, mbc = 496 | |
indx = 496, new size = 638 | |
indx = 602, mbc = 638 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/vm/moar/QAST/QASTCompilerMAST.nqp b/src/vm/moar/QAST/QASTCompilerMAST.nqp | |
index a1ccd845b..a547d153c 100644 | |
--- a/src/vm/moar/QAST/QASTCompilerMAST.nqp | |
+++ b/src/vm/moar/QAST/QASTCompilerMAST.nqp | |
@@ -2611,66 +2611,105 @@ class MoarVM::BytecodeWriter { | |
my @handlers := $f.handlers; | |
my @debug_map_idxs := $f.debug_map_idxs; | |
my int $debug_map_idxs_length := nqp::elems(@debug_map_idxs); | |
- $!mbc.write_uint32($f.bytecode-offset); # Bytecode segment offset | |
- $!mbc.write_uint32($f.bytecode-length); # Bytecode length in bytes | |
- $!mbc.write_uint32(my uint $num_local_types := nqp::elems(@local_types)); # Number of locals/registers | |
- $!mbc.write_uint32(my uint $num_lexical_types := nqp::elems(@lexical_types)); # Number of lexicals | |
- $!mbc.write_uint32($f.cuuid-idx); # Compilation unit unique ID (string heap index) | |
- $!mbc.write_uint32($f.name-idx); # Name (string heap index) | |
+ my uint $indx := nqp::elems($!mbc); | |
+ note("indx = " ~ $indx ~ ", new size = " ~ $indx + 12 * 4 + 3 * 2 + 2 * nqp::elems(@local_types) + 6 * nqp::elems(@lexical_types) + 20 * nqp::elems(@handlers) + 12 * $num_static_lex_values + 6 * $debug_map_idxs_length); | |
+ nqp::setelems($!mbc, $indx + 12 * 4 + 3 * 2 + 2 * nqp::elems(@local_types) + 6 * nqp::elems(@lexical_types) + 20 * nqp::elems(@handlers) + 12 * $num_static_lex_values + 6 * $debug_map_idxs_length); | |
+ $!mbc.write_uint32_at($f.bytecode-offset, $indx); # Bytecode segment offset | |
+ $indx := $indx + 4; | |
+ $!mbc.write_uint32_at($f.bytecode-length, $indx); # Bytecode length in bytes | |
+ $indx := $indx + 4; | |
+ $!mbc.write_uint32_at((my uint $num_local_types := nqp::elems(@local_types)), $indx); # Number of locals/registers | |
+ $indx := $indx + 4; | |
+ $!mbc.write_uint32_at((my $num_lexical_types := nqp::elems(@lexical_types)), $indx); # Number of lexicals | |
+ $indx := $indx + 4; | |
+ $!mbc.write_uint32_at($f.cuuid-idx, $indx); # Compilation unit unique ID (string heap index) | |
+ $indx := $indx + 4; | |
+ $!mbc.write_uint32_at($f.name-idx, $indx); # Name (string heap index) | |
+ $indx := $indx + 4; | |
my $outer := $f.outer; | |
if nqp::defined($outer) { | |
- $!mbc.write_uint16(my uint $frame_index := self.get_frame_index($outer)); # Outer | |
+ $!mbc.write_uint16_at((my uint $frame_index := self.get_frame_index($outer)), $indx); # Outer | |
+ $indx := $indx + 2; | |
} | |
else { | |
- $!mbc.write_uint16($idx); # Outer | |
+ $!mbc.write_uint16_at($idx, $indx); # Outer | |
+ $indx := $indx + 2; | |
} | |
- $!mbc.write_uint32($f.annotations-offset); # Annotation segment offset | |
- $!mbc.write_uint32($f.num-annotations); # Number of annotations | |
- $!mbc.write_uint32(my uint $num_handlers := nqp::elems(@handlers)); # Number of handlers | |
- $!mbc.write_uint16(my uint $flags := $f.flags); # Frame flag bits | |
- $!mbc.write_uint16($num_static_lex_values); # Number of entries in static lexical values table | |
+ $!mbc.write_uint32_at($f.annotations-offset, $indx); # Annotation segment offset | |
+ $indx := $indx + 4; | |
+ $!mbc.write_uint32_at($f.num-annotations, $indx); # Number of annotations | |
+ $indx := $indx + 4; | |
+ $!mbc.write_uint32_at((my uint $num_handlers := nqp::elems(@handlers)), $indx); # Number of handlers | |
+ $indx := $indx + 4; | |
+ $!mbc.write_uint16_at((my uint $flags := $f.flags), $indx); # Frame flag bits | |
+ $indx := $indx + 2; | |
+ $!mbc.write_uint16_at($num_static_lex_values, $indx); # Number of entries in static lexical values table | |
+ $indx := $indx + 2; | |
if $f.flags +& 4 { # FRAME_FLAG_HAS_CODE_OBJ | |
- $!mbc.write_uint32(my uint $idx := nqp::add_i($f.code_obj_sc_dep_idx, 1)); # Code object SC dependency index + 1 | |
- $!mbc.write_uint32($f.code_obj_sc_idx); # SC object index | |
+ $!mbc.write_uint32_at((my uint $idx := nqp::add_i($f.code_obj_sc_dep_idx, 1)), $indx); # Code object SC dependency index + 1 | |
+ $indx := $indx + 4; | |
+ $!mbc.write_uint32_at($f.code_obj_sc_idx, $indx); # SC object index | |
+ $indx := $indx + 4; | |
} | |
else { | |
my uint $zero := 0; | |
- $!mbc.write_uint32($zero); # No code object SC dependency index | |
- $!mbc.write_uint32($zero); # No SC object index | |
+ $!mbc.write_uint32_at($zero, $indx); # No code object SC dependency index | |
+ $indx := $indx + 4; | |
+ $!mbc.write_uint32_at($zero, $indx); # No SC object index | |
+ $indx := $indx + 4; | |
} | |
- $!mbc.write_uint32(my uint $num_debug_map := nqp::elems($f.debug_map)); | |
+ $!mbc.write_uint32_at((my uint $num_debug_map := nqp::elems($f.debug_map)), $indx); | |
+ $indx := $indx + 4; | |
for @local_types { | |
- $!mbc.write_uint16(my uint16 $type := type_to_local_type($_)); | |
+ $!mbc.write_uint16_at((my uint16 $type := type_to_local_type($_)), $indx); | |
+ $indx := $indx + 2; | |
} | |
my int $i := 0; | |
for @lexical_types { | |
- $!mbc.write_uint16(my uint16 $type := type_to_local_type($_)); | |
- $!mbc.write_uint32(my uint32 $name := nqp::atpos_i(@lexical_names, $i++)); | |
+ $!mbc.write_uint16_at((my uint16 $type := type_to_local_type($_)), $indx); | |
+ $indx := $indx + 2; | |
+ $!mbc.write_uint32_at((my uint32 $name := nqp::atpos_i(@lexical_names, $i++)), $indx); | |
+ $indx := $indx + 4; | |
} | |
for @handlers { | |
- $!mbc.write_uint32($_.start_offset); | |
- $!mbc.write_uint32($_.end_offset); | |
- $!mbc.write_uint32($_.category_mask); | |
- $!mbc.write_uint16($_.action); | |
- $!mbc.write_uint16($_.local); | |
- $!mbc.write_uint32($f.resolve-label($_.label)); | |
+ $!mbc.write_uint32_at($_.start_offset, $indx); | |
+ $indx := $indx + 4; | |
+ $!mbc.write_uint32_at($_.end_offset, $indx); | |
+ $indx := $indx + 4; | |
+ $!mbc.write_uint32_at($_.category_mask, $indx); | |
+ $indx := $indx + 4; | |
+ $!mbc.write_uint16_at($_.action, $indx); | |
+ $indx := $indx + 2; | |
+ $!mbc.write_uint16_at($_.local, $indx); | |
+ $indx := $indx + 2; | |
+ $!mbc.write_uint32_at($f.resolve-label($_.label), $indx); | |
+ $indx := $indx + 4; | |
if $_.category_mask +& 4096 { # MVM_EX_CATEGORY_LABELED | |
- $!mbc.write_uint16($_.label_reg); | |
+ $!mbc.write_uint16_at($_.label_reg, $indx); | |
+ $indx := $indx + 2; | |
+ nqp::setelems($!mbc, nqp::elems($!mbc) + 2); | |
} | |
} | |
$i := 0; | |
while ($i < $num_static_lex_values) { | |
- $!mbc.write_uint16(my uint $index := nqp::atpos_i(@static_lex_values, 4 * $i)); | |
- $!mbc.write_uint16(my uint $flags := nqp::atpos_i(@static_lex_values, 4 * $i + 1)); | |
- $!mbc.write_uint32(my uint $sc_idx := nqp::atpos_i(@static_lex_values, 4 * $i + 2)); | |
- $!mbc.write_uint32(my uint $idx := nqp::atpos_i(@static_lex_values, 4 * $i + 3)); | |
+ $!mbc.write_uint16_at((my uint $index := nqp::atpos_i(@static_lex_values, 4 * $i)), $indx); | |
+ $indx := $indx + 2; | |
+ $!mbc.write_uint16_at((my uint $flags := nqp::atpos_i(@static_lex_values, 4 * $i + 1)), $indx); | |
+ $indx := $indx + 2; | |
+ $!mbc.write_uint32_at((my uint $sc_idx := nqp::atpos_i(@static_lex_values, 4 * $i + 2)), $indx); | |
+ $indx := $indx + 4; | |
+ $!mbc.write_uint32_at((my uint $idx := nqp::atpos_i(@static_lex_values, 4 * $i + 3)), $indx); | |
+ $indx := $indx + 4; | |
$i++; | |
} | |
$i := 0; | |
while $i < $debug_map_idxs_length { | |
- $!mbc.write_uint16(my uint $idx := nqp::atpos_i(@debug_map_idxs, $i++)); | |
- $!mbc.write_uint32(my uint $name := nqp::atpos_i(@debug_map_idxs, $i++)); | |
+ $!mbc.write_uint16_at((my uint $idx := nqp::atpos_i(@debug_map_idxs, $i++)), $indx); | |
+ $indx := $indx + 2; | |
+ $!mbc.write_uint32_at((my uint $name := nqp::atpos_i(@debug_map_idxs, $i++)), $indx); | |
+ $indx := $indx + 4; | |
} | |
+ note("indx = " ~ $indx ~ ", mbc = " ~ nqp::elems($!mbc)); | |
} | |
method collect_bytecode() { | |
for @!frames { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment