Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
91 lines (74 loc) · 2.88 KB

File metadata and controls

91 lines (74 loc) · 2.88 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// 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/codegen/assembler-inl.h"
#include "src/codegen/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,
uint32_t code_comments_size)
: code_comments_start_(code_comments_start),
code_comments_size_(code_comments_size),
current_entry_(code_comments_start + kOffsetToFirstCommentEntry) {
DCHECK_NE(kNullAddress, code_comments_start);
DCHECK_IMPLIES(code_comments_size,
code_comments_size ==
base::ReadUnalignedValue<uint32_t>(code_comments_start_));
}
uint32_t CodeCommentsIterator::size() const { return code_comments_size_; }
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 ReadUnalignedValue<uint32_t>(current_entry_ + kOffsetToCommentSize);
}
uint32_t CodeCommentsIterator::GetPCOffset() const {
return ReadUnalignedValue<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_);
}
} // namespace internal
} // namespace v8
Morty Proxy This is a proxified and sanitized view of the page, visit original site.