Commit aabed218 authored by Michael Achenbach's avatar Michael Achenbach Committed by Commit Bot

Revert "[disassembler] Better support for root-relative values"

This reverts commit 574daf03.

Reason for revert: Seems to break native arm:
https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Android%20Arm64%20-%20N5X/1051
https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Arm%20GC%20Stress/8462

Original change's description:
> [disassembler] Better support for root-relative values
> 
> In particular, recognize builtins' values accesses and direct accesses
> to external reference values. For example:
> 
>   REX.W leaq rax,[r13+0x47a0]
>   REX.W leaq rbx,[r13+0x80b0]
> 
> turns into
> 
>   REX.W leaq rax,[r13+0x47a0] (builtin (RecordWrite))
>   REX.W leaq rbx,[r13+0x80b0] (external value (Isolate::context_address))
> 
> This CL also extends the via-root-register-accessible region to the
> whole Isolate object.
> 
> Bug: v8:8238
> Change-Id: I218d8589690579919cfa01b2f3c3094af0e73c51
> Reviewed-on: https://chromium-review.googlesource.com/1251550
> Commit-Queue: Igor Sheludko <ishell@chromium.org>
> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#56332}

TBR=mstarzinger@chromium.org,ishell@chromium.org

Change-Id: I28ad24c923f04fffbc2fd5a5d2248740302fae02
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:8238
Reviewed-on: https://chromium-review.googlesource.com/1256772Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56335}
parent 67383be9
......@@ -5,7 +5,6 @@
#include "src/disassembler.h"
#include <memory>
#include <unordered_map>
#include <vector>
#include "src/assembler-inl.h"
......@@ -39,39 +38,12 @@ class V8NameConverter: public disasm::NameConverter {
const CodeReference& code() const { return code_; }
private:
void InitExternalRefsCache() const;
Isolate* isolate_;
CodeReference code_;
EmbeddedVector<char, 128> v8_buffer_;
// Map from root-register relative offset of the external reference value to
// the external reference name (stored in the external reference table).
// This cache is used to recognize [root_reg + offs] patterns as direct
// access to certain external reference's value.
mutable std::unordered_map<int, const char*> directly_accessed_external_refs_;
};
void V8NameConverter::InitExternalRefsCache() const {
ExternalReferenceTable* external_reference_table =
isolate_->heap()->external_reference_table();
if (!external_reference_table->is_initialized()) return;
base::AddressRegion addressable_region =
isolate_->root_register_addressable_region();
Address roots_start =
reinterpret_cast<Address>(isolate_->heap()->roots_array_start());
for (uint32_t i = 0; i < external_reference_table->size(); i++) {
Address address = external_reference_table->address(i);
if (addressable_region.contains(address)) {
int offset = static_cast<int>(address - roots_start);
const char* name = external_reference_table->name(i);
directly_accessed_external_refs_.insert({offset, name});
}
}
}
const char* V8NameConverter::NameOfAddress(byte* pc) const {
if (!code_.is_null()) {
......@@ -118,11 +90,8 @@ const char* V8NameConverter::RootRelativeName(int offset) const {
const int kRootsStart = 0;
const int kRootsEnd = Heap::roots_to_external_reference_table_offset();
const int kExtRefsStart = kRootsEnd;
const int kExtRefsStart = Heap::roots_to_external_reference_table_offset();
const int kExtRefsEnd = Heap::roots_to_builtins_offset();
const int kBuiltinsStart = kExtRefsEnd;
const int kBuiltinsEnd =
kBuiltinsStart + Builtins::builtin_count * kPointerSize;
if (kRootsStart <= offset && offset < kRootsEnd) {
uint32_t offset_in_roots_table = offset - kRootsStart;
......@@ -140,7 +109,6 @@ const char* V8NameConverter::RootRelativeName(int offset) const {
SNPrintF(v8_buffer_, "root (%s)", obj_name.get());
return v8_buffer_.start();
} else if (kExtRefsStart <= offset && offset < kExtRefsEnd) {
uint32_t offset_in_extref_table = offset - kExtRefsStart;
......@@ -158,29 +126,8 @@ const char* V8NameConverter::RootRelativeName(int offset) const {
isolate_->heap()->external_reference_table()->NameFromOffset(
offset_in_extref_table));
return v8_buffer_.start();
} else if (kBuiltinsStart <= offset && offset < kBuiltinsEnd) {
uint32_t offset_in_builtins_table = (offset - kBuiltinsStart);
Builtins::Name builtin_id =
static_cast<Builtins::Name>(offset_in_builtins_table / kPointerSize);
const char* name = Builtins::name(builtin_id);
SNPrintF(v8_buffer_, "builtin (%s)", name);
return v8_buffer_.start();
} else {
// It must be a direct access to one of the external values.
if (directly_accessed_external_refs_.empty()) {
InitExternalRefsCache();
}
auto iter = directly_accessed_external_refs_.find(offset);
if (iter != directly_accessed_external_refs_.end()) {
SNPrintF(v8_buffer_, "external value (%s)", iter->second);
return v8_buffer_.start();
}
return "WAAT??? What are we accessing here???";
return nullptr;
}
}
......
......@@ -811,6 +811,15 @@ class Heap {
return kRootsBuiltinsOffset;
}
static constexpr int root_register_addressable_end_offset() {
return kRootRegisterAddressableEndOffset;
}
Address root_register_addressable_end() {
return reinterpret_cast<Address>(roots_array_start()) +
kRootRegisterAddressableEndOffset;
}
// Sets the stub_cache_ (only used when expanding the dictionary).
void SetRootCodeStubs(SimpleNumberDictionary* value);
......@@ -1938,6 +1947,12 @@ class Heap {
ExternalReferenceTable::SizeInBytes();
Object* builtins_[Builtins::builtin_count];
// kRootRegister may be used to address any location that starts at the
// Isolate and ends at this point. Fields past this point are not guaranteed
// to live at a static offset from kRootRegister.
static constexpr int kRootRegisterAddressableEndOffset =
kRootsBuiltinsOffset + Builtins::builtin_count * kPointerSize;
size_t code_range_size_ = 0;
size_t max_semi_space_size_ = 8 * (kPointerSize / 4) * MB;
size_t initial_semispace_size_ = kMinSemiSpaceSizeInKB * KB;
......
......@@ -998,14 +998,6 @@ class Isolate : private HiddenFactory {
}
StackGuard* stack_guard() { return &stack_guard_; }
Heap* heap() { return &heap_; }
// kRootRegister may be used to address any location that falls into this
// region. Fields outside this region are not guaranteed to live at a static
// offset from kRootRegister.
base::AddressRegion root_register_addressable_region() const {
return base::AddressRegion(reinterpret_cast<Address>(this),
sizeof(Isolate));
}
StubCache* load_stub_cache() { return load_stub_cache_; }
StubCache* store_stub_cache() { return store_stub_cache_; }
DeoptimizerData* deoptimizer_data() { return deoptimizer_data_; }
......
......@@ -106,8 +106,10 @@ intptr_t TurboAssemblerBase::RootRegisterOffsetForExternalReference(
// static
bool TurboAssemblerBase::IsAddressableThroughRootRegister(
Isolate* isolate, const ExternalReference& reference) {
Address start = reinterpret_cast<Address>(isolate);
Address end = isolate->heap()->root_register_addressable_end();
Address address = reference.address();
return isolate->root_register_addressable_region().contains(address);
return start <= address && address < end;
}
// static
......
......@@ -64,7 +64,7 @@ class V8_EXPORT_PRIVATE TurboAssemblerBase : public Assembler {
Isolate* isolate, const ExternalReference& reference);
// An address is addressable through kRootRegister if it is located within
// isolate->root_register_addressable_region().
// [isolate, roots_ + root_register_addressable_end_offset[.
static bool IsAddressableThroughRootRegister(
Isolate* isolate, const ExternalReference& reference);
......
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