Commit e7070c2f authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Fix race in code lookup for exception locations.

R=clemensh@chromium.org
BUG=v8:7424

Change-Id: Ifa7029872c4d5cfda2f2411534abad6970dda323
Reviewed-on: https://chromium-review.googlesource.com/1156549Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55034}
parent aa87ae47
......@@ -1737,18 +1737,15 @@ bool Isolate::ComputeLocationFromStackTrace(MessageLocation* target,
Handle<WasmInstanceObject> instance(elements->WasmInstance(i), this);
uint32_t func_index =
static_cast<uint32_t>(elements->WasmFunctionIndex(i)->value());
wasm::WasmCode* wasm_code = reinterpret_cast<wasm::WasmCode*>(
elements->WasmCodeObject(i)->foreign_address());
int code_offset = elements->Offset(i)->value();
// TODO(titzer): store a reference to the code object in FrameArray;
// a second lookup here could lead to inconsistency.
int byte_offset =
FrameSummary::WasmCompiledFrameSummary::GetWasmSourcePosition(
instance->module_object()->native_module()->code(func_index),
code_offset);
bool is_at_number_conversion =
elements->IsAsmJsWasmFrame(i) &&
elements->Flags(i)->value() & FrameArray::kAsmJsAtNumberConversion;
int byte_offset =
FrameSummary::WasmCompiledFrameSummary::GetWasmSourcePosition(
wasm_code, code_offset);
int pos = WasmModuleObject::GetSourcePosition(
handle(instance->module_object(), this), func_index, byte_offset,
is_at_number_conversion);
......
......@@ -649,8 +649,8 @@ void WasmStackFrame::FromFrameArray(Isolate* isolate, Handle<FrameArray> array,
if (array->IsWasmInterpretedFrame(frame_ix)) {
code_ = nullptr;
} else {
code_ = wasm_instance_->module_object()->native_module()->code(
wasm_func_index_);
code_ = reinterpret_cast<wasm::WasmCode*>(
array->WasmCodeObject(frame_ix)->foreign_address());
}
offset_ = array->Offset(frame_ix)->value();
}
......
......@@ -10629,14 +10629,16 @@ Handle<FrameArray> FrameArray::AppendJSFrame(Handle<FrameArray> in,
Handle<FrameArray> FrameArray::AppendWasmFrame(
Handle<FrameArray> in, Handle<WasmInstanceObject> wasm_instance,
int wasm_function_index, wasm::WasmCode* code, int offset, int flags) {
Isolate* isolate = wasm_instance->GetIsolate();
const int frame_count = in->FrameCount();
const int new_length = LengthFor(frame_count + 1);
Handle<FrameArray> array =
EnsureSpace(wasm_instance->GetIsolate(), in, new_length);
Handle<FrameArray> array = EnsureSpace(isolate, in, new_length);
// The {code} will be {nullptr} for interpreted wasm frames.
Handle<Foreign> code_foreign =
isolate->factory()->NewForeign(reinterpret_cast<Address>(code));
array->SetWasmInstance(frame_count, *wasm_instance);
array->SetWasmFunctionIndex(frame_count, Smi::FromInt(wasm_function_index));
// The {code} will be {nullptr} for interpreted wasm frames.
array->SetIsWasmInterpreterFrame(frame_count, Smi::FromInt(code == nullptr));
array->SetWasmCodeObject(frame_count, *code_foreign);
array->SetOffset(frame_count, Smi::FromInt(offset));
array->SetFlags(frame_count, Smi::FromInt(flags));
array->set(kFrameCountIndex, Smi::FromInt(frame_count + 1));
......
......@@ -20,7 +20,7 @@ class Handle;
#define FRAME_ARRAY_FIELD_LIST(V) \
V(WasmInstance, WasmInstanceObject) \
V(WasmFunctionIndex, Smi) \
V(IsWasmInterpreterFrame, Smi) \
V(WasmCodeObject, Foreign) \
V(Receiver, Object) \
V(Function, JSFunction) \
V(Code, AbstractCode) \
......@@ -74,7 +74,7 @@ class FrameArray : public FixedArray {
static const int kWasmInstanceOffset = 0;
static const int kWasmFunctionIndexOffset = 1;
static const int kIsWasmInterpreterFrameOffset = 2;
static const int kWasmCodeObjectOffset = 2;
static const int kReceiverOffset = 0;
static const int kFunctionOffset = 1;
......
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