Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Decontainerize a little earlier in scalar assignment, so that the val…
…ue type check will actually work from the correct type check cache, rather than creating an inferior runloop to do the type check. Should very significantly speed up every $a = $b.
  • Loading branch information
jnthn committed Jul 9, 2011
1 parent e66e95f commit f583316
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/binder/container.c
Expand Up @@ -54,6 +54,7 @@ void Rakudo_cont_store(PARROT_INTERP, PMC *cont, PMC *value,
/* If it's a scalar container, optimized path. */
if (STABLE(cont)->WHAT == scalar_type) {
Rakudo_Scalar *scalar = (Rakudo_Scalar *)PMC_data(cont);
PMC *value_decont = Rakudo_cont_decontainerize(interp, value);
if (rw_check) {
INTVAL rw = 0;
if (!PMC_IS_NULL(scalar->descriptor))
Expand All @@ -67,11 +68,11 @@ void Rakudo_cont_store(PARROT_INTERP, PMC *cont, PMC *value,
INTVAL ok = 0;
if (!PMC_IS_NULL(scalar->descriptor)) {
Rakudo_ContainerDescriptor *desc = ((Rakudo_ContainerDescriptor *)PMC_data(scalar->descriptor));
ok = STABLE(value)->type_check(interp, value, desc->of);
ok = STABLE(value_decont)->type_check(interp, value_decont, desc->of);
if (!ok) {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Type check failed in assignment to '%S'; expected '%S' but got '%S'",
desc->name, typename(interp, desc->of), typename(interp, value));
desc->name, typename(interp, desc->of), typename(interp, value_decont));
}
}
else {
Expand All @@ -87,7 +88,7 @@ void Rakudo_cont_store(PARROT_INTERP, PMC *cont, PMC *value,
}

/* If we get here, all is fine; store the value. */
scalar->value = Rakudo_cont_decontainerize(interp, value);
scalar->value = value_decont;
PARROT_GC_WRITE_BARRIER(interp, cont);
}

Expand Down

0 comments on commit f583316

Please sign in to comment.