Revert "Introduce CodeReference"
This reverts commit 4d7ad46db4
.
Reason for revert: Makes i18n bot red
https://logs.chromium.org/v/?s=chromium%2Fbb%2Fclient.v8%2FV8_Linux_-_noi18n_-_debug%2F20162%2F%2B%2Frecipes%2Fsteps%2FCheck%2F0%2Flogs%2FAssemblerIa32JumpTabl..%2F0
Original change's description:
> Introduce CodeReference
>
> Add a struct CodeReference that can be stack allocated to pass a
> reference to either an on-heap code object or off-heap WasmCode object
> in a gc safe manner. The struct also provides a common interface such
> that code can be written independently of the kind of code object it
> references.
>
> Change-Id: I5a6f74462e6e141d167c7fd9bac8c21941fd83b1
> Reviewed-on: https://chromium-review.googlesource.com/977905
> Commit-Queue: Stephan Herhut <herhut@chromium.org>
> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#52580}
TBR=mstarzinger@chromium.org,herhut@chromium.org
Change-Id: I9c49da9ee97e7423284e58bec3fdc1d212ff1af0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/1010544
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52582}
This commit is contained in:
parent
ae4529f9e1
commit
d71c34dcee
2
BUILD.gn
2
BUILD.gn
@ -1438,8 +1438,6 @@ v8_source_set("v8_base") {
|
||||
"src/code-events.h",
|
||||
"src/code-factory.cc",
|
||||
"src/code-factory.h",
|
||||
"src/code-reference.cc",
|
||||
"src/code-reference.h",
|
||||
"src/code-stub-assembler.cc",
|
||||
"src/code-stub-assembler.h",
|
||||
"src/code-stubs-utils.h",
|
||||
|
@ -96,7 +96,7 @@ void AssemblerBase::FlushICache(void* start, size_t size) {
|
||||
|
||||
void AssemblerBase::Print(Isolate* isolate) {
|
||||
OFStream os(stdout);
|
||||
v8::internal::Disassembler::Decode(isolate, &os, buffer_, pc_);
|
||||
v8::internal::Disassembler::Decode(isolate, &os, buffer_, pc_, nullptr);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -462,17 +462,6 @@ RelocIterator::RelocIterator(Code* code, int mode_mask)
|
||||
next();
|
||||
}
|
||||
|
||||
RelocIterator::RelocIterator(const CodeReference code_reference, int mode_mask)
|
||||
: mode_mask_(mode_mask) {
|
||||
rinfo_.pc_ = code_reference.instruction_start();
|
||||
rinfo_.data_ = 0;
|
||||
rinfo_.constant_pool_ = code_reference.constant_pool();
|
||||
pos_ = code_reference.relocation_start() + code_reference.relocation_size();
|
||||
end_ = code_reference.relocation_start();
|
||||
if (mode_mask_ == 0) pos_ = end_;
|
||||
next();
|
||||
}
|
||||
|
||||
RelocIterator::RelocIterator(const CodeDesc& desc, int mode_mask)
|
||||
: mode_mask_(mode_mask) {
|
||||
rinfo_.pc_ = desc.buffer;
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include <map>
|
||||
|
||||
#include "src/allocation.h"
|
||||
#include "src/code-reference.h"
|
||||
#include "src/contexts.h"
|
||||
#include "src/deoptimize-reason.h"
|
||||
#include "src/double.h"
|
||||
@ -684,8 +683,6 @@ class RelocIterator: public Malloced {
|
||||
// iteration iff bit k of mode_mask is set.
|
||||
explicit RelocIterator(Code* code, int mode_mask = -1);
|
||||
explicit RelocIterator(const CodeDesc& desc, int mode_mask = -1);
|
||||
explicit RelocIterator(const CodeReference code_reference,
|
||||
int mode_mask = -1);
|
||||
explicit RelocIterator(Vector<byte> instructions,
|
||||
Vector<const byte> reloc_info, Address const_pool,
|
||||
int mode_mask = -1);
|
||||
|
@ -1,45 +0,0 @@
|
||||
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/code-reference.h"
|
||||
|
||||
#include "src/handles-inl.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/wasm/wasm-code-manager.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
Address CodeReference::constant_pool() const {
|
||||
return kind == JS ? code.js->constant_pool() : code.wasm->constant_pool();
|
||||
}
|
||||
|
||||
Address CodeReference::instruction_start() const {
|
||||
return kind == JS ? code.js->InstructionStart()
|
||||
: code.wasm->instructions().start();
|
||||
}
|
||||
|
||||
Address CodeReference::instruction_end() const {
|
||||
return kind == JS ? code.js->InstructionEnd()
|
||||
: code.wasm->instructions().start() +
|
||||
code.wasm->instructions().size();
|
||||
}
|
||||
|
||||
int CodeReference::instruction_size() const {
|
||||
return kind == JS ? code.js->InstructionSize()
|
||||
: static_cast<int>(code.wasm->instructions().size());
|
||||
}
|
||||
|
||||
const byte* CodeReference::relocation_start() const {
|
||||
return kind == JS ? code.js->relocation_start()
|
||||
: code.wasm->reloc_info().start();
|
||||
}
|
||||
|
||||
int CodeReference::relocation_size() const {
|
||||
return kind == JS ? code.js->relocation_size()
|
||||
: static_cast<int>(code.wasm->reloc_info().size());
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
@ -1,52 +0,0 @@
|
||||
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef V8_CODE_REFERENCE_H_
|
||||
#define V8_CODE_REFERENCE_H_
|
||||
|
||||
#include "src/handles.h"
|
||||
#include "src/objects.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
class Code;
|
||||
|
||||
namespace wasm {
|
||||
class WasmCode;
|
||||
}
|
||||
|
||||
struct CodeReference {
|
||||
explicit CodeReference(const wasm::WasmCode* wasm_code = nullptr)
|
||||
: kind(WASM), code(wasm_code) {}
|
||||
explicit CodeReference(Handle<Code> js_code) : kind(JS), code(js_code) {}
|
||||
|
||||
Address constant_pool() const;
|
||||
Address instruction_start() const;
|
||||
Address instruction_end() const;
|
||||
int instruction_size() const;
|
||||
const byte* relocation_start() const;
|
||||
int relocation_size() const;
|
||||
bool is_null() const {
|
||||
return kind == JS ? !code.js.is_null() : code.wasm != nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
enum { JS, WASM } kind;
|
||||
union CodeUnion {
|
||||
explicit CodeUnion(Handle<Code> js_code) : js(js_code) {}
|
||||
explicit CodeUnion(const wasm::WasmCode* wasm_code) : wasm(wasm_code) {}
|
||||
CodeUnion() : wasm(nullptr) {}
|
||||
|
||||
const wasm::WasmCode* wasm;
|
||||
Handle<Code> js;
|
||||
} code;
|
||||
|
||||
DISALLOW_NEW_AND_DELETE()
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_CODE_REFERENCE_H_
|
@ -8,7 +8,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "src/assembler-inl.h"
|
||||
#include "src/code-reference.h"
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/debug/debug.h"
|
||||
#include "src/deoptimizer.h"
|
||||
@ -28,45 +27,39 @@ namespace internal {
|
||||
|
||||
class V8NameConverter: public disasm::NameConverter {
|
||||
public:
|
||||
explicit V8NameConverter(Code* code)
|
||||
: isolate_(code->GetIsolate()), code_(CodeReference(handle(code))) {}
|
||||
V8NameConverter(Isolate* isolate, const wasm::WasmCode* code)
|
||||
: isolate_(isolate), code_(CodeReference(code)) {}
|
||||
explicit V8NameConverter(Isolate* isolate)
|
||||
: isolate_(isolate), code_(CodeReference()) {}
|
||||
explicit V8NameConverter(Code* code) : code_(code) {}
|
||||
virtual const char* NameOfAddress(byte* pc) const;
|
||||
virtual const char* NameInCode(byte* addr) const;
|
||||
const CodeReference& code() const { return code_; }
|
||||
|
||||
Code* code() const { return code_; }
|
||||
private:
|
||||
Isolate* isolate_;
|
||||
CodeReference code_;
|
||||
Code* code_;
|
||||
|
||||
EmbeddedVector<char, 128> v8_buffer_;
|
||||
};
|
||||
|
||||
|
||||
const char* V8NameConverter::NameOfAddress(byte* pc) const {
|
||||
if (isolate_ != nullptr) {
|
||||
const char* name = isolate_->builtins()->Lookup(pc);
|
||||
if (code_ != nullptr) {
|
||||
Isolate* isolate = code_->GetIsolate();
|
||||
const char* name = isolate->builtins()->Lookup(pc);
|
||||
|
||||
if (name != nullptr) {
|
||||
SNPrintF(v8_buffer_, "%p (%s)", static_cast<void*>(pc), name);
|
||||
return v8_buffer_.start();
|
||||
}
|
||||
|
||||
int offs = static_cast<int>(pc - code_.instruction_start());
|
||||
int offs = static_cast<int>(pc - code_->raw_instruction_start());
|
||||
// print as code offset, if it seems reasonable
|
||||
if (0 <= offs && offs < code_.instruction_size()) {
|
||||
if (0 <= offs && offs < code_->raw_instruction_size()) {
|
||||
SNPrintF(v8_buffer_, "%p <+0x%x>", static_cast<void*>(pc), offs);
|
||||
return v8_buffer_.start();
|
||||
}
|
||||
|
||||
wasm::WasmCode* wasm_code =
|
||||
isolate_->wasm_engine()->code_manager()->LookupCode(pc);
|
||||
isolate->wasm_engine()->code_manager()->LookupCode(pc);
|
||||
if (wasm_code != nullptr) {
|
||||
SNPrintF(v8_buffer_, "%p (%s)", static_cast<void*>(pc),
|
||||
wasm::GetWasmCodeKindAsString(wasm_code->kind()));
|
||||
GetWasmCodeKindAsString(wasm_code->kind()));
|
||||
return v8_buffer_.start();
|
||||
}
|
||||
}
|
||||
@ -78,7 +71,7 @@ const char* V8NameConverter::NameOfAddress(byte* pc) const {
|
||||
const char* V8NameConverter::NameInCode(byte* addr) const {
|
||||
// The V8NameConverter is used for well known code, so we can "safely"
|
||||
// dereference pointers in generated code.
|
||||
return code_.is_null() ? "" : reinterpret_cast<const char*>(addr);
|
||||
return (code_ != nullptr) ? reinterpret_cast<const char*>(addr) : "";
|
||||
}
|
||||
|
||||
|
||||
@ -131,30 +124,21 @@ static void PrintRelocInfo(StringBuilder* out, Isolate* isolate,
|
||||
out->AddFormatted(" ;; external reference (%s)", reference_name);
|
||||
} else if (RelocInfo::IsCodeTarget(rmode)) {
|
||||
out->AddFormatted(" ;; code:");
|
||||
wasm::WasmCode* wasmCode =
|
||||
isolate->wasm_engine()->code_manager()->LookupCode(
|
||||
relocinfo->target_address());
|
||||
if (wasmCode) {
|
||||
out->AddFormatted(" wasm(%s)",
|
||||
wasm::GetWasmCodeKindAsString(wasmCode->kind()));
|
||||
Code* code = Code::GetCodeFromTargetAddress(relocinfo->target_address());
|
||||
Code::Kind kind = code->kind();
|
||||
if (kind == Code::STUB) {
|
||||
// Get the STUB key and extract major and minor key.
|
||||
uint32_t key = code->stub_key();
|
||||
uint32_t minor_key = CodeStub::MinorKeyFromKey(key);
|
||||
CodeStub::Major major_key = CodeStub::GetMajorKey(code);
|
||||
DCHECK(major_key == CodeStub::MajorKeyFromKey(key));
|
||||
out->AddFormatted(" %s, %s, ", Code::Kind2String(kind),
|
||||
CodeStub::MajorName(major_key));
|
||||
out->AddFormatted("minor: %d", minor_key);
|
||||
} else if (code->is_builtin()) {
|
||||
out->AddFormatted(" Builtin::%s", Builtins::name(code->builtin_index()));
|
||||
} else {
|
||||
Code* code = Code::GetCodeFromTargetAddress(relocinfo->target_address());
|
||||
Code::Kind kind = code->kind();
|
||||
if (kind == Code::STUB) {
|
||||
// Get the STUB key and extract major and minor key.
|
||||
uint32_t key = code->stub_key();
|
||||
uint32_t minor_key = CodeStub::MinorKeyFromKey(key);
|
||||
CodeStub::Major major_key = CodeStub::GetMajorKey(code);
|
||||
DCHECK(major_key == CodeStub::MajorKeyFromKey(key));
|
||||
out->AddFormatted(" %s, %s, ", Code::Kind2String(kind),
|
||||
CodeStub::MajorName(major_key));
|
||||
out->AddFormatted("minor: %d", minor_key);
|
||||
} else if (code->is_builtin()) {
|
||||
out->AddFormatted(" Builtin::%s",
|
||||
Builtins::name(code->builtin_index()));
|
||||
} else {
|
||||
out->AddFormatted(" %s", Code::Kind2String(kind));
|
||||
}
|
||||
out->AddFormatted(" %s", Code::Kind2String(kind));
|
||||
}
|
||||
} else if (RelocInfo::IsRuntimeEntry(rmode) &&
|
||||
isolate->deoptimizer_data() != nullptr) {
|
||||
@ -195,7 +179,7 @@ static int DecodeIt(Isolate* isolate, std::ostream* os,
|
||||
byte* pc = begin;
|
||||
disasm::Disassembler d(converter);
|
||||
RelocIterator* it = nullptr;
|
||||
if (!converter.code().is_null()) {
|
||||
if (converter.code() != nullptr) {
|
||||
it = new RelocIterator(converter.code());
|
||||
} else {
|
||||
// No relocation information when printing code stubs.
|
||||
@ -274,10 +258,9 @@ static int DecodeIt(Isolate* isolate, std::ostream* os,
|
||||
// Print all the reloc info for this instruction which are not comments.
|
||||
for (size_t i = 0; i < pcs.size(); i++) {
|
||||
// Put together the reloc info
|
||||
const CodeReference& host = converter.code();
|
||||
RelocInfo relocinfo(pcs[i], rmodes[i], datas[i], nullptr);
|
||||
relocinfo.set_constant_pool(host.is_null() ? nullptr
|
||||
: host.constant_pool());
|
||||
Code* host = converter.code();
|
||||
RelocInfo relocinfo(pcs[i], rmodes[i], datas[i], host);
|
||||
relocinfo.set_constant_pool(host ? host->constant_pool() : nullptr);
|
||||
|
||||
bool first_reloc_info = (i == 0);
|
||||
PrintRelocInfo(&out, isolate, ref_encoder, os, &relocinfo,
|
||||
@ -287,7 +270,7 @@ static int DecodeIt(Isolate* isolate, std::ostream* os,
|
||||
// If this is a constant pool load and we haven't found any RelocInfo
|
||||
// already, check if we can find some RelocInfo for the target address in
|
||||
// the constant pool.
|
||||
if (pcs.empty() && !converter.code().is_null()) {
|
||||
if (pcs.empty() && converter.code() != nullptr) {
|
||||
RelocInfo dummy_rinfo(prev_pc, RelocInfo::NONE, 0, nullptr);
|
||||
if (dummy_rinfo.IsInConstantPool()) {
|
||||
byte* constant_pool_entry_address =
|
||||
@ -333,13 +316,6 @@ int Disassembler::Decode(Isolate* isolate, std::ostream* os, byte* begin,
|
||||
return DecodeIt(isolate, os, v8NameConverter, begin, end, current_pc);
|
||||
}
|
||||
|
||||
int Disassembler::Decode(Isolate* isolate, std::ostream* os, byte* begin,
|
||||
byte* end, const wasm::WasmCode* code,
|
||||
void* current_pc) {
|
||||
V8NameConverter v8NameConverter(isolate, code);
|
||||
return DecodeIt(isolate, os, v8NameConverter, begin, end, current_pc);
|
||||
}
|
||||
|
||||
#else // ENABLE_DISASSEMBLER
|
||||
|
||||
int Disassembler::Decode(Isolate* isolate, std::ostream* os, byte* begin,
|
||||
|
@ -10,10 +10,6 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
namespace wasm {
|
||||
class WasmCode;
|
||||
}
|
||||
|
||||
class Disassembler : public AllStatic {
|
||||
public:
|
||||
// Decode instructions in the the interval [begin, end) and print the
|
||||
@ -22,8 +18,6 @@ class Disassembler : public AllStatic {
|
||||
// the code object is used for name resolution and may be null.
|
||||
static int Decode(Isolate* isolate, std::ostream* os, byte* begin, byte* end,
|
||||
Code* code = nullptr, void* current_pc = nullptr);
|
||||
static int Decode(Isolate* isolate, std::ostream* os, byte* begin, byte* end,
|
||||
const wasm::WasmCode* code, void* current_pc = nullptr);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
@ -256,7 +256,7 @@ void WasmCode::Disassemble(const char* name, Isolate* isolate,
|
||||
// TODO(mtrofin): rework the dependency on isolate and code in
|
||||
// Disassembler::Decode.
|
||||
Disassembler::Decode(isolate, &os, instructions().start(),
|
||||
instructions().start() + instruction_size, this);
|
||||
instructions().start() + instruction_size, nullptr);
|
||||
os << "\n";
|
||||
|
||||
if (!source_positions().is_empty()) {
|
||||
|
Loading…
Reference in New Issue
Block a user