@@ -137,21 +137,11 @@ bool A64Emitter::Emit(GuestFunction* function, HIRBuilder* builder,
137137
138138void * A64Emitter::Emplace (const EmitFunctionInfo& func_info,
139139 GuestFunction* function) {
140- // To avoid changing xbyak, we do a switcharoo here.
141- // top_ points to the Xbyak buffer, and since we are in AutoGrow mode
142- // it has pending relocations. We copy the top_ to our buffer, swap the
143- // pointer, relocate, then return the original scratch pointer for use.
144- // top_ is used by Xbyak's ready() as both write base pointer and the absolute
145- // address base, which would not work on platforms not supporting writable
146- // executable memory, but Xenia doesn't use absolute label addresses in the
147- // generated code.
148-
149- // uint8_t* old_address = top_;
140+ // Copy the current oaknut instruction-buffer into the code-cache
150141 uint32_t * old_address = CodeBlock::ptr ();
151142 void * new_execute_address;
152143 void * new_write_address;
153144
154- // assert_true(func_info.code_size.total == size_);
155145 assert_true (func_info.code_size .total == offset ());
156146
157147 if (function) {
@@ -162,15 +152,9 @@ void* A64Emitter::Emplace(const EmitFunctionInfo& func_info,
162152 code_cache_->PlaceHostCode (0 , CodeBlock::ptr (), func_info,
163153 new_execute_address, new_write_address);
164154 }
165- // top_ = reinterpret_cast<uint8_t*>(new_write_address);
166- // set_wptr(reinterpret_cast<uint32_t*>(new_write_address));
167155
168- // ready();
169-
170- // top_ = old_address;
156+ // Reset the oaknut instruction-buffer
171157 set_wptr (reinterpret_cast <uint32_t *>(old_address));
172-
173- // reset();
174158 label_lookup_.clear ();
175159
176160 return new_execute_address;
@@ -357,7 +341,7 @@ void A64Emitter::MarkSourceOffset(const Instr* i) {
357341}
358342
359343void A64Emitter::EmitGetCurrentThreadId () {
360- // rsi must point to context. We could fetch from the stack if needed.
344+ // X27 must point to context. We could fetch from the stack if needed.
361345 LDRH (W0, GetContextReg (), offsetof (ppc::PPCContext, thread_id));
362346}
363347
@@ -442,14 +426,11 @@ void A64Emitter::Call(const hir::Instr* instr, GuestFunction* function) {
442426 // TODO(benvanik): is it worth it to do this? It removes the need for
443427 // a ResolveFunction call, but makes the table less useful.
444428 assert_zero (uint64_t (fn->machine_code ()) & 0xFFFFFFFF00000000 );
445- // mov(eax, uint32_t(uint64_t(fn->machine_code())));
446429 MOV (X16, uint32_t (uint64_t (fn->machine_code ())));
447430 } else if (code_cache_->has_indirection_table ()) {
448431 // Load the pointer to the indirection table maintained in A64CodeCache.
449432 // The target dword will either contain the address of the generated code
450433 // or a thunk to ResolveAddress.
451- // mov(ebx, function->address());
452- // mov(eax, dword[ebx]);
453434 MOV (W17, function->address ());
454435 LDR (W16, X17);
455436 } else {
@@ -476,10 +457,8 @@ void A64Emitter::Call(const hir::Instr* instr, GuestFunction* function) {
476457 BR (X16);
477458 } else {
478459 // Return address is from the previous SET_RETURN_ADDRESS.
479- // mov(rcx, qword[rsp + StackLayout::GUEST_CALL_RET_ADDR]);
480460 LDR (X0, SP, StackLayout::GUEST_CALL_RET_ADDR);
481461
482- // call(rax);
483462 BLR (X16);
484463 }
485464}
@@ -488,8 +467,6 @@ void A64Emitter::CallIndirect(const hir::Instr* instr,
488467 const oaknut::XReg& reg) {
489468 // Check if return.
490469 if (instr->flags & hir::CALL_POSSIBLE_RETURN) {
491- // cmp(reg.cvt32(), dword[rsp + StackLayout::GUEST_RET_ADDR]);
492- // je(epilog_label(), CodeGenerator::T_NEAR);
493470 LDR (W16, SP, StackLayout::GUEST_RET_ADDR);
494471 CMP (reg.toW (), W16);
495472 B (oaknut::Cond::EQ, epilog_label ());
@@ -622,8 +599,6 @@ void A64Emitter::CallNativeSafe(void* fn) {
622599}
623600
624601void A64Emitter::SetReturnAddress (uint64_t value) {
625- // mov(rax, value);
626- // mov(qword[rsp + StackLayout::GUEST_CALL_RET_ADDR], rax);
627602 MOV (X0, value);
628603 STR (X0, SP, StackLayout::GUEST_CALL_RET_ADDR);
629604}
0 commit comments