Commit d11ccc5c authored by Maya Lekova's avatar Maya Lekova Committed by V8 LUCI CQ

Migrate PerIsolateAssertScope storage to separate booleans

This CL modifies the underlying storage of PerIsolateAssertScope from
a bitfield to separate booleans. This slightly increases the space taken
by the isolate, but allows for easier access to the individual fields,
which is a prerequisite for implementing assertion scopes in TurboFan.

It also refactors the template PerIsolateAssertScope class to separate
simple C++ scope classes, defined through macros.

Bug: chromium:1218898
Change-Id: Ia5e43352ebba28be6f013376b75f13ec8d5dc972
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2975303
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75369}
parent 44e73e0b
......@@ -17,8 +17,6 @@ namespace {
template <PerThreadAssertType kType>
using PerThreadDataBit = base::BitField<bool, kType, 1>;
template <PerIsolateAssertType kType>
using PerIsolateDataBit = base::BitField<bool, kType, 1>;
// Thread-local storage for assert data. Default all asserts to "allow".
thread_local uint32_t current_per_thread_assert_data(~0);
......@@ -50,45 +48,41 @@ bool PerThreadAssertScope<kType, kAllow>::IsAllowed() {
return PerThreadDataBit<kType>::decode(current_per_thread_assert_data);
}
template <PerIsolateAssertType kType, bool kAllow>
PerIsolateAssertScope<kType, kAllow>::PerIsolateAssertScope(Isolate* isolate)
: isolate_(isolate), old_data_(isolate->per_isolate_assert_data()) {
DCHECK_NOT_NULL(isolate);
isolate_->set_per_isolate_assert_data(
PerIsolateDataBit<kType>::update(old_data_, kAllow));
}
template <PerIsolateAssertType kType, bool kAllow>
PerIsolateAssertScope<kType, kAllow>::~PerIsolateAssertScope() {
isolate_->set_per_isolate_assert_data(old_data_);
}
// static
template <PerIsolateAssertType kType, bool kAllow>
bool PerIsolateAssertScope<kType, kAllow>::IsAllowed(Isolate* isolate) {
return PerIsolateDataBit<kType>::decode(isolate->per_isolate_assert_data());
}
// static
template <PerIsolateAssertType kType, bool kAllow>
void PerIsolateAssertScope<kType, kAllow>::Open(Isolate* isolate,
bool* was_execution_allowed) {
DCHECK_NOT_NULL(isolate);
DCHECK_NOT_NULL(was_execution_allowed);
uint32_t old_data = isolate->per_isolate_assert_data();
*was_execution_allowed = PerIsolateDataBit<kType>::decode(old_data);
isolate->set_per_isolate_assert_data(
PerIsolateDataBit<kType>::update(old_data, kAllow));
}
// static
template <PerIsolateAssertType kType, bool kAllow>
void PerIsolateAssertScope<kType, kAllow>::Close(Isolate* isolate,
bool was_execution_allowed) {
DCHECK_NOT_NULL(isolate);
uint32_t old_data = isolate->per_isolate_assert_data();
isolate->set_per_isolate_assert_data(
PerIsolateDataBit<kType>::update(old_data, was_execution_allowed));
}
#define PER_ISOLATE_ASSERT_SCOPE_DEFINITION(ScopeType, field, enable) \
ScopeType::ScopeType(Isolate* isolate) \
: isolate_(isolate), old_data_(isolate->field()) { \
DCHECK_NOT_NULL(isolate); \
isolate_->set_##field(enable); \
} \
\
ScopeType::~ScopeType() { isolate_->set_##field(old_data_); } \
\
/* static */ \
bool ScopeType::IsAllowed(Isolate* isolate) { return isolate->field(); } \
\
/* static */ \
void ScopeType::Open(Isolate* isolate, bool* was_execution_allowed) { \
DCHECK_NOT_NULL(isolate); \
DCHECK_NOT_NULL(was_execution_allowed); \
*was_execution_allowed = isolate->field(); \
isolate->set_##field(enable); \
} \
/* static */ \
void ScopeType::Close(Isolate* isolate, bool was_execution_allowed) { \
DCHECK_NOT_NULL(isolate); \
isolate->set_##field(was_execution_allowed); \
}
#define PER_ISOLATE_ASSERT_ENABLE_SCOPE_DEFINITION(EnableType, _, field, \
enable) \
PER_ISOLATE_ASSERT_SCOPE_DEFINITION(EnableType, field, enable)
#define PER_ISOLATE_ASSERT_DISABLE_SCOPE_DEFINITION(_, DisableType, field, \
enable) \
PER_ISOLATE_ASSERT_SCOPE_DEFINITION(DisableType, field, enable)
PER_ISOLATE_ASSERT_TYPE(PER_ISOLATE_ASSERT_ENABLE_SCOPE_DEFINITION, true)
PER_ISOLATE_ASSERT_TYPE(PER_ISOLATE_ASSERT_DISABLE_SCOPE_DEFINITION, false)
// -----------------------------------------------------------------------------
// Instantiations.
......@@ -107,18 +101,5 @@ template class PerThreadAssertScope<CODE_ALLOCATION_ASSERT, false>;
template class PerThreadAssertScope<CODE_ALLOCATION_ASSERT, true>;
template class PerThreadAssertScope<GC_MOLE, false>;
template class PerIsolateAssertScope<JAVASCRIPT_EXECUTION_ASSERT, false>;
template class PerIsolateAssertScope<JAVASCRIPT_EXECUTION_ASSERT, true>;
template class PerIsolateAssertScope<JAVASCRIPT_EXECUTION_THROWS, false>;
template class PerIsolateAssertScope<JAVASCRIPT_EXECUTION_THROWS, true>;
template class PerIsolateAssertScope<JAVASCRIPT_EXECUTION_DUMP, false>;
template class PerIsolateAssertScope<JAVASCRIPT_EXECUTION_DUMP, true>;
template class PerIsolateAssertScope<DEOPTIMIZATION_ASSERT, false>;
template class PerIsolateAssertScope<DEOPTIMIZATION_ASSERT, true>;
template class PerIsolateAssertScope<COMPILATION_ASSERT, false>;
template class PerIsolateAssertScope<COMPILATION_ASSERT, true>;
template class PerIsolateAssertScope<NO_EXCEPTION_ASSERT, false>;
template class PerIsolateAssertScope<NO_EXCEPTION_ASSERT, true>;
} // namespace internal
} // namespace v8
This diff is collapsed.
......@@ -453,7 +453,6 @@ using DebugObjectCache = std::vector<Handle<HeapObject>>;
V(MicrotaskQueue*, default_microtask_queue, nullptr) \
V(CompilationStatistics*, turbo_statistics, nullptr) \
V(CodeTracer*, code_tracer, nullptr) \
V(uint32_t, per_isolate_assert_data, 0xFFFFFFFFu) \
V(PromiseRejectCallback, promise_reject_callback, nullptr) \
V(const v8::StartupData*, snapshot_blob, nullptr) \
V(int, code_and_metadata_size, 0) \
......@@ -476,7 +475,13 @@ using DebugObjectCache = std::vector<Handle<HeapObject>>;
V(int, embedder_wrapper_object_index, -1) \
V(compiler::NodeObserver*, node_observer, nullptr) \
/* Used in combination with --script-run-delay-once */ \
V(bool, did_run_script_delay, false)
V(bool, did_run_script_delay, false) \
V(bool, javascript_execution_assert, true) \
V(bool, javascript_execution_throws, true) \
V(bool, javascript_execution_dump, true) \
V(bool, deoptimization_assert, true) \
V(bool, compilation_assert, true) \
V(bool, no_exception_assert, true)
#define THREAD_LOCAL_TOP_ACCESSOR(type, name) \
inline void set_##name(type v) { thread_local_top()->name##_ = v; } \
......
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