Commit b9abc7f0 authored by Brad Nelson's avatar Brad Nelson Committed by Commit Bot

[wasm] Enable guards on 64-bit systems.

R=eholk@chromium.org

Bug: 
Change-Id: Ia099cf085510da50a87b9f999020d6a66d6eab20
Reviewed-on: https://chromium-review.googlesource.com/838250
Commit-Queue: Brad Nelson <bradnelson@chromium.org>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarEric Holk <eholk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50300}
parent 461274fb
......@@ -3174,7 +3174,14 @@ Handle<JSArrayBuffer> InstanceBuilder::AllocateMemory(uint32_t num_pages) {
thrower_->RangeError("Out of memory: wasm memory too large");
return Handle<JSArrayBuffer>::null();
}
#if V8_TARGET_ARCH_64_BIT && !defined(THREAD_SANITIZER) && \
!defined(LEAK_SANITIZER) && !defined(V8_USE_ADDRESS_SANITIZER)
// TODO(eholk): Enable sanitizers once we have back-pressure.
// Always turn on guard regions in 64-bit.
const bool enable_guard_regions = true;
#else
const bool enable_guard_regions = use_trap_handler();
#endif
const bool is_shared_memory =
module_->has_shared_memory && i::FLAG_experimental_wasm_threads;
Handle<JSArrayBuffer> mem_buffer = NewArrayBuffer(
......
......@@ -600,8 +600,15 @@ void WebAssemblyMemory(const v8::FunctionCallbackInfo<v8::Value>& args) {
size_t size = static_cast<size_t>(i::wasm::WasmModule::kPageSize) *
static_cast<size_t>(initial);
#if V8_TARGET_ARCH_64_BIT && !defined(THREAD_SANITIZER) && \
!defined(LEAK_SANITIZER) && !defined(V8_USE_ADDRESS_SANITIZER)
// TODO(eholk): Enable sanitizers once we have back-pressure.
// Always turn on guard regions in 64-bit.
const bool enable_guard_regions = true;
#else
const bool enable_guard_regions =
internal::trap_handler::IsTrapHandlerEnabled();
#endif
i::Handle<i::JSArrayBuffer> buffer = i::wasm::NewArrayBuffer(
i_isolate, size, enable_guard_regions,
is_shared_memory ? i::SharedFlag::kShared : i::SharedFlag::kNotShared);
......
......@@ -369,8 +369,17 @@ Handle<JSArrayBuffer> GrowMemoryBuffer(Isolate* isolate,
if (old_pages > maximum_pages || pages > maximum_pages - old_pages) {
return Handle<JSArrayBuffer>::null();
}
#if V8_TARGET_ARCH_64_BIT && !defined(THREAD_SANITIZER) && \
!defined(LEAK_SANITIZER) && !defined(V8_USE_ADDRESS_SANITIZER)
// TODO(eholk): Enable sanitizers once we have back-pressure.
// Always turn on guard regions in 64-bit.
// But allow for previously unguarded memory for some cctests.
const bool enable_guard_regions =
old_buffer.is_null() ? true : old_buffer->has_guard_region();
#else
const bool enable_guard_regions =
old_buffer.is_null() ? use_trap_handler : old_buffer->has_guard_region();
#endif
size_t new_size =
static_cast<size_t>(old_pages + pages) * WasmModule::kPageSize;
if (new_size > FLAG_wasm_max_mem_pages * WasmModule::kPageSize ||
......
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