Strict parse Liquid::Variable.new objects to a Liquid::C::Expression#111
Strict parse Liquid::Variable.new objects to a Liquid::C::Expression#111dylanahsmith merged 3 commits intomasterfrom
Conversation
| .parse_context = parse_context, | ||
| }; | ||
| try_variable_strict_parse((VALUE)&parse_args); | ||
| RB_GC_GUARD(markup); |
There was a problem hiding this comment.
I'm not sure why this is needed. How is markup at risk of being GC'd?
There was a problem hiding this comment.
isn't needed before try_variable_strict_parse is called, so the markup local variable could get re-used by the compiler and remove the reference to the object from the C stack. If the only reference to the markup object were passed into this method, then in theory, it seems like the GC could end up cleanup the string before we are done using it.
It probably isn't needed in practice, but it makes the code more obviously correct.
There was a problem hiding this comment.
Thanks for clarifying!
macournoyer
left a comment
There was a problem hiding this comment.
🤯
Just unsure about that push_nil at the end.
|
|
||
| if (p.cur.type == TOKEN_EOS) | ||
| if (p.cur.type == TOKEN_EOS) { | ||
| vm_assembler_add_push_nil(code); |
There was a problem hiding this comment.
Not sure I understand why you need to push nil here? Is it to make an empty variable leave something on the stack? Since expressions must always return a value.
There was a problem hiding this comment.
Yeah, we need something left on the stack since it will be followed by a pop to get the return value
Strict parse Liquid::Variable.new objects to a Liquid::C::Expression (cherry picked from commit ea85e64)
This solves the problem that #96 intended to solve in a simpler way, so that PR can be focused on introducing support for compiling tags to VM code. Instead, this PR compiles the variable expression and filtering into a
Liquid::C::Expressionobject that is stored in theLiquid::Variableobject's@nameinstance variable, which will be evaluated on render.Benchmark
The liquid benchmark only uses the assign tag
{% assign article = pages.frontpage %}and doesn't use the echo tag, so the benchmark is mostly for unaffected code. However, I wrote a micro-benchmark that shows the performance improvementresult on master
result on this branch