mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
rose: use bytecode_ptr for interpreter programs
This commit is contained in:
parent
0a3bd455ad
commit
b6047ea5d4
@ -2567,11 +2567,10 @@ u32 writeProgram(build_context &bc, RoseProgram &&program) {
|
|||||||
recordResources(bc.resources, program);
|
recordResources(bc.resources, program);
|
||||||
recordLongLiterals(bc.longLiterals, program);
|
recordLongLiterals(bc.longLiterals, program);
|
||||||
|
|
||||||
u32 len = 0;
|
auto prog_bytecode = writeProgram(bc.engine_blob, program);
|
||||||
auto prog_bytecode = writeProgram(bc.engine_blob, program, &len);
|
u32 offset = bc.engine_blob.add(prog_bytecode);
|
||||||
u32 offset = bc.engine_blob.add(prog_bytecode.get(), len,
|
DEBUG_PRINTF("prog len %zu written at offset %u\n", prog_bytecode.size(),
|
||||||
ROSE_INSTR_MIN_ALIGN);
|
offset);
|
||||||
DEBUG_PRINTF("prog len %u written at offset %u\n", len, offset);
|
|
||||||
bc.program_cache.emplace(move(program), offset);
|
bc.program_cache.emplace(move(program), offset);
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
@ -639,12 +639,14 @@ OffsetMap makeOffsetMap(const RoseProgram &program, u32 *total_len) {
|
|||||||
return offset_map;
|
return offset_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
aligned_unique_ptr<char>
|
bytecode_ptr<char> writeProgram(RoseEngineBlob &blob,
|
||||||
writeProgram(RoseEngineBlob &blob, const RoseProgram &program, u32 *total_len) {
|
const RoseProgram &program) {
|
||||||
const auto offset_map = makeOffsetMap(program, total_len);
|
u32 total_len = 0;
|
||||||
DEBUG_PRINTF("%zu instructions, len %u\n", program.size(), *total_len);
|
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();
|
char *ptr = bytecode.get();
|
||||||
|
|
||||||
for (const auto &ri : program) {
|
for (const auto &ri : program) {
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "rose_build_impl.h"
|
#include "rose_build_impl.h"
|
||||||
#include "rose_program.h"
|
#include "rose_program.h"
|
||||||
#include "som/som_operation.h"
|
#include "som/som_operation.h"
|
||||||
#include "util/alloc.h"
|
#include "util/bytecode_ptr.h"
|
||||||
#include "util/container.h"
|
#include "util/container.h"
|
||||||
#include "util/hash.h"
|
#include "util/hash.h"
|
||||||
#include "util/make_unique.h"
|
#include "util/make_unique.h"
|
||||||
@ -2328,8 +2328,8 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
aligned_unique_ptr<char>
|
bytecode_ptr<char> writeProgram(RoseEngineBlob &blob,
|
||||||
writeProgram(RoseEngineBlob &blob, const RoseProgram &program, u32 *total_len);
|
const RoseProgram &program);
|
||||||
|
|
||||||
class RoseProgramHash {
|
class RoseProgramHash {
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user