mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset fc66e3f4afc9
This commit is contained in:
parent
3b0d6c1a97
commit
ef5f70907e
@ -1606,12 +1606,36 @@ namespace nanojit
|
||||
}
|
||||
}
|
||||
|
||||
void LirNameMap::addName(LInsp i, const char* name) {
|
||||
LabelMap::Entry::~Entry()
|
||||
{
|
||||
}
|
||||
|
||||
LirNameMap::Entry::~Entry()
|
||||
{
|
||||
}
|
||||
|
||||
LirNameMap::~LirNameMap()
|
||||
{
|
||||
Entry *e;
|
||||
|
||||
while ((e = names.removeLast()) != NULL) {
|
||||
labels->core->freeString(e->name);
|
||||
NJ_DELETE(e);
|
||||
}
|
||||
}
|
||||
|
||||
bool LirNameMap::addName(LInsp i, Stringp name) {
|
||||
if (!names.containsKey(i)) {
|
||||
char *copy = new (allocator) char[VMPI_strlen(name)+1];
|
||||
VMPI_strcpy(copy, name);
|
||||
Entry *e = new (allocator) Entry(copy);
|
||||
Entry *e = NJ_NEW(labels->core->gc, Entry)(name);
|
||||
names.put(i, e);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void LirNameMap::addName(LInsp i, const char *name) {
|
||||
Stringp new_name = labels->core->newString(name);
|
||||
if (!addName(i, new_name)) {
|
||||
labels->core->freeString(new_name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1619,11 +1643,11 @@ namespace nanojit
|
||||
char s2[200];
|
||||
if (isdigit(s[strlen(s)-1])) {
|
||||
// if s ends with a digit, add '_' to clarify the suffix
|
||||
VMPI_sprintf(s2,"%s_%d", s, suffix);
|
||||
sprintf(s2,"%s_%d", s, suffix);
|
||||
} else {
|
||||
VMPI_sprintf(s2,"%s%d", s, suffix);
|
||||
sprintf(s2,"%s%d", s, suffix);
|
||||
}
|
||||
addName(i, s2);
|
||||
addName(i, labels->core->newString(s2));
|
||||
}
|
||||
|
||||
void LirNameMap::formatImm(int32_t c, char *buf) {
|
||||
@ -1637,9 +1661,10 @@ namespace nanojit
|
||||
{
|
||||
char buffer[200], *buf=buffer;
|
||||
buf[0]=0;
|
||||
GC *gc = labels->core->gc;
|
||||
if (names.containsKey(ref)) {
|
||||
const char* name = names.get(ref)->name;
|
||||
VMPI_strcat(buf, name);
|
||||
StringNullTerminatedUTF8 cname(gc, names.get(ref)->name);
|
||||
strcat(buf, cname.c_str());
|
||||
}
|
||||
else if (ref->isconstq()) {
|
||||
#if defined NANOJIT_64BIT
|
||||
@ -1670,8 +1695,8 @@ namespace nanojit
|
||||
NanoAssert(size_t(ref->opcode()) < sizeof(lirNames) / sizeof(lirNames[0]));
|
||||
copyName(ref, lirNames[ref->opcode()], lircounts.add(ref->opcode()));
|
||||
}
|
||||
const char* name = names.get(ref)->name;
|
||||
VMPI_strcat(buf, name);
|
||||
StringNullTerminatedUTF8 cname(gc, names.get(ref)->name);
|
||||
strcat(buf, cname.c_str());
|
||||
}
|
||||
return labels->dup(buffer);
|
||||
}
|
||||
@ -2203,7 +2228,7 @@ namespace nanojit
|
||||
|
||||
#if defined(NJ_VERBOSE)
|
||||
LabelMap::LabelMap(AvmCore *core, nanojit::Allocator& a)
|
||||
: allocator(a), names(core->gc), addrs(core->config.verbose_addrs), end(buf)
|
||||
: allocator(a), names(core->gc), addrs(core->config.verbose_addrs), end(buf), core(core)
|
||||
{}
|
||||
|
||||
LabelMap::~LabelMap()
|
||||
@ -2213,17 +2238,25 @@ namespace nanojit
|
||||
|
||||
void LabelMap::clear()
|
||||
{
|
||||
// don't free entries since they're owned by Allocator
|
||||
names.clear();
|
||||
Entry *e;
|
||||
while ((e = names.removeLast()) != NULL) {
|
||||
core->freeString(e->name);
|
||||
NJ_DELETE(e);
|
||||
}
|
||||
}
|
||||
|
||||
void LabelMap::add(const void *p, size_t size, size_t align, const char *name)
|
||||
{
|
||||
if (!this || names.containsKey(p))
|
||||
return;
|
||||
char* copy = new (allocator) char[VMPI_strlen(name)+1];
|
||||
VMPI_strcpy(copy, name);
|
||||
Entry *e = new (allocator) Entry(copy, size << align, align);
|
||||
add(p, size, align, core->newString(name));
|
||||
}
|
||||
|
||||
void LabelMap::add(const void *p, size_t size, size_t align, Stringp name)
|
||||
{
|
||||
if (!this || names.containsKey(p))
|
||||
return;
|
||||
Entry *e = NJ_NEW(core->gc, Entry)(name, size<<align, align);
|
||||
names.put(p, e);
|
||||
}
|
||||
|
||||
@ -2235,41 +2268,42 @@ namespace nanojit
|
||||
const void *start = names.keyAt(i);
|
||||
Entry *e = names.at(i);
|
||||
const void *end = (const char*)start + e->size;
|
||||
const char *name = e->name;
|
||||
avmplus::StringNullTerminatedUTF8 cname(core->gc, e->name);
|
||||
const char *name = cname.c_str();
|
||||
if (p == start) {
|
||||
if (addrs)
|
||||
VMPI_sprintf(b,"%p %s",p,name);
|
||||
sprintf(b,"%p %s",p,name);
|
||||
else
|
||||
VMPI_strcpy(b, name);
|
||||
strcpy(b, name);
|
||||
return dup(b);
|
||||
}
|
||||
else if (p > start && p < end) {
|
||||
int32_t d = int32_t(intptr_t(p)-intptr_t(start)) >> e->align;
|
||||
if (addrs)
|
||||
VMPI_sprintf(b, "%p %s+%d", p, name, d);
|
||||
sprintf(b, "%p %s+%d", p, name, d);
|
||||
else
|
||||
VMPI_sprintf(b,"%s+%d", name, d);
|
||||
sprintf(b,"%s+%d", name, d);
|
||||
return dup(b);
|
||||
}
|
||||
else {
|
||||
VMPI_sprintf(b, "%p", p);
|
||||
sprintf(b, "%p", p);
|
||||
return dup(b);
|
||||
}
|
||||
}
|
||||
VMPI_sprintf(b, "%p", p);
|
||||
sprintf(b, "%p", p);
|
||||
return dup(b);
|
||||
}
|
||||
|
||||
const char *LabelMap::dup(const char *b)
|
||||
{
|
||||
size_t need = VMPI_strlen(b)+1;
|
||||
size_t need = strlen(b)+1;
|
||||
char *s = end;
|
||||
end += need;
|
||||
if (end > buf+sizeof(buf)) {
|
||||
s = buf;
|
||||
end = s+need;
|
||||
}
|
||||
VMPI_strcpy(s, b);
|
||||
strcpy(s, b);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -853,21 +853,25 @@ namespace nanojit
|
||||
class LabelMap MMGC_SUBCLASS_DECL
|
||||
{
|
||||
Allocator& allocator;
|
||||
class Entry
|
||||
class Entry MMGC_SUBCLASS_DECL
|
||||
{
|
||||
public:
|
||||
Entry(char *n, size_t s, size_t a) : name(n),size(s),align(a) {}
|
||||
char* name;
|
||||
Entry(int) : name(0), size(0), align(0) {}
|
||||
Entry(avmplus::String *n, size_t s, size_t a) : name(n),size(s),align(a) {}
|
||||
~Entry();
|
||||
DRCWB(avmplus::String*) name;
|
||||
size_t size:29, align:3;
|
||||
};
|
||||
avmplus::SortedMap<const void*, Entry*, avmplus::LIST_NonGCObjects> names;
|
||||
avmplus::SortedMap<const void*, Entry*, avmplus::LIST_GCObjects> names;
|
||||
bool addrs, pad[3];
|
||||
char buf[1000], *end;
|
||||
void formatAddr(const void *p, char *buf);
|
||||
public:
|
||||
LabelMap(AvmCore* core, Allocator& allocator);
|
||||
avmplus::AvmCore *core;
|
||||
LabelMap(avmplus::AvmCore *, Allocator& allocator);
|
||||
~LabelMap();
|
||||
void add(const void *p, size_t size, size_t align, const char *name);
|
||||
void add(const void *p, size_t size, size_t align, avmplus::String*);
|
||||
const char *dup(const char *);
|
||||
const char *format(const void *p);
|
||||
void clear();
|
||||
@ -893,13 +897,15 @@ namespace nanojit
|
||||
CountMap<int> lircounts;
|
||||
CountMap<const CallInfo *> funccounts;
|
||||
|
||||
class Entry
|
||||
class Entry MMGC_SUBCLASS_DECL
|
||||
{
|
||||
public:
|
||||
Entry(char* n) : name(n) {}
|
||||
char* name;
|
||||
Entry(int) : name(0) {}
|
||||
Entry(avmplus::String *n) : name(n) {}
|
||||
~Entry();
|
||||
DRCWB(avmplus::String*) name;
|
||||
};
|
||||
avmplus::SortedMap<LInsp, Entry*, avmplus::LIST_NonGCObjects> names;
|
||||
avmplus::SortedMap<LInsp, Entry*, avmplus::LIST_GCObjects> names;
|
||||
LabelMap *labels;
|
||||
void formatImm(int32_t c, char *buf);
|
||||
public:
|
||||
@ -911,8 +917,10 @@ namespace nanojit
|
||||
names(gc),
|
||||
labels(r)
|
||||
{}
|
||||
~LirNameMap();
|
||||
|
||||
void addName(LInsp i, const char *s);
|
||||
bool addName(LInsp i, avmplus::String *s);
|
||||
void copyName(LInsp i, const char *s, int suffix);
|
||||
const char *formatRef(LIns *ref);
|
||||
const char *formatIns(LInsp i);
|
||||
|
@ -288,11 +288,6 @@ namespace MMgc {
|
||||
|
||||
#define MMGC_MEM_TYPE(x)
|
||||
|
||||
#define VMPI_strlen strlen
|
||||
#define VMPI_strcat strcat
|
||||
#define VMPI_strcpy strcpy
|
||||
#define VMPI_sprintf sprintf
|
||||
|
||||
extern void VMPI_setPageProtection(void *address,
|
||||
size_t size,
|
||||
bool executableFlag,
|
||||
|
Loading…
Reference in New Issue
Block a user