Skip to content

Commit

Permalink
Initial work on getting MoarVM op information
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Apr 21, 2024
1 parent ff5162c commit 2e5d184
Show file tree
Hide file tree
Showing 7 changed files with 2,113 additions and 12 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ Revision history for MoarVM::Bytecode

{{$NEXT}}
- Make sure all classes have at least a rudimentary "gist" method
- Add "Op" class to obtain bytecode operation information, including
a helper script "makeOPS.raku" to cull that information from the
MoarVM oplist

0.0.8 2024-04-18T22:56:28+02:00
- Only add "Statement" objects if the bytecode offset is different
Expand Down
3 changes: 2 additions & 1 deletion META6.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"name": "MoarVM::Bytecode",
"perl": "6.d",
"provides": {
"MoarVM::Bytecode": "lib/MoarVM/Bytecode.rakumod"
"MoarVM::Bytecode": "lib/MoarVM/Bytecode.rakumod",
"MoarVM::Ops": "lib/MoarVM/Ops.rakumod"
},
"resources": [
],
Expand Down
28 changes: 28 additions & 0 deletions doc/MoarVM/Bytecode.rakudoc
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ C<deserialization-frame-index>

=head1 SUBCLASSES

Instances of these classes are usually created automatically.

=head2 Argument

The C<Argument> class provides these methods:
Expand Down Expand Up @@ -479,6 +481,32 @@ The line number of this statement.

The bytecode offset of this statement.

=head2 Op

=head attributes

A C<Map> of additional attribute strings.

=head3 index

The numerical index of this operation.

=head3 name

The name of this operation.

=head3 type

The (special) type of this operation. Currently recognized are:

=item dispatch
=item jump
=item parameter
=item return
=item spesh

If this is not a special operation, the type will be the empty string.

=head1 AUTHOR

Elizabeth Mattijsen <liz@raku.rocks>
Expand Down
10 changes: 1 addition & 9 deletions lib/MoarVM/Bytecode.rakumod
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# An attempt at providing introspection into the MoarVM bytecode format

use MoarVM::Ops;
use List::Agnostic:ver<0.0.1>:auth<zef:lizmat>;
use paths:ver<10.0.9>:auth<zef:lizmat>;

Expand Down Expand Up @@ -625,15 +626,6 @@ class MoarVM::Bytecode {
paths(self.rootdir, :file(*.ends-with(".moarvm"))).sort
}

method ops() {
Map.new: self.rootdir.add("nqp/MoarVM/src/core/oplist").lines.map({
if $_ && !.starts-with("#") {
my @parts = .words;
@parts.shift => @parts
}
})
}

multi method gist(MoarVM::Bytecode:D:) {
my str $head = $!path ?? "File: $!path" !! "Created from a Blob";
my str @parts = "$head ($!bytecode.elems() bytes)";
Expand Down

0 comments on commit 2e5d184

Please sign in to comment.