Making functions naked for now, as it makes life way easier.

This commit is contained in:
Ben Vanik 2014-01-02 23:53:18 -08:00
parent 99c200fda5
commit 2468645bf2
2 changed files with 19 additions and 7 deletions

View File

@ -213,12 +213,17 @@ void X64CodeChunk::AddTableEntry(uint8_t* code, size_t code_size) {
size_t unwind_info_offset = offset;
offset += UNWIND_INFO_SIZE;
// TODO(benvanik): take as parameters?
bool has_prolog = false;
uint8_t prolog_size = 4;
uint8_t stack_bytes = 16;
// http://msdn.microsoft.com/en-us/library/ddssxxy8.aspx
UNWIND_INFO* unwind_info = (UNWIND_INFO*)(buffer + unwind_info_offset);
unwind_info->Version = 1;
unwind_info->Flags = 0;
unwind_info->SizeOfProlog = 4;
unwind_info->CountOfCodes = 1;
unwind_info->SizeOfProlog = has_prolog ? prolog_size : 0;
unwind_info->CountOfCodes = has_prolog ? 1 : 0;
unwind_info->FrameRegister = 0;
unwind_info->FrameOffset = 0;
@ -226,7 +231,8 @@ void X64CodeChunk::AddTableEntry(uint8_t* code, size_t code_size) {
auto& code_0 = unwind_info->UnwindCode[0];
code_0.CodeOffset = 4; // end of instruction + 1 == offset of next instruction
code_0.UnwindOp = UWOP_ALLOC_SMALL;
code_0.OpInfo = 16;
code_0.OpInfo = stack_bytes;
XEASSERT(stack_bytes < 128);
// Add entry.
auto& fn_entry = fn_table[fn_table_count++];

View File

@ -103,7 +103,7 @@ void* XbyakGenerator::Emplace(X64CodeCache* code_cache) {
int XbyakGenerator::Emit(LIRBuilder* builder) {
// Function prolog.
// Must be 16b aligned.
// Windows is very strict about the form of this and the eiplog:
// Windows is very strict about the form of this and the epilog:
// http://msdn.microsoft.com/en-us/library/tawsa7cb.aspx
// TODO(benvanik): save off non-volatile registers so we can use them:
// RBX, RBP, RDI, RSI, RSP, R12, R13, R14, R15
@ -112,8 +112,12 @@ int XbyakGenerator::Emit(LIRBuilder* builder) {
// IMPORTANT: any changes to the prolog must be kept in sync with
// X64CodeCache, which dynamically generates exception information.
// Adding or changing anything here must be matched!
const bool emit_prolog = false;
const size_t stack_size = 16;
sub(rsp, stack_size);
if (emit_prolog) {
sub(rsp, stack_size);
// TODO(benvanik): save registers.
}
// Body.
auto block = builder->first_block();
@ -145,8 +149,10 @@ int XbyakGenerator::Emit(LIRBuilder* builder) {
// Function epilog.
L("epilog");
add(rsp, stack_size);
// TODO(benvanik): restore registers.
if (emit_prolog) {
add(rsp, stack_size);
// TODO(benvanik): restore registers.
}
ret();
return 0;