-
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
OS#16244108: Small refactor of Parser::CreateCallNode and Parser::CreateSuperCallNode #4804
Conversation
lib/Parser/Parse.cpp
Outdated
{ | ||
pnode->nop = nop; | ||
|
||
// make Parser::Init public? |
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.
Alternately, make this Parser::InitCallNode
and have it delegate this first part to Parser::InitNode
? #Resolved
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.
Yes, could do that too. What is our philosophy on free functions versus members? :) #Resolved
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.
Judging by this file, I think that static class functions would fit in well. I also noticed something similar to what you are doing here:
Perhaps instead of allocating space explicitly in Create[Super]CallNode
, it would be cleaner to StaticCreateNodeT<kcbPn[Super]Call>(m_nodeAllocator, ...)
and then InitCallNode
on the result of that? #Resolved
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.
As we've been generally making a push to move the ParseNodes into a real class hierarchy, I am kind of a fan of adding a method like ParseNodeCall::Init
which would do this stuff and delegate up to an ParseNode::Init
for the base class stuff. Or just continue to rely on InitNode
for that. Could use pnode->AsParseNodeCall()->Init
or something along those lines. Regardless, I prefer to avoid the duplication of initializing these members in two places. #Resolved
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.
To be clear, this is fine though. Just been thinking about cleanups in this area since Curtis refactored the ParseNodes recently. #Resolved
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.
I find private static methods on a class somewhat weird. Made a step towards class hierarchy with type dependent "Init" methods. Is that what you had in mind?
In reply to: 173598566 [](ancestors = 173598566)
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.
Yes, that's what I was thinking about. 👍 #Resolved
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.
👍
lib/Parser/Parse.h
Outdated
@@ -380,7 +377,6 @@ class Parser | |||
ParseNodePtr CreateIntNodeWithScanner(int32 lw); | |||
ParseNodePtr CreateProgNodeWithScanner(bool isModuleSource); | |||
|
|||
static void InitNode(OpCode nop,ParseNodePtr pnode); | |||
static void InitBlockNode(ParseNodePtr pnode, int blockId, PnodeBlockType blockType); | |||
|
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.
Should I go through the exercise of replacing this static method with an instance Init as well? #Resolved
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.
If you're feeling motivated. #Resolved
@@ -4,6 +4,20 @@ | |||
//------------------------------------------------------------------------------------------------------- | |||
#include "ParserPch.h" | |||
|
|||
void ParseNode::Init(OpCode nop, charcount_t ichMin, charcount_t ichLim) |
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.
Dumb question, and maybe @boingoing knows the answer- why not just make this a constructor instead of an explicitly named Init function? #WontFix
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.
and then use placement new at the call sites? Is that what you mean?
In reply to: 173610992 [](ancestors = 173610992)
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 placement new is wrapped by AllocatorNew
In reply to: 173858893 [](ancestors = 173858893,173610992)
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 inits could be replaced by constructors + AllocatorNew at the callsite, however the constructors have to be propagated through the inheritance hierarchy and would hide default ones. I think we could wait with this till ParseNode* classes get more flesh and then we should consistently provide all of them with constructors (and remove Init methods if any).
In reply to: 173897962 [](ancestors = 173897962,173858893,173610992)
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.
It looks like this has had some semantic changes; the "hello world" test we run on release builds is failing with
|
79e08df
to
bb68776
Compare
…ateCallNode and Parser::CreateSuperCallNode Merge pull request #4804 from irinayat-MS:ParseNodeCall https://microsoft.visualstudio.com/OS/_workitems/edit/16244108 The uninitialized field was introduced by #3917. The only read of the field is in EmitArgList, and if it ends up "true" instead of the default "false" an extra defensive load will be emitted for the constructor parameters so not a security/correctness concern.
https://microsoft.visualstudio.com/OS/_workitems/edit/16244108
The uninitialized field was introduced by #3917. The only read of the field is in EmitArgList, and if it ends up "true" instead of the default "false" an extra defensive load will be emitted for the constructor parameters so not a security/correctness concern.