shaver's favorite operating system of choice doesn't like templates, so de-template tracker since we use it with LInsp only anyway.

This commit is contained in:
Andreas Gal 2008-07-10 18:42:04 -07:00
parent 3a3cd06c43
commit 5e77678d2a
3 changed files with 23 additions and 27 deletions

View File

@ -58,29 +58,27 @@ using namespace nanojit;
static GC gc = GC();
static avmplus::AvmCore* core = new (&gc) avmplus::AvmCore();
template<typename T>
Tracker<T>::Tracker()
Tracker::Tracker()
{
pagelist = 0;
}
template<typename T>
Tracker<T>::~Tracker()
Tracker::~Tracker()
{
clear();
}
template<typename T> jsuword
Tracker<T>::getPageBase(const void* v) const
jsuword
Tracker::getPageBase(const void* v) const
{
return jsuword(v) & ~jsuword(NJ_PAGE_SIZE-1);
}
template<typename T> struct Tracker<T>::Page*
Tracker<T>::findPage(const void* v) const
struct Tracker::Page*
Tracker::findPage(const void* v) const
{
jsuword base = getPageBase(v);
struct Tracker<T>::Page* p = pagelist;
struct Tracker::Page* p = pagelist;
while (p) {
if (p->base == base) {
return p;
@ -90,19 +88,19 @@ Tracker<T>::findPage(const void* v) const
return 0;
}
template <typename T> struct Tracker<T>::Page*
Tracker<T>::addPage(const void* v) {
struct Tracker::Page*
Tracker::addPage(const void* v) {
jsuword base = getPageBase(v);
struct Tracker::Page* p = (struct Tracker::Page*)
GC::Alloc(sizeof(*p) - sizeof(p->map) + (NJ_PAGE_SIZE >> 2) * sizeof(T));
GC::Alloc(sizeof(*p) - sizeof(p->map) + (NJ_PAGE_SIZE >> 2) * sizeof(LIns*));
p->base = base;
p->next = pagelist;
pagelist = p;
return p;
}
template <typename T> void
Tracker<T>::clear()
void
Tracker::clear()
{
while (pagelist) {
Page* p = pagelist;
@ -111,20 +109,20 @@ Tracker<T>::clear()
}
}
template <typename T> T
Tracker<T>::get(const void* v) const
LIns*
Tracker::get(const void* v) const
{
struct Tracker<T>::Page* p = findPage(v);
struct Tracker::Page* p = findPage(v);
JS_ASSERT(p != 0); /* we must have a page for the slot we are looking for */
T i = p->map[(jsuword(v) & 0xfff) >> 2];
LIns* i = p->map[(jsuword(v) & 0xfff) >> 2];
JS_ASSERT(i != 0);
return i;
}
template <typename T> void
Tracker<T>::set(const void* v, T i)
void
Tracker::set(const void* v, LIns* i)
{
struct Tracker<T>::Page* p = findPage(v);
struct Tracker::Page* p = findPage(v);
if (!p)
p = addPage(v);
p->map[(jsuword(v) & 0xfff) >> 2] = i;

View File

@ -66,12 +66,11 @@
* Tracker is used to keep track of values being manipulated by the interpreter
* during trace recording.
*/
template <typename T>
class Tracker {
struct Page {
struct Page* next;
jsuword base;
T map[1];
nanojit::LIns* map[1];
};
struct Page* pagelist;
@ -82,8 +81,8 @@ public:
Tracker();
~Tracker();
T get(const void* v) const;
void set(const void* v, T ins);
nanojit::LIns* get(const void* v) const;
void set(const void* v, nanojit::LIns* ins);
void clear();
};
@ -109,7 +108,7 @@ extern struct nanojit::CallInfo builtins[];
class TraceRecorder {
JSContext* cx;
JSStackFrame* global;
Tracker<nanojit::LIns*> tracker;
Tracker tracker;
char* entryTypeMap;
struct JSStackFrame* entryFrame;
struct JSFrameRegs entryRegs;

View File

@ -124,4 +124,3 @@ function ursh(n)
}
test("ursh(8)", ursh(8), 16777215);
// test("ursh(33)", ursh(33), 2147483620);