Skip to content

Commit cdbb9d1

Browse files
committed
Avoid an apparent invokedynamic bug.
Seems that optional args to the resolver can somehow get "lost" in a sufficiently large class file. Weird.
1 parent 740258f commit cdbb9d1

File tree

2 files changed

+445
-28
lines changed

2 files changed

+445
-28
lines changed

src/vm/jvm/QAST/Compiler.nqp

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,15 +1359,15 @@ QAST::OperationsJAST.add_core_op('call', sub ($qastcomp, $node) {
13591359
# Emit the call. Note, name passed as extra arg as some valid names in
13601360
# Perl 6 are not valid method names on the JVM. We use the fact that
13611361
# the stack was spilled to sneak the ThreadContext arg in.
1362+
nqp::unshift(@argstuff[2], 'I');
1363+
nqp::unshift(@argstuff[2], $TYPE_STR);
1364+
$il.append(JAST::PushSVal.new( :value($node.name) ));
1365+
$il.append(JAST::PushIndex.new( :value($cs_idx) ));
13621366
$il.append($ALOAD_1);
13631367
$*STACK.obtain($il, |@argstuff[1]) if @argstuff[1];
13641368
$il.append(JAST::InvokeDynamic.new(
1365-
'subcall', 'V', @argstuff[2],
1366-
'org/perl6/nqp/runtime/IndyBootstrap', 'subcall',
1367-
[
1368-
JAST::PushSVal.new( :value($node.name) ),
1369-
JAST::PushIndex.new( :value($cs_idx) )
1370-
]
1369+
'subcall_noa', 'V', @argstuff[2],
1370+
'org/perl6/nqp/runtime/IndyBootstrap', 'subcall_noa'
13711371
));
13721372
}
13731373

@@ -1384,14 +1384,13 @@ QAST::OperationsJAST.add_core_op('call', sub ($qastcomp, $node) {
13841384

13851385
# Emit the call, using the same thread context trick. The first thing
13861386
# will be invoked.
1387+
nqp::unshift(@argstuff[2], 'I');
1388+
$il.append(JAST::PushIndex.new( :value($cs_idx) ));
13871389
$il.append($ALOAD_1);
13881390
$*STACK.obtain($il, |@argstuff[1]) if @argstuff[1];
13891391
$il.append(JAST::InvokeDynamic.new(
1390-
'indcall', 'V', @argstuff[2],
1391-
'org/perl6/nqp/runtime/IndyBootstrap', 'indcall',
1392-
[
1393-
JAST::PushIndex.new( :value($cs_idx) )
1394-
]
1392+
'indcall_noa', 'V', @argstuff[2],
1393+
'org/perl6/nqp/runtime/IndyBootstrap', 'indcall_noa'
13951394
));
13961395
}
13971396

@@ -1427,15 +1426,15 @@ QAST::OperationsJAST.add_core_op('callmethod', -> $qastcomp, $node {
14271426
# Emit the call. Note, name passed as extra arg as some valid names in
14281427
# Perl 6 are not valid method names on the JVM. We use the fact that
14291428
# the stack was spilled to sneak the ThreadContext arg in.
1429+
nqp::unshift(@argstuff[2], 'I');
1430+
nqp::unshift(@argstuff[2], $TYPE_STR);
1431+
$il.append(JAST::PushSVal.new( :value($node.name) ));
1432+
$il.append(JAST::PushIndex.new( :value($cs_idx) ));
14301433
$il.append($ALOAD_1);
14311434
$*STACK.obtain($il, |@argstuff[1]) if @argstuff[1];
14321435
$il.append(JAST::InvokeDynamic.new(
1433-
'methcall', 'V', @argstuff[2],
1434-
'org/perl6/nqp/runtime/IndyBootstrap', 'methcall',
1435-
[
1436-
JAST::PushSVal.new( :value($node.name) ),
1437-
JAST::PushIndex.new( :value($cs_idx) )
1438-
]
1436+
'methcall_noa', 'V', @argstuff[2],
1437+
'org/perl6/nqp/runtime/IndyBootstrap', 'methcall_noa',
14391438
));
14401439
}
14411440

@@ -1458,14 +1457,13 @@ QAST::OperationsJAST.add_core_op('callmethod', -> $qastcomp, $node {
14581457
$*STACK.spill_to_locals($il);
14591458

14601459
# Emit the call.
1460+
nqp::unshift(@argstuff[2], 'I');
1461+
$il.append(JAST::PushIndex.new( :value($cs_idx) ));
14611462
$il.append($ALOAD_1);
14621463
$*STACK.obtain($il, |@argstuff[1]) if @argstuff[1];
14631464
$il.append(JAST::InvokeDynamic.new(
1464-
'indmethcall', 'V', @argstuff[2],
1465-
'org/perl6/nqp/runtime/IndyBootstrap', 'indmethcall',
1466-
[
1467-
JAST::PushIndex.new( :value($cs_idx) )
1468-
]
1465+
'indmethcall_noa', 'V', @argstuff[2],
1466+
'org/perl6/nqp/runtime/IndyBootstrap', 'indmethcall_noa'
14691467
));
14701468
}
14711469

@@ -3885,14 +3883,12 @@ class QAST::CompilerJAST {
38853883
my $handle := nqp::scgethandle($sc);
38863884
my $idx := nqp::scgetobjidx($sc, $val);
38873885
my $il := JAST::InstructionList.new();
3886+
$il.append(JAST::PushSVal.new( :value($handle) ));
3887+
$il.append(JAST::PushIndex.new( :value($idx) ));
38883888
$il.append($ALOAD_1);
38893889
$il.append(JAST::InvokeDynamic.new(
3890-
'wval', $TYPE_SMO, [$TYPE_TC],
3891-
'org/perl6/nqp/runtime/IndyBootstrap', 'wval',
3892-
[
3893-
JAST::PushSVal.new( :value($handle) ),
3894-
JAST::PushIVal.new( :value($idx) )
3895-
]
3890+
'wval_noa', $TYPE_SMO, [$TYPE_STR, 'I', $TYPE_TC],
3891+
'org/perl6/nqp/runtime/IndyBootstrap', 'wval_noa'
38963892
));
38973893
result($il, $RT_OBJ);
38983894
}

0 commit comments

Comments
 (0)