Skip to content

Commit 70b689a

Browse files
committed
Add object allocator, externally expose allocators
1 parent e7cb045 commit 70b689a

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/main/java/myworld/hummingbird/HummingbirdVM.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package myworld.hummingbird;
22

3+
import myworld.hummingbird.util.BitFieldAllocator;
34
import myworld.hummingbird.util.TrackingAllocator;
45

56
import java.util.*;
@@ -13,14 +14,18 @@ public final class HummingbirdVM {
1314
public static final int YIELD_INTERPRETER_CONTROL = -Integer.MAX_VALUE;
1415

1516
private final Executable exe;
16-
private Allocator allocator;
17+
public final ForeignFunction[] foreign;
18+
1719
public MemoryLimits limits;
1820
private int[] memory;
21+
private Allocator allocator;
1922
private Object[] objMemory;
23+
private BitFieldAllocator objAllocator;
24+
2025
private Fiber currentFiber;
21-
private List<Function<Throwable, Integer>> trapCodes;
2226
private final Deque<Fiber> runQueue;
23-
public final ForeignFunction[] foreign;
27+
28+
private List<Function<Throwable, Integer>> trapCodes;
2429

2530
private DebugHandler debugHandler;
2631

@@ -36,6 +41,7 @@ public HummingbirdVM(Executable exe, MemoryLimits limits) {
3641

3742
memory = new int[limits.words()];
3843
objMemory = new Object[limits.objects()];
44+
objAllocator = new BitFieldAllocator(limits.objects());
3945

4046
runQueue = new LinkedList<>();
4147
trapCodes = new ArrayList<>();
@@ -81,6 +87,14 @@ public Symbol findForeignFunction(String name, TypeFlag rType){
8187
return null;
8288
}
8389

90+
public Allocator getAllocator(){
91+
return allocator;
92+
}
93+
94+
public BitFieldAllocator getObjAllocator(){
95+
return objAllocator;
96+
}
97+
8498
public Object run(){
8599
return run(null, null);
86100
}

0 commit comments

Comments
 (0)