Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/jit/bitsetasshortlong.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class BitSetOps</*BitSetType*/ BitSetShortLongRep,
static void UnionDLong(Env env, BitSetShortLongRep& bs1, BitSetShortLongRep bs2);
static void DiffDLong(Env env, BitSetShortLongRep& bs1, BitSetShortLongRep bs2);
static void AddElemDLong(Env env, BitSetShortLongRep& bs, unsigned i);
static bool TryAddElemDLong(Env env, BitSetShortLongRep& bs, unsigned i);
static void RemoveElemDLong(Env env, BitSetShortLongRep& bs, unsigned i);
static void ClearDLong(Env env, BitSetShortLongRep& bs);
static BitSetShortLongRep MakeUninitArrayBits(Env env);
Expand Down Expand Up @@ -276,6 +277,23 @@ class BitSetOps</*BitSetType*/ BitSetShortLongRep,
return res;
}

static bool TryAddElemD(Env env, BitSetShortLongRep& bs, unsigned i)
{
assert(i < BitSetTraits::GetSize(env));
if (IsShort(env))
{
size_t mask = ((size_t)1) << i;
size_t bits = (size_t)bs;
bool added = (bits & mask) == 0;
bs = (BitSetShortLongRep)(bits | mask);
return added;
}
else
{
return TryAddElemDLong(env, bs, i);
}
}

static bool IsMember(Env env, const BitSetShortLongRep bs, unsigned i)
{
assert(i < BitSetTraits::GetSize(env));
Expand Down Expand Up @@ -644,6 +662,21 @@ void BitSetOps</*BitSetType*/ BitSetShortLongRep,
bs[index] |= mask;
}

template <typename Env, typename BitSetTraits>
bool BitSetOps</*BitSetType*/ BitSetShortLongRep,
/*Brand*/ BSShortLong,
/*Env*/ Env,
/*BitSetTraits*/ BitSetTraits>::TryAddElemDLong(Env env, BitSetShortLongRep& bs, unsigned i)
{
assert(!IsShort(env));
unsigned index = i / BitsInSizeT;
size_t mask = ((size_t)1) << (i % BitsInSizeT);
size_t bits = bs[index];
bool added = (bits & mask) == 0;
bs[index] = bits | mask;
return added;
}

template <typename Env, typename BitSetTraits>
void BitSetOps</*BitSetType*/ BitSetShortLongRep,
/*Brand*/ BSShortLong,
Expand Down
6 changes: 6 additions & 0 deletions src/jit/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -1202,9 +1202,15 @@ struct JitPtrKeyFuncs<BasicBlock> : public JitKeyFuncsDefEquals<const BasicBlock
// A set of blocks.
typedef JitHashTable<BasicBlock*, JitPtrKeyFuncs<BasicBlock>, bool> BlkSet;

// A vector of blocks.
typedef jitstd::vector<BasicBlock*> BlkVector;

// A map of block -> set of blocks, can be used as sparse block trees.
typedef JitHashTable<BasicBlock*, JitPtrKeyFuncs<BasicBlock>, BlkSet*> BlkToBlkSetMap;

// A map of block -> vector of blocks, can be used as sparse block trees.
typedef JitHashTable<BasicBlock*, JitPtrKeyFuncs<BasicBlock>, BlkVector> BlkToBlkVectorMap;

// Map from Block to Block. Used for a variety of purposes.
typedef JitHashTable<BasicBlock*, JitPtrKeyFuncs<BasicBlock>, BasicBlock*> BlockToBlockMap;

Expand Down
4 changes: 2 additions & 2 deletions src/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include "jit.h"
#include "opcode.h"
#include "varset.h"
#include "jitstd.h"
#include "jithashtable.h"
#include "gentree.h"
#include "lir.h"
#include "block.h"
Expand All @@ -33,10 +35,8 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include "instr.h"
#include "regalloc.h"
#include "sm.h"
#include "jithashtable.h"
#include "cycletimer.h"
#include "blockset.h"
#include "jitstd.h"
#include "arraystack.h"
#include "hashbv.h"
#include "fp.h"
Expand Down
1 change: 1 addition & 0 deletions src/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include "ssaconfig.h" // For "SsaConfig::RESERVED_SSA_NUM"
#include "reglist.h"
#include "valuenumtype.h"
#include "jitstd.h"
#include "jithashtable.h"
#include "nodeinfo.h"
#include "simd.h"
Expand Down
44 changes: 41 additions & 3 deletions src/jit/jithashtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,50 @@ class JitHashTable
}
else
{
Node* pNewNode = new (m_alloc) Node(k, v, m_table[index]);
Node* pNewNode = new (m_alloc) Node(m_table[index], k, v);
m_table[index] = pNewNode;
m_tableCount++;
return false;
}
}

//------------------------------------------------------------------------
// Emplace: Associates the specified key with a value constructed in-place
// using the supplied args if the key is not already present.
//
// Arguments:
// k - the key
// args - the args used to construct the value
//
// Return Value:
// A pointer to the existing or newly constructed value.
//
template <class... Args>
Value* Emplace(Key k, Args&&... args)
{
CheckGrowth();

assert(m_tableSizeInfo.prime != 0);

unsigned index = GetIndexForKey(k);

Node* n = m_table[index];
while ((n != nullptr) && !KeyFuncs::Equals(k, n->m_key))
{
n = n->m_next;
}

if (n == nullptr)
{
n = new (m_alloc) Node(m_table[index], k, jitstd::forward<Args>(args)...);

m_table[index] = n;
m_tableCount++;
}

return &n->m_val;
}

//------------------------------------------------------------------------
// Remove: Remove the specified key and its associated value.
//
Expand Down Expand Up @@ -592,7 +629,7 @@ class JitHashTable
// Assumptions:
// This must not be the "end" iterator.
//
const Value& GetValue() const
Value& GetValue() const
{
assert(m_node != nullptr);

Expand Down Expand Up @@ -721,7 +758,8 @@ class JitHashTable
Key m_key;
Value m_val;

Node(Key k, Value v, Node* next) : m_next(next), m_key(k), m_val(v)
template <class... Args>
Node(Node* next, Key k, Args&&... args) : m_next(next), m_key(k), m_val(jitstd::forward<Args>(args)...)
{
}

Expand Down
Loading