[
https://issues.apache.org/jira/browse/GROOVY-12138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18094444#comment-18094444
]
ASF GitHub Bot commented on GROOVY-12138:
-----------------------------------------
paulk-asert opened a new pull request, #2674:
URL: https://github.com/apache/groovy/pull/2674
Property writes were the last un-cached dispatch surface: even in indy mode
they compiled to static ScriptBytecodeAdapter.setProperty calls, paying
getMetaClass() plus a full MetaClassImpl.setProperty resolution walk on every
write, in both indy and classic modes.
Behind the compile-time flag groovy.indy.setproperty (default: off),
AsmClassGenerator now diverts plain (non-safe, non-spread) property writes to a
new CallSiteWriter.makeSetPropertySite hook. The default implementation is the
classic adapter call, so classic mode and flag-off builds are unchanged;
IndyCallSiteWriter overrides it to emit invokedynamic
setProperty:(ReceiverType, ValueType)V with the receiver first, preserving the
runtime's arguments[0]-is-receiver invariant.
The new SetPropertySelector (replacing the 'not supported' GroovyBugError
for CallType.SET) fast-paths only shapes whose resolution is provably sender-
and metaclass-independent: a public setter whose backing field is private or
absent (GROOVY-8283 field-precedence is sender-dependent), or a public
non-final field, each accepting the runtime value type directly. Everything
else — Maps (GROOVY-8065/11367), Class receivers, categories,
overridden/mixed-in/expando setProperty (detected by both a reflection probe
and a metaclass pickMethod probe; ExpandoMetaClass is excluded wholesale,
mirroring the GET selector), value coercion, listeners, propertyMissing — binds
the sender-aware ScriptBytecodeAdapter.setProperty as the call-site handle,
making non-fast-path behavior identical to the classic path by construction.
Guards, PIC, and hit-count promotion come free from the existing call-site
machinery; the value participates in the argument-class guards so type changes
at a site re-select correctly.
Measured: ~42x on a hot property-write loop (6M mixed setter/field writes:
~435ms -> ~10ms, written state consumed and verified). Full root test suite
(15678 tests) passes with the flag enabled for all test-code compilation; a
12-scenario semantic stress produces identical output compiled with and without
the flag.
> emit invokedynamic call sites for property writes
> -------------------------------------------------
>
> Key: GROOVY-12138
> URL: https://issues.apache.org/jira/browse/GROOVY-12138
> Project: Groovy
> Issue Type: Improvement
> Reporter: Paul King
> Priority: Major
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)