Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Debreak build; need to pass coderef heap size to deserialize so a pro…
…per prefix can be taken
  • Loading branch information
sorear committed Jun 21, 2013
1 parent f18cb70 commit c51de3f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/vm/jvm/QAST/Compiler.nqp
Expand Up @@ -2016,7 +2016,7 @@ QAST::OperationsJAST.map_classlib_core_op('scobjcount', $TYPE_OPS, 'scobjcount',
QAST::OperationsJAST.map_classlib_core_op('setobjsc', $TYPE_OPS, 'setobjsc', [$RT_OBJ, $RT_OBJ], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('getobjsc', $TYPE_OPS, 'getobjsc', [$RT_OBJ], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('serialize', $TYPE_OPS, 'serialize', [$RT_OBJ, $RT_OBJ], $RT_STR, :tc);
QAST::OperationsJAST.map_classlib_core_op('deserialize', $TYPE_OPS, 'deserialize', [$RT_STR, $RT_OBJ, $RT_OBJ, $RT_OBJ, $RT_OBJ], $RT_STR, :tc);
QAST::OperationsJAST.map_classlib_core_op('deserialize', $TYPE_OPS, 'deserialize', [$RT_STR, $RT_OBJ, $RT_OBJ, $RT_INT, $RT_OBJ], $RT_STR, :tc);
QAST::OperationsJAST.map_classlib_core_op('wval', $TYPE_OPS, 'wval', [$RT_STR, $RT_INT], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('scwbdisable', $TYPE_OPS, 'scwbdisable', [], $RT_INT, :tc);
QAST::OperationsJAST.map_classlib_core_op('scwbenable', $TYPE_OPS, 'scwbenable', [], $RT_INT, :tc);
Expand Down Expand Up @@ -2990,7 +2990,7 @@ class QAST::CompilerJAST {
QAST::SVal.new( :value($serialized) ),
QAST::Var.new( :name('cur_sc'), :scope('local') ),
$sh_ast,
QAST::Op.new( :op('null') ),
QAST::IVal.new( :value(+@code_ref_blocks) ),
QAST::Var.new( :name('conflicts'), :scope('local') )
),
QAST::Op.new(
Expand Down
34 changes: 24 additions & 10 deletions src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java
Expand Up @@ -3057,7 +3057,7 @@ public static String serialize(SixModelObject scRef, SixModelObject sh, ThreadCo
throw ExceptionHandling.dieInternal(tc, "serialize was not passed a valid SCRef");
}
}
public static String deserialize(String blob, SixModelObject scRef, SixModelObject sh, SixModelObject cr, SixModelObject conflict, ThreadContext tc) {
public static String deserialize(String blob, SixModelObject scRef, SixModelObject sh, SixModelObject cr, SixModelObject conflict, ThreadContext tc) { /*FOR_STAGE0*/
if (scRef instanceof SCRefInstance) {
SerializationContext sc = ((SCRefInstance)scRef).referencedSC;

Expand All @@ -3067,17 +3067,12 @@ public static String deserialize(String blob, SixModelObject scRef, SixModelObje
shArray[i] = tc.native_s;
}

CodeRef[] crArray;
if (cr == null) {
crArray = tc.curFrame.codeRef.staticInfo.compUnit.qbidToCodeRef;
} else {
crArray = new CodeRef[(int)cr.elems(tc)];
for (int i = 0; i < crArray.length; i++)
crArray[i] = (CodeRef)cr.at_pos_boxed(tc, i);
}
CodeRef[] crArray = new CodeRef[(int)cr.elems(tc)];
for (int i = 0; i < crArray.length; i++)
crArray[i] = (CodeRef)cr.at_pos_boxed(tc, i);

SerializationReader sr = new SerializationReader(
tc, sc, shArray, crArray,
tc, sc, shArray, crArray, crArray.length,
Base64.decode(blob));
sr.deserialize();

Expand All @@ -3087,6 +3082,25 @@ public static String deserialize(String blob, SixModelObject scRef, SixModelObje
throw ExceptionHandling.dieInternal(tc, "deserialize was not passed a valid SCRef");
}
}
public static String deserialize(String blob, SixModelObject scRef, SixModelObject sh, long crCount, SixModelObject conflict, ThreadContext tc) {
if (!(scRef instanceof SCRefInstance))
throw ExceptionHandling.dieInternal(tc, "deserialize was not passed a valid SCRef");

SerializationContext sc = ((SCRefInstance)scRef).referencedSC;

String[] shArray = new String[(int)sh.elems(tc)];
for (int i = 0; i < shArray.length; i++) {
sh.at_pos_native(tc, i);
shArray[i] = tc.native_s;
}

SerializationReader sr = new SerializationReader(
tc, sc, shArray, tc.curFrame.codeRef.staticInfo.compUnit.qbidToCodeRef,
(int)crCount, Base64.decode(blob));
sr.deserialize();

return blob;
}
public static SixModelObject wval(String sc, long idx, ThreadContext tc) {
return tc.gc.scs.get(sc).root_objects.get((int)idx);
}
Expand Down
Expand Up @@ -44,6 +44,7 @@ public class SerializationReader {
private SerializationContext sc;
private String[] sh;
private CodeRef[] cr;
private int crCount;
private CallFrame[] contexts;
private ByteBuffer orig;

Expand Down Expand Up @@ -71,11 +72,12 @@ public class SerializationReader {
SerializationContext[] dependentSCs;

public SerializationReader(ThreadContext tc, SerializationContext sc,
String[] sh, CodeRef[] cr, ByteBuffer orig) {
String[] sh, CodeRef[] cr, int crCount, ByteBuffer orig) {
this.tc = tc;
this.sc = sc;
this.sh = sh;
this.cr = cr;
this.crCount = crCount;
this.orig = orig;
}

Expand All @@ -88,8 +90,7 @@ public void deserialize() {
resolveDependencies();

// Put code refs in place.
for (int i = 0; i < cr.length; i++) {
if (cr[i] == null) break;
for (int i = 0; i < crCount; i++) {
cr[i].isStaticCodeRef = true;
cr[i].sc = sc;
sc.root_codes.add(cr[i]);
Expand Down Expand Up @@ -118,7 +119,7 @@ public void deserialize() {

// Finish up contexts and closures.
deserializeContexts();
attachClosureOuters(cr.length);
attachClosureOuters(crCount);
attachContextOuters();
}

Expand Down

0 comments on commit c51de3f

Please sign in to comment.