rose: use bytecode_ptr for interpreter programs

This commit is contained in:
Justin Viiret 2017-04-04 11:19:07 +10:00 committed by Matthew Barr
parent 0a3bd455ad
commit b6047ea5d4
3 changed files with 14 additions and 13 deletions

View File

@ -2567,11 +2567,10 @@ u32 writeProgram(build_context &bc, RoseProgram &&program) {
recordResources(bc.resources, program);
recordLongLiterals(bc.longLiterals, program);
u32 len = 0;
auto prog_bytecode = writeProgram(bc.engine_blob, program, &len);
u32 offset = bc.engine_blob.add(prog_bytecode.get(), len,
ROSE_INSTR_MIN_ALIGN);
DEBUG_PRINTF("prog len %u written at offset %u\n", len, offset);
auto prog_bytecode = writeProgram(bc.engine_blob, program);
u32 offset = bc.engine_blob.add(prog_bytecode);
DEBUG_PRINTF("prog len %zu written at offset %u\n", prog_bytecode.size(),
offset);
bc.program_cache.emplace(move(program), offset);
return offset;
}

View File

@ -639,12 +639,14 @@ OffsetMap makeOffsetMap(const RoseProgram &program, u32 *total_len) {
return offset_map;
}
aligned_unique_ptr<char>
writeProgram(RoseEngineBlob &blob, const RoseProgram &program, u32 *total_len) {
const auto offset_map = makeOffsetMap(program, total_len);
DEBUG_PRINTF("%zu instructions, len %u\n", program.size(), *total_len);
bytecode_ptr<char> writeProgram(RoseEngineBlob &blob,
const RoseProgram &program) {
u32 total_len = 0;
const auto offset_map = makeOffsetMap(program, &total_len);
DEBUG_PRINTF("%zu instructions, len %u\n", program.size(), total_len);
auto bytecode = aligned_zmalloc_unique<char>(*total_len);
auto bytecode = make_zeroed_bytecode_ptr<char>(total_len,
ROSE_INSTR_MIN_ALIGN);
char *ptr = bytecode.get();
for (const auto &ri : program) {

View File

@ -32,7 +32,7 @@
#include "rose_build_impl.h"
#include "rose_program.h"
#include "som/som_operation.h"
#include "util/alloc.h"
#include "util/bytecode_ptr.h"
#include "util/container.h"
#include "util/hash.h"
#include "util/make_unique.h"
@ -2328,8 +2328,8 @@ public:
}
};
aligned_unique_ptr<char>
writeProgram(RoseEngineBlob &blob, const RoseProgram &program, u32 *total_len);
bytecode_ptr<char> writeProgram(RoseEngineBlob &blob,
const RoseProgram &program);
class RoseProgramHash {
public: