Skip to content

Commit

Permalink
Fix LabelSymbol constructor to always require a CodeGenerator
Browse files Browse the repository at this point in the history
* Remove constructor without `CodeGenerator` parameter
* Replace `TR::comp()` reach inside each constructor with `CodeGenerator` query
* Add missing `_directlyTargeted` field initializaton to all constructors

Signed-off-by: Daryl Maier <maier@ca.ibm.com>
  • Loading branch information
0xdaryl committed Nov 9, 2021
1 parent a54f109 commit 735fa5a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 65 deletions.
15 changes: 6 additions & 9 deletions compiler/il/LabelSymbol.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2019 IBM Corp. and others
* Copyright (c) 2000, 2021 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -34,18 +34,15 @@ class OMR_EXTENSIBLE LabelSymbol : public OMR::LabelSymbolConnector

protected:

LabelSymbol() :
OMR::LabelSymbolConnector() { }
LabelSymbol(TR::CodeGenerator *cg) :
OMR::LabelSymbolConnector(cg) { }

LabelSymbol(TR::CodeGenerator *codeGen) :
OMR::LabelSymbolConnector(codeGen) { }

LabelSymbol(TR::CodeGenerator *codeGen, TR::Block *labb):
OMR::LabelSymbolConnector(codeGen, labb) { }
LabelSymbol(TR::CodeGenerator *cg, TR::Block *labb):
OMR::LabelSymbolConnector(cg, labb) { }

private:

// When adding another class to the heirarchy, add it as a friend here
// When adding another class to the hierarchy, add it as a friend here
friend class OMR::LabelSymbol;

};
Expand Down
70 changes: 22 additions & 48 deletions compiler/il/OMRLabelSymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,18 @@ OMR::LabelSymbol::self()
}

template <typename AllocatorType>
TR::LabelSymbol * OMR::LabelSymbol::create(AllocatorType t)
TR::LabelSymbol * OMR::LabelSymbol::create(AllocatorType t, TR::CodeGenerator *cg)
{
return new (t) TR::LabelSymbol();
return new (t) TR::LabelSymbol(cg);
}

template <typename AllocatorType>
TR::LabelSymbol * OMR::LabelSymbol::create(AllocatorType t, TR::CodeGenerator* c)
TR::LabelSymbol * OMR::LabelSymbol::create(AllocatorType t, TR::CodeGenerator *cg, TR::Block *b)
{
return new (t) TR::LabelSymbol(c);
return new (t) TR::LabelSymbol(cg, b);
}

template <typename AllocatorType>
TR::LabelSymbol * OMR::LabelSymbol::create(AllocatorType t, TR::CodeGenerator* c, TR::Block* b)
{
return new (t) TR::LabelSymbol(c,b);
}

OMR::LabelSymbol::LabelSymbol() :
OMR::LabelSymbol::LabelSymbol(TR::CodeGenerator *cg) :
TR::Symbol(),
_instruction(NULL),
_codeLocation(NULL),
Expand All @@ -74,37 +68,24 @@ OMR::LabelSymbol::LabelSymbol() :
{
self()->setIsLabel();

TR::Compilation *comp = TR::comp();
if (comp && comp->getDebug())
comp->getDebug()->newLabelSymbol(self());
}

OMR::LabelSymbol::LabelSymbol(TR::CodeGenerator *codeGen) :
TR::Symbol(),
_instruction(NULL),
_codeLocation(NULL),
_estimatedCodeLocation(0),
_snippet(NULL)
{
self()->setIsLabel();

TR::Compilation *comp = TR::comp();
if (comp && comp->getDebug())
comp->getDebug()->newLabelSymbol(self());
TR_Debug *debug = cg->comp()->getDebug();
if (debug)
debug->newLabelSymbol(self());
}

OMR::LabelSymbol::LabelSymbol(TR::CodeGenerator *codeGen, TR::Block *labb) :
OMR::LabelSymbol::LabelSymbol(TR::CodeGenerator *cg, TR::Block *labb) :
TR::Symbol(),
_instruction(NULL),
_codeLocation(NULL),
_estimatedCodeLocation(0),
_snippet(NULL)
_snippet(NULL),
_directlyTargeted(false)
{
self()->setIsLabel();

TR::Compilation *comp = TR::comp();
if (comp && comp->getDebug())
comp->getDebug()->newLabelSymbol(self());
TR_Debug *debug = cg->comp()->getDebug();
if (debug)
debug->newLabelSymbol(self());
}

TR_YesNoMaybe
Expand Down Expand Up @@ -154,23 +135,16 @@ template <typename AllocatorType>
TR::LabelSymbol *
OMR::LabelSymbol::createRelativeLabel(AllocatorType m, TR::CodeGenerator * cg, intptr_t offset)
{
TR::LabelSymbol * rel = new (m) TR::LabelSymbol();
TR::LabelSymbol * rel = new (m) TR::LabelSymbol(cg);
rel->makeRelativeLabelSymbol(offset);
return rel;
}

// Explicit instantiation
template TR::LabelSymbol * OMR::LabelSymbol::create(TR_HeapMemory t);
template TR::LabelSymbol * OMR::LabelSymbol::create(TR_HeapMemory t, TR::CodeGenerator* c);
template TR::LabelSymbol * OMR::LabelSymbol::create(TR_HeapMemory t, TR::CodeGenerator* c, TR::Block* b);
template TR::LabelSymbol * OMR::LabelSymbol::createRelativeLabel(TR_HeapMemory m, TR::CodeGenerator * cg, intptr_t offset);

template TR::LabelSymbol * OMR::LabelSymbol::create(TR_StackMemory t);
template TR::LabelSymbol * OMR::LabelSymbol::create(TR_StackMemory t, TR::CodeGenerator* c);
template TR::LabelSymbol * OMR::LabelSymbol::create(TR_StackMemory t, TR::CodeGenerator* c, TR::Block* b);
template TR::LabelSymbol * OMR::LabelSymbol::createRelativeLabel(TR_StackMemory m, TR::CodeGenerator * cg, intptr_t offset);

template TR::LabelSymbol * OMR::LabelSymbol::create(PERSISTENT_NEW_DECLARE t);
template TR::LabelSymbol * OMR::LabelSymbol::create(PERSISTENT_NEW_DECLARE t, TR::CodeGenerator* c);
template TR::LabelSymbol * OMR::LabelSymbol::create(PERSISTENT_NEW_DECLARE t, TR::CodeGenerator* c, TR::Block* b);
template TR::LabelSymbol * OMR::LabelSymbol::createRelativeLabel(PERSISTENT_NEW_DECLARE m, TR::CodeGenerator * cg, intptr_t offset);
template TR::LabelSymbol * OMR::LabelSymbol::create(TR_HeapMemory t, TR::CodeGenerator* cg);
template TR::LabelSymbol * OMR::LabelSymbol::create(TR_HeapMemory t, TR::CodeGenerator* cg, TR::Block* b);
template TR::LabelSymbol * OMR::LabelSymbol::createRelativeLabel(TR_HeapMemory m, TR::CodeGenerator* cg, intptr_t offset);

template TR::LabelSymbol * OMR::LabelSymbol::create(TR_StackMemory t, TR::CodeGenerator* cg);
template TR::LabelSymbol * OMR::LabelSymbol::create(TR_StackMemory t, TR::CodeGenerator* cg, TR::Block* b);
template TR::LabelSymbol * OMR::LabelSymbol::createRelativeLabel(TR_StackMemory m, TR::CodeGenerator* cg, intptr_t offset);
8 changes: 2 additions & 6 deletions compiler/il/OMRLabelSymbol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ class OMR_EXTENSIBLE LabelSymbol : public TR::Symbol
public:
TR::LabelSymbol * self();

template <typename AllocatorType>
static TR::LabelSymbol * create(AllocatorType);

template <typename AllocatorType>
static TR::LabelSymbol * create(AllocatorType, TR::CodeGenerator*);

Expand All @@ -75,9 +72,8 @@ class OMR_EXTENSIBLE LabelSymbol : public TR::Symbol

protected:

LabelSymbol();
LabelSymbol(TR::CodeGenerator *codeGen);
LabelSymbol(TR::CodeGenerator *codeGen, TR::Block *labb);
LabelSymbol(TR::CodeGenerator *cg);
LabelSymbol(TR::CodeGenerator *cg, TR::Block *labb);

public:

Expand Down
4 changes: 2 additions & 2 deletions compiler/z/codegen/S390Instruction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,11 +624,11 @@ class S390PseudoInstruction : public TR::Instruction

virtual uint8_t *generateBinaryEncoding();

uint64_t setCallDescValue(uint64_t cdv, TR_Memory * m)
uint64_t setCallDescValue(uint64_t cdv, TR_Memory * m, TR::CodeGenerator *cg)
{
if (!_callDescLabel)
{
_callDescLabel = TR::LabelSymbol::create(m->trHeapMemory());
_callDescLabel = TR::LabelSymbol::create(m->trHeapMemory(), cg);
}
return _callDescValue = cdv;
}
Expand Down

0 comments on commit 735fa5a

Please sign in to comment.