Reland "Reland "Reland "[code-comments] Put code comments into the code object"""
This is a reland of9c0a48580b
Original change's description: > Reland "Reland "[code-comments] Put code comments into the code object"" > > This is a reland ofed3d647284
> > This reland fixes that padding at the end of Wasm instruction streams > triggered asserts in the code printer. > > Original change's description: > > Reland "[code-comments] Put code comments into the code object" > > > > This is a reland ofe774cffe2b
> > > > This reland disables a test as v8:8548 is blocking it, which was > > broken by a recent CL. CQ did not catch this because the merge-base > > CQ used did not yet contain the CL that caused v8:8548. > > > > Original change's description: > > > [code-comments] Put code comments into the code object > > > > > > Code comments in the snapshot can now be enabled with gn > > > arg 'v8_enable_snapshot_code_comments' > > > > > > Bug: v8:7989 > > > Change-Id: I8bd00cafa63132d00d849394c311ba15e6b6daf3 > > > Reviewed-on: https://chromium-review.googlesource.com/c/1329173 > > > Commit-Queue: Sigurd Schneider <sigurds@chromium.org> > > > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > > > Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> > > > Reviewed-by: Michael Stanton <mvstanton@chromium.org> > > > Cr-Commit-Position: refs/heads/master@{#58020} > > > > TBR=mvstanton@chromium.org,mstarzinger@chromium.org,jgruber@chromium.org,tebbi@chromium.org > > > > Bug: v8:7989, v8:8548 > > Change-Id: I464fc897205fefdf2dfc2eadc54d699c4e08a0e9 > > Reviewed-on: https://chromium-review.googlesource.com/c/1361166 > > Reviewed-by: Sigurd Schneider <sigurds@chromium.org> > > Commit-Queue: Sigurd Schneider <sigurds@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#58028} > > Bug: v8:7989, v8:8548 > Change-Id: I254f55ff687ad049f8d92b09331ed26a2bd05d7d > Reviewed-on: https://chromium-review.googlesource.com/c/1371784 > Commit-Queue: Sigurd Schneider <sigurds@chromium.org> > Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> > Reviewed-by: Jakob Gruber <jgruber@chromium.org> > Cr-Commit-Position: refs/heads/master@{#58221} TBR=jgruber@chromium.org,mstarzinger@chromium.org Bug: v8:7989, v8:8548, v8:8593 Change-Id: I4f7ffc98e0281c7b744eb4a04ba0763896c7b59b Reviewed-on: https://chromium-review.googlesource.com/c/1375919 Reviewed-by: Sigurd Schneider <sigurds@chromium.org> Commit-Queue: Sigurd Schneider <sigurds@chromium.org> Cr-Commit-Position: refs/heads/master@{#58232}
This commit is contained in:
parent
7e123a74dc
commit
b55dd17f19
10
BUILD.gn
10
BUILD.gn
@ -88,6 +88,9 @@ declare_args() {
|
||||
# Enable embedded builtins.
|
||||
v8_enable_embedded_builtins = true
|
||||
|
||||
# Enable code comments for builtins in the snapshot (impacts performance).
|
||||
v8_enable_snapshot_code_comments = false
|
||||
|
||||
# Build-time flag for enabling nojit mode.
|
||||
# TODO(v8:7777): Remove the build-time flag once the --jitless runtime flag
|
||||
# does everything we need.
|
||||
@ -1148,6 +1151,10 @@ template("run_mksnapshot") {
|
||||
args += [ rebase_path(v8_embed_script, root_build_dir) ]
|
||||
}
|
||||
|
||||
if (v8_enable_snapshot_code_comments) {
|
||||
args += [ "--code-comments" ]
|
||||
}
|
||||
|
||||
if (v8_enable_fast_mksnapshot) {
|
||||
args += [
|
||||
"--no-turbo-rewrite-far-jumps",
|
||||
@ -1734,6 +1741,8 @@ v8_source_set("v8_base") {
|
||||
"src/char-predicates.cc",
|
||||
"src/char-predicates.h",
|
||||
"src/checks.h",
|
||||
"src/code-comments.cc",
|
||||
"src/code-comments.h",
|
||||
"src/code-events.h",
|
||||
"src/code-factory.cc",
|
||||
"src/code-factory.h",
|
||||
@ -2239,7 +2248,6 @@ v8_source_set("v8_base") {
|
||||
"src/lookup-inl.h",
|
||||
"src/lookup.cc",
|
||||
"src/lookup.h",
|
||||
"src/lsan.h",
|
||||
"src/machine-type.cc",
|
||||
"src/machine-type.h",
|
||||
"src/macro-assembler-inl.h",
|
||||
|
@ -561,10 +561,11 @@ Assembler::~Assembler() {
|
||||
|
||||
void Assembler::GetCode(Isolate* isolate, CodeDesc* desc) {
|
||||
// Emit constant pool if necessary.
|
||||
int constant_pool_offset = 0;
|
||||
CheckConstPool(true, false);
|
||||
DCHECK(pending_32_bit_constants_.empty());
|
||||
|
||||
int code_comments_size = WriteCodeComments();
|
||||
|
||||
AllocateAndInstallRequestedHeapObjects(isolate);
|
||||
|
||||
// Set up code descriptor.
|
||||
@ -572,11 +573,11 @@ void Assembler::GetCode(Isolate* isolate, CodeDesc* desc) {
|
||||
desc->buffer_size = buffer_size_;
|
||||
desc->instr_size = pc_offset();
|
||||
desc->reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos();
|
||||
desc->constant_pool_size =
|
||||
(constant_pool_offset ? desc->instr_size - constant_pool_offset : 0);
|
||||
desc->constant_pool_size = 0;
|
||||
desc->origin = this;
|
||||
desc->unwinding_info_size = 0;
|
||||
desc->unwinding_info = nullptr;
|
||||
desc->code_comments_size = code_comments_size;
|
||||
}
|
||||
|
||||
|
||||
@ -5102,7 +5103,7 @@ void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) {
|
||||
|
||||
void Assembler::ConstantPoolAddEntry(int position, RelocInfo::Mode rmode,
|
||||
intptr_t value) {
|
||||
DCHECK(rmode != RelocInfo::COMMENT && rmode != RelocInfo::CONST_POOL);
|
||||
DCHECK(rmode != RelocInfo::CONST_POOL);
|
||||
// We can share CODE_TARGETs because we don't patch the code objects anymore,
|
||||
// and we make sure we emit only one reloc info for them (thus delta patching)
|
||||
// will apply the delta only once. At the moment, we do not dedup code targets
|
||||
|
@ -1414,10 +1414,6 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(BlockConstPoolScope);
|
||||
};
|
||||
|
||||
// Record a comment relocation entry that can be used by a disassembler.
|
||||
// Use --code-comments to enable.
|
||||
void RecordComment(const char* msg);
|
||||
|
||||
// Record a deoptimization reason that can be used by a log or cpu profiler.
|
||||
// Use --trace-deopt to enable.
|
||||
void RecordDeoptReason(DeoptimizeReason reason, SourcePosition position,
|
||||
@ -1678,6 +1674,8 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
|
||||
intptr_t value);
|
||||
void AllocateAndInstallRequestedHeapObjects(Isolate* isolate);
|
||||
|
||||
int WriteCodeComments();
|
||||
|
||||
friend class RelocInfo;
|
||||
friend class BlockConstPoolScope;
|
||||
friend class EnsureSpace;
|
||||
|
@ -331,8 +331,7 @@ bool ConstPool::AddSharedEntry(SharedEntryMap& entry_map, uint64_t data,
|
||||
|
||||
// Constant Pool.
|
||||
bool ConstPool::RecordEntry(intptr_t data, RelocInfo::Mode mode) {
|
||||
DCHECK(mode != RelocInfo::COMMENT && mode != RelocInfo::CONST_POOL &&
|
||||
mode != RelocInfo::VENEER_POOL &&
|
||||
DCHECK(mode != RelocInfo::CONST_POOL && mode != RelocInfo::VENEER_POOL &&
|
||||
mode != RelocInfo::DEOPT_SCRIPT_OFFSET &&
|
||||
mode != RelocInfo::DEOPT_INLINING_ID &&
|
||||
mode != RelocInfo::DEOPT_REASON && mode != RelocInfo::DEOPT_ID);
|
||||
@ -607,6 +606,8 @@ void Assembler::GetCode(Isolate* isolate, CodeDesc* desc) {
|
||||
CheckConstPool(true, false);
|
||||
DCHECK(constpool_.IsEmpty());
|
||||
|
||||
int code_comments_size = WriteCodeComments();
|
||||
|
||||
AllocateAndInstallRequestedHeapObjects(isolate);
|
||||
|
||||
// Set up code descriptor.
|
||||
@ -621,6 +622,7 @@ void Assembler::GetCode(Isolate* isolate, CodeDesc* desc) {
|
||||
desc->constant_pool_size = 0;
|
||||
desc->unwinding_info_size = 0;
|
||||
desc->unwinding_info = nullptr;
|
||||
desc->code_comments_size = code_comments_size;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4748,15 +4750,14 @@ void Assembler::GrowBuffer() {
|
||||
|
||||
void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data,
|
||||
ConstantPoolMode constant_pool_mode) {
|
||||
if ((rmode == RelocInfo::COMMENT) ||
|
||||
(rmode == RelocInfo::INTERNAL_REFERENCE) ||
|
||||
if ((rmode == RelocInfo::INTERNAL_REFERENCE) ||
|
||||
(rmode == RelocInfo::CONST_POOL) || (rmode == RelocInfo::VENEER_POOL) ||
|
||||
(rmode == RelocInfo::DEOPT_SCRIPT_OFFSET) ||
|
||||
(rmode == RelocInfo::DEOPT_INLINING_ID) ||
|
||||
(rmode == RelocInfo::DEOPT_REASON) || (rmode == RelocInfo::DEOPT_ID)) {
|
||||
// Adjust code for new modes.
|
||||
DCHECK(RelocInfo::IsComment(rmode) || RelocInfo::IsDeoptReason(rmode) ||
|
||||
RelocInfo::IsDeoptId(rmode) || RelocInfo::IsDeoptPosition(rmode) ||
|
||||
DCHECK(RelocInfo::IsDeoptReason(rmode) || RelocInfo::IsDeoptId(rmode) ||
|
||||
RelocInfo::IsDeoptPosition(rmode) ||
|
||||
RelocInfo::IsInternalReference(rmode) ||
|
||||
RelocInfo::IsConstPool(rmode) || RelocInfo::IsVeneerPool(rmode));
|
||||
// These modes do not need an entry in the constant pool.
|
||||
|
@ -1085,9 +1085,6 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
|
||||
EndBlockVeneerPool();
|
||||
}
|
||||
|
||||
// Debugging ----------------------------------------------------------------
|
||||
void RecordComment(const char* msg);
|
||||
|
||||
// Record a deoptimization reason that can be used by a log or cpu profiler.
|
||||
// Use --trace-deopt to enable.
|
||||
void RecordDeoptReason(DeoptimizeReason reason, SourcePosition position,
|
||||
@ -3587,6 +3584,8 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
|
||||
|
||||
void AllocateAndInstallRequestedHeapObjects(Isolate* isolate);
|
||||
|
||||
int WriteCodeComments();
|
||||
|
||||
friend class EnsureSpace;
|
||||
friend class ConstPool;
|
||||
};
|
||||
|
@ -190,13 +190,6 @@ void Assembler::RecordDeoptReason(DeoptimizeReason reason,
|
||||
RecordRelocInfo(RelocInfo::DEOPT_ID, id);
|
||||
}
|
||||
|
||||
void Assembler::RecordComment(const char* msg) {
|
||||
if (FLAG_code_comments) {
|
||||
EnsureSpace ensure_space(this);
|
||||
RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg));
|
||||
}
|
||||
}
|
||||
|
||||
void Assembler::DataAlign(int m) {
|
||||
DCHECK(m >= 2 && base::bits::IsPowerOfTwo(m));
|
||||
while ((pc_offset() & (m - 1)) != 0) {
|
||||
@ -245,5 +238,14 @@ void AssemblerBase::ReserveCodeTargetSpace(size_t num_of_code_targets) {
|
||||
code_targets_.reserve(num_of_code_targets);
|
||||
}
|
||||
|
||||
int Assembler::WriteCodeComments() {
|
||||
if (!FLAG_code_comments || code_comments_writer_.entry_count() == 0) return 0;
|
||||
int offset = pc_offset();
|
||||
code_comments_writer_.Emit(this);
|
||||
int size = pc_offset() - offset;
|
||||
DCHECK_EQ(size, code_comments_writer_.section_size());
|
||||
return size;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
@ -37,6 +37,7 @@
|
||||
|
||||
#include <forward_list>
|
||||
|
||||
#include "src/code-comments.h"
|
||||
#include "src/deoptimize-reason.h"
|
||||
#include "src/external-reference.h"
|
||||
#include "src/flags.h"
|
||||
@ -237,6 +238,14 @@ class V8_EXPORT_PRIVATE AssemblerBase : public Malloced {
|
||||
// Used to print the name of some special registers.
|
||||
static const char* GetSpecialRegisterName(int code) { return "UNKNOWN"; }
|
||||
|
||||
// Record an inline code comment that can be used by a disassembler.
|
||||
// Use --code-comments to enable.
|
||||
void RecordComment(const char* msg) {
|
||||
if (FLAG_code_comments) {
|
||||
code_comments_writer_.Add(pc_offset(), std::string(msg));
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
// Add 'target' to the {code_targets_} vector, if necessary, and return the
|
||||
// offset at which it is stored.
|
||||
@ -283,6 +292,8 @@ class V8_EXPORT_PRIVATE AssemblerBase : public Malloced {
|
||||
return true;
|
||||
}
|
||||
|
||||
CodeCommentsWriter code_comments_writer_;
|
||||
|
||||
private:
|
||||
// Before we copy code into the code space, we sometimes cannot encode
|
||||
// call/jump code targets as we normally would, as the difference between the
|
||||
|
@ -214,7 +214,7 @@ void HandlerBuiltinsAssembler::Generate_ElementsTransitionAndStore(
|
||||
Node* vector = Parameter(Descriptor::kVector);
|
||||
Node* context = Parameter(Descriptor::kContext);
|
||||
|
||||
Comment("ElementsTransitionAndStore: store_mode=%d", store_mode);
|
||||
Comment("ElementsTransitionAndStore: store_mode=", store_mode);
|
||||
|
||||
Label miss(this);
|
||||
|
||||
@ -329,7 +329,7 @@ void HandlerBuiltinsAssembler::Generate_StoreFastElementIC(
|
||||
Node* vector = Parameter(Descriptor::kVector);
|
||||
Node* context = Parameter(Descriptor::kContext);
|
||||
|
||||
Comment("StoreFastElementStub: store_mode=%d", store_mode);
|
||||
Comment("StoreFastElementStub: store_mode=", store_mode);
|
||||
|
||||
Label miss(this);
|
||||
|
||||
|
102
src/code-comments.cc
Normal file
102
src/code-comments.cc
Normal file
@ -0,0 +1,102 @@
|
||||
// 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 <cstring>
|
||||
#include <iomanip>
|
||||
|
||||
#include "src/assembler-inl.h"
|
||||
#include "src/code-comments.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
namespace {
|
||||
static constexpr uint8_t kOffsetToFirstCommentEntry = kUInt32Size;
|
||||
static constexpr uint8_t kOffsetToPCOffset = 0;
|
||||
static constexpr uint8_t kOffsetToCommentSize = kOffsetToPCOffset + kUInt32Size;
|
||||
static constexpr uint8_t kOffsetToCommentString =
|
||||
kOffsetToCommentSize + kUInt32Size;
|
||||
} // namespace
|
||||
|
||||
uint32_t CodeCommentEntry::comment_length() const {
|
||||
return static_cast<uint32_t>(comment.size() + 1);
|
||||
}
|
||||
|
||||
uint32_t CodeCommentEntry::size() const {
|
||||
return kOffsetToCommentString + comment_length();
|
||||
}
|
||||
|
||||
CodeCommentsIterator::CodeCommentsIterator(Address code_comments_start)
|
||||
: code_comments_start_(code_comments_start),
|
||||
current_entry_(code_comments_start + kOffsetToFirstCommentEntry) {}
|
||||
|
||||
uint32_t CodeCommentsIterator::size() const {
|
||||
return code_comments_start_ != kNullAddress
|
||||
? *reinterpret_cast<uint32_t*>(code_comments_start_)
|
||||
: 0;
|
||||
}
|
||||
|
||||
const char* CodeCommentsIterator::GetComment() const {
|
||||
const char* comment_string =
|
||||
reinterpret_cast<const char*>(current_entry_ + kOffsetToCommentString);
|
||||
CHECK_EQ(GetCommentSize(), strlen(comment_string) + 1);
|
||||
return comment_string;
|
||||
}
|
||||
|
||||
uint32_t CodeCommentsIterator::GetCommentSize() const {
|
||||
return *reinterpret_cast<uint32_t*>(current_entry_ + kOffsetToCommentSize);
|
||||
}
|
||||
|
||||
uint32_t CodeCommentsIterator::GetPCOffset() const {
|
||||
return *reinterpret_cast<uint32_t*>(current_entry_ + kOffsetToPCOffset);
|
||||
}
|
||||
|
||||
void CodeCommentsIterator::Next() {
|
||||
current_entry_ += kOffsetToCommentString + GetCommentSize();
|
||||
}
|
||||
|
||||
bool CodeCommentsIterator::HasCurrent() const {
|
||||
return current_entry_ < code_comments_start_ + size();
|
||||
}
|
||||
|
||||
void CodeCommentsWriter::Emit(Assembler* assm) {
|
||||
assm->dd(section_size());
|
||||
for (auto i = comments_.begin(); i != comments_.end(); ++i) {
|
||||
assm->dd(i->pc_offset);
|
||||
assm->dd(i->comment_length());
|
||||
for (char c : i->comment) {
|
||||
EnsureSpace ensure_space(assm);
|
||||
assm->db(c);
|
||||
}
|
||||
assm->db('\0');
|
||||
}
|
||||
}
|
||||
|
||||
void CodeCommentsWriter::Add(uint32_t pc_offset, std::string comment) {
|
||||
CodeCommentEntry entry = {pc_offset, std::move(comment)};
|
||||
byte_count_ += entry.size();
|
||||
comments_.push_back(std::move(entry));
|
||||
}
|
||||
|
||||
size_t CodeCommentsWriter::entry_count() const { return comments_.size(); }
|
||||
uint32_t CodeCommentsWriter::section_size() const {
|
||||
return kOffsetToFirstCommentEntry + static_cast<uint32_t>(byte_count_);
|
||||
}
|
||||
|
||||
void PrintCodeCommentsSection(std::ostream& out, Address code_comments_start) {
|
||||
CodeCommentsIterator it(code_comments_start);
|
||||
out << "CodeComments (size = " << it.size() << ")\n";
|
||||
if (it.HasCurrent()) {
|
||||
out << std::setw(6) << "pc" << std::setw(6) << "len"
|
||||
<< " comment\n";
|
||||
}
|
||||
for (; it.HasCurrent(); it.Next()) {
|
||||
out << std::hex << std::setw(6) << it.GetPCOffset() << std::dec
|
||||
<< std::setw(6) << it.GetCommentSize() << " (" << it.GetComment()
|
||||
<< ")\n";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
68
src/code-comments.h
Normal file
68
src/code-comments.h
Normal file
@ -0,0 +1,68 @@
|
||||
// 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_COMMENTS_H_
|
||||
#define V8_CODE_COMMENTS_H_
|
||||
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "include/v8-internal.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
class Assembler;
|
||||
|
||||
// Code comments section layout:
|
||||
// byte count content
|
||||
// ------------------------------------------------------------------------
|
||||
// 4 size as uint32_t
|
||||
// [Inline array of CodeCommentEntry in increasing pc_offset order]
|
||||
// ┌ 4 pc_offset of entry as uint32_t
|
||||
// ├ 4 length of the comment including terminating '\0'
|
||||
// └ <variable length> characters of the comment including terminating '\0'
|
||||
|
||||
struct CodeCommentEntry {
|
||||
uint32_t pc_offset;
|
||||
std::string comment;
|
||||
uint32_t comment_length() const;
|
||||
uint32_t size() const;
|
||||
};
|
||||
|
||||
class CodeCommentsWriter {
|
||||
public:
|
||||
void Add(uint32_t pc_offset, std::string comment);
|
||||
void Emit(Assembler* assm);
|
||||
size_t entry_count() const;
|
||||
uint32_t section_size() const;
|
||||
|
||||
private:
|
||||
uint32_t byte_count_ = 0;
|
||||
std::vector<CodeCommentEntry> comments_;
|
||||
};
|
||||
|
||||
class CodeCommentsIterator {
|
||||
public:
|
||||
// Address can be kNullAddress. In this case HasCurrent() will return false.
|
||||
explicit CodeCommentsIterator(Address code_comments_start);
|
||||
uint32_t size() const;
|
||||
const char* GetComment() const;
|
||||
uint32_t GetCommentSize() const;
|
||||
uint32_t GetPCOffset() const;
|
||||
void Next();
|
||||
bool HasCurrent() const;
|
||||
|
||||
private:
|
||||
Address code_comments_start_;
|
||||
Address current_entry_;
|
||||
};
|
||||
|
||||
void PrintCodeCommentsSection(std::ostream& out, Address code_comments_start);
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_CODE_COMMENTS_H_
|
@ -49,5 +49,9 @@ int CodeReference::relocation_size() const {
|
||||
: wasm_code_->reloc_info().length();
|
||||
}
|
||||
|
||||
Address CodeReference::code_comments() const {
|
||||
return kind_ == JS ? js_code_->code_comments() : wasm_code_->code_comments();
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
@ -31,6 +31,7 @@ class CodeReference {
|
||||
const byte* relocation_start() const;
|
||||
const byte* relocation_end() const;
|
||||
int relocation_size() const;
|
||||
Address code_comments() const;
|
||||
bool is_null() const {
|
||||
return kind_ == JS ? js_code_.is_null() : wasm_code_ == nullptr;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ void CodeStubAssembler::Check(const BranchGenerator& branch,
|
||||
Label ok(this);
|
||||
Label not_ok(this, Label::kDeferred);
|
||||
if (message != nullptr && FLAG_code_comments) {
|
||||
Comment("[ Assert: %s", message);
|
||||
Comment("[ Assert: ", message);
|
||||
} else {
|
||||
Comment("[ Assert");
|
||||
}
|
||||
@ -2875,7 +2875,7 @@ TNode<Smi> CodeStubAssembler::BuildAppendJSArray(ElementsKind kind,
|
||||
TVariable<IntPtrT>* arg_index,
|
||||
Label* bailout) {
|
||||
CSA_SLOW_ASSERT(this, IsJSArray(array));
|
||||
Comment("BuildAppendJSArray: %s", ElementsKindToString(kind));
|
||||
Comment("BuildAppendJSArray: ", ElementsKindToString(kind));
|
||||
Label pre_bailout(this);
|
||||
Label success(this);
|
||||
TVARIABLE(Smi, var_tagged_length);
|
||||
@ -2942,7 +2942,7 @@ void CodeStubAssembler::TryStoreArrayElement(ElementsKind kind,
|
||||
void CodeStubAssembler::BuildAppendJSArray(ElementsKind kind, Node* array,
|
||||
Node* value, Label* bailout) {
|
||||
CSA_SLOW_ASSERT(this, IsJSArray(array));
|
||||
Comment("BuildAppendJSArray: %s", ElementsKindToString(kind));
|
||||
Comment("BuildAppendJSArray: ", ElementsKindToString(kind));
|
||||
ParameterMode mode = OptimalParameterMode();
|
||||
VARIABLE(var_length, OptimalParameterRepresentation(),
|
||||
TaggedToParameter(LoadFastJSArrayLength(array), mode));
|
||||
@ -5050,8 +5050,8 @@ void CodeStubAssembler::CopyStringCharacters(Node* from_string, Node* to_string,
|
||||
bool from_one_byte = from_encoding == String::ONE_BYTE_ENCODING;
|
||||
bool to_one_byte = to_encoding == String::ONE_BYTE_ENCODING;
|
||||
DCHECK_IMPLIES(to_one_byte, from_one_byte);
|
||||
Comment("CopyStringCharacters %s -> %s",
|
||||
from_one_byte ? "ONE_BYTE_ENCODING" : "TWO_BYTE_ENCODING",
|
||||
Comment("CopyStringCharacters ",
|
||||
from_one_byte ? "ONE_BYTE_ENCODING" : "TWO_BYTE_ENCODING", " -> ",
|
||||
to_one_byte ? "ONE_BYTE_ENCODING" : "TWO_BYTE_ENCODING");
|
||||
|
||||
ElementsKind from_kind = from_one_byte ? UINT8_ELEMENTS : UINT16_ELEMENTS;
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "src/counters.h"
|
||||
#include "src/eh-frame.h"
|
||||
#include "src/frames.h"
|
||||
#include "src/lsan.h"
|
||||
#include "src/macro-assembler-inl.h"
|
||||
#include "src/objects/smi.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
@ -65,10 +64,7 @@ CodeGenerator::CodeGenerator(
|
||||
deoptimization_exits_(zone()),
|
||||
deoptimization_states_(zone()),
|
||||
deoptimization_literals_(zone()),
|
||||
inlined_function_count_(0),
|
||||
translations_(zone()),
|
||||
handler_table_offset_(0),
|
||||
last_lazy_deopt_pc_(0),
|
||||
caller_registers_saved_(false),
|
||||
jump_tables_(nullptr),
|
||||
ools_(nullptr),
|
||||
@ -202,29 +198,21 @@ void CodeGenerator::AssembleCode() {
|
||||
current_block_ = block->rpo_number();
|
||||
unwinding_info_writer_.BeginInstructionBlock(tasm()->pc_offset(), block);
|
||||
if (FLAG_code_comments) {
|
||||
Vector<char> buffer = Vector<char>::New(200);
|
||||
char* buffer_start = buffer.start();
|
||||
LSAN_IGNORE_OBJECT(buffer_start);
|
||||
|
||||
int next = SNPrintF(
|
||||
buffer, "-- B%d start%s%s%s%s", block->rpo_number().ToInt(),
|
||||
block->IsDeferred() ? " (deferred)" : "",
|
||||
block->needs_frame() ? "" : " (no frame)",
|
||||
block->must_construct_frame() ? " (construct frame)" : "",
|
||||
block->must_deconstruct_frame() ? " (deconstruct frame)" : "");
|
||||
|
||||
buffer = buffer.SubVector(next, buffer.length());
|
||||
std::ostringstream buffer;
|
||||
buffer << "-- B" << block->rpo_number().ToInt() << " start";
|
||||
if (block->IsDeferred()) buffer << " (deferred)";
|
||||
if (!block->needs_frame()) buffer << " (no frame)";
|
||||
if (block->must_construct_frame()) buffer << " (construct frame)";
|
||||
if (block->must_deconstruct_frame()) buffer << " (deconstruct frame)";
|
||||
|
||||
if (block->IsLoopHeader()) {
|
||||
next = SNPrintF(buffer, " (loop up to %d)", block->loop_end().ToInt());
|
||||
buffer = buffer.SubVector(next, buffer.length());
|
||||
buffer << " (loop up to " << block->loop_end().ToInt() << ")";
|
||||
}
|
||||
if (block->loop_header().IsValid()) {
|
||||
next = SNPrintF(buffer, " (in loop %d)", block->loop_header().ToInt());
|
||||
buffer = buffer.SubVector(next, buffer.length());
|
||||
buffer << " (in loop " << block->loop_header().ToInt() << ")";
|
||||
}
|
||||
SNPrintF(buffer, " --");
|
||||
tasm()->RecordComment(buffer_start);
|
||||
buffer << " --";
|
||||
tasm()->RecordComment(buffer.str().c_str());
|
||||
}
|
||||
|
||||
frame_access_state()->MarkHasFrame(block->needs_frame());
|
||||
@ -408,6 +396,7 @@ MaybeHandle<Code> CodeGenerator::FinalizeCode() {
|
||||
tasm()->AbortedCodeGeneration();
|
||||
return MaybeHandle<Code>();
|
||||
}
|
||||
|
||||
isolate()->counters()->total_compiled_code_size()->Increment(
|
||||
code->raw_instruction_size());
|
||||
|
||||
@ -734,9 +723,7 @@ void CodeGenerator::AssembleSourcePosition(SourcePosition source_position) {
|
||||
buffer << source_position.InliningStack(info);
|
||||
}
|
||||
buffer << " --";
|
||||
char* str = StrDup(buffer.str().c_str());
|
||||
LSAN_IGNORE_OBJECT(str);
|
||||
tasm()->RecordComment(str);
|
||||
tasm()->RecordComment(buffer.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -415,10 +415,10 @@ class CodeGenerator final : public GapResolver::Assembler {
|
||||
ZoneDeque<DeoptimizationExit*> deoptimization_exits_;
|
||||
ZoneDeque<DeoptimizationState*> deoptimization_states_;
|
||||
ZoneDeque<DeoptimizationLiteral> deoptimization_literals_;
|
||||
size_t inlined_function_count_;
|
||||
size_t inlined_function_count_ = 0;
|
||||
TranslationBuffer translations_;
|
||||
int handler_table_offset_;
|
||||
int last_lazy_deopt_pc_;
|
||||
int handler_table_offset_ = 0;
|
||||
int last_lazy_deopt_pc_ = 0;
|
||||
|
||||
// kArchCallCFunction could be reached either:
|
||||
// kArchCallCFunction;
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "src/frames.h"
|
||||
#include "src/interface-descriptors.h"
|
||||
#include "src/interpreter/bytecodes.h"
|
||||
#include "src/lsan.h"
|
||||
#include "src/machine-type.h"
|
||||
#include "src/macro-assembler.h"
|
||||
#include "src/memcopy.h"
|
||||
@ -420,25 +419,9 @@ void CodeAssembler::Unreachable() {
|
||||
raw_assembler()->Unreachable();
|
||||
}
|
||||
|
||||
void CodeAssembler::Comment(const char* format, ...) {
|
||||
void CodeAssembler::Comment(std::string str) {
|
||||
if (!FLAG_code_comments) return;
|
||||
char buffer[4 * KB];
|
||||
StringBuilder builder(buffer, arraysize(buffer));
|
||||
va_list arguments;
|
||||
va_start(arguments, format);
|
||||
builder.AddFormattedList(format, arguments);
|
||||
va_end(arguments);
|
||||
|
||||
// Copy the string before recording it in the assembler to avoid
|
||||
// issues when the stack allocated buffer goes out of scope.
|
||||
const int prefix_len = 2;
|
||||
int length = builder.position() + 1;
|
||||
char* copy = reinterpret_cast<char*>(malloc(length + prefix_len));
|
||||
LSAN_IGNORE_OBJECT(copy);
|
||||
MemCopy(copy + prefix_len, builder.Finalize(), length);
|
||||
copy[0] = ';';
|
||||
copy[1] = ' ';
|
||||
raw_assembler()->Comment(copy);
|
||||
raw_assembler()->Comment(str);
|
||||
}
|
||||
|
||||
void CodeAssembler::Bind(Label* label) { return label->Bind(); }
|
||||
|
@ -847,7 +847,18 @@ class V8_EXPORT_PRIVATE CodeAssembler {
|
||||
void DebugAbort(Node* message);
|
||||
void DebugBreak();
|
||||
void Unreachable();
|
||||
void Comment(const char* format, ...);
|
||||
void Comment(const char* msg) {
|
||||
if (!FLAG_code_comments) return;
|
||||
Comment(std::string(msg));
|
||||
}
|
||||
void Comment(std::string msg);
|
||||
template <class... Args>
|
||||
void Comment(Args&&... args) {
|
||||
if (!FLAG_code_comments) return;
|
||||
std::ostringstream s;
|
||||
USE((s << std::forward<Args>(args))...);
|
||||
Comment(s.str());
|
||||
}
|
||||
|
||||
void Bind(Label* label);
|
||||
#if DEBUG
|
||||
|
@ -813,7 +813,7 @@ struct MachineOperatorGlobalCache {
|
||||
struct CommentOperator : public Operator1<const char*> {
|
||||
explicit CommentOperator(const char* msg)
|
||||
: Operator1<const char*>(IrOpcode::kComment, Operator::kNoThrow,
|
||||
"Comment", 0, 0, 0, 0, 0, 0, msg) {}
|
||||
"Comment", 0, 1, 1, 0, 1, 0, msg) {}
|
||||
};
|
||||
|
||||
static base::LazyInstance<MachineOperatorGlobalCache>::type
|
||||
|
@ -547,8 +547,11 @@ void RawMachineAssembler::Unreachable() {
|
||||
current_block_ = nullptr;
|
||||
}
|
||||
|
||||
void RawMachineAssembler::Comment(const char* msg) {
|
||||
AddNode(machine()->Comment(msg));
|
||||
void RawMachineAssembler::Comment(std::string msg) {
|
||||
size_t length = msg.length() + 1;
|
||||
char* zone_buffer = zone()->NewArray<char>(length);
|
||||
MemCopy(zone_buffer, msg.c_str(), length);
|
||||
AddNode(machine()->Comment(zone_buffer));
|
||||
}
|
||||
|
||||
Node* RawMachineAssembler::CallN(CallDescriptor* call_descriptor,
|
||||
|
@ -924,7 +924,7 @@ class V8_EXPORT_PRIVATE RawMachineAssembler {
|
||||
void DebugAbort(Node* message);
|
||||
void DebugBreak();
|
||||
void Unreachable();
|
||||
void Comment(const char* msg);
|
||||
void Comment(std::string msg);
|
||||
|
||||
#if DEBUG
|
||||
void Bind(RawMachineLabel* label, AssemblerDebugInfo info);
|
||||
|
@ -177,7 +177,7 @@ void ConstantPoolBuilder::EmitGroup(Assembler* assm,
|
||||
}
|
||||
}
|
||||
|
||||
// Emit and return position of pool. Zero implies no constant pool.
|
||||
// Emit and return size of pool.
|
||||
int ConstantPoolBuilder::Emit(Assembler* assm) {
|
||||
bool emitted = emitted_label_.is_bound();
|
||||
bool empty = IsEmpty();
|
||||
@ -203,7 +203,7 @@ int ConstantPoolBuilder::Emit(Assembler* assm) {
|
||||
}
|
||||
}
|
||||
|
||||
return !empty ? emitted_label_.pos() : 0;
|
||||
return !empty ? (assm->pc_offset() - emitted_label_.pos()) : 0;
|
||||
}
|
||||
|
||||
#endif // defined(V8_TARGET_ARCH_PPC)
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "src/assembler-inl.h"
|
||||
#include "src/code-comments.h"
|
||||
#include "src/code-reference.h"
|
||||
#include "src/debug/debug.h"
|
||||
#include "src/deoptimizer.h"
|
||||
@ -264,6 +265,7 @@ static int DecodeIt(Isolate* isolate, ExternalReferenceEncoder* ref_encoder,
|
||||
std::ostream* os, CodeReference code,
|
||||
const V8NameConverter& converter, byte* begin, byte* end,
|
||||
Address current_pc) {
|
||||
CHECK(!code.is_null());
|
||||
v8::internal::EmbeddedVector<char, 128> decode_buffer;
|
||||
v8::internal::EmbeddedVector<char, kOutBufferSize> out_buffer;
|
||||
StringBuilder out(out_buffer.start(), out_buffer.length());
|
||||
@ -271,7 +273,11 @@ static int DecodeIt(Isolate* isolate, ExternalReferenceEncoder* ref_encoder,
|
||||
disasm::Disassembler d(converter,
|
||||
disasm::Disassembler::kContinueOnUnimplementedOpcode);
|
||||
RelocIterator* it = nullptr;
|
||||
if (!code.is_null()) {
|
||||
CodeCommentsIterator cit(code.code_comments());
|
||||
// Relocation exists if we either have no isolate (wasm code),
|
||||
// or we have an isolate and it is not an off-heap instruction stream.
|
||||
if (!isolate ||
|
||||
!InstructionStream::PcIsOffHeap(isolate, bit_cast<Address>(begin))) {
|
||||
it = new RelocIterator(code);
|
||||
} else {
|
||||
// No relocation information when printing code stubs.
|
||||
@ -317,19 +323,18 @@ static int DecodeIt(Isolate* isolate, ExternalReferenceEncoder* ref_encoder,
|
||||
std::vector<intptr_t> datas;
|
||||
if (it != nullptr) {
|
||||
while (!it->done() && it->rinfo()->pc() < reinterpret_cast<Address>(pc)) {
|
||||
if (RelocInfo::IsComment(it->rinfo()->rmode())) {
|
||||
// For comments just collect the text.
|
||||
comments.push_back(
|
||||
reinterpret_cast<const char*>(it->rinfo()->data()));
|
||||
} else {
|
||||
// For other reloc info collect all data.
|
||||
pcs.push_back(it->rinfo()->pc());
|
||||
rmodes.push_back(it->rinfo()->rmode());
|
||||
datas.push_back(it->rinfo()->data());
|
||||
}
|
||||
// Collect all data.
|
||||
pcs.push_back(it->rinfo()->pc());
|
||||
rmodes.push_back(it->rinfo()->rmode());
|
||||
datas.push_back(it->rinfo()->data());
|
||||
it->next();
|
||||
}
|
||||
}
|
||||
while (cit.HasCurrent() &&
|
||||
cit.GetPCOffset() < static_cast<Address>(pc - begin)) {
|
||||
comments.push_back(cit.GetComment());
|
||||
cit.Next();
|
||||
}
|
||||
|
||||
// Comments.
|
||||
for (size_t i = 0; i < comments.size(); i++) {
|
||||
@ -392,14 +397,11 @@ static int DecodeIt(Isolate* isolate, ExternalReferenceEncoder* ref_encoder,
|
||||
}
|
||||
|
||||
// Emit comments following the last instruction (if any).
|
||||
if (it != nullptr) {
|
||||
for ( ; !it->done(); it->next()) {
|
||||
if (RelocInfo::IsComment(it->rinfo()->rmode())) {
|
||||
out.AddFormatted(" %s",
|
||||
reinterpret_cast<const char*>(it->rinfo()->data()));
|
||||
DumpBuffer(os, &out);
|
||||
}
|
||||
}
|
||||
while (cit.HasCurrent() &&
|
||||
cit.GetPCOffset() < static_cast<Address>(pc - begin)) {
|
||||
out.AddFormatted(" %s", cit.GetComment());
|
||||
DumpBuffer(os, &out);
|
||||
cit.Next();
|
||||
}
|
||||
|
||||
delete it;
|
||||
@ -409,19 +411,16 @@ static int DecodeIt(Isolate* isolate, ExternalReferenceEncoder* ref_encoder,
|
||||
int Disassembler::Decode(Isolate* isolate, std::ostream* os, byte* begin,
|
||||
byte* end, CodeReference code, Address current_pc) {
|
||||
V8NameConverter v8NameConverter(isolate, code);
|
||||
bool decode_off_heap = isolate && InstructionStream::PcIsOffHeap(
|
||||
isolate, bit_cast<Address>(begin));
|
||||
CodeReference code_ref = decode_off_heap ? CodeReference() : code;
|
||||
if (isolate) {
|
||||
// We have an isolate, so support external reference names.
|
||||
SealHandleScope shs(isolate);
|
||||
DisallowHeapAllocation no_alloc;
|
||||
ExternalReferenceEncoder ref_encoder(isolate);
|
||||
return DecodeIt(isolate, &ref_encoder, os, code_ref, v8NameConverter, begin,
|
||||
return DecodeIt(isolate, &ref_encoder, os, code, v8NameConverter, begin,
|
||||
end, current_pc);
|
||||
} else {
|
||||
// No isolate => isolate-independent code. No external reference names.
|
||||
return DecodeIt(nullptr, nullptr, os, code_ref, v8NameConverter, begin, end,
|
||||
return DecodeIt(nullptr, nullptr, os, code, v8NameConverter, begin, end,
|
||||
current_pc);
|
||||
}
|
||||
}
|
||||
|
@ -760,28 +760,32 @@ enum ParseRestriction {
|
||||
// A CodeDesc describes a buffer holding instructions and relocation
|
||||
// information. The instructions start at the beginning of the buffer
|
||||
// and grow forward, the relocation information starts at the end of
|
||||
// the buffer and grows backward. A constant pool may exist at the
|
||||
// end of the instructions.
|
||||
// the buffer and grows backward. A constant pool and a code comments
|
||||
// section may exist at the in this order at the end of the instructions.
|
||||
//
|
||||
// |<--------------- buffer_size ----------------------------------->|
|
||||
// |<------------- instr_size ---------->| |<-- reloc_size -->|
|
||||
// | |<- const_pool_size ->| |
|
||||
// +=====================================+========+==================+
|
||||
// | instructions | data | free | reloc info |
|
||||
// +=====================================+========+==================+
|
||||
// ^
|
||||
// |
|
||||
// │<--------------- buffer_size ----------------------------------->│
|
||||
// │<---------------- instr_size ------------->│ │<-reloc_size->│
|
||||
// │ │<-const pool->│ │ │ │
|
||||
// │ │<- comments->│ │ │
|
||||
// ├───────────────────────────────────────────┼──────┼──────────────┤
|
||||
// │ instructions │ data │ free │ reloc info │
|
||||
// ├───────────────────────────────────────────┴──────┴──────────────┘
|
||||
// buffer
|
||||
|
||||
struct CodeDesc {
|
||||
byte* buffer;
|
||||
int buffer_size;
|
||||
int instr_size;
|
||||
int reloc_size;
|
||||
int constant_pool_size;
|
||||
byte* unwinding_info;
|
||||
int unwinding_info_size;
|
||||
Assembler* origin;
|
||||
byte* buffer = nullptr;
|
||||
int buffer_size = 0;
|
||||
int instr_size = 0;
|
||||
int reloc_size = 0;
|
||||
int constant_pool_size = 0;
|
||||
int code_comments_size = 0;
|
||||
byte* unwinding_info = 0;
|
||||
int unwinding_info_size = 0;
|
||||
Assembler* origin = nullptr;
|
||||
int constant_pool_offset() const {
|
||||
return code_comments_offset() - constant_pool_size;
|
||||
}
|
||||
int code_comments_offset() const { return instr_size - code_comments_size; }
|
||||
};
|
||||
|
||||
// State for inline cache call sites. Aliased as IC::State.
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "src/heap/code-stats.h"
|
||||
|
||||
#include "src/code-comments.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/reloc-info.h"
|
||||
|
||||
@ -164,36 +165,28 @@ void CodeStatistics::EnterComment(Isolate* isolate, const char* comment,
|
||||
// Call for each nested comment start (start marked with '[ xxx', end marked
|
||||
// with ']'. RelocIterator 'it' must point to a comment reloc info.
|
||||
void CodeStatistics::CollectCommentStatistics(Isolate* isolate,
|
||||
RelocIterator* it) {
|
||||
DCHECK(!it->done());
|
||||
DCHECK(it->rinfo()->rmode() == RelocInfo::COMMENT);
|
||||
const char* tmp = reinterpret_cast<const char*>(it->rinfo()->data());
|
||||
if (tmp[0] != '[') {
|
||||
CodeCommentsIterator* cit) {
|
||||
DCHECK(cit->HasCurrent());
|
||||
const char* comment_txt = cit->GetComment();
|
||||
if (comment_txt[0] != '[') {
|
||||
// Not a nested comment; skip
|
||||
return;
|
||||
}
|
||||
|
||||
// Search for end of nested comment or a new nested comment
|
||||
const char* const comment_txt =
|
||||
reinterpret_cast<const char*>(it->rinfo()->data());
|
||||
Address prev_pc = it->rinfo()->pc();
|
||||
int prev_pc_offset = cit->GetPCOffset();
|
||||
int flat_delta = 0;
|
||||
it->next();
|
||||
while (true) {
|
||||
cit->Next();
|
||||
for (; cit->HasCurrent(); cit->Next()) {
|
||||
// All nested comments must be terminated properly, and therefore exit
|
||||
// from loop.
|
||||
DCHECK(!it->done());
|
||||
if (it->rinfo()->rmode() == RelocInfo::COMMENT) {
|
||||
const char* const txt =
|
||||
reinterpret_cast<const char*>(it->rinfo()->data());
|
||||
flat_delta += static_cast<int>(it->rinfo()->pc() - prev_pc);
|
||||
if (txt[0] == ']') break; // End of nested comment
|
||||
// A new comment
|
||||
CollectCommentStatistics(isolate, it);
|
||||
// Skip code that was covered with previous comment
|
||||
prev_pc = it->rinfo()->pc();
|
||||
}
|
||||
it->next();
|
||||
const char* const txt = cit->GetComment();
|
||||
flat_delta += cit->GetPCOffset() - prev_pc_offset;
|
||||
if (txt[0] == ']') break; // End of nested comment
|
||||
// A new comment
|
||||
CollectCommentStatistics(isolate, cit);
|
||||
// Skip code that was covered with previous comment
|
||||
prev_pc_offset = cit->GetPCOffset();
|
||||
}
|
||||
EnterComment(isolate, comment_txt, flat_delta);
|
||||
}
|
||||
@ -208,21 +201,18 @@ void CodeStatistics::CollectCodeCommentStatistics(HeapObject* obj,
|
||||
}
|
||||
|
||||
Code code = Code::cast(obj);
|
||||
RelocIterator it(code);
|
||||
CodeCommentsIterator cit(code->code_comments());
|
||||
int delta = 0;
|
||||
Address prev_pc = code->raw_instruction_start();
|
||||
while (!it.done()) {
|
||||
if (it.rinfo()->rmode() == RelocInfo::COMMENT) {
|
||||
delta += static_cast<int>(it.rinfo()->pc() - prev_pc);
|
||||
CollectCommentStatistics(isolate, &it);
|
||||
prev_pc = it.rinfo()->pc();
|
||||
}
|
||||
it.next();
|
||||
int prev_pc_offset = 0;
|
||||
while (cit.HasCurrent()) {
|
||||
delta += static_cast<int>(cit.GetPCOffset() - prev_pc_offset);
|
||||
CollectCommentStatistics(isolate, &cit);
|
||||
prev_pc_offset = cit.GetPCOffset();
|
||||
cit.Next();
|
||||
}
|
||||
|
||||
DCHECK(code->raw_instruction_start() <= prev_pc &&
|
||||
prev_pc <= code->raw_instruction_end());
|
||||
delta += static_cast<int>(code->raw_instruction_end() - prev_pc);
|
||||
DCHECK(0 <= prev_pc_offset && prev_pc_offset <= code->raw_instruction_size());
|
||||
delta += static_cast<int>(code->raw_instruction_size() - prev_pc_offset);
|
||||
EnterComment(isolate, "NoComment", delta);
|
||||
}
|
||||
#endif
|
||||
|
@ -8,11 +8,11 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
class Isolate;
|
||||
class CodeCommentsIterator;
|
||||
class HeapObject;
|
||||
class Isolate;
|
||||
class LargeObjectSpace;
|
||||
class PagedSpace;
|
||||
class RelocIterator;
|
||||
|
||||
class CodeStatistics {
|
||||
public:
|
||||
@ -35,7 +35,8 @@ class CodeStatistics {
|
||||
Isolate* isolate);
|
||||
|
||||
#ifdef DEBUG
|
||||
static void CollectCommentStatistics(Isolate* isolate, RelocIterator* it);
|
||||
static void CollectCommentStatistics(Isolate* isolate,
|
||||
CodeCommentsIterator* it);
|
||||
static void CollectCodeCommentStatistics(HeapObject* obj, Isolate* isolate);
|
||||
static void EnterComment(Isolate* isolate, const char* comment, int delta);
|
||||
static void ResetCodeStatistics(Isolate* isolate);
|
||||
|
@ -86,7 +86,8 @@ void InitializeCode(Heap* heap, Handle<Code> code, int object_size,
|
||||
code->set_code_data_container(*data_container);
|
||||
code->set_deoptimization_data(*deopt_data);
|
||||
code->set_source_position_table(*source_position_table);
|
||||
code->set_constant_pool_offset(desc.instr_size - desc.constant_pool_size);
|
||||
code->set_constant_pool_offset(desc.constant_pool_offset());
|
||||
code->set_code_comments_offset(desc.code_comments_offset());
|
||||
code->set_builtin_index(builtin_index);
|
||||
|
||||
// Allow self references to created code object by patching the handle to
|
||||
@ -2830,6 +2831,7 @@ Handle<Code> Factory::NewOffHeapTrampolineFor(Handle<Code> code,
|
||||
if (code->has_safepoint_info()) {
|
||||
result->set_safepoint_table_offset(code->safepoint_table_offset());
|
||||
}
|
||||
result->set_code_comments_offset(code->code_comments_offset());
|
||||
|
||||
// Replace the newly generated trampoline's RelocInfo ByteArray with the
|
||||
// canonical one stored in the roots to avoid duplicating it for every
|
||||
|
@ -328,6 +328,7 @@ Assembler::Assembler(const AssemblerOptions& options, void* buffer,
|
||||
}
|
||||
|
||||
void Assembler::GetCode(Isolate* isolate, CodeDesc* desc) {
|
||||
int code_comments_size = WriteCodeComments();
|
||||
// Finalize code (at this point overflow() may be true, but the gap ensures
|
||||
// that we are still not overlapping instructions and relocation info).
|
||||
DCHECK(pc_ <= reloc_info_writer.pos()); // No overlap.
|
||||
@ -343,6 +344,7 @@ void Assembler::GetCode(Isolate* isolate, CodeDesc* desc) {
|
||||
desc->constant_pool_size = 0;
|
||||
desc->unwinding_info_size = 0;
|
||||
desc->unwinding_info = nullptr;
|
||||
desc->code_comments_size = code_comments_size;
|
||||
|
||||
// Collection stage
|
||||
auto jump_opt = jump_optimization_info();
|
||||
@ -388,7 +390,6 @@ bool Assembler::IsNop(Address addr) {
|
||||
|
||||
void Assembler::Nop(int bytes) {
|
||||
EnsureSpace ensure_space(this);
|
||||
|
||||
// Multi byte nops from http://support.amd.com/us/Processor_TechDocs/40546.pdf
|
||||
while (bytes > 0) {
|
||||
switch (bytes) {
|
||||
|
@ -1720,9 +1720,6 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
|
||||
return pc_offset() - label->pos();
|
||||
}
|
||||
|
||||
// Use --code-comments to enable.
|
||||
void RecordComment(const char* msg);
|
||||
|
||||
// Record a deoptimization reason that can be used by a log or cpu profiler.
|
||||
// Use --trace-deopt to enable.
|
||||
void RecordDeoptReason(DeoptimizeReason reason, SourcePosition position,
|
||||
@ -1847,6 +1844,8 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
|
||||
|
||||
void AllocateAndInstallRequestedHeapObjects(Isolate* isolate);
|
||||
|
||||
int WriteCodeComments();
|
||||
|
||||
friend class EnsureSpace;
|
||||
|
||||
// Internal reference positions, required for (potential) patching in
|
||||
|
31
src/lsan.h
31
src/lsan.h
@ -1,31 +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.
|
||||
|
||||
// LeakSanitizer support.
|
||||
|
||||
#ifndef V8_LSAN_H_
|
||||
#define V8_LSAN_H_
|
||||
|
||||
#include "src/base/macros.h"
|
||||
#include "src/globals.h"
|
||||
|
||||
// There is no compile time flag for LSan, to enable this whenever ASan is
|
||||
// enabled. Note that LSan can be used as part of ASan with 'detect_leaks=1'.
|
||||
// On windows, LSan is not implemented yet, so disable it there.
|
||||
#if defined(V8_USE_ADDRESS_SANITIZER) && !defined(V8_OS_WIN)
|
||||
|
||||
#include <sanitizer/lsan_interface.h>
|
||||
|
||||
#define LSAN_IGNORE_OBJECT(ptr) __lsan_ignore_object(ptr)
|
||||
|
||||
#else // defined(V8_USE_ADDRESS_SANITIZER) && !defined(V8_OS_WIN)
|
||||
|
||||
#define LSAN_IGNORE_OBJECT(ptr) \
|
||||
static_assert(std::is_pointer<decltype(ptr)>::value || \
|
||||
std::is_same<v8::internal::Address, decltype(ptr)>::value, \
|
||||
"static type violation")
|
||||
|
||||
#endif // defined(V8_USE_ADDRESS_SANITIZER) && !defined(V8_OS_WIN)
|
||||
|
||||
#endif // V8_LSAN_H_
|
@ -327,6 +327,9 @@ Assembler::Assembler(const AssemblerOptions& options, void* buffer,
|
||||
|
||||
void Assembler::GetCode(Isolate* isolate, CodeDesc* desc) {
|
||||
EmitForbiddenSlotInstruction();
|
||||
|
||||
int code_comments_size = WriteCodeComments();
|
||||
|
||||
DCHECK(pc_ <= reloc_info_writer.pos()); // No overlap.
|
||||
|
||||
AllocateAndInstallRequestedHeapObjects(isolate);
|
||||
@ -340,6 +343,7 @@ void Assembler::GetCode(Isolate* isolate, CodeDesc* desc) {
|
||||
desc->constant_pool_size = 0;
|
||||
desc->unwinding_info_size = 0;
|
||||
desc->unwinding_info = nullptr;
|
||||
desc->code_comments_size = code_comments_size;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1727,10 +1727,6 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(BlockGrowBufferScope);
|
||||
};
|
||||
|
||||
// Record a comment relocation entry that can be used by a disassembler.
|
||||
// Use --code-comments to enable.
|
||||
void RecordComment(const char* msg);
|
||||
|
||||
// Record a deoptimization reason that can be used by a log or cpu profiler.
|
||||
// Use --trace-deopt to enable.
|
||||
void RecordDeoptReason(DeoptimizeReason reason, SourcePosition position,
|
||||
@ -2232,6 +2228,8 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
|
||||
private:
|
||||
void AllocateAndInstallRequestedHeapObjects(Isolate* isolate);
|
||||
|
||||
int WriteCodeComments();
|
||||
|
||||
friend class RegExpMacroAssemblerMIPS;
|
||||
friend class RelocInfo;
|
||||
friend class BlockTrampolinePoolScope;
|
||||
|
@ -304,6 +304,9 @@ Assembler::Assembler(const AssemblerOptions& options, void* buffer,
|
||||
|
||||
void Assembler::GetCode(Isolate* isolate, CodeDesc* desc) {
|
||||
EmitForbiddenSlotInstruction();
|
||||
|
||||
int code_comments_size = WriteCodeComments();
|
||||
|
||||
DCHECK(pc_ <= reloc_info_writer.pos()); // No overlap.
|
||||
|
||||
AllocateAndInstallRequestedHeapObjects(isolate);
|
||||
@ -318,6 +321,7 @@ void Assembler::GetCode(Isolate* isolate, CodeDesc* desc) {
|
||||
desc->constant_pool_size = 0;
|
||||
desc->unwinding_info_size = 0;
|
||||
desc->unwinding_info = nullptr;
|
||||
desc->code_comments_size = code_comments_size;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1795,10 +1795,6 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(BlockGrowBufferScope);
|
||||
};
|
||||
|
||||
// Record a comment relocation entry that can be used by a disassembler.
|
||||
// Use --code-comments to enable.
|
||||
void RecordComment(const char* msg);
|
||||
|
||||
// Record a deoptimization reason that can be used by a log or cpu profiler.
|
||||
// Use --trace-deopt to enable.
|
||||
void RecordDeoptReason(DeoptimizeReason reason, SourcePosition position,
|
||||
@ -2267,6 +2263,8 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
|
||||
private:
|
||||
void AllocateAndInstallRequestedHeapObjects(Isolate* isolate);
|
||||
|
||||
int WriteCodeComments();
|
||||
|
||||
friend class RegExpMacroAssemblerMIPS;
|
||||
friend class RelocInfo;
|
||||
friend class BlockTrampolinePoolScope;
|
||||
|
@ -1206,7 +1206,8 @@ void CodeDataContainer::CodeDataContainerVerify(Isolate* isolate) {
|
||||
}
|
||||
|
||||
void Code::CodeVerify(Isolate* isolate) {
|
||||
CHECK_LE(constant_pool_offset(), InstructionSize());
|
||||
CHECK_LE(constant_pool_offset(), code_comments_offset());
|
||||
CHECK_LE(code_comments_offset(), InstructionSize());
|
||||
CHECK(IsAligned(raw_instruction_start(), kCodeAlignment));
|
||||
relocation_info()->ObjectVerify(isolate);
|
||||
CHECK(Code::SizeFor(body_size()) <= kMaxRegularHeapObjectSize ||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "src/objects.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <iomanip>
|
||||
#include <memory>
|
||||
@ -14817,13 +14818,10 @@ bool Code::IsIsolateIndependent(Isolate* isolate) {
|
||||
constexpr int all_real_modes_mask =
|
||||
(1 << (RelocInfo::LAST_REAL_RELOC_MODE + 1)) - 1;
|
||||
constexpr int mode_mask = all_real_modes_mask &
|
||||
~RelocInfo::ModeMask(RelocInfo::COMMENT) &
|
||||
~RelocInfo::ModeMask(RelocInfo::CONST_POOL) &
|
||||
~RelocInfo::ModeMask(RelocInfo::OFF_HEAP_TARGET) &
|
||||
~RelocInfo::ModeMask(RelocInfo::VENEER_POOL);
|
||||
STATIC_ASSERT(RelocInfo::LAST_REAL_RELOC_MODE == RelocInfo::VENEER_POOL);
|
||||
STATIC_ASSERT(RelocInfo::ModeMask(RelocInfo::COMMENT) ==
|
||||
(1 << RelocInfo::COMMENT));
|
||||
STATIC_ASSERT(mode_mask ==
|
||||
(RelocInfo::ModeMask(RelocInfo::CODE_TARGET) |
|
||||
RelocInfo::ModeMask(RelocInfo::RELATIVE_CODE_TARGET) |
|
||||
@ -15199,24 +15197,24 @@ void Code::Disassemble(const char* name, std::ostream& os, Address current_pc) {
|
||||
int size = InstructionSize();
|
||||
int safepoint_offset =
|
||||
has_safepoint_info() ? safepoint_table_offset() : size;
|
||||
int constant_pool_offset = this->constant_pool_offset();
|
||||
int const_pool_offset = constant_pool_offset();
|
||||
int handler_offset = handler_table_offset() ? handler_table_offset() : size;
|
||||
int comments_offset = code_comments_offset();
|
||||
|
||||
// Stop before reaching any embedded tables
|
||||
int code_size =
|
||||
Min(handler_offset, Min(safepoint_offset, constant_pool_offset));
|
||||
int code_size = std::min(
|
||||
{handler_offset, safepoint_offset, const_pool_offset, comments_offset});
|
||||
os << "Instructions (size = " << code_size << ")\n";
|
||||
DisassembleCodeRange(isolate, os, *this, InstructionStart(), code_size,
|
||||
current_pc);
|
||||
|
||||
if (constant_pool_offset < size) {
|
||||
int constant_pool_size = safepoint_offset - constant_pool_offset;
|
||||
DCHECK_EQ(constant_pool_size & kPointerAlignmentMask, 0);
|
||||
os << "\nConstant Pool (size = " << constant_pool_size << ")\n";
|
||||
if (int pool_size = constant_pool_size()) {
|
||||
DCHECK_EQ(pool_size & kPointerAlignmentMask, 0);
|
||||
os << "\nConstant Pool (size = " << pool_size << ")\n";
|
||||
Vector<char> buf = Vector<char>::New(50);
|
||||
intptr_t* ptr = reinterpret_cast<intptr_t*>(InstructionStart() +
|
||||
constant_pool_offset);
|
||||
for (int i = 0; i < constant_pool_size; i += kPointerSize, ptr++) {
|
||||
intptr_t* ptr =
|
||||
reinterpret_cast<intptr_t*>(InstructionStart() + const_pool_offset);
|
||||
for (int i = 0; i < pool_size; i += kPointerSize, ptr++) {
|
||||
SNPrintF(buf, "%4d %08" V8PRIxPTR, i, *ptr);
|
||||
os << static_cast<const void*>(ptr) << " " << buf.start() << "\n";
|
||||
}
|
||||
@ -15292,6 +15290,10 @@ void Code::Disassemble(const char* name, std::ostream& os, Address current_pc) {
|
||||
eh_frame_disassembler.DisassembleToStream(os);
|
||||
os << "\n";
|
||||
}
|
||||
|
||||
if (code_comments_offset() < InstructionSize()) {
|
||||
PrintCodeCommentsSection(os, code_comments());
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_DISASSEMBLER
|
||||
|
||||
|
@ -539,25 +539,51 @@ bool Code::is_optimized_code() const { return kind() == OPTIMIZED_FUNCTION; }
|
||||
bool Code::is_wasm_code() const { return kind() == WASM_FUNCTION; }
|
||||
|
||||
int Code::constant_pool_offset() const {
|
||||
if (!FLAG_enable_embedded_constant_pool) return InstructionSize();
|
||||
if (!FLAG_enable_embedded_constant_pool) return code_comments_offset();
|
||||
return READ_INT_FIELD(this, kConstantPoolOffset);
|
||||
}
|
||||
|
||||
void Code::set_constant_pool_offset(int value) {
|
||||
if (!FLAG_enable_embedded_constant_pool) return;
|
||||
DCHECK_LT(value, InstructionSize());
|
||||
WRITE_INT_FIELD(this, kConstantPoolOffset, value);
|
||||
}
|
||||
|
||||
int Code::constant_pool_size() const {
|
||||
if (!FLAG_enable_embedded_constant_pool) return 0;
|
||||
return code_comments_offset() - constant_pool_offset();
|
||||
}
|
||||
Address Code::constant_pool() const {
|
||||
if (FLAG_enable_embedded_constant_pool) {
|
||||
int offset = constant_pool_offset();
|
||||
if (offset < InstructionSize()) {
|
||||
if (offset < code_comments_offset()) {
|
||||
return InstructionStart() + offset;
|
||||
}
|
||||
}
|
||||
return kNullAddress;
|
||||
}
|
||||
|
||||
int Code::code_comments_offset() const {
|
||||
int offset = READ_INT_FIELD(this, kCodeCommentsOffset);
|
||||
DCHECK_LE(0, offset);
|
||||
DCHECK_LE(offset, InstructionSize());
|
||||
return offset;
|
||||
}
|
||||
|
||||
void Code::set_code_comments_offset(int offset) {
|
||||
DCHECK_LE(0, offset);
|
||||
DCHECK_LE(offset, InstructionSize());
|
||||
WRITE_INT_FIELD(this, kCodeCommentsOffset, offset);
|
||||
}
|
||||
|
||||
Address Code::code_comments() const {
|
||||
int offset = code_comments_offset();
|
||||
if (offset < InstructionSize()) {
|
||||
return InstructionStart() + offset;
|
||||
}
|
||||
return kNullAddress;
|
||||
}
|
||||
|
||||
Code Code::GetCodeFromTargetAddress(Address address) {
|
||||
{
|
||||
// TODO(jgruber,v8:6666): Support embedded builtins here. We'd need to pass
|
||||
|
@ -100,6 +100,12 @@ class Code : public HeapObjectPtr {
|
||||
// Valid for FLAG_enable_embedded_constant_pool only
|
||||
inline int constant_pool_offset() const;
|
||||
inline void set_constant_pool_offset(int offset);
|
||||
inline int constant_pool_size() const;
|
||||
|
||||
// [code_comments_offset]: Offset of the code comment section.
|
||||
inline int code_comments_offset() const;
|
||||
inline void set_code_comments_offset(int offset);
|
||||
inline Address code_comments() const;
|
||||
|
||||
// Unchecked accessors to be used during GC.
|
||||
inline ByteArray unchecked_relocation_info() const;
|
||||
@ -367,6 +373,7 @@ class Code : public HeapObjectPtr {
|
||||
V(kHandlerTableOffsetOffset, kIntSize) \
|
||||
V(kConstantPoolOffset, FLAG_enable_embedded_constant_pool ? kIntSize : 0) \
|
||||
V(kBuiltinIndexOffset, kIntSize) \
|
||||
V(kCodeCommentsOffset, kIntSize) \
|
||||
/* Add padding to align the instruction start following right after */ \
|
||||
/* the Code object header. */ \
|
||||
V(kHeaderPaddingStart, CODE_POINTER_PADDING(kHeaderPaddingStart)) \
|
||||
@ -378,28 +385,28 @@ class Code : public HeapObjectPtr {
|
||||
// This documents the amount of free space we have in each Code object header
|
||||
// due to padding for code alignment.
|
||||
#if V8_TARGET_ARCH_ARM64
|
||||
static constexpr int kHeaderPaddingSize = 4;
|
||||
static constexpr int kHeaderPaddingSize = 0;
|
||||
STATIC_ASSERT(kHeaderSize - kHeaderPaddingStart == kHeaderPaddingSize);
|
||||
#elif V8_TARGET_ARCH_MIPS64
|
||||
static constexpr int kHeaderPaddingSize = 4;
|
||||
static constexpr int kHeaderPaddingSize = 0;
|
||||
STATIC_ASSERT(kHeaderSize - kHeaderPaddingStart == kHeaderPaddingSize);
|
||||
#elif V8_TARGET_ARCH_X64
|
||||
static constexpr int kHeaderPaddingSize = 4;
|
||||
static constexpr int kHeaderPaddingSize = 0;
|
||||
STATIC_ASSERT(kHeaderSize - kHeaderPaddingStart == kHeaderPaddingSize);
|
||||
#elif V8_TARGET_ARCH_ARM
|
||||
static constexpr int kHeaderPaddingSize = 24;
|
||||
static constexpr int kHeaderPaddingSize = 20;
|
||||
STATIC_ASSERT(kHeaderSize - kHeaderPaddingStart == kHeaderPaddingSize);
|
||||
#elif V8_TARGET_ARCH_IA32
|
||||
static constexpr int kHeaderPaddingSize = 24;
|
||||
static constexpr int kHeaderPaddingSize = 20;
|
||||
STATIC_ASSERT(kHeaderSize - kHeaderPaddingStart == kHeaderPaddingSize);
|
||||
#elif V8_TARGET_ARCH_MIPS
|
||||
static constexpr int kHeaderPaddingSize = 24;
|
||||
static constexpr int kHeaderPaddingSize = 20;
|
||||
STATIC_ASSERT(kHeaderSize - kHeaderPaddingStart == kHeaderPaddingSize);
|
||||
#elif V8_TARGET_ARCH_PPC
|
||||
// No static assert possible since padding size depends on the
|
||||
// FLAG_enable_embedded_constant_pool runtime flag.
|
||||
#elif V8_TARGET_ARCH_S390
|
||||
static constexpr int kHeaderPaddingSize = 24;
|
||||
static constexpr int kHeaderPaddingSize = 20;
|
||||
STATIC_ASSERT(kHeaderSize - kHeaderPaddingStart == kHeaderPaddingSize);
|
||||
#else
|
||||
#error Unknown architecture.
|
||||
|
@ -265,9 +265,12 @@ Assembler::Assembler(const AssemblerOptions& options, void* buffer,
|
||||
|
||||
void Assembler::GetCode(Isolate* isolate, CodeDesc* desc) {
|
||||
// Emit constant pool if necessary.
|
||||
int constant_pool_offset = EmitConstantPool();
|
||||
int constant_pool_size = EmitConstantPool();
|
||||
|
||||
EmitRelocations();
|
||||
|
||||
int code_comments_size = WriteCodeComments();
|
||||
|
||||
AllocateAndInstallRequestedHeapObjects(isolate);
|
||||
|
||||
// Set up code descriptor.
|
||||
@ -275,11 +278,11 @@ void Assembler::GetCode(Isolate* isolate, CodeDesc* desc) {
|
||||
desc->buffer_size = buffer_size_;
|
||||
desc->instr_size = pc_offset();
|
||||
desc->reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos();
|
||||
desc->constant_pool_size =
|
||||
(constant_pool_offset ? desc->instr_size - constant_pool_offset : 0);
|
||||
desc->constant_pool_size = constant_pool_size;
|
||||
desc->origin = this;
|
||||
desc->unwinding_info_size = 0;
|
||||
desc->unwinding_info = nullptr;
|
||||
desc->code_comments_size = code_comments_size;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1335,10 +1335,6 @@ class Assembler : public AssemblerBase {
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(BlockConstantPoolEntrySharingScope);
|
||||
};
|
||||
|
||||
// Record a comment relocation entry that can be used by a disassembler.
|
||||
// Use --code-comments to enable.
|
||||
void RecordComment(const char* msg);
|
||||
|
||||
// Record a deoptimization reason that can be used by a log or cpu profiler.
|
||||
// Use --trace-deopt to enable.
|
||||
void RecordDeoptReason(DeoptimizeReason reason, SourcePosition position,
|
||||
@ -1622,6 +1618,8 @@ class Assembler : public AssemblerBase {
|
||||
|
||||
void AllocateAndInstallRequestedHeapObjects(Isolate* isolate);
|
||||
|
||||
int WriteCodeComments();
|
||||
|
||||
friend class RegExpMacroAssemblerPPC;
|
||||
friend class RelocInfo;
|
||||
friend class BlockTrampolinePoolScope;
|
||||
|
@ -158,9 +158,7 @@ void RelocInfoWriter::Write(const RelocInfo* rinfo) {
|
||||
WriteShortTaggedPC(pc_delta, kWasmStubCallTag);
|
||||
} else {
|
||||
WriteModeAndPC(pc_delta, rmode);
|
||||
if (RelocInfo::IsComment(rmode)) {
|
||||
WriteData(rinfo->data());
|
||||
} else if (RelocInfo::IsDeoptReason(rmode)) {
|
||||
if (RelocInfo::IsDeoptReason(rmode)) {
|
||||
DCHECK_LT(rinfo->data(), 1 << kBitsPerByte);
|
||||
WriteShortData(rinfo->data());
|
||||
} else if (RelocInfo::IsConstPool(rmode) ||
|
||||
@ -249,13 +247,7 @@ void RelocIterator::next() {
|
||||
AdvanceReadLongPCJump();
|
||||
} else {
|
||||
AdvanceReadPC();
|
||||
if (RelocInfo::IsComment(rmode)) {
|
||||
if (SetMode(rmode)) {
|
||||
AdvanceReadData();
|
||||
return;
|
||||
}
|
||||
Advance(kIntptrSize);
|
||||
} else if (RelocInfo::IsDeoptReason(rmode)) {
|
||||
if (RelocInfo::IsDeoptReason(rmode)) {
|
||||
Advance();
|
||||
if (SetMode(rmode)) {
|
||||
ReadShortData();
|
||||
@ -420,8 +412,6 @@ const char* RelocInfo::RelocModeName(RelocInfo::Mode rmode) {
|
||||
return "relative code target";
|
||||
case RUNTIME_ENTRY:
|
||||
return "runtime entry";
|
||||
case COMMENT:
|
||||
return "comment";
|
||||
case EXTERNAL_REFERENCE:
|
||||
return "external reference";
|
||||
case INTERNAL_REFERENCE:
|
||||
@ -455,9 +445,7 @@ const char* RelocInfo::RelocModeName(RelocInfo::Mode rmode) {
|
||||
|
||||
void RelocInfo::Print(Isolate* isolate, std::ostream& os) { // NOLINT
|
||||
os << reinterpret_cast<const void*>(pc_) << " " << RelocModeName(rmode_);
|
||||
if (IsComment(rmode_)) {
|
||||
os << " (" << reinterpret_cast<char*>(data_) << ")";
|
||||
} else if (rmode_ == DEOPT_SCRIPT_OFFSET || rmode_ == DEOPT_INLINING_ID) {
|
||||
if (rmode_ == DEOPT_SCRIPT_OFFSET || rmode_ == DEOPT_INLINING_ID) {
|
||||
os << " (" << data() << ")";
|
||||
} else if (rmode_ == DEOPT_REASON) {
|
||||
os << " ("
|
||||
@ -532,7 +520,6 @@ void RelocInfo::Verify(Isolate* isolate) {
|
||||
break;
|
||||
}
|
||||
case RUNTIME_ENTRY:
|
||||
case COMMENT:
|
||||
case EXTERNAL_REFERENCE:
|
||||
case DEOPT_SCRIPT_OFFSET:
|
||||
case DEOPT_INLINING_ID:
|
||||
|
@ -62,7 +62,6 @@ class RelocInfo {
|
||||
WASM_STUB_CALL,
|
||||
|
||||
RUNTIME_ENTRY,
|
||||
COMMENT,
|
||||
|
||||
EXTERNAL_REFERENCE, // The address of an external C++ function.
|
||||
INTERNAL_REFERENCE, // An address inside the same function.
|
||||
@ -141,7 +140,6 @@ class RelocInfo {
|
||||
static constexpr bool IsWasmStubCall(Mode mode) {
|
||||
return mode == WASM_STUB_CALL;
|
||||
}
|
||||
static constexpr bool IsComment(Mode mode) { return mode == COMMENT; }
|
||||
static constexpr bool IsConstPool(Mode mode) { return mode == CONST_POOL; }
|
||||
static constexpr bool IsVeneerPool(Mode mode) { return mode == VENEER_POOL; }
|
||||
static constexpr bool IsDeoptPosition(Mode mode) {
|
||||
|
@ -366,6 +366,8 @@ Assembler::Assembler(const AssemblerOptions& options, void* buffer,
|
||||
void Assembler::GetCode(Isolate* isolate, CodeDesc* desc) {
|
||||
EmitRelocations();
|
||||
|
||||
int code_comments_size = WriteCodeComments();
|
||||
|
||||
AllocateAndInstallRequestedHeapObjects(isolate);
|
||||
|
||||
// Set up code descriptor.
|
||||
@ -377,6 +379,7 @@ void Assembler::GetCode(Isolate* isolate, CodeDesc* desc) {
|
||||
desc->origin = this;
|
||||
desc->unwinding_info_size = 0;
|
||||
desc->unwinding_info = nullptr;
|
||||
desc->code_comments_size = code_comments_size;
|
||||
}
|
||||
|
||||
void Assembler::Align(int m) {
|
||||
|
@ -1491,10 +1491,6 @@ inline void ss_a_format(Opcode op, int f1, int f2, int f3, int f4, int f5) {
|
||||
return pc_offset() - label->pos();
|
||||
}
|
||||
|
||||
// Record a comment relocation entry that can be used by a disassembler.
|
||||
// Use --code-comments to enable.
|
||||
void RecordComment(const char* msg);
|
||||
|
||||
// Record a deoptimization reason that can be used by a log or cpu profiler.
|
||||
// Use --trace-deopt to enable.
|
||||
void RecordDeoptReason(DeoptimizeReason reason, SourcePosition position,
|
||||
@ -1655,6 +1651,8 @@ inline void ss_a_format(Opcode op, int f1, int f2, int f3, int f4, int f5) {
|
||||
|
||||
void AllocateAndInstallRequestedHeapObjects(Isolate* isolate);
|
||||
|
||||
int WriteCodeComments();
|
||||
|
||||
friend class RegExpMacroAssemblerS390;
|
||||
friend class RelocInfo;
|
||||
friend class EnsureSpace;
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "src/builtins/constants-table-builder.h"
|
||||
#include "src/isolate-data.h"
|
||||
#include "src/isolate-inl.h"
|
||||
#include "src/lsan.h"
|
||||
#include "src/snapshot/serializer-common.h"
|
||||
|
||||
namespace v8 {
|
||||
@ -118,14 +117,9 @@ bool TurboAssemblerBase::IsAddressableThroughRootRegister(
|
||||
|
||||
void TurboAssemblerBase::RecordCommentForOffHeapTrampoline(int builtin_index) {
|
||||
if (!FLAG_code_comments) return;
|
||||
size_t len = strlen("-- Inlined Trampoline to --") +
|
||||
strlen(Builtins::name(builtin_index)) + 1;
|
||||
Vector<char> buffer = Vector<char>::New(static_cast<int>(len));
|
||||
char* buffer_start = buffer.start();
|
||||
LSAN_IGNORE_OBJECT(buffer_start);
|
||||
SNPrintF(buffer, "-- Inlined Trampoline to %s --",
|
||||
Builtins::name(builtin_index));
|
||||
RecordComment(buffer_start);
|
||||
std::ostringstream str;
|
||||
str << "-- Inlined Trampoline to " << Builtins::name(builtin_index) << " --";
|
||||
RecordComment(str.str().c_str());
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
@ -105,13 +105,20 @@ base::AddressRegion DisjointAllocationPool::Allocate(size_t size) {
|
||||
|
||||
Address WasmCode::constant_pool() const {
|
||||
if (FLAG_enable_embedded_constant_pool) {
|
||||
if (constant_pool_offset_ < instructions().size()) {
|
||||
if (constant_pool_offset_ < code_comments_offset_) {
|
||||
return instruction_start() + constant_pool_offset_;
|
||||
}
|
||||
}
|
||||
return kNullAddress;
|
||||
}
|
||||
|
||||
Address WasmCode::code_comments() const {
|
||||
if (code_comments_offset_ < unpadded_binary_size_) {
|
||||
return instruction_start() + code_comments_offset_;
|
||||
}
|
||||
return kNullAddress;
|
||||
}
|
||||
|
||||
size_t WasmCode::trap_handler_index() const {
|
||||
CHECK(HasTrapHandlerIndex());
|
||||
return static_cast<size_t>(trap_handler_index_);
|
||||
@ -227,7 +234,6 @@ void WasmCode::Validate() const {
|
||||
break;
|
||||
}
|
||||
case RelocInfo::EXTERNAL_REFERENCE:
|
||||
case RelocInfo::COMMENT:
|
||||
case RelocInfo::CONST_POOL:
|
||||
case RelocInfo::VENEER_POOL:
|
||||
// These are OK to appear.
|
||||
@ -252,12 +258,13 @@ void WasmCode::Disassemble(const char* name, std::ostream& os,
|
||||
if (!IsAnonymous()) os << "index: " << index() << "\n";
|
||||
os << "kind: " << GetWasmCodeKindAsString(kind_) << "\n";
|
||||
os << "compiler: " << (is_liftoff() ? "Liftoff" : "TurboFan") << "\n";
|
||||
size_t body_size = instructions().size();
|
||||
os << "Body (size = " << body_size << ")\n";
|
||||
size_t padding = instructions().size() - unpadded_binary_size_;
|
||||
os << "Body (size = " << instructions().size() << " = "
|
||||
<< unpadded_binary_size_ << " + " << padding << " padding)\n";
|
||||
|
||||
#ifdef ENABLE_DISASSEMBLER
|
||||
size_t instruction_size = body_size;
|
||||
if (constant_pool_offset_ && constant_pool_offset_ < instruction_size) {
|
||||
size_t instruction_size = unpadded_binary_size_;
|
||||
if (constant_pool_offset_ < instruction_size) {
|
||||
instruction_size = constant_pool_offset_;
|
||||
}
|
||||
if (safepoint_table_offset_ && safepoint_table_offset_ < instruction_size) {
|
||||
@ -332,6 +339,12 @@ void WasmCode::Disassemble(const char* name, std::ostream& os,
|
||||
it.rinfo()->Print(nullptr, os);
|
||||
}
|
||||
os << "\n";
|
||||
|
||||
if (code_comments_offset() < unpadded_binary_size_) {
|
||||
Address code_comments = reinterpret_cast<Address>(instructions().start() +
|
||||
code_comments_offset());
|
||||
PrintCodeCommentsSection(os, code_comments);
|
||||
}
|
||||
#endif // ENABLE_DISASSEMBLER
|
||||
}
|
||||
|
||||
@ -417,7 +430,8 @@ CompilationEnv NativeModule::CreateCompilationEnv() const {
|
||||
WasmCode* NativeModule::AddOwnedCode(
|
||||
uint32_t index, Vector<const byte> instructions, uint32_t stack_slots,
|
||||
size_t safepoint_table_offset, size_t handler_table_offset,
|
||||
size_t constant_pool_offset,
|
||||
size_t constant_pool_offset, size_t code_comments_offset,
|
||||
size_t unpadded_binary_size,
|
||||
OwnedVector<trap_handler::ProtectedInstructionData> protected_instructions,
|
||||
OwnedVector<const byte> reloc_info,
|
||||
OwnedVector<const byte> source_position_table, WasmCode::Kind kind,
|
||||
@ -429,11 +443,11 @@ WasmCode* NativeModule::AddOwnedCode(
|
||||
base::MutexGuard lock(&allocation_mutex_);
|
||||
Vector<byte> executable_buffer = AllocateForCode(instructions.size());
|
||||
// Ownership will be transferred to {owned_code_} below.
|
||||
code = new WasmCode(this, index, executable_buffer, stack_slots,
|
||||
safepoint_table_offset, handler_table_offset,
|
||||
constant_pool_offset, std::move(protected_instructions),
|
||||
std::move(reloc_info), std::move(source_position_table),
|
||||
kind, tier);
|
||||
code = new WasmCode(
|
||||
this, index, executable_buffer, stack_slots, safepoint_table_offset,
|
||||
handler_table_offset, constant_pool_offset, code_comments_offset,
|
||||
unpadded_binary_size, std::move(protected_instructions),
|
||||
std::move(reloc_info), std::move(source_position_table), kind, tier);
|
||||
|
||||
if (owned_code_.empty() ||
|
||||
code->instruction_start() > owned_code_.back()->instruction_start()) {
|
||||
@ -517,6 +531,8 @@ WasmCode* NativeModule::AddAnonymousCode(Handle<Code> code, WasmCode::Kind kind,
|
||||
safepoint_table_offset, // safepoint_table_offset
|
||||
code->handler_table_offset(), // handler_table_offset
|
||||
code->constant_pool_offset(), // constant_pool_offset
|
||||
code->code_comments_offset(), // code_comments_offset
|
||||
instructions.size(), // unpadded_binary_size
|
||||
{}, // protected_instructions
|
||||
std::move(reloc_info), // reloc_info
|
||||
std::move(source_pos), // source positions
|
||||
@ -562,12 +578,13 @@ WasmCode* NativeModule::AddCode(
|
||||
OwnedVector<byte> reloc_info = OwnedVector<byte>::New(desc.reloc_size);
|
||||
memcpy(reloc_info.start(), desc.buffer + desc.buffer_size - desc.reloc_size,
|
||||
desc.reloc_size);
|
||||
WasmCode* ret =
|
||||
AddOwnedCode(index, {desc.buffer, static_cast<size_t>(desc.instr_size)},
|
||||
stack_slots, safepoint_table_offset, handler_table_offset,
|
||||
desc.instr_size - desc.constant_pool_size,
|
||||
std::move(protected_instructions), std::move(reloc_info),
|
||||
std::move(source_pos_table), kind, tier);
|
||||
|
||||
WasmCode* ret = AddOwnedCode(
|
||||
index, {desc.buffer, static_cast<size_t>(desc.instr_size)}, stack_slots,
|
||||
safepoint_table_offset, handler_table_offset, desc.constant_pool_offset(),
|
||||
desc.code_comments_offset(), desc.instr_size,
|
||||
std::move(protected_instructions), std::move(reloc_info),
|
||||
std::move(source_pos_table), kind, tier);
|
||||
|
||||
// Apply the relocation delta by iterating over the RelocInfo.
|
||||
intptr_t delta = ret->instructions().start() - desc.buffer;
|
||||
@ -606,13 +623,15 @@ WasmCode* NativeModule::AddCode(
|
||||
WasmCode* NativeModule::AddDeserializedCode(
|
||||
uint32_t index, Vector<const byte> instructions, uint32_t stack_slots,
|
||||
size_t safepoint_table_offset, size_t handler_table_offset,
|
||||
size_t constant_pool_offset,
|
||||
size_t constant_pool_offset, size_t code_comments_offset,
|
||||
size_t unpadded_binary_size,
|
||||
OwnedVector<trap_handler::ProtectedInstructionData> protected_instructions,
|
||||
OwnedVector<const byte> reloc_info,
|
||||
OwnedVector<const byte> source_position_table, WasmCode::Tier tier) {
|
||||
WasmCode* code =
|
||||
AddOwnedCode(index, instructions, stack_slots, safepoint_table_offset,
|
||||
handler_table_offset, constant_pool_offset,
|
||||
code_comments_offset, unpadded_binary_size,
|
||||
std::move(protected_instructions), std::move(reloc_info),
|
||||
std::move(source_position_table), WasmCode::kFunction, tier);
|
||||
|
||||
@ -663,9 +682,11 @@ WasmCode* NativeModule::CreateEmptyJumpTable(uint32_t num_wasm_functions) {
|
||||
return AddOwnedCode(WasmCode::kAnonymousFuncIndex, // index
|
||||
instructions.as_vector(), // instructions
|
||||
0, // stack_slots
|
||||
0, // safepoint_table_offset
|
||||
0, // handler_table_offset
|
||||
0, // constant_pool_offset
|
||||
instructions.size(), // safepoint_table_offset
|
||||
instructions.size(), // handler_table_offset
|
||||
instructions.size(), // constant_pool_offset
|
||||
instructions.size(), // code_comments_offset
|
||||
instructions.size(), // unpadded_binary_size
|
||||
{}, // protected_instructions
|
||||
{}, // reloc_info
|
||||
{}, // source_pos
|
||||
|
@ -113,9 +113,12 @@ class V8_EXPORT_PRIVATE WasmCode final {
|
||||
NativeModule* native_module() const { return native_module_; }
|
||||
Tier tier() const { return tier_; }
|
||||
Address constant_pool() const;
|
||||
Address code_comments() const;
|
||||
size_t constant_pool_offset() const { return constant_pool_offset_; }
|
||||
size_t safepoint_table_offset() const { return safepoint_table_offset_; }
|
||||
size_t handler_table_offset() const { return handler_table_offset_; }
|
||||
size_t code_comments_offset() const { return code_comments_offset_; }
|
||||
size_t unpadded_binary_size() const { return unpadded_binary_size_; }
|
||||
uint32_t stack_slots() const { return stack_slots_; }
|
||||
bool is_liftoff() const { return tier_ == kLiftoff; }
|
||||
bool contains(Address pc) const {
|
||||
@ -151,7 +154,8 @@ class V8_EXPORT_PRIVATE WasmCode final {
|
||||
WasmCode(NativeModule* native_module, uint32_t index,
|
||||
Vector<byte> instructions, uint32_t stack_slots,
|
||||
size_t safepoint_table_offset, size_t handler_table_offset,
|
||||
size_t constant_pool_offset,
|
||||
size_t constant_pool_offset, size_t code_comments_offset,
|
||||
size_t unpadded_binary_size,
|
||||
OwnedVector<trap_handler::ProtectedInstructionData>
|
||||
protected_instructions,
|
||||
OwnedVector<const byte> reloc_info,
|
||||
@ -166,11 +170,14 @@ class V8_EXPORT_PRIVATE WasmCode final {
|
||||
stack_slots_(stack_slots),
|
||||
safepoint_table_offset_(safepoint_table_offset),
|
||||
handler_table_offset_(handler_table_offset),
|
||||
code_comments_offset_(code_comments_offset),
|
||||
unpadded_binary_size_(unpadded_binary_size),
|
||||
protected_instructions_(std::move(protected_instructions)),
|
||||
tier_(tier) {
|
||||
DCHECK_LE(safepoint_table_offset, instructions.size());
|
||||
DCHECK_LE(constant_pool_offset, instructions.size());
|
||||
DCHECK_LE(handler_table_offset, instructions.size());
|
||||
DCHECK_LE(safepoint_table_offset, unpadded_binary_size);
|
||||
DCHECK_LE(handler_table_offset, unpadded_binary_size);
|
||||
DCHECK_LE(code_comments_offset, unpadded_binary_size);
|
||||
DCHECK_LE(constant_pool_offset, unpadded_binary_size);
|
||||
}
|
||||
|
||||
// Code objects that have been registered with the global trap handler within
|
||||
@ -196,6 +203,8 @@ class V8_EXPORT_PRIVATE WasmCode final {
|
||||
// conversions.
|
||||
size_t safepoint_table_offset_ = 0;
|
||||
size_t handler_table_offset_ = 0;
|
||||
size_t code_comments_offset_ = 0;
|
||||
size_t unpadded_binary_size_ = 0;
|
||||
intptr_t trap_handler_index_ = -1;
|
||||
OwnedVector<trap_handler::ProtectedInstructionData> protected_instructions_;
|
||||
Tier tier_;
|
||||
@ -226,7 +235,8 @@ class V8_EXPORT_PRIVATE NativeModule final {
|
||||
WasmCode* AddDeserializedCode(
|
||||
uint32_t index, Vector<const byte> instructions, uint32_t stack_slots,
|
||||
size_t safepoint_table_offset, size_t handler_table_offset,
|
||||
size_t constant_pool_offset,
|
||||
size_t constant_pool_offset, size_t code_comments_offset,
|
||||
size_t unpadded_binary_size,
|
||||
OwnedVector<trap_handler::ProtectedInstructionData>
|
||||
protected_instructions,
|
||||
OwnedVector<const byte> reloc_info,
|
||||
@ -366,6 +376,8 @@ class V8_EXPORT_PRIVATE NativeModule final {
|
||||
uint32_t stack_slots, size_t safepoint_table_offset,
|
||||
size_t handler_table_offset,
|
||||
size_t constant_pool_offset,
|
||||
size_t code_comments_offset,
|
||||
size_t unpadded_binary_size,
|
||||
OwnedVector<trap_handler::ProtectedInstructionData>,
|
||||
OwnedVector<const byte> reloc_info,
|
||||
OwnedVector<const byte> source_position_table,
|
||||
|
@ -191,6 +191,8 @@ constexpr size_t kCodeHeaderSize =
|
||||
sizeof(size_t) + // offset of constant pool
|
||||
sizeof(size_t) + // offset of safepoint table
|
||||
sizeof(size_t) + // offset of handler table
|
||||
sizeof(size_t) + // offset of code comments
|
||||
sizeof(size_t) + // unpadded binary size
|
||||
sizeof(uint32_t) + // stack slots
|
||||
sizeof(size_t) + // code size
|
||||
sizeof(size_t) + // reloc size
|
||||
@ -329,6 +331,8 @@ void NativeModuleSerializer::WriteCode(const WasmCode* code, Writer* writer) {
|
||||
writer->Write(code->constant_pool_offset());
|
||||
writer->Write(code->safepoint_table_offset());
|
||||
writer->Write(code->handler_table_offset());
|
||||
writer->Write(code->code_comments_offset());
|
||||
writer->Write(code->unpadded_binary_size());
|
||||
writer->Write(code->stack_slots());
|
||||
writer->Write(code->instructions().size());
|
||||
writer->Write(code->reloc_info().size());
|
||||
@ -366,7 +370,7 @@ void NativeModuleSerializer::WriteCode(const WasmCode* code, Writer* writer) {
|
||||
code->constant_pool(), mask);
|
||||
for (RelocIterator iter(
|
||||
{code_start, code->instructions().size()}, code->reloc_info(),
|
||||
reinterpret_cast<Address>(code_start) + code->constant_pool_offset(),
|
||||
reinterpret_cast<Address>(code_start) + code->unpadded_binary_size(),
|
||||
mask);
|
||||
!iter.done(); iter.next(), orig_iter.next()) {
|
||||
RelocInfo::Mode mode = orig_iter.rinfo()->rmode();
|
||||
@ -487,6 +491,8 @@ bool NativeModuleDeserializer::ReadCode(uint32_t fn_index, Reader* reader) {
|
||||
size_t constant_pool_offset = reader->Read<size_t>();
|
||||
size_t safepoint_table_offset = reader->Read<size_t>();
|
||||
size_t handler_table_offset = reader->Read<size_t>();
|
||||
size_t code_comment_offset = reader->Read<size_t>();
|
||||
size_t unpadded_binary_size = reader->Read<size_t>();
|
||||
uint32_t stack_slot_count = reader->Read<uint32_t>();
|
||||
size_t code_size = reader->Read<size_t>();
|
||||
size_t reloc_size = reader->Read<size_t>();
|
||||
@ -508,9 +514,9 @@ bool NativeModuleDeserializer::ReadCode(uint32_t fn_index, Reader* reader) {
|
||||
|
||||
WasmCode* code = native_module_->AddDeserializedCode(
|
||||
fn_index, code_buffer, stack_slot_count, safepoint_table_offset,
|
||||
handler_table_offset, constant_pool_offset,
|
||||
std::move(protected_instructions), std::move(reloc_info),
|
||||
std::move(source_pos), tier);
|
||||
handler_table_offset, constant_pool_offset, code_comment_offset,
|
||||
unpadded_binary_size, std::move(protected_instructions),
|
||||
std::move(reloc_info), std::move(source_pos), tier);
|
||||
|
||||
// Relocate the code.
|
||||
int mask = RelocInfo::ModeMask(RelocInfo::WASM_CALL) |
|
||||
|
@ -450,6 +450,8 @@ void Assembler::GetCode(Isolate* isolate, CodeDesc* desc) {
|
||||
PatchConstPool();
|
||||
DCHECK(constpool_.IsEmpty());
|
||||
|
||||
int code_comments_size = WriteCodeComments();
|
||||
|
||||
// At this point overflow() may be true, but the gap ensures
|
||||
// that we are still not overlapping instructions and relocation info.
|
||||
DCHECK(pc_ <= reloc_info_writer.pos()); // No overlap.
|
||||
@ -467,6 +469,7 @@ void Assembler::GetCode(Isolate* isolate, CodeDesc* desc) {
|
||||
desc->constant_pool_size = 0;
|
||||
desc->unwinding_info_size = 0;
|
||||
desc->unwinding_info = nullptr;
|
||||
desc->code_comments_size = code_comments_size;
|
||||
|
||||
// Collection stage
|
||||
auto jump_opt = jump_optimization_info();
|
||||
|
@ -1913,10 +1913,6 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
|
||||
return pc_offset() - label->pos();
|
||||
}
|
||||
|
||||
// Record a comment relocation entry that can be used by a disassembler.
|
||||
// Use --code-comments to enable.
|
||||
void RecordComment(const char* msg);
|
||||
|
||||
// Record a deoptimization reason that can be used by a log or cpu profiler.
|
||||
// Use --trace-deopt to enable.
|
||||
void RecordDeoptReason(DeoptimizeReason reason, SourcePosition position,
|
||||
@ -2403,6 +2399,8 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
|
||||
|
||||
void AllocateAndInstallRequestedHeapObjects(Isolate* isolate);
|
||||
|
||||
int WriteCodeComments();
|
||||
|
||||
friend class EnsureSpace;
|
||||
friend class RegExpMacroAssemblerX64;
|
||||
|
||||
|
@ -582,6 +582,28 @@ TEST(ExceptionHandler) {
|
||||
CHECK_EQ(2, ft.CallChecked<Smi>()->value());
|
||||
}
|
||||
|
||||
TEST(TestCodeAssemblerCodeComment) {
|
||||
i::FLAG_code_comments = true;
|
||||
Isolate* isolate(CcTest::InitIsolateOnce());
|
||||
const int kNumParams = 0;
|
||||
CodeAssemblerTester asm_tester(isolate, kNumParams);
|
||||
CodeAssembler m(asm_tester.state());
|
||||
|
||||
m.Comment("Comment1");
|
||||
m.Return(m.SmiConstant(1));
|
||||
|
||||
Handle<Code> code = asm_tester.GenerateCode();
|
||||
CHECK_NE(code->code_comments(), kNullAddress);
|
||||
CodeCommentsIterator it(code->code_comments());
|
||||
CHECK(it.HasCurrent());
|
||||
bool found_comment = false;
|
||||
while (it.HasCurrent()) {
|
||||
if (strcmp(it.GetComment(), "Comment1") == 0) found_comment = true;
|
||||
it.Next();
|
||||
}
|
||||
CHECK(found_comment);
|
||||
}
|
||||
|
||||
} // namespace compiler
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
@ -30,6 +30,7 @@ TEST(CodeLayoutWithoutUnwindingInfo) {
|
||||
code_desc.origin = nullptr;
|
||||
code_desc.unwinding_info = nullptr;
|
||||
code_desc.unwinding_info_size = 0;
|
||||
code_desc.code_comments_size = 0;
|
||||
|
||||
Handle<Code> code = CcTest::i_isolate()->factory()->NewCode(
|
||||
code_desc, Code::STUB, Handle<Object>::null());
|
||||
@ -68,6 +69,7 @@ TEST(CodeLayoutWithUnwindingInfo) {
|
||||
code_desc.origin = nullptr;
|
||||
code_desc.unwinding_info = unwinding_info;
|
||||
code_desc.unwinding_info_size = unwinding_info_size;
|
||||
code_desc.code_comments_size = 0;
|
||||
|
||||
Handle<Code> code = CcTest::i_isolate()->factory()->NewCode(
|
||||
code_desc, Code::STUB, Handle<Object>::null());
|
||||
|
@ -5,6 +5,7 @@
|
||||
// Embed a user function in the snapshot and step through it.
|
||||
|
||||
// Flags: --embed 'function c(f, ...args) { return f(...args); }'
|
||||
// Flags: --no-turbo-rewrite-far-jumps
|
||||
|
||||
let {session, contextGroup, Protocol} = InspectorTest.start('Tests that stepping works on snapshotted function');
|
||||
session.setupScriptMap();
|
||||
|
Loading…
Reference in New Issue
Block a user