[wasm] Make {ProtectedInstructions} unique per module.
Now that we no longer clone {WasmCode} objects, the referenced protected instructions became unique to each such object. We no longer need to maintain a reference count on the protected instructions. R=clemensh@chromium.org Change-Id: Iaa5b9cd4b56cc06d75f7d0b71429b6147378c2ca Reviewed-on: https://chromium-review.googlesource.com/1034061 Commit-Queue: Michael Starzinger <mstarzinger@chromium.org> Reviewed-by: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#52881}
This commit is contained in:
parent
833c3dbf97
commit
9011927acd
@ -388,7 +388,7 @@ WasmCode* NativeModule::AddOwnedCode(
|
||||
Maybe<uint32_t> index, WasmCode::Kind kind, size_t constant_pool_offset,
|
||||
uint32_t stack_slots, size_t safepoint_table_offset,
|
||||
size_t handler_table_offset,
|
||||
std::shared_ptr<ProtectedInstructions> protected_instructions,
|
||||
std::unique_ptr<ProtectedInstructions> protected_instructions,
|
||||
WasmCode::Tier tier, WasmCode::FlushICache flush_icache) {
|
||||
// both allocation and insertion in owned_code_ happen in the same critical
|
||||
// section, thus ensuring owned_code_'s elements are rarely if ever moved.
|
||||
@ -469,7 +469,7 @@ WasmCode* NativeModule::AddAnonymousCode(Handle<Code> code,
|
||||
source_pos.reset(new byte[source_pos_table->length()]);
|
||||
source_pos_table->copy_out(0, source_pos.get(), source_pos_table->length());
|
||||
}
|
||||
std::shared_ptr<ProtectedInstructions> protected_instructions(
|
||||
std::unique_ptr<ProtectedInstructions> protected_instructions(
|
||||
new ProtectedInstructions(0));
|
||||
Vector<const byte> orig_instructions(
|
||||
reinterpret_cast<byte*>(code->raw_instruction_start()),
|
||||
@ -483,15 +483,15 @@ WasmCode* NativeModule::AddAnonymousCode(Handle<Code> code,
|
||||
static_cast<size_t>(code->relocation_size()), // reloc_size
|
||||
std::move(source_pos), // source positions
|
||||
static_cast<size_t>(source_pos_table->length()),
|
||||
Nothing<uint32_t>(), // index
|
||||
kind, // kind
|
||||
code->constant_pool_offset(), // constant_pool_offset
|
||||
stack_slots, // stack_slots
|
||||
safepoint_table_offset, // safepoint_table_offset
|
||||
code->handler_table_offset(), // handler_table_offset
|
||||
protected_instructions, // protected_instructions
|
||||
WasmCode::kOther, // kind
|
||||
WasmCode::kNoFlushICache); // flush_icache
|
||||
Nothing<uint32_t>(), // index
|
||||
kind, // kind
|
||||
code->constant_pool_offset(), // constant_pool_offset
|
||||
stack_slots, // stack_slots
|
||||
safepoint_table_offset, // safepoint_table_offset
|
||||
code->handler_table_offset(), // handler_table_offset
|
||||
std::move(protected_instructions), // protected_instructions
|
||||
WasmCode::kOther, // kind
|
||||
WasmCode::kNoFlushICache); // flush_icache
|
||||
intptr_t delta = ret->instruction_start() - code->raw_instruction_start();
|
||||
int mask = RelocInfo::kApplyMask | RelocInfo::kCodeTargetMask |
|
||||
RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
|
||||
@ -769,15 +769,17 @@ WasmCode* NativeModule::CloneCode(const WasmCode* original_code,
|
||||
memcpy(source_pos.get(), original_code->source_positions().start(),
|
||||
original_code->source_positions().size());
|
||||
}
|
||||
DCHECK_EQ(0, original_code->protected_instructions().size());
|
||||
std::unique_ptr<ProtectedInstructions> protected_instructions(
|
||||
new ProtectedInstructions(0));
|
||||
WasmCode* ret = AddOwnedCode(
|
||||
original_code->instructions(), std::move(reloc_info),
|
||||
original_code->reloc_info().size(), std::move(source_pos),
|
||||
original_code->source_positions().size(), original_code->index_,
|
||||
original_code->kind(), original_code->constant_pool_offset_,
|
||||
original_code->stack_slots(), original_code->safepoint_table_offset_,
|
||||
original_code->handler_table_offset_,
|
||||
original_code->protected_instructions_, original_code->tier(),
|
||||
flush_icache);
|
||||
original_code->handler_table_offset_, std::move(protected_instructions),
|
||||
original_code->tier(), flush_icache);
|
||||
if (!ret->IsAnonymous()) {
|
||||
code_table_[ret->index()] = ret;
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ class V8_EXPORT_PRIVATE WasmCode final {
|
||||
Maybe<uint32_t> index, Kind kind, size_t constant_pool_offset,
|
||||
uint32_t stack_slots, size_t safepoint_table_offset,
|
||||
size_t handler_table_offset,
|
||||
std::shared_ptr<ProtectedInstructions> protected_instructions,
|
||||
std::unique_ptr<ProtectedInstructions> protected_instructions,
|
||||
Tier tier)
|
||||
: instructions_(instructions),
|
||||
reloc_info_(std::move(reloc_info)),
|
||||
@ -201,7 +201,7 @@ class V8_EXPORT_PRIVATE WasmCode final {
|
||||
size_t safepoint_table_offset_ = 0;
|
||||
size_t handler_table_offset_ = 0;
|
||||
intptr_t trap_handler_index_ = -1;
|
||||
std::shared_ptr<ProtectedInstructions> protected_instructions_;
|
||||
std::unique_ptr<ProtectedInstructions> protected_instructions_;
|
||||
Tier tier_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(WasmCode);
|
||||
@ -311,7 +311,7 @@ class V8_EXPORT_PRIVATE NativeModule final {
|
||||
WasmCode::Kind kind, size_t constant_pool_offset,
|
||||
uint32_t stack_slots, size_t safepoint_table_offset,
|
||||
size_t handler_table_offset,
|
||||
std::shared_ptr<ProtectedInstructions>, WasmCode::Tier,
|
||||
std::unique_ptr<ProtectedInstructions>, WasmCode::Tier,
|
||||
WasmCode::FlushICache);
|
||||
WasmCode* CloneCode(const WasmCode*, WasmCode::FlushICache);
|
||||
WasmCode* Lookup(Address);
|
||||
|
@ -480,9 +480,6 @@ bool NativeModuleDeserializer::ReadCode(uint32_t fn_index, Reader* reader) {
|
||||
size_t protected_instructions_size = reader->Read<size_t>();
|
||||
WasmCode::Tier tier = reader->Read<WasmCode::Tier>();
|
||||
|
||||
std::shared_ptr<ProtectedInstructions> protected_instructions(
|
||||
new ProtectedInstructions(protected_instructions_size));
|
||||
|
||||
Vector<const byte> code_buffer = {reader->current_location(), code_size};
|
||||
reader->Skip(code_size);
|
||||
|
||||
@ -496,11 +493,20 @@ bool NativeModuleDeserializer::ReadCode(uint32_t fn_index, Reader* reader) {
|
||||
source_pos.reset(new byte[source_position_size]);
|
||||
reader->ReadVector({source_pos.get(), source_position_size});
|
||||
}
|
||||
std::unique_ptr<ProtectedInstructions> protected_instructions(
|
||||
new ProtectedInstructions(protected_instructions_size));
|
||||
if (protected_instructions_size > 0) {
|
||||
size_t size = sizeof(trap_handler::ProtectedInstructionData) *
|
||||
protected_instructions->size();
|
||||
Vector<byte> data(reinterpret_cast<byte*>(protected_instructions->data()),
|
||||
size);
|
||||
reader->ReadVector(data);
|
||||
}
|
||||
WasmCode* ret = native_module_->AddOwnedCode(
|
||||
code_buffer, std::move(reloc_info), reloc_size, std::move(source_pos),
|
||||
source_position_size, Just(fn_index), WasmCode::kFunction,
|
||||
constant_pool_offset, stack_slot_count, safepoint_table_offset,
|
||||
handler_table_offset, protected_instructions, tier,
|
||||
handler_table_offset, std::move(protected_instructions), tier,
|
||||
WasmCode::kNoFlushICache);
|
||||
native_module_->code_table_[fn_index] = ret;
|
||||
|
||||
@ -551,13 +557,6 @@ bool NativeModuleDeserializer::ReadCode(uint32_t fn_index, Reader* reader) {
|
||||
Assembler::FlushICache(ret->instructions().start(),
|
||||
ret->instructions().size());
|
||||
|
||||
if (protected_instructions_size > 0) {
|
||||
size_t size = sizeof(trap_handler::ProtectedInstructionData) *
|
||||
protected_instructions->size();
|
||||
Vector<byte> data(reinterpret_cast<byte*>(protected_instructions->data()),
|
||||
size);
|
||||
reader->ReadVector(data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user