Mercurial > hg > Members > anatofuz > MoarVM
changeset 54:55dc893b653f
add change_INTERP2INTER.pl
author | Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 12 Jan 2019 18:03:19 +0900 |
parents | 00bd9b3e6d86 |
children | 661d6ab22571 9f73f6a78cb9 |
files | cbctools/change_INTERP2INTER.pl src/core/cbc-interp.cbc |
diffstat | 2 files changed, 46 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbctools/change_INTERP2INTER.pl Sat Jan 12 18:03:19 2019 +0900 @@ -0,0 +1,39 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +open my $fh, '<', shift or die 'input cbc file...'; + +while (my $line = <$fh>) { + $line =~ s/^__code\s+(.*)\(INTERP i\)\s*\{/__code $1(INTER i){/; + print change_i($line); +} + +sub change_i { + my $str = shift; + map { $str = substitution_regex($str,$_); } qw/op cu cur_op tc cur_callsite bytecode_start reg_base/; + # + #for my $reg (@regex_targets){ + # $str = substitution_regex($str,$reg); + #} + #$str =~ s/(\A)op|([\s,(])op/$2i->op/g; + #$str =~ s/(\A)cu|([\s,(])cu/$2i->cu/g; + #$str =~ s/(\A)cur_op|([\s,(])cur_op/$2i->cur_op/g; + #$str =~ s/(\A)tc|([\s,(&])tc/$2i->tc/g; + #$str =~ s/(\A)cur_callsite|([\s,(&])cur_callsite/$2i->cur_callsite/g; + #$str =~ s/(\A)bytecode_start|([\s,(&])bytecode_start/$2i->bytecode_start/g; + return $str; +} + +sub substitution_regex { + my ($str,$target) = @_; + if ($str =~ /(\A)i->$target/){ + $str =~ s/(\A)i->$target/i.$target/g; + return $str; + } + if ($str =~ /([!=*\[\]\s,+\-()&])i->$target/){ + $str =~ s/([!=*\[\]\s,+\-()&])i->$target/$1i.$target/g; + return $str; + } + return $str; +}
--- a/src/core/cbc-interp.cbc Wed Dec 12 18:21:48 2018 +0900 +++ b/src/core/cbc-interp.cbc Sat Jan 12 18:03:19 2019 +0900 @@ -6132,35 +6132,35 @@ GET_REG(i->cur_op, 4,i).s); i->cur_op += 6; goto cbc_next(i); - } +} __code cbc_sp_deref_get_i64(INTERP i){ MVMObject *o = GET_REG(i->cur_op, 2,i).o; MVMint64 **target = ((MVMint64 **)((char *)o + GET_UI16(i->cur_op, 4))); GET_REG(i->cur_op, 0,i).i64 = **target; i->cur_op += 6; goto cbc_next(i); - } +} __code cbc_sp_deref_get_n(INTERP i){ MVMObject *o = GET_REG(i->cur_op, 2,i).o; MVMnum64 **target = ((MVMnum64 **)((char *)o + GET_UI16(i->cur_op, 4))); GET_REG(i->cur_op, 0,i).n64 = **target; i->cur_op += 6; goto cbc_next(i); - } +} __code cbc_sp_deref_bind_i64(INTERP i){ MVMObject *o = GET_REG(i->cur_op, 0,i).o; MVMint64 **target = ((MVMint64 **)((char *)o + GET_UI16(i->cur_op, 4))); **target = GET_REG(i->cur_op, 2,i).i64; i->cur_op += 6; goto cbc_next(i); - } +} __code cbc_sp_deref_bind_n(INTERP i){ MVMObject *o = GET_REG(i->cur_op, 0,i).o; MVMnum64 **target = ((MVMnum64 **)((char *)o + GET_UI16(i->cur_op, 4))); **target = GET_REG(i->cur_op, 2,i).n64; i->cur_op += 6; goto cbc_next(i); - } +} __code cbc_sp_getlexvia_o(INTERP i){ MVMFrame *f = ((MVMCode *)GET_REG(i->cur_op, 6,i).o)->body.outer; MVMuint16 idx = GET_UI16(i->cur_op, 2); @@ -6178,7 +6178,7 @@ : found.o; i->cur_op += 8; goto cbc_next(i); - } +} __code cbc_sp_getlexvia_ins(INTERP i){ MVMFrame *f = ((MVMCode *)GET_REG(i->cur_op, 6,i).o)->body.outer; MVMuint16 idx = GET_UI16(i->cur_op, 2); @@ -6192,7 +6192,7 @@ GET_REG(i->cur_op, 0,i) = GET_LEX(i->cur_op, 2, f,i); i->cur_op += 8; goto cbc_next(i); - } +} __code cbc_sp_getstringfrom(INTERP i){ MVMCompUnit *dep = (MVMCompUnit *)i->tc->cur_frame->effective_spesh_slots[GET_UI16(i->cur_op, 2)]; MVMuint32 idx = GET_UI32(i->cur_op, 4);