Skip to content

Update PropertyRecord interface to preserve the record life time - #4580

Merged
chakrabot merged 1 commit into
chakra-core:release/1.8from
obastemur:props_swb
Jan 23, 2018
Merged

chakrabot merged 1 commit into
chakra-core:release/1.8from
obastemur:props_swb

Conversation

@obastemur

Copy link
Copy Markdown
Collaborator

No description provided.

{
this->propertyRecord = propStr->GetPropertyRecord();
Js::PropertyRecord const * localPropertyRecord;
propStr->GetPropertyRecord(&localPropertyRecord);

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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?

@jackhorton jackhorton left a comment

Copy link
Copy Markdown
Contributor

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?

Comment thread lib/Runtime/Library/ConcatString.h Outdated

public:
virtual Js::PropertyRecord const * GetPropertyRecord(bool dontLookupFromDictionary = false) override;
virtual void GetPropertyRecord(_Out_ PropertyRecord const** propRecord, bool dontLookupFromDictionary = false) override

Copy link
Copy Markdown
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?

Comment thread lib/Runtime/Library/ConcatString.h Outdated
*propRecord = this->propertyRecord;
}

virtual Js::PropertyId GetPropertyId() override

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator Author

@jianchun please review.

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

@jianchun jianchun Jan 20, 2018 •

Copy link
Copy Markdown

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.

Comment thread lib/Runtime/Library/ConcatString.cpp Outdated
if (propStr != nullptr)
{
this->propertyRecord = propStr->GetPropertyRecord();
// why use local variable ? read SWB wiki

Copy link
Copy Markdown

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
Copy Markdown
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