More C++11ification.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <alloy/backend/x64/x64_assembler.h>
|
||||
|
||||
#include <alloy/reset_scope.h>
|
||||
#include <alloy/backend/x64/x64_backend.h>
|
||||
#include <alloy/backend/x64/x64_emitter.h>
|
||||
#include <alloy/backend/x64/x64_function.h>
|
||||
@@ -33,12 +34,9 @@ using alloy::runtime::Function;
|
||||
using alloy::runtime::FunctionInfo;
|
||||
|
||||
X64Assembler::X64Assembler(X64Backend* backend)
|
||||
: Assembler(backend), x64_backend_(backend), emitter_(0), allocator_(0) {}
|
||||
: Assembler(backend), x64_backend_(backend) {}
|
||||
|
||||
X64Assembler::~X64Assembler() {
|
||||
delete emitter_;
|
||||
delete allocator_;
|
||||
}
|
||||
X64Assembler::~X64Assembler() = default;
|
||||
|
||||
int X64Assembler::Initialize() {
|
||||
int result = Assembler::Initialize();
|
||||
@@ -46,8 +44,8 @@ int X64Assembler::Initialize() {
|
||||
return result;
|
||||
}
|
||||
|
||||
allocator_ = new XbyakAllocator();
|
||||
emitter_ = new X64Emitter(x64_backend_, allocator_);
|
||||
allocator_.reset(new XbyakAllocator());
|
||||
emitter_.reset(new X64Emitter(x64_backend_, allocator_.get()));
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -58,39 +56,39 @@ void X64Assembler::Reset() {
|
||||
}
|
||||
|
||||
int X64Assembler::Assemble(FunctionInfo* symbol_info, HIRBuilder* builder,
|
||||
uint32_t debug_info_flags, DebugInfo* debug_info,
|
||||
uint32_t debug_info_flags,
|
||||
std::unique_ptr<DebugInfo> debug_info,
|
||||
Function** out_function) {
|
||||
SCOPE_profile_cpu_f("alloy");
|
||||
|
||||
int result = 0;
|
||||
// Reset when we leave.
|
||||
make_reset_scope(this);
|
||||
|
||||
// Lower HIR -> x64.
|
||||
void* machine_code = 0;
|
||||
size_t code_size = 0;
|
||||
result = emitter_->Emit(builder, debug_info_flags, debug_info, machine_code,
|
||||
code_size);
|
||||
XEEXPECTZERO(result);
|
||||
int result = emitter_->Emit(builder, debug_info_flags, debug_info.get(),
|
||||
machine_code, code_size);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Stash generated machine code.
|
||||
if (debug_info_flags & DebugInfoFlags::DEBUG_INFO_MACHINE_CODE_DISASM) {
|
||||
DumpMachineCode(debug_info, machine_code, code_size, &string_buffer_);
|
||||
DumpMachineCode(debug_info.get(), machine_code, code_size, &string_buffer_);
|
||||
debug_info->set_machine_code_disasm(string_buffer_.ToString());
|
||||
string_buffer_.Reset();
|
||||
}
|
||||
|
||||
{
|
||||
X64Function* fn = new X64Function(symbol_info);
|
||||
fn->set_debug_info(debug_info);
|
||||
fn->set_debug_info(std::move(debug_info));
|
||||
fn->Setup(machine_code, code_size);
|
||||
|
||||
*out_function = fn;
|
||||
|
||||
result = 0;
|
||||
}
|
||||
|
||||
XECLEANUP:
|
||||
Reset();
|
||||
return result;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void X64Assembler::DumpMachineCode(DebugInfo* debug_info, void* machine_code,
|
||||
|
||||
Reference in New Issue
Block a user