blob: 330b2bb0d6b8688dc80c8d699bcbd381e20b9c92 (
plain)
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
|
// 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_CODEGEN_CODE_COMMENTS_H_
#define V8_CODEGEN_CODE_COMMENTS_H_
#include <ostream>
#include <string>
#include <vector>
#include "include/v8-internal.h"
#include "src/base/macros.h"
namespace v8 {
namespace internal {
class Assembler;
// InstructionStream comments section layout:
// byte count content
// ------------------------------------------------------------------------
// 4 size as uint32_t (only for a check)
// [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:
V8_EXPORT_PRIVATE 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 V8_EXPORT_PRIVATE CodeCommentsIterator {
public:
CodeCommentsIterator(Address code_comments_start,
uint32_t code_comments_size);
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_;
uint32_t code_comments_size_;
Address current_entry_;
};
} // namespace internal
} // namespace v8
#endif // V8_CODEGEN_CODE_COMMENTS_H_
|