New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Call*Node#*name use the constant pool #1533
Conversation
eregon
commented
Sep 16, 2023
- Part of Some type: string fields should be type: constant #1530
d06e2cd
to
8926bcf
Compare
I have rebased this.
We also see |
9e6d042
to
59e0d61
Compare
OK I found the issue, the problem was: pm_call_and_write_node_create(pm_parser_t *parser, pm_call_node_t *target, const pm_token_t *operator, pm_node_t *value) {
...
*node = (pm_call_and_write_node_t) {
...
.write_name = target->name, And the C compiler says nothing here, even though it's assigning a pm_constant_id_t=uint32_t to a pm_string_t (a struct with 3 fields). WTF! It turns out if I change |
59e0d61
to
6cf2e5a
Compare
OK this is ready for review.
|
pm_parser_constant_id_static(pm_parser_t *parser, const char *start, size_t length) { | ||
uint8_t *owned_copy; | ||
if (length > 0) { | ||
owned_copy = malloc(length); | ||
memcpy(owned_copy, start, length); | ||
} else { | ||
owned_copy = malloc(1); | ||
owned_copy[0] = '\0'; | ||
} | ||
return pm_constant_pool_insert_owned(&parser->constant_pool, owned_copy, length); | ||
// Does not work because the static literal cannot be serialized as an offset of source | ||
// return pm_constant_pool_insert_shared(&parser->constant_pool, start, length); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think once we always serialize all constants as embedded then we can simplify this and actually use the C literal string pointer without copying, because then we only need start+offset, and don't care if that's within the source or not when serializing.
CI is green now, after ruby-head has been rebuilt with the latest fixes. |
I also made the PR to adopt the change in CRuby: ruby/ruby#8573 |