Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Work towards objects stack allocation #6653

Merged
merged 1 commit into from
Aug 9, 2016
Merged

Work towards objects stack allocation #6653

merged 1 commit into from
Aug 9, 2016

Conversation

echesakov
Copy link

Work towards objects stack allocation: moved allocation part of newobj-lowering into separate phase

  1. Introduced GT_ALLOCOBJ node to mark places where object allocation happens
  2. In importer.cpp changed lowering of allocation part of newobj instruction from an allocation helper call to a GT_ALLOCOBJ node creation
  3. Created new phase ObjectAllocator (PHASE_ALLOCATE_OBJECTS) and put it right after dominator computing (we will need the information for escape analysis)
  4. Current implementation of ObjectAllocator walks over all basic blocks having flag BBF_HAS_NEWOBJ set and replaces GT_ALLOCOBJ with an allocation helper call

I did coreclr testing and throughput measurement. We have one assembly diff (an improvement) related to deleting unreachable basic blocks. Throughput remains the same.

@erozenfeld PTAL
cc @dotnet/jit-contrib

TYP_REF, 0,
gtNewArgList(op1));
op1 = gtNewAllocObjNode( info.compCompHnd->getNewHelper(&resolvedToken, info.compMethodHnd),
resolvedToken.hClass, TYP_REF, op1 );

Choose a reason for hiding this comment

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

This code always assigns the newly allocated object to a temp. However, it's not entirely clear that this is a fundamental requirement. So, either here or above the call to impAssignTempGen, I would add a comment that the ObjectAllocator relies on this.

@CarolEidt
Copy link

LGTM, other than one suggestion for a comment.
I think it would be good to add a COMPlus_EnableObjectStackAllocation or similar.

assert(tree != nullptr);
assert(tree->OperGet() != GT_ALLOCOBJ);

return Compiler::fgWalkResult::WALK_CONTINUE;
Copy link

Choose a reason for hiding this comment

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

Looks like the indentation is off in this function.

@pgavlin
Copy link

pgavlin commented Aug 8, 2016

LGTM aside from a few nits.

@erozenfeld
Copy link
Member

@dotnet-bot test OSX x64 Checked Build and Test

@erozenfeld
Copy link
Member

@dotnet-bot test Ubuntu x64 Checked Build and Test

1 similar comment
@erozenfeld
Copy link
Member

@dotnet-bot test Ubuntu x64 Checked Build and Test

CORINFO_CLASS_HANDLE gtAllocObjClsHnd;

GenTreeAllocObj(var_types type, unsigned int helper, CORINFO_CLASS_HANDLE clsHnd, GenTreePtr op
DEBUGARG(bool largeNode = false)) :

Choose a reason for hiding this comment

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

Do we really need another DEBUGARG() here?

PeterK is currently revisiting all uses of "largeNodes" in our codebase.

It would seem that we should know if this node needs to be large or not and not have every callsite determine this properly.

…j-lowering into separate phase

1. Introduced `GT_ALLOCOBJ` node to mark places where object allocation happens
2. In `importer.cpp` changed lowering of allocation part of newobj instruction from an allocation helper call to a `GT_ALLOCOBJ` node creation
3. Created new phase `ObjectAllocator` (`PHASE_ALLOCATE_OBJECTS`) and put it right after dominator computing (we will need the information for escape analysis)
4. Current implementation of ObjectAllocator walks over all basic blocks having flag `BBF_HAS_NEWOBJ` set and replaces `GT_ALLOCOBJ` with  an allocation helper call
@echesakov
Copy link
Author

@dotnet-bot test Windows_NT x86 ryujit Checked Build and Test

@briansull
Copy link

LGTM

1 similar comment
@erozenfeld
Copy link
Member

LGTM

picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Work towards objects stack allocation

Commit migrated from dotnet/coreclr@3779842
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants