Commit 082b0d37 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] [cleanup] Replace std::unique_ptr by base::Optional

Both can be used to optionally initialize an object, but with
base::Optional it will be stack-allocated.

R=ahaas@chromium.org

Change-Id: I9977e1b2e0532505f8582cc68e27687aaeebd33d
Reviewed-on: https://chromium-review.googlesource.com/781920Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49548}
parent 0f2223c8
......@@ -5,6 +5,7 @@
#include "src/wasm/wasm-code-specialization.h"
#include "src/assembler-inl.h"
#include "src/base/optional.h"
#include "src/objects-inl.h"
#include "src/source-position-table.h"
#include "src/wasm/decoder.h"
......@@ -187,7 +188,7 @@ bool CodeSpecialization::ApplyToWasmCode(Code* code,
add_mode(reloc_direct_calls, RelocInfo::CODE_TARGET);
add_mode(reloc_pointers, RelocInfo::WASM_GLOBAL_HANDLE);
std::unique_ptr<PatchDirectCallsHelper> patch_direct_calls_helper;
base::Optional<PatchDirectCallsHelper> patch_direct_calls_helper;
bool changed = false;
// TODO(6792): No longer needed once WebAssembly code is off heap.
......@@ -207,8 +208,8 @@ bool CodeSpecialization::ApplyToWasmCode(Code* code,
// bytes to find the new compiled function.
size_t offset = it.rinfo()->pc() - code->instruction_start();
if (!patch_direct_calls_helper) {
patch_direct_calls_helper.reset(new PatchDirectCallsHelper(
*relocate_direct_calls_instance, code));
patch_direct_calls_helper.emplace(*relocate_direct_calls_instance,
code);
}
int byte_pos = AdvanceSourcePositionTableIterator(
patch_direct_calls_helper->source_pos_it, offset);
......
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