Skip to content

Commit

Permalink
[jvm] Split large synthesized heap initialization method at proper bo…
Browse files Browse the repository at this point in the history
…undary (#284)
  • Loading branch information
titzer authored Oct 1, 2024
1 parent 19c58e1 commit 581bf4d
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 178 deletions.
15 changes: 13 additions & 2 deletions aeneas/src/jvm/JvmBuilder.v3
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class JvmClassfileBuilder(jprog: JvmProgram, jclass: JvmClass) {
file.this_class = newClassref(jclass.name);
file.super_class = newClassref(jclass.superName);
}
def emitValue(code: JvmCodeBuilder, etype: Type, val: Val) -> int {
return jprog.jheap.emitValue(code, etype, val);
def emitValue(code: JvmCodeBuilder, etype: Type, val: Val) {
jprog.jheap.emitValue(code, etype, val);
}
def newField(name: string, desc: string) -> JvmField {
var fld = JvmField.new(newUtf8(name), newUtf8(desc));
Expand Down Expand Up @@ -572,4 +572,15 @@ class JvmCodeBuilder(builder: JvmClassfileBuilder) {
iconst(64 - width);
binop(JvmBytecode.LUSHR);
}
//------- helper routines -----------------------------------------
def splitAt(pos: int) -> JvmCodeBuilder {
var n = JvmCodeBuilder.new(builder);
n.code = Arrays.range(code, pos, cur_pos);
n.cur_stack = cur_stack;
n.max_locals = max_locals;
n.max_stack = max_stack;
n.cur_pos = n.code.length;
cur_pos = pos;
return n;
}
}
3 changes: 3 additions & 0 deletions aeneas/src/jvm/JvmGen.v3
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class JvmProgram(compiler: Compiler, prog: Program) {
if (prog.getMain() != null) jvmType(prog.getMain().receiver);
prog.ir.classes.apply(processIrClass);
var pos = Vectors.drain(classQueue, 0, JvmClassGen.build);
context.method = null;
context.block = null;
context.graph = null;
jheap.emit();
Vectors.drain(classQueue, pos, JvmClassGen.build);
classQueue.apply(JvmClassGen.emit);
Expand Down
Loading

0 comments on commit 581bf4d

Please sign in to comment.