-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Update PropertyRecord interface to preserve the record life time #4580
Conversation
@@ -143,7 +143,9 @@ namespace Js | |||
this->propertyString = propStr; | |||
if (propStr != nullptr) | |||
{ | |||
this->propertyRecord = propStr->GetPropertyRecord(); | |||
Js::PropertyRecord const * localPropertyRecord; | |||
propStr->GetPropertyRecord(&localPropertyRecord); |
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.
Why the local variable here, rather than passing in &(this->propertyRecord)
?
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.
That wouldn't trigger SWB operator
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.
Ah I see, makes sense. Could you please add a comment there so it doesn't get "cleaned up" later?
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.
There is a lot of indirection that got removed in this PR. Is there any perf gain that you're aware of/expecting?
lib/Runtime/Library/ConcatString.h
Outdated
@@ -13,7 +13,40 @@ namespace Js | |||
Field(const Js::PropertyRecord*) propertyRecord; | |||
|
|||
public: | |||
virtual Js::PropertyRecord const * GetPropertyRecord(bool dontLookupFromDictionary = false) override; | |||
virtual void GetPropertyRecord(_Out_ PropertyRecord const** propRecord, bool dontLookupFromDictionary = false) override |
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.
Any reason why this moved to the header?
lib/Runtime/Library/ConcatString.h
Outdated
*propRecord = this->propertyRecord; | ||
} | ||
|
||
virtual Js::PropertyId GetPropertyId() override |
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.
Is this override needed if you've got the same code on Js::JavascriptString
?
|
||
return propertyRecord; | ||
Assert(propertyRecord != nullptr); | ||
return propertyRecord->GetPropertyId(); |
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.
The propertyRecord could still be collected after this GetPropertyId() and propertyId becomes invalid, right?
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.
For PropertyString?
4f609f4
to
18f88ca
Compare
@jianchun please review. |
// WARNING: This will return false for PropertyStrings that are actually InternalPropertyIds | ||
Assert(!PropertyString::Is(key) || !IsInternalPropertyId(((PropertyString*)key)->GetPropertyRecord()->GetPropertyId())); |
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.
!IsInternalPropertyId(((PropertyString*)key)->GetPropertyRecord()->GetPropertyId()) [](start = 43, length = 83)
nit: Since in this ||
branch key is PropertyString, can be simplified to !IsInternalPropertyId(((PropertyString*)key)->GetPropertyId())
, keeping original one line ASSERT.
lib/Runtime/Library/ConcatString.cpp
Outdated
@@ -143,7 +143,10 @@ namespace Js | |||
this->propertyString = propStr; | |||
if (propStr != nullptr) | |||
{ | |||
this->propertyRecord = propStr->GetPropertyRecord(); | |||
// why use local variable ? read SWB wiki |
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.
nit: This comment isn't really helpful. No comment is ok -- any reader interested or doubtful could easily find out there is a type mismatch between "this->propertyRecord" vs. "->GetPropertyRecord(...).
@MSLaguana @jackhorton @jianchun Thanks for the review! |
…the record life time Merge pull request #4580 from obastemur:props_swb
… preserve the record life time Merge pull request #4580 from obastemur:props_swb
… interface to preserve the record life time Merge pull request #4580 from obastemur:props_swb
No description provided.