From fe34477624b40696b66e6e79b0a996f6c2ac6e7a Mon Sep 17 00:00:00 2001 From: Jeremy Studer Date: Tue, 29 May 2018 22:20:38 -0400 Subject: [PATCH] Use BitSet to represent JVM IsHllInit values It would be really inefficient to use an array to record whether the hll statevar is init when only one bit is needed (per lexical), especially when there are a large amount of lexicals. Record in a BitSet instead. --- src/vm/jvm/runtime/org/perl6/nqp/runtime/CallFrame.java | 3 ++- src/vm/jvm/runtime/org/perl6/nqp/runtime/CodeRef.java | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/vm/jvm/runtime/org/perl6/nqp/runtime/CallFrame.java b/src/vm/jvm/runtime/org/perl6/nqp/runtime/CallFrame.java index 7a9692b365..1257072a48 100644 --- a/src/vm/jvm/runtime/org/perl6/nqp/runtime/CallFrame.java +++ b/src/vm/jvm/runtime/org/perl6/nqp/runtime/CallFrame.java @@ -1,5 +1,6 @@ package org.perl6.nqp.runtime; +import java.util.BitSet; import java.util.HashMap; import org.perl6.nqp.sixmodel.InvocationSpec; @@ -149,7 +150,7 @@ public CallFrame(ThreadContext tc, CodeRef cr) { case 2: if (cr.oLexState == null) { cr.oLexState = new SixModelObject[sci.oLexStatic.length]; - cr.oLexStateIsHllInit = new boolean[sci.oLexStatic.length]; + cr.oLexStateIsHllInit = new BitSet(sci.oLexStatic.length); this.stateInit = true; } if (cr.oLexState[i] == null) diff --git a/src/vm/jvm/runtime/org/perl6/nqp/runtime/CodeRef.java b/src/vm/jvm/runtime/org/perl6/nqp/runtime/CodeRef.java index c17c37b962..b80e84519d 100644 --- a/src/vm/jvm/runtime/org/perl6/nqp/runtime/CodeRef.java +++ b/src/vm/jvm/runtime/org/perl6/nqp/runtime/CodeRef.java @@ -1,6 +1,8 @@ package org.perl6.nqp.runtime; import java.lang.invoke.MethodHandle; +import java.util.BitSet; + import org.perl6.nqp.sixmodel.SixModelObject; /** @@ -41,7 +43,7 @@ public class CodeRef extends SixModelObject { /** * Has the given statevar been assigned a value by the HLL? */ - public boolean[] oLexStateIsHllInit; + public BitSet oLexStateIsHllInit; /** * The (human-readable) name of the code-ref (not in staticInfo as a