Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Tag compile-time stubs so we don't try and serialize their outer (whi…
…ch is the create_code_object method in World).
  • Loading branch information
jnthn committed Feb 26, 2012
1 parent 5bc64cc commit 5fb6c0b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/Perl6/Metamodel/BOOTSTRAP.pm
Expand Up @@ -490,6 +490,10 @@ BEGIN {
Code.HOW.add_method(Code, 'clone', static(sub ($self) {
my $dcself := pir::perl6_decontainerize__PP($self);
my $cloned := pir::repr_clone__PP($dcself);
nqp::bindattr($cloned, Code, '$!do',
pir::perl6_associate_sub_code_object__0PP(
pir::clone__PP(nqp::getattr($dcself, Code, '$!do')),
$cloned));
Q:PIR {
$P0 = find_lex '$dcself'
$P1 = find_lex 'Code'
Expand All @@ -500,10 +504,7 @@ BEGIN {
$P1($P0, $P2)
no_callback:
};
pir::setattribute__0PPSP($cloned, Code, '$!do',
pir::perl6_associate_sub_code_object__0PP(
pir::clone__PP(nqp::getattr($dcself, Code, '$!do')),
$cloned))
$cloned
}));
Code.HOW.add_method(Code, 'derive_dispatcher', static(sub ($self) {
my $clone := $self.clone();
Expand Down Expand Up @@ -561,6 +562,10 @@ BEGIN {
Block.HOW.add_method(Block, 'clone', static(sub ($self) {
my $dcself := pir::perl6_decontainerize__PP($self);
my $cloned := pir::repr_clone__PP($dcself);
nqp::bindattr($cloned, Code, '$!do',
pir::perl6_associate_sub_code_object__0PP(
pir::clone__PP(nqp::getattr($dcself, Code, '$!do')),
$cloned));
Q:PIR {
$P0 = find_lex '$dcself'
$P1 = find_lex 'Code'
Expand All @@ -572,10 +577,7 @@ BEGIN {
no_callback:
};
pir::setattribute__0PPSP($cloned, Block, '$!state_vars', nqp::null());
pir::setattribute__0PPSP($cloned, Code, '$!do',
pir::perl6_associate_sub_code_object__0PP(
pir::clone__PP(nqp::getattr($dcself, Code, '$!do')),
$cloned))
$cloned
}));

# class Routine is Block { ... }
Expand Down
12 changes: 12 additions & 0 deletions src/Perl6/World.pm
Expand Up @@ -612,9 +612,21 @@ class Perl6::World is HLL::World {

# Tag it as a static code ref and add it to the root code refs set.
pir::setprop__vPsP($stub, 'STATIC_CODE_REF', $stub);
pir::setprop__vPsP($stub, 'COMPILER_STUB', $stub);
my $code_ref_idx := self.add_root_code_ref($stub, $code_past);
%!sub_id_to_sc_idx{$code_past.subid()} := $code_ref_idx;

# If we clone the stub, need to mark it as a dynamic compilation
# boundary.
if self.is_precompilation_mode() {
my $clone_handler := sub ($orig, $clone) {
my $do := nqp::getattr($clone, $code_type, '$!do');
pir::setprop__vPsP($do, 'COMPILER_STUB', $do);
pir::setprop__vPsP($do, 'CLONE_CALLBACK', $clone_handler);
};
pir::setprop__vPsP($stub, 'CLONE_CALLBACK', $clone_handler);
}

# Fixup will install the real thing, unless we're in a role, in
# which case pre-comp will have sorted it out.
unless $*PKGDECL eq 'role' {
Expand Down

0 comments on commit 5fb6c0b

Please sign in to comment.