summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorHendiadyoin1 <leon.a@serenityos.org>2022-10-30 12:24:22 +0100
committerAndreas Kling <kling@serenityos.org>2022-11-01 11:21:18 +0100
commit1ac1a5bd58961e3964aa87c3a88777fe008cd3d3 (patch)
tree74b83adc0b3ba89258dc4532d053ebbcd0d378e2 /Userland/Libraries
parenta1f1d9e4a7309fe3ea2c3aa6e31fd4fe0a704121 (diff)
downloadserenity-1ac1a5bd58961e3964aa87c3a88777fe008cd3d3.zip
LibJS: Don't memcpy NewBigInt instruction
These aren't trivially copyable, so we have to be a bit more careful
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibJS/Bytecode/Pass/MergeBlocks.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/Userland/Libraries/LibJS/Bytecode/Pass/MergeBlocks.cpp b/Userland/Libraries/LibJS/Bytecode/Pass/MergeBlocks.cpp
index f9e3ac55bd..0d2bb4dac9 100644
--- a/Userland/Libraries/LibJS/Bytecode/Pass/MergeBlocks.cpp
+++ b/Userland/Libraries/LibJS/Bytecode/Pass/MergeBlocks.cpp
@@ -142,16 +142,24 @@ void MergeBlocks::perform(PassPipelineExecutable& executable)
for (size_t i = 0; i < successors.size(); ++i) {
auto& entry = successors[i];
InstructionStreamIterator it { entry->instruction_stream() };
- size_t copy_end = 0;
while (!it.at_end()) {
auto& instruction = *it;
++it;
if (instruction.is_terminator() && last_successor_index != i)
break;
- copy_end = it.offset();
+ // FIXME: Op::NewBigInt is not trivially copyable, so we cant use
+ // a simple memcpy to transfer them.
+ // When this is resolved we can use a single memcpy to copy
+ // the whole block at once
+ if (instruction.type() == Instruction::Type::NewBigInt) {
+ new (block.next_slot()) Op::NewBigInt(static_cast<Op::NewBigInt const&>(instruction));
+ block.grow(sizeof(Op::NewBigInt));
+ } else {
+ auto instruction_size = instruction.length();
+ memcpy(block.next_slot(), &instruction, instruction_size);
+ block.grow(instruction_size);
+ }
}
- __builtin_memcpy(block.next_slot(), entry->instruction_stream().data(), copy_end);
- block.grow(copy_end);
}
executable.executable.basic_blocks.insert(*first_successor_position, move(new_block));