[vm] Flatten stub code handle list.
TEST=ci Change-Id: I852120f3af711f385534e5d1b007705fb3aec078 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/491684 Commit-Queue: Ryan Macnak <rmacnak@google.com> Reviewed-by: Alexander Aprelev <aam@google.com>
This commit is contained in:
committed by
Commit Queue
parent
8cf2e69e7a
commit
21a67c5c31
+19
-21
@@ -31,16 +31,7 @@ DEFINE_FLAG(bool,
|
||||
"Generate probe points for installation of user space probes");
|
||||
#endif
|
||||
|
||||
StubCode::StubCodeEntry StubCode::entries_[kNumStubEntries] = {
|
||||
#if defined(DART_PRECOMPILED_RUNTIME)
|
||||
#define STUB_CODE_DECLARE(name) {nullptr, #name},
|
||||
#else
|
||||
#define STUB_CODE_DECLARE(name) \
|
||||
{nullptr, #name, &compiler::StubCodeCompiler::Generate##name##Stub},
|
||||
#endif
|
||||
VM_STUB_CODE_LIST(STUB_CODE_DECLARE)
|
||||
#undef STUB_CODE_DECLARE
|
||||
};
|
||||
Code* StubCode::handles_[kNumStubEntries] = {nullptr};
|
||||
AcqRelAtomic<bool> StubCode::initialized_ = {false};
|
||||
|
||||
#if defined(DART_PRECOMPILED_RUNTIME)
|
||||
@@ -55,17 +46,24 @@ void StubCode::Init() {
|
||||
compiler::ObjectPoolBuilder object_pool_builder;
|
||||
|
||||
// Generate all the stubs.
|
||||
for (size_t i = 0; i < ARRAY_SIZE(entries_); i++) {
|
||||
entries_[i].code = Code::ReadOnlyHandle();
|
||||
*(entries_[i].code) =
|
||||
Generate(entries_[i].name, &object_pool_builder, entries_[i].generator);
|
||||
static void (compiler::StubCodeCompiler::* const generators[])() = {
|
||||
#define STUB_CODE_DECLARE(name) \
|
||||
&compiler::StubCodeCompiler::Generate##name##Stub,
|
||||
VM_STUB_CODE_LIST(STUB_CODE_DECLARE)
|
||||
#undef STUB_CODE_DECLARE
|
||||
};
|
||||
|
||||
for (intptr_t i = 0; i < kNumStubEntries; i++) {
|
||||
handles_[i] = Code::ReadOnlyHandle();
|
||||
*(handles_[i]) =
|
||||
Generate(StubNames[i], &object_pool_builder, generators[i]);
|
||||
}
|
||||
|
||||
const ObjectPool& object_pool =
|
||||
ObjectPool::Handle(ObjectPool::NewFromBuilder(object_pool_builder));
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(entries_); i++) {
|
||||
entries_[i].code->set_object_pool(object_pool.ptr());
|
||||
for (intptr_t i = 0; i < kNumStubEntries; i++) {
|
||||
handles_[i]->set_object_pool(object_pool.ptr());
|
||||
}
|
||||
|
||||
InitializationDone();
|
||||
@@ -131,8 +129,8 @@ CodePtr StubCode::Generate(const char* name,
|
||||
void StubCode::Cleanup() {
|
||||
initialized_.store(false, std::memory_order_release);
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(entries_); i++) {
|
||||
entries_[i].code = nullptr;
|
||||
for (intptr_t i = 0; i < kNumStubEntries; i++) {
|
||||
handles_[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,9 +347,9 @@ const Code& StubCode::UnoptimizedStaticCallEntry(intptr_t num_args_tested) {
|
||||
|
||||
void StubCode::ForEachStub(
|
||||
const std::function<bool(const char*, uword)>& callback) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(entries_); i++) {
|
||||
if (entries_[i].code != nullptr && !entries_[i].code->IsNull()) {
|
||||
if (!callback(entries_[i].name, entries_[i].code->EntryPoint())) {
|
||||
for (intptr_t i = 0; i < kNumStubEntries; i++) {
|
||||
if (handles_[i] != nullptr && !handles_[i]->IsNull()) {
|
||||
if (!callback(StubNames[i], handles_[i]->EntryPoint())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-13
@@ -69,7 +69,7 @@ class StubCode : public AllStatic {
|
||||
|
||||
// Define the shared stub code accessors.
|
||||
#define STUB_CODE_ACCESSOR(name) \
|
||||
static const Code& name() { return *entries_[k##name##Index].code; } \
|
||||
static const Code& name() { return *handles_[k##name##Index]; } \
|
||||
static intptr_t name##Size() { return name().Size(); }
|
||||
VM_STUB_CODE_LIST(STUB_CODE_ACCESSOR);
|
||||
#undef STUB_CODE_ACCESSOR
|
||||
@@ -108,13 +108,13 @@ class StubCode : public AllStatic {
|
||||
|
||||
static const Code& UnoptimizedStaticCallEntry(intptr_t num_args_tested);
|
||||
|
||||
static const char* NameAt(intptr_t index) { return entries_[index].name; }
|
||||
static const char* NameAt(intptr_t index) { return StubNames[index]; }
|
||||
|
||||
static const Code& EntryAt(intptr_t index) { return *(entries_[index].code); }
|
||||
static const Code& EntryAt(intptr_t index) { return *(handles_[index]); }
|
||||
static void EntryAtPut(intptr_t index, Code* entry) {
|
||||
DEBUG_ASSERT(entry->IsReadOnlyHandle());
|
||||
ASSERT(entries_[index].code == nullptr);
|
||||
entries_[index].code = entry;
|
||||
ASSERT(handles_[index] == nullptr);
|
||||
handles_[index] = entry;
|
||||
}
|
||||
static intptr_t NumEntries() { return kNumStubEntries; }
|
||||
|
||||
@@ -140,14 +140,7 @@ class StubCode : public AllStatic {
|
||||
kNumStubEntries
|
||||
};
|
||||
|
||||
struct StubCodeEntry {
|
||||
Code* code;
|
||||
const char* name;
|
||||
#if !defined(DART_PRECOMPILED_RUNTIME)
|
||||
void (compiler::StubCodeCompiler::*generator)();
|
||||
#endif
|
||||
};
|
||||
static StubCodeEntry entries_[kNumStubEntries];
|
||||
static Code* handles_[kNumStubEntries];
|
||||
static AcqRelAtomic<bool> initialized_;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user