-
-
Notifications
You must be signed in to change notification settings - Fork 560
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
PropertyDescriptor improvements #1648
PropertyDescriptor improvements #1648
Conversation
add PropertyFlag.NonData now PropertyDescriptor's for Clr Field, Property and Indexer are accessor property descriptors
Here is a test, which fail in the main branch current: class TestClass
{
public static readonly TestClass Instance = new TestClass();
private int x = 1;
public int PropertySideEffect => x++;
}
[Fact]
public void ClrPropertySideEffect()
{
_engine.SetValue("testClass", TestClass.Instance);
_engine.Execute("""
const handler = {
get(target, property, receiver) {
return 2; // the same value to second call, make data property check happy
}
};
const p = new Proxy(testClass, handler);
""");
Assert.Equal(1, TestClass.Instance.PropertySideEffect); // first call to PropertySideEffect
Assert.Equal(2, _engine.Evaluate("p.PropertySideEffect").AsInteger()); // no call to PropertySideEffect
Assert.Equal(2, TestClass.Instance.PropertySideEffect); // second call to PropertySideEffect
} |
IMO, class PropertyDescriptor {
public bool CustomJsValue => false;
public bool NonData=> false;
}
class ReflectionDescriptor {
public bool CustomJsValue => true;
public bool NonData=> true;
} |
So if this is about performance (and to validate there's not regressions), could you show show some benchmark results before/after? |
It's not about performance mainly. It changed the behavior by making CLR Property and Indexer to be js accessor descriptor instead of data descriptor. So, the I think It's maybe a problem that CLR Field is also js accessor descriptor now. |
property-descriptor-nondata 64ee20f
main 8ebdc34
|
Generally we can't tell much about performance by reading test run timings, there's a lot more going on there. But this seems quite safe and covered with tests, thank you for your contribution. |
PropertyDescriptor improvements
add
PropertyFlag.NonData
now
PropertyDescriptor
s for CLR Field, Property and Indexer are accessor property descriptors.By treating CLR Property as accessor property, it will reduce the time of call to Property Getter.