Commit 61391f36 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Ensure WasmCode always has protected instructions.

R=clemensh@chromium.org
TEST=mjsunit/regress/wasm/regress-808012
BUG=chromium:808012

Change-Id: Ia1e4527c6c845ffd01ecf5c7fa13b8b484d6ef6e
Reviewed-on: https://chromium-review.googlesource.com/899122
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51103}
parent 84504c2a
...@@ -393,13 +393,16 @@ WasmCode* NativeModule::AddAnonymousCode(Handle<Code> code, ...@@ -393,13 +393,16 @@ WasmCode* NativeModule::AddAnonymousCode(Handle<Code> code,
reloc_info.reset(new byte[code->relocation_size()]); reloc_info.reset(new byte[code->relocation_size()]);
memcpy(reloc_info.get(), code->relocation_start(), code->relocation_size()); memcpy(reloc_info.get(), code->relocation_start(), code->relocation_size());
} }
std::shared_ptr<ProtectedInstructions> protected_instructions(
new ProtectedInstructions(0));
WasmCode* ret = AddOwnedCode( WasmCode* ret = AddOwnedCode(
{code->instruction_start(), {code->instruction_start(),
static_cast<size_t>(code->instruction_size())}, static_cast<size_t>(code->instruction_size())},
std::move(reloc_info), static_cast<size_t>(code->relocation_size()), std::move(reloc_info), static_cast<size_t>(code->relocation_size()),
Nothing<uint32_t>(), kind, code->constant_pool_offset(), Nothing<uint32_t>(), kind, code->constant_pool_offset(),
(code->has_safepoint_info() ? code->stack_slots() : 0), (code->has_safepoint_info() ? code->stack_slots() : 0),
(code->has_safepoint_info() ? code->safepoint_table_offset() : 0), {}); (code->has_safepoint_info() ? code->safepoint_table_offset() : 0),
protected_instructions);
if (ret == nullptr) return nullptr; if (ret == nullptr) return nullptr;
intptr_t delta = ret->instructions().start() - code->instruction_start(); intptr_t delta = ret->instructions().start() - code->instruction_start();
int mask = RelocInfo::kApplyMask | RelocInfo::kCodeTargetMask | int mask = RelocInfo::kApplyMask | RelocInfo::kCodeTargetMask |
......
...@@ -120,6 +120,9 @@ class V8_EXPORT_PRIVATE WasmCode final { ...@@ -120,6 +120,9 @@ class V8_EXPORT_PRIVATE WasmCode final {
void ResetTrapHandlerIndex(); void ResetTrapHandlerIndex();
const ProtectedInstructions& protected_instructions() const { const ProtectedInstructions& protected_instructions() const {
// TODO(mstarzinger): Code that doesn't have trapping instruction should
// not be required to have this vector, make it possible to be null.
DCHECK_NOT_NULL(protected_instructions_);
return *protected_instructions_.get(); return *protected_instructions_.get();
} }
......
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --wasm-lazy-compilation
load('test/mjsunit/wasm/wasm-constants.js');
load('test/mjsunit/wasm/wasm-module-builder.js');
const builder = new WasmModuleBuilder();
builder.addFunction('test', kSig_i_i).addBody([kExprUnreachable]);
let module = new WebAssembly.Module(builder.toBuffer());
var worker = new Worker('onmessage = function() {};');
worker.postMessage(module);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment