Skip to content

Commit

Permalink
Make all versions of die opcode resumable
Browse files Browse the repository at this point in the history
die_s and die_p both were resumable, but die_i_i wasn't.  Finding no
particular reason that should be the case, I made them consistent.
The three opcodes now share a lot of code.  Perhaps a common function
should be factored out?
  • Loading branch information
Benabik committed Aug 25, 2011
1 parent 2b8c29e commit 431c51a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/ops/core.ops
Expand Up @@ -811,10 +811,16 @@ inline op die(in INT, in INT) :flow {
if ($1 == EXCEPT_doomed)
_exit($2);
else {
opcode_t *dest;
opcode_t * const ret = expr NEXT();
PMC * const resume = pmc_new(interp, enum_class_Continuation);
PMC * const exception = Parrot_ex_build_exception(interp, $1, $2, NULL);
opcode_t * const dest = Parrot_ex_throw_from_op(interp, exception, ret);

VTABLE_set_pointer(interp, resume, ret);

VTABLE_set_attr_str(interp, exception,
Parrot_str_new_constant(interp, "resume"), resume);
dest = Parrot_ex_throw_from_op(interp, exception, ret);
goto ADDRESS(dest);
}
}
Expand Down
24 changes: 20 additions & 4 deletions src/ops/core_ops.c
Expand Up @@ -13748,10 +13748,14 @@ Parrot_die_i_i(opcode_t *cur_opcode, PARROT_INTERP) {
_exit(IREG(2));
}
else {
opcode_t * dest;
opcode_t * const ret = cur_opcode + 3;
PMC * const resume = pmc_new(interp, enum_class_Continuation);
PMC * const exception = Parrot_ex_build_exception(interp, IREG(1), IREG(2), NULL);
opcode_t * const dest = Parrot_ex_throw_from_op(interp, exception, ret);

VTABLE_set_pointer(interp, resume, ret);
VTABLE_set_attr_str(interp, exception, Parrot_str_new_constant(interp, "resume"), resume);
dest = Parrot_ex_throw_from_op(interp, exception, ret);
return (opcode_t *)dest;
}

Expand All @@ -13763,10 +13767,14 @@ Parrot_die_ic_i(opcode_t *cur_opcode, PARROT_INTERP) {
_exit(IREG(2));
}
else {
opcode_t * dest;
opcode_t * const ret = cur_opcode + 3;
PMC * const resume = pmc_new(interp, enum_class_Continuation);
PMC * const exception = Parrot_ex_build_exception(interp, ICONST(1), IREG(2), NULL);
opcode_t * const dest = Parrot_ex_throw_from_op(interp, exception, ret);

VTABLE_set_pointer(interp, resume, ret);
VTABLE_set_attr_str(interp, exception, Parrot_str_new_constant(interp, "resume"), resume);
dest = Parrot_ex_throw_from_op(interp, exception, ret);
return (opcode_t *)dest;
}

Expand All @@ -13778,10 +13786,14 @@ Parrot_die_i_ic(opcode_t *cur_opcode, PARROT_INTERP) {
_exit(ICONST(2));
}
else {
opcode_t * dest;
opcode_t * const ret = cur_opcode + 3;
PMC * const resume = pmc_new(interp, enum_class_Continuation);
PMC * const exception = Parrot_ex_build_exception(interp, IREG(1), ICONST(2), NULL);
opcode_t * const dest = Parrot_ex_throw_from_op(interp, exception, ret);

VTABLE_set_pointer(interp, resume, ret);
VTABLE_set_attr_str(interp, exception, Parrot_str_new_constant(interp, "resume"), resume);
dest = Parrot_ex_throw_from_op(interp, exception, ret);
return (opcode_t *)dest;
}

Expand All @@ -13793,10 +13805,14 @@ Parrot_die_ic_ic(opcode_t *cur_opcode, PARROT_INTERP) {
_exit(ICONST(2));
}
else {
opcode_t * dest;
opcode_t * const ret = cur_opcode + 3;
PMC * const resume = pmc_new(interp, enum_class_Continuation);
PMC * const exception = Parrot_ex_build_exception(interp, ICONST(1), ICONST(2), NULL);
opcode_t * const dest = Parrot_ex_throw_from_op(interp, exception, ret);

VTABLE_set_pointer(interp, resume, ret);
VTABLE_set_attr_str(interp, exception, Parrot_str_new_constant(interp, "resume"), resume);
dest = Parrot_ex_throw_from_op(interp, exception, ret);
return (opcode_t *)dest;
}

Expand Down

0 comments on commit 431c51a

Please sign in to comment.