diff options
author | Michaël Zasso <targos@protonmail.com> | 2018-12-04 08:20:37 +0100 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2018-12-06 15:23:33 +0100 |
commit | 9b4bf7de6c9a7c25f116c7a502384c20b5cfaea3 (patch) | |
tree | 2b0c843168dafb939d8df8a15b2aa72b76dee51d /deps/v8/src/disassembler.cc | |
parent | b8fbe69db1292307adb2c2b2e0d5ef48c4ab2faf (diff) | |
download | android-node-v8-9b4bf7de6c9a7c25f116c7a502384c20b5cfaea3.tar.gz android-node-v8-9b4bf7de6c9a7c25f116c7a502384c20b5cfaea3.tar.bz2 android-node-v8-9b4bf7de6c9a7c25f116c7a502384c20b5cfaea3.zip |
deps: update V8 to 7.1.302.28
PR-URL: https://github.com/nodejs/node/pull/23423
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'deps/v8/src/disassembler.cc')
-rw-r--r-- | deps/v8/src/disassembler.cc | 75 |
1 files changed, 67 insertions, 8 deletions
diff --git a/deps/v8/src/disassembler.cc b/deps/v8/src/disassembler.cc index 4ccddc289c..0bb59ec0fd 100644 --- a/deps/v8/src/disassembler.cc +++ b/deps/v8/src/disassembler.cc @@ -5,6 +5,7 @@ #include "src/disassembler.h" #include <memory> +#include <unordered_map> #include <vector> #include "src/assembler-inl.h" @@ -38,12 +39,39 @@ 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()) { @@ -90,8 +118,11 @@ const char* V8NameConverter::RootRelativeName(int offset) const { const int kRootsStart = 0; const int kRootsEnd = Heap::roots_to_external_reference_table_offset(); - const int kExtRefsStart = Heap::roots_to_external_reference_table_offset(); + const int kExtRefsStart = kRootsEnd; 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; @@ -99,8 +130,8 @@ const char* V8NameConverter::RootRelativeName(int offset) const { // Fail safe in the unlikely case of an arbitrary root-relative offset. if (offset_in_roots_table % kPointerSize != 0) return nullptr; - Heap::RootListIndex root_index = - static_cast<Heap::RootListIndex>(offset_in_roots_table / kPointerSize); + RootIndex root_index = + static_cast<RootIndex>(offset_in_roots_table / kPointerSize); HeapStringAllocator allocator; StringStream accumulator(&allocator); @@ -109,6 +140,7 @@ 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; @@ -126,8 +158,29 @@ 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 { - return nullptr; + // 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???"; } } @@ -142,8 +195,8 @@ static const int kRelocInfoPosition = 57; static void PrintRelocInfo(StringBuilder* out, Isolate* isolate, const ExternalReferenceEncoder* ref_encoder, - std::ostream* os, RelocInfo* relocinfo, - bool first_reloc_info = true) { + std::ostream* os, CodeReference host, + RelocInfo* relocinfo, bool first_reloc_info = true) { // Indent the printing of the reloc info. if (first_reloc_info) { // The first reloc info is printed after the disassembled instruction. @@ -199,6 +252,11 @@ static void PrintRelocInfo(StringBuilder* out, Isolate* isolate, } else { out->AddFormatted(" %s", Code::Kind2String(kind)); } + } else if (RelocInfo::IsWasmStubCall(rmode) && !isolate) { + // Host is isolate-independent, try wasm native module instead. + wasm::WasmCode* code = host.as_wasm_code()->native_module()->Lookup( + relocinfo->wasm_stub_call_address()); + out->AddFormatted(" ;; wasm stub: %s", code->GetRuntimeStubName()); } else if (RelocInfo::IsRuntimeEntry(rmode) && isolate && isolate->deoptimizer_data() != nullptr) { // A runtime entry relocinfo might be a deoptimization bailout. @@ -313,7 +371,7 @@ static int DecodeIt(Isolate* isolate, ExternalReferenceEncoder* ref_encoder, RelocInfo relocinfo(pcs[i], rmodes[i], datas[i], nullptr, constant_pool); bool first_reloc_info = (i == 0); - PrintRelocInfo(&out, isolate, ref_encoder, os, &relocinfo, + PrintRelocInfo(&out, isolate, ref_encoder, os, code, &relocinfo, first_reloc_info); } @@ -331,7 +389,8 @@ static int DecodeIt(Isolate* isolate, ExternalReferenceEncoder* ref_encoder, if (reloc_it.rinfo()->IsInConstantPool() && (reloc_it.rinfo()->constant_pool_entry_address() == constant_pool_entry_address)) { - PrintRelocInfo(&out, isolate, ref_encoder, os, reloc_it.rinfo()); + PrintRelocInfo(&out, isolate, ref_encoder, os, code, + reloc_it.rinfo()); break; } reloc_it.next(); |