Skip to content

Commit 06dd701

Browse files
committed
Compile methods as static methods taking CompilationUnit rather than instance
This means that all methods for which MethodHandles are generated have types that do not mention dynamically generated types, so the intern table in MethodType does not indefinitely hold references to our classes (and indirectly, GlobalContexts and everything in them).
1 parent 5722e28 commit 06dd701

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/vm/jvm/QAST/Compiler.nqp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3054,7 +3054,7 @@ class QAST::CompilerJAST {
30543054
# Create JAST method and register it with the block's compilation unit
30553055
# unique ID and name. (Note, always void return here as return values
30563056
# are handled out of band).
3057-
my $*JMETH := JAST::Method.new( :name(self.unique('qb_')), :returns('Void'), :static(0) );
3057+
my $*JMETH := JAST::Method.new( :name(self.unique('qb_')), :returns('Void'), :static(1) );
30583058
$*JMETH.cr_name($node.name);
30593059
$*JMETH.cr_cuid($node.cuid);
30603060
$*CODEREFS.register_method($*JMETH, $node.cuid);
@@ -3065,6 +3065,7 @@ class QAST::CompilerJAST {
30653065
}
30663066

30673067
# Always take ThreadContext and callsite descriptor as arguments.
3068+
$*JMETH.add_argument('cu', $TYPE_CU);
30683069
$*JMETH.add_argument('tc', $TYPE_TC);
30693070
$*JMETH.add_argument('cr', $TYPE_CR);
30703071
$*JMETH.add_argument('csd', $TYPE_CSD);
@@ -3298,7 +3299,7 @@ class QAST::CompilerJAST {
32983299
# don't save/reload the resume pointer (could get messy :p) or the thread context (restored separately since we can change threads)
32993300
# or the callframe (can also change)
33003301
# also self doesn't get saved/restored, but that's OK because the resume handle is primed with it.
3301-
for $*JMETH.arguments { nqp::push(@merged, $_) unless $_[0] eq 'resume' || $_[0] eq 'tc' }
3302+
for $*JMETH.arguments { nqp::push(@merged, $_) unless $_[0] eq 'resume' || $_[0] eq 'tc' || $_[0] eq 'cu' }
33023303
for $*JMETH.locals { nqp::push(@merged, $_) unless $_[0] eq 'cf' }
33033304

33043305
my int $i := 0;
@@ -3409,10 +3410,10 @@ class QAST::CompilerJAST {
34093410
$il.append($ACONST_NULL);
34103411

34113412
# Emit the virtual call.
3412-
$il.append(savesite(JAST::Instruction.new( :op('invokevirtual'),
3413+
$il.append(savesite(JAST::Instruction.new( :op('invokestatic'),
34133414
'L' ~ $*JCLASS.name ~ ';',
34143415
$*CODEREFS.cuid_to_jastmethname($node.cuid),
3415-
'V', $TYPE_TC, $TYPE_CR, $TYPE_CSD, "[$TYPE_OBJ", $TYPE_RESUME )));
3416+
'V', $TYPE_CU, $TYPE_TC, $TYPE_CR, $TYPE_CSD, "[$TYPE_OBJ", $TYPE_RESUME )));
34163417

34173418
# Load result onto the stack, unless in void context.
34183419
if $*WANT != $RT_VOID {

0 commit comments

Comments
 (0)