Commit eeb772b2 authored by Jakob Kummerow's avatar Jakob Kummerow Committed by V8 LUCI CQ

[wasm] Fix TSan reports for feedback vector size access

By using atomic accessors.

Change-Id: I7ff8660aa118c809da9ce6ff851ebd5080a7b1c6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3217197
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77318}
parent 7b70036e
......@@ -6,6 +6,7 @@
#include "src/api/api.h"
#include "src/asmjs/asm-js.h"
#include "src/base/atomicops.h"
#include "src/base/platform/wrappers.h"
#include "src/logging/counters-scopes.h"
#include "src/logging/metrics.h"
......@@ -715,7 +716,8 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
instance->set_feedback_vectors(*vectors);
for (int i = 0; i < num_functions; i++) {
int func_index = module_->num_imported_functions + i;
int slots = module_->functions[func_index].feedback_slots;
int slots =
base::Relaxed_Load(&module_->functions[func_index].feedback_slots);
if (slots == 0) continue;
if (FLAG_trace_wasm_speculative_inlining) {
PrintF("[Function %d (declared %d): allocating %d feedback slots]\n",
......
......@@ -8,6 +8,7 @@
#include <iomanip>
#include <numeric>
#include "src/base/atomicops.h"
#include "src/base/build_config.h"
#include "src/base/iterator.h"
#include "src/base/macros.h"
......@@ -2268,10 +2269,13 @@ std::vector<std::unique_ptr<WasmCode>> NativeModule::AddCompiledCode(
total_code_space += RoundUp<kCodeAlignment>(result.code_desc.instr_size);
if (result.result_tier == ExecutionTier::kLiftoff) {
int index = result.func_index;
DCHECK(module()->functions[index].feedback_slots == 0 ||
module()->functions[index].feedback_slots ==
result.feedback_vector_slots);
module()->functions[index].feedback_slots = result.feedback_vector_slots;
int* slots = &module()->functions[index].feedback_slots;
#if DEBUG
int current_value = base::Relaxed_Load(slots);
DCHECK(current_value == 0 ||
current_value == result.feedback_vector_slots);
#endif
base::Relaxed_Store(slots, result.feedback_vector_slots);
}
}
base::Vector<byte> code_space;
......
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