Skip to content
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

Merged
merged 1 commit into from
Jan 23, 2018

Conversation

obastemur
Copy link
Collaborator

No description provided.

@@ -143,7 +143,9 @@ namespace Js
this->propertyString = propStr;
if (propStr != nullptr)
{
this->propertyRecord = propStr->GetPropertyRecord();
Js::PropertyRecord const * localPropertyRecord;
propStr->GetPropertyRecord(&localPropertyRecord);
Copy link
Contributor

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)?

Copy link
Collaborator Author

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

Copy link
Contributor

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?

Copy link
Contributor

@jackhorton jackhorton left a 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?

@@ -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
Copy link
Contributor

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?

*propRecord = this->propertyRecord;
}

virtual Js::PropertyId GetPropertyId() override
Copy link
Contributor

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();
Copy link
Contributor

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For PropertyString?

@obastemur obastemur force-pushed the props_swb branch 4 times, most recently from 4f609f4 to 18f88ca Compare January 19, 2018 23:56
@obastemur
Copy link
Collaborator Author

@jianchun please review.

// WARNING: This will return false for PropertyStrings that are actually InternalPropertyIds
Assert(!PropertyString::Is(key) || !IsInternalPropertyId(((PropertyString*)key)->GetPropertyRecord()->GetPropertyId()));
Copy link

@jianchun jianchun Jan 20, 2018

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.

@@ -143,7 +143,10 @@ namespace Js
this->propertyString = propStr;
if (propStr != nullptr)
{
this->propertyRecord = propStr->GetPropertyRecord();
// why use local variable ? read SWB wiki

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(...).

@obastemur
Copy link
Collaborator Author

@MSLaguana @jackhorton @jianchun Thanks for the review!

@chakrabot chakrabot merged commit 3677469 into chakra-core:release/1.8 Jan 23, 2018
chakrabot pushed a commit that referenced this pull request Jan 23, 2018
…the record life time

Merge pull request #4580 from obastemur:props_swb
chakrabot pushed a commit that referenced this pull request Jan 24, 2018
… preserve the record life time

Merge pull request #4580 from obastemur:props_swb
chakrabot pushed a commit that referenced this pull request Jan 24, 2018
… interface to preserve the record life time

Merge pull request #4580 from obastemur:props_swb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants