25 #ifndef _JIT_COMPILER2_SEGMENT
26 #define _JIT_COMPILER2_SEGMENT
43 template <
typename Tag,
typename RefCategory>
49 template <
typename Tag>
57 template <
typename Tag>
58 bool operator<(SegmentTag<Tag> *lhs, SegmentTag<Tag> *rhs) {
59 LOG2(
"non-member Segment::operator<"<<
nl);
60 return (*lhs) < (*rhs);
63 template <
typename Tag>
64 bool operator==(SegmentTag<Tag> *lhs, SegmentTag<Tag> *rhs) {
65 LOG2(
"non-member Segment::operator=="<<
nl);
66 return (*lhs) == (*rhs);
77 template <
typename Tag,
typename RefCategory>
133 typename EntriesTy::const_iterator
i =
entries.find(tag);
209 std::size_t start =
content.size();
211 return Ref(
this,IdxTy(start),t);
220 return Ref(
this,idx,t);
224 template<
typename Tag2>
229 template<
typename Tag2>
244 template<
typename Tag2>
253 template<
typename Tag2>
264 for(
typename EntriesTy::const_iterator
i =
entries.begin(),
e =
entries.end() ;
268 OS <<
" value: " <<
i->second <<
nl;
291 template <
typename Tag,
typename RefCategory>
301 : parent(parent), index(index), _size(_size) {}
316 assert(
_size - v >= 0);
321 return doAccess(*
this,i,RefCategory());
344 return getBegin(*
this,RefCategory());
357 return getEnd(*
this,RefCategory());
400 template <
typename Tag>
406 template <
typename Tag>
413 template <
typename Tag,
typename RefCategory>
416 assert(i < ref.
size());
420 template <
typename Tag,
typename RefCategory>
423 assert(i < ref.
size());
428 template <
typename Tag,
typename RefCategory>
429 inline typename SegRef<Tag,RefCategory>::IdxTy
434 template <
typename Tag,
typename RefCategory>
435 inline typename SegRef<Tag,RefCategory>::IdxTy
441 template <
typename Tag,
typename RefCategory>
442 inline typename SegRef<Tag,RefCategory>::IdxTy
447 template <
typename Tag,
typename RefCategory>
448 inline typename SegRef<Tag,RefCategory>::IdxTy
454 template <
typename Tag,
typename RefCategory>
455 inline typename SegRef<Tag,RefCategory>::IdxTy
460 template <
typename Tag,
typename RefCategory>
461 inline typename SegRef<Tag,RefCategory>::IdxTy
467 template <
typename Tag,
typename RefCategory>
468 inline typename Segment<Tag,RefCategory>::IdxTy
473 template <
typename Tag,
typename RefCategory>
474 inline typename Segment<Tag,RefCategory>::IdxTy
479 template <
class Type>
483 virtual u8 hash()
const = 0;
486 return type == other.type &&
hash() == other.hash();
489 if (
type == other.type)
490 return hash() < other.hash();
491 return type < other.type;
499 template <
class Type>
503 template <
class Type>
504 inline OStream& operator<<(OStream &OS, SegmentTag<Type> *
tag) {
509 template <
class Type,
class ConstTy, Type t>
513 if (
sizeof(ConstTy) ==
sizeof(
u1))
514 return u8(*reinterpret_cast<const u1*>(&
c));
515 if (
sizeof(ConstTy) ==
sizeof(
u2))
516 return u8(*reinterpret_cast<const u2*>(&
c));
517 if (
sizeof(ConstTy) ==
sizeof(
u4))
518 return u8(*reinterpret_cast<const u4*>(&
c));
519 return *
reinterpret_cast<const u8*
>(&
c);
524 return OS <<
"ConstTag Type: " << t <<
" ptr: " <<
c;
531 template <
class Type,
class Ptr, Type t>
540 return OS <<
"PointerTag Type: " << t <<
" ptr: " <<
ptr;
IdxTy get_index_end_raw() const
Get the raw end index.
bool operator==(const IdxTy &other) const
OStream & print(OStream &OS) const
bool operator==(const SegmentTag &other) const
static IdxTy invalid_index()
invalid index
bool contains_tag_intern(SegmentTag< Tag > *tag) const
contains tag
virtual OStream & print(OStream &OS) const
alloc::map< SegmentTag< Tag > *, IdxTy, classcomp< Tag > >::type EntriesTy
u1 & operator[](std::size_t i)
SegRef(const SegRef< Tag, RefCategory > &other)
Copy Constructor.
virtual OStream & print(OStream &OS) const =0
SegRef< Tag, RefCategory >::IdxTy getEnd(const SegRef< Tag, RefCategory > &ref, NormalRefCategory)
get last but one index
IdxTy insert_tag(Tag2 tag, const Ref &ref)
insert tag
alloc::vector< u1 >::type content
content of the segment
Segment(CodeMemory *CM)
Constructor.
u1 at(std::size_t i) const
get content
SegRef & operator=(const SegRef< Tag, RefCategory > &other)
Copy assignment operator.
IdxTy insert_tag(Tag2 tag)
insert tag
Segment< Tag, RefCategory >::IdxTy getFollowingIndex(const Segment< Tag, RefCategory > &ref, NormalRefCategory)
SegRef(Segment< Tag, RefCategory > *parent, IdxTy index, std::size_t _size)
std::size_t size() const
get size
Ref get_Ref(IdxTy idx, std::size_t t)
get a reference to the segment
CodeMemory & get_CodeMemory()
JNIEnv jthread jobject jclass jlong size
EntriesTy entries
tagged entries
static bool is_invalid(IdxTy idx)
is invalid index
u1 & operator[](IdxTy i)
write content
void reverse()
reverse content
u1 * get_end()
get end address
IdxTy(std::size_t idx)
explicit constructor
Segment< Tag, RefCategory > * get_Segment() const
Get containing segment.
IdxTy get_index_begin_raw() const
Get the raw start index.
CodeMemory * get_CodeMemory() const
Get containing CodeMemory.
std::vector< T, Allocator< T > > type
IdxTy operator-(std::size_t i) const
IdxTy get_end() const
Get the index of the first element after the reference.
bool operator()(const SegmentTag< Tag > *lhs, const SegmentTag< Tag > *rhs) const
Segment< Tag, RefCategory >::IdxTy IdxTy
bool contains_tag(Tag2 tag) const
contains tag
Simple stream class for formatted output.
u1 & operator[](std::size_t i)
access data
Segment< Tag, RefCategory > * parent
Segment< Tag, RefCategory > & get_Segment()
std::size_t size() const
size of the reference
u1 & doAccess(SegRef< Tag, RefCategory > &ref, std::size_t i, NormalRefCategory)
access data
IdxTy operator+(std::size_t i) const
IdxTy & operator=(const IdxTy &other)
copy assignment operator
IdxTy insert_tag(SegmentTag< Tag > *tag, IdxTy o)
insert tag
Segment(CodeMemory *CM, IdxTy capacity)
Constructor with default capacity.
bool operator==(const UseDef &lhs, const UseDef &rhs)
IdxTy get_index(Tag2 tag) const
get the index of a tag
IdxTy get_following_index() const
Get the start index of next Reference in line.
SegRef< Tag, RefCategory >::IdxTy getBegin(const SegRef< Tag, RefCategory > &ref, NormalRefCategory)
get first index
A segment of the code memory.
SegRef operator+(std::size_t v)
Get a sub-segment.
SegRef< Tag, RefCategory > Ref
virtual u8 hash() const =0
IdxTy()
default constructor
u1 * get_start()
get start address
SegRef< Tag, RefCategory >::IdxTy getAddStartIndex(SegRef< Tag, RefCategory > &ref, std::size_t v, NormalRefCategory)
get subreference
IdxTy get_begin() const
Get the index of the first element.
bool operator<(const SegmentTag &other) const
IdxTy get_index_intern(SegmentTag< Tag > *tag) const
get index
Ref get_Ref(std::size_t t)
get a new reference to the segment
virtual OStream & print(OStream &OS) const