mirror of
https://github.com/corda/corda.git
synced 2025-01-06 05:04:20 +00:00
give thunks symbol names in the bootimage build, use Heap::allocate instead of malloc
This commit is contained in:
parent
4266b0df7f
commit
7c38ea75e4
@ -55,7 +55,7 @@ public:
|
|||||||
unsigned addr;
|
unsigned addr;
|
||||||
String name;
|
String name;
|
||||||
|
|
||||||
inline SymbolInfo(uint64_t addr, const char* name):
|
inline SymbolInfo(uint64_t addr, const String& name):
|
||||||
addr(addr),
|
addr(addr),
|
||||||
name(name) {}
|
name(name) {}
|
||||||
|
|
||||||
|
@ -1291,28 +1291,32 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp
|
|||||||
|
|
||||||
class MyCompilationHandler : public Processor::CompilationHandler {
|
class MyCompilationHandler : public Processor::CompilationHandler {
|
||||||
public:
|
public:
|
||||||
virtual void compiled(const void* code, unsigned size UNUSED, unsigned frameSize UNUSED, const char* class_, const char* name, const char* spec) {
|
|
||||||
if (class_ and name and spec) {
|
String heapDup(const char* name) {
|
||||||
size_t classLen = strlen(class_);
|
String ret(name);
|
||||||
size_t nameLen = strlen(name);
|
char* n = (char*)heap->allocate(ret.length + 1);
|
||||||
size_t specLen = strlen(spec);
|
memcpy(n, ret.text, ret.length + 1);
|
||||||
|
ret.text = n;
|
||||||
char* completeName = (char*)malloc(classLen + nameLen + specLen + 2);
|
return ret;
|
||||||
sprintf(completeName, "%s.%s%s", class_, name, spec);
|
}
|
||||||
uint64_t offset = reinterpret_cast<uint64_t>(code) - codeOffset;
|
|
||||||
symbols.add(SymbolInfo(offset, completeName));
|
virtual void compiled(const void* code, unsigned size UNUSED, unsigned frameSize UNUSED, const char* name) {
|
||||||
// printf("%ld %ld %s.%s%s\n", offset, offset + size, class_, name, spec);
|
uint64_t offset = reinterpret_cast<uint64_t>(code) - codeOffset;
|
||||||
}
|
symbols.add(SymbolInfo(offset, heapDup(name)));
|
||||||
|
// printf("%ld %ld %s.%s%s\n", offset, offset + size, class_, name, spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void dispose() {}
|
virtual void dispose() {}
|
||||||
|
|
||||||
DynamicArray<SymbolInfo> symbols;
|
DynamicArray<SymbolInfo> symbols;
|
||||||
uint64_t codeOffset;
|
uint64_t codeOffset;
|
||||||
|
Heap* heap;
|
||||||
|
|
||||||
MyCompilationHandler(uint64_t codeOffset):
|
MyCompilationHandler(uint64_t codeOffset, Heap* heap):
|
||||||
codeOffset(codeOffset) {}
|
codeOffset(codeOffset),
|
||||||
} compilationHandler(reinterpret_cast<uint64_t>(code));
|
heap(heap) {}
|
||||||
|
|
||||||
|
} compilationHandler(reinterpret_cast<uint64_t>(code), t->m->heap);
|
||||||
|
|
||||||
t->m->processor->addCompilationHandler(&compilationHandler);
|
t->m->processor->addCompilationHandler(&compilationHandler);
|
||||||
|
|
||||||
@ -1660,13 +1664,13 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp
|
|||||||
|
|
||||||
platform->writeObject(bootimageOutput, Slice<SymbolInfo>(bootimageSymbols, 2), Slice<const uint8_t>(bootimageData.data, bootimageData.length), Platform::Writable, TargetBytesPerWord);
|
platform->writeObject(bootimageOutput, Slice<SymbolInfo>(bootimageSymbols, 2), Slice<const uint8_t>(bootimageData.data, bootimageData.length), Platform::Writable, TargetBytesPerWord);
|
||||||
|
|
||||||
compilationHandler.symbols.add(SymbolInfo(0, strdup("_binary_codeimage_bin_start")));
|
compilationHandler.symbols.add(SymbolInfo(0, "_binary_codeimage_bin_start"));
|
||||||
compilationHandler.symbols.add(SymbolInfo(image->codeSize, strdup("_binary_codeimage_bin_end")));
|
compilationHandler.symbols.add(SymbolInfo(image->codeSize, "_binary_codeimage_bin_end"));
|
||||||
|
|
||||||
platform->writeObject(codeOutput, Slice<SymbolInfo>(compilationHandler.symbols), Slice<const uint8_t>(code, image->codeSize), Platform::Executable, TargetBytesPerWord);
|
platform->writeObject(codeOutput, Slice<SymbolInfo>(compilationHandler.symbols), Slice<const uint8_t>(code, image->codeSize), Platform::Executable, TargetBytesPerWord);
|
||||||
|
|
||||||
for(SymbolInfo* sym = compilationHandler.symbols.begin(); sym != compilationHandler.symbols.end(); sym++) {
|
for(SymbolInfo* sym = compilationHandler.symbols.begin(); sym != compilationHandler.symbols.end() - 2; sym++) {
|
||||||
free(const_cast<void*>((const void*)sym->name.text));
|
t->m->heap->free(const_cast<void*>((const void*)sym->name.text), sym->name.length + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9087,6 +9087,20 @@ class MyProcessor: public Processor {
|
|||||||
CompilationHandlerList* compilationHandlers;
|
CompilationHandlerList* compilationHandlers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char*
|
||||||
|
stringOrNull(const char* str) {
|
||||||
|
if(str) {
|
||||||
|
return str;
|
||||||
|
} else {
|
||||||
|
return "(null)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
stringOrNullSize(const char* str) {
|
||||||
|
return strlen(stringOrNull(str));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
logCompile(MyThread* t, const void* code, unsigned size, const char* class_,
|
logCompile(MyThread* t, const void* code, unsigned size, const char* class_,
|
||||||
const char* name, const char* spec)
|
const char* name, const char* spec)
|
||||||
@ -9108,9 +9122,15 @@ logCompile(MyThread* t, const void* code, unsigned size, const char* class_,
|
|||||||
class_, name, spec);
|
class_, name, spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t nameLength = stringOrNullSize(class_) + stringOrNullSize(name) + stringOrNullSize(spec) + 2;
|
||||||
|
|
||||||
|
THREAD_RUNTIME_ARRAY(t, char, completeName, nameLength);
|
||||||
|
|
||||||
|
sprintf(RUNTIME_ARRAY_BODY(completeName), "%s.%s%s", stringOrNull(class_), stringOrNull(name), stringOrNull(spec));
|
||||||
|
|
||||||
MyProcessor* p = static_cast<MyProcessor*>(t->m->processor);
|
MyProcessor* p = static_cast<MyProcessor*>(t->m->processor);
|
||||||
for(CompilationHandlerList* h = p->compilationHandlers; h; h = h->next) {
|
for(CompilationHandlerList* h = p->compilationHandlers; h; h = h->next) {
|
||||||
h->handler->compiled(code, 0, 0, class_, name, spec);
|
h->handler->compiled(code, 0, 0, RUNTIME_ARRAY_BODY(completeName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class Processor {
|
|||||||
|
|
||||||
class CompilationHandler {
|
class CompilationHandler {
|
||||||
public:
|
public:
|
||||||
virtual void compiled(const void* code, unsigned size, unsigned frameSize, const char* class_, const char* name, const char* spec) = 0;
|
virtual void compiled(const void* code, unsigned size, unsigned frameSize, const char* name) = 0;
|
||||||
|
|
||||||
virtual void dispose() = 0;
|
virtual void dispose() = 0;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user