Skip to content

Commit 71fc322

Browse files
committed
Map the new nativeinvoke OP
nativecallbuild now has a return value indicating whether we were able to JIT compile code for the call site
1 parent 1f0a598 commit 71fc322

13 files changed

+14
-3
lines changed

src/vm/moar/QAST/QASTOperationsMAST.nqp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,7 @@ sub arrange_args(@in) {
13771377
my $call_gen := sub ($qastcomp, $op) {
13781378
# Work out what callee is.
13791379
my $callee;
1380+
my $return_type;
13801381
my @args := $op.list;
13811382
if $op.name {
13821383
$callee := $qastcomp.as_mast($op.op eq 'callstatic'
@@ -1386,6 +1387,9 @@ my $call_gen := sub ($qastcomp, $op) {
13861387
elsif +@args {
13871388
@args := nqp::clone(@args);
13881389
$callee := $qastcomp.as_mast(@args.shift(), :want($MVM_reg_obj));
1390+
if $op.op eq 'nativeinvoke' {
1391+
$return_type := $qastcomp.as_mast(@args.shift(), :want($MVM_reg_obj));
1392+
}
13891393
}
13901394
else {
13911395
nqp::die("No name for call and empty children list");
@@ -1406,6 +1410,9 @@ my $call_gen := sub ($qastcomp, $op) {
14061410

14071411
# Append the code to evaluate the callee expression
14081412
push_ilist(@ins, $callee);
1413+
if $op.op eq 'nativeinvoke' {
1414+
push_ilist(@ins, $return_type);
1415+
}
14091416

14101417
# Process arguments.
14111418
for @args {
@@ -1436,18 +1443,22 @@ my $call_gen := sub ($qastcomp, $op) {
14361443
# and allocate a register for it. Probably reuse an arg's or the callee's.
14371444
my $res_reg := $regalloc.fresh_register($res_kind);
14381445

1446+
nqp::unshift(@arg_regs, $return_type.result_reg) if $op.op eq 'nativeinvoke';
1447+
14391448
# Generate call.
14401449
nqp::push(@ins, MAST::Call.new(
14411450
:target($decont_reg),
14421451
:flags(@arg_flags),
14431452
|@arg_regs,
1444-
:result($res_reg)
1453+
:result($res_reg),
1454+
:op($op.op eq 'nativeinvoke' ?? 1 !! 0),
14451455
));
14461456

14471457
MAST::InstructionList.new(@ins, $res_reg, $res_kind)
14481458
};
14491459
QAST::MASTOperations.add_core_op('call', $call_gen, :!inlinable);
14501460
QAST::MASTOperations.add_core_op('callstatic', $call_gen, :!inlinable);
1461+
QAST::MASTOperations.add_core_op('nativeinvoke', $call_gen, :!inlinable);
14511462

14521463
QAST::MASTOperations.add_core_op('callmethod', -> $qastcomp, $op {
14531464
my @args := nqp::clone($op.list);
@@ -2801,7 +2812,7 @@ QAST::MASTOperations.add_core_moarop_mapping('nfarunalt', 'nfarunalt', 0);
28012812

28022813
# native call ops
28032814
QAST::MASTOperations.add_core_moarop_mapping('initnativecall', 'no_op');
2804-
QAST::MASTOperations.add_core_moarop_mapping('buildnativecall', 'nativecallbuild', 0);
2815+
QAST::MASTOperations.add_core_moarop_mapping('buildnativecall', 'nativecallbuild');
28052816
QAST::MASTOperations.add_core_moarop_mapping('nativecallinvoke', 'nativecallinvoke');
28062817
QAST::MASTOperations.add_core_op('nativecall', -> $qastcomp, $op {
28072818
proto decont_all(@args) {

src/vm/moar/stage0/MASTNodes.moarvm

176 Bytes
Binary file not shown.

src/vm/moar/stage0/MASTOps.moarvm

3.34 KB
Binary file not shown.
64 Bytes
Binary file not shown.
1.73 KB
Binary file not shown.

src/vm/moar/stage0/NQPHLL.moarvm

-1.68 KB
Binary file not shown.

src/vm/moar/stage0/NQPP6QRegex.moarvm

1.02 KB
Binary file not shown.

src/vm/moar/stage0/QAST.moarvm

1.94 KB
Binary file not shown.

src/vm/moar/stage0/QASTNode.moarvm

0 Bytes
Binary file not shown.

src/vm/moar/stage0/QRegex.moarvm

968 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)