Commit 444ee7bd authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Store trap handler index as int

The index is an {int} initially. We then store it as {intptr_t}, and
the accessor returns it as {size_t}.
This CL consolidates everything to {int}, fixes naming of
{HasTrapHandlerIndex} and defines the simple accessors inline.

R=titzer@chromium.org

Bug: v8:9183
Change-Id: I1afa792117201d4dda3fcc437a4e518489b9ff17
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1590079Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61146}
parent 7584a9b0
......@@ -126,17 +126,8 @@ uint32_t WasmCode::code_comments_size() const {
return static_cast<uint32_t>(unpadded_binary_size_ - code_comments_offset_);
}
size_t WasmCode::trap_handler_index() const {
CHECK(HasTrapHandlerIndex());
return static_cast<size_t>(trap_handler_index_);
}
void WasmCode::set_trap_handler_index(size_t value) {
trap_handler_index_ = value;
}
void WasmCode::RegisterTrapHandlerData() {
DCHECK(!HasTrapHandlerIndex());
DCHECK(!has_trap_handler_index());
if (kind() != WasmCode::kFunction) return;
if (protected_instructions_.empty()) return;
......@@ -149,11 +140,10 @@ void WasmCode::RegisterTrapHandlerData() {
// TODO(eholk): if index is negative, fail.
CHECK_LE(0, index);
set_trap_handler_index(static_cast<size_t>(index));
set_trap_handler_index(index);
DCHECK(has_trap_handler_index());
}
bool WasmCode::HasTrapHandlerIndex() const { return trap_handler_index_ >= 0; }
bool WasmCode::ShouldBeLogged(Isolate* isolate) {
// The return value is cached in {WasmEngine::IsolateData::log_codes}. Ensure
// to call {WasmEngine::EnableCodeLogging} if this return value would change
......@@ -373,10 +363,8 @@ const char* GetWasmCodeKindAsString(WasmCode::Kind kind) {
}
WasmCode::~WasmCode() {
if (HasTrapHandlerIndex()) {
CHECK_LT(trap_handler_index(),
static_cast<size_t>(std::numeric_limits<int>::max()));
trap_handler::ReleaseHandlerData(static_cast<int>(trap_handler_index()));
if (has_trap_handler_index()) {
trap_handler::ReleaseHandlerData(trap_handler_index());
}
}
......
......@@ -213,9 +213,15 @@ class V8_EXPORT_PRIVATE WasmCode final {
// Code objects that have been registered with the global trap handler within
// this process, will have a {trap_handler_index} associated with them.
size_t trap_handler_index() const;
void set_trap_handler_index(size_t);
bool HasTrapHandlerIndex() const;
int trap_handler_index() const {
CHECK(has_trap_handler_index());
return trap_handler_index_;
}
void set_trap_handler_index(int value) {
CHECK(!has_trap_handler_index());
trap_handler_index_ = value;
}
bool has_trap_handler_index() const { return trap_handler_index_ >= 0; }
// Register protected instruction information with the trap handler. Sets
// trap_handler_index.
......@@ -243,7 +249,7 @@ class V8_EXPORT_PRIVATE WasmCode final {
size_t handler_table_offset_ = 0;
size_t code_comments_offset_ = 0;
size_t unpadded_binary_size_ = 0;
intptr_t trap_handler_index_ = -1;
int trap_handler_index_ = -1;
OwnedVector<trap_handler::ProtectedInstructionData> protected_instructions_;
ExecutionTier tier_;
......
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