Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
first stab at implementing scdisclaim for jvm
  • Loading branch information
FROGGS committed May 17, 2015
1 parent 2844001 commit e7b8aef
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/vm/jvm/QAST/Compiler.nqp
Expand Up @@ -2282,6 +2282,7 @@ QAST::OperationsJAST.map_classlib_core_op('scwbenable', $TYPE_OPS, 'scwbenable',
QAST::OperationsJAST.map_classlib_core_op('pushcompsc', $TYPE_OPS, 'pushcompsc', [$RT_OBJ], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('popcompsc', $TYPE_OPS, 'popcompsc', [], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('neverrepossess', $TYPE_OPS, 'neverrepossess', [$RT_OBJ], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('scdisclaim', $TYPE_OPS, 'scdisclaim', [$RT_OBJ], $RT_OBJ, :tc);

# bitwise opcodes
QAST::OperationsJAST.map_classlib_core_op('bitor_i', $TYPE_OPS, 'bitor_i', [$RT_INT, $RT_INT], $RT_INT);
Expand Down
12 changes: 12 additions & 0 deletions src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java
Expand Up @@ -4334,6 +4334,18 @@ public static SixModelObject neverrepossess(SixModelObject obj, ThreadContext tc
tc.gc.neverRepossess.put(obj, null);
return obj;
}
public static SixModelObject scdisclaim(SixModelObject scRef, ThreadContext tc) {
if (scRef instanceof SCRefInstance) {
SerializationContext sc = ((SCRefInstance)scRef).referencedSC;
sc.disclaimObjects();
sc.disclaimSTables();
sc.disclaimCodes();
return scRef;
}
else {
throw ExceptionHandling.dieInternal(tc, "scdisclaim was not passed a valid SCRef");
}
}

/* SC write barriers (not really ops, but putting them here with the SC
* related bits). */
Expand Down
Expand Up @@ -168,4 +168,23 @@ public CodeRef getCodeRef(int index) {
public int coderefCount() {
return root_codes.size();
}

public void disclaimObjects() {
for (SixModelObject obj : this.root_objects) {
obj.sc = null;
}
this.root_objects = new ArrayList<SixModelObject>();
}
public void disclaimSTables() {
for (STable stable : this.root_stables) {
stable.sc = null;
}
this.root_stables = new ArrayList<STable>();
}
public void disclaimCodes() {
for (CodeRef obj : this.root_codes) {
obj.sc = null;
}
this.root_codes = new ArrayList<CodeRef>();
}
}

0 comments on commit e7b8aef

Please sign in to comment.