Skip to content

Instantly share code, notes, and snippets.

@donaldh
Last active August 29, 2015 14:13
Show Gist options
  • Save donaldh/91a212b38725642131be to your computer and use it in GitHub Desktop.
Save donaldh/91a212b38725642131be to your computer and use it in GitHub Desktop.
Cause of NQPMatch serialization
# ./perl6 --target=jar -o match.jar match.p6
#
# An NQPMatch will be serialized into match.jar
sub f() {
X::NYI.new(feature => 'broken').throw;
}
@donaldh
Copy link
Author

donaldh commented Jan 10, 2015

The root cause of this is that QAST annotations can reference NQPMatch objects and the annotations don't get sanitized when QAST nodes get cloned. This happens during add_inlining_info_if_possible and results in NQPMatch objects being serialized in the setting. The offending annotation in this situation is before_promotion but I guess any annotation that references the AST could be problematic.

@donaldh
Copy link
Author

donaldh commented Jan 10, 2015

Three possible solutions:

  1. Node.shallow_clone() could always clear the annotations.
  2. add_inlining_info_if_possible could clear the annotations.
  3. add_inlining_info_if_possible could copy and sanitize the annotations.

@donaldh
Copy link
Author

donaldh commented Jan 19, 2015

Implemented #2
Before
CORE.setting.jar 2.9M
% jar tvf CORE.setting.jar
25 Mon Jan 19 11:58:26 GMT 2015 META-INF/MANIFEST.MF
10787719 Mon Jan 19 11:58:26 GMT 2015 07E78BB789BE74AF2F60C21C9A44E246EB0613F6.class
8321848 Mon Jan 19 11:58:26 GMT 2015 07E78BB789BE74AF2F60C21C9A44E246EB0613F6.serialized

After
CORE.setting.jar 2.6M
% jar tvf CORE.setting.jar
25 Mon Jan 19 12:03:04 GMT 2015 META-INF/MANIFEST.MF
9176483 Mon Jan 19 12:03:04 GMT 2015 7C526785F6867A079A6061202A27DDB0F8CE8C25.class
8178018 Mon Jan 19 12:03:04 GMT 2015 7C526785F6867A079A6061202A27DDB0F8CE8C25.serialized

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment