20int WriteDirectiveOrSeparator(PlatformEmbeddedFileWriterBase* w,
21 int current_line_length,
24 if (current_line_length == 0) {
25 printed_chars = w->IndentedDataDirective(directive);
28 printed_chars = fprintf(w->fp(),
",");
31 return current_line_length + printed_chars;
34int WriteLineEndIfNeeded(PlatformEmbeddedFileWriterBase* w,
35 int current_line_length,
int write_size) {
36 static const int kTextWidth = 100;
40 if (current_line_length + strlen(
",0x") + write_size * 2 > kTextWidth) {
41 fprintf(w->fp(),
"\n");
44 return current_line_length;
53 const bool is_default_variant =
57 if (is_default_variant) {
59 base::SNPrintF(builtin_symbol,
"Builtins_%s", i::Builtins::name(builtin));
62 i::Builtins::name(builtin));
70 blob->InstructionSizeOf(builtin));
71 const int builtin_id =
static_cast<int>(
builtin);
76 current_positions.size());
81 CHECK(positions.done());
88 const std::vector<LabelInfo>& current_labels =
label_info_[builtin_id];
89 auto label = current_labels.begin();
92 reinterpret_cast<const uint8_t*
>(blob->InstructionStartOf(builtin));
93 uint32_t size = blob->PaddedInstructionSizeOf(builtin);
95 uint32_t next_source_pos_offset =
96 static_cast<uint32_t
>(positions.done() ? size : positions.code_offset());
97 uint32_t next_label_offset =
static_cast<uint32_t
>(
98 (
label == current_labels.end()) ? size :
label->offset);
99 uint32_t next_offset = 0;
101 if (
i == next_source_pos_offset) {
103 w->
SourceInfo(positions.source_position().ExternalFileId(),
105 positions.source_position().ExternalFileId()),
106 positions.source_position().ExternalLine());
108 next_source_pos_offset =
static_cast<uint32_t
>(
109 positions.done() ? size : positions.code_offset());
112 if (
i == next_label_offset) {
115 next_label_offset =
static_cast<uint32_t
>(
116 (
label == current_labels.end()) ? size :
label->offset);
119 next_offset = std::min(next_source_pos_offset, next_label_offset);
128 std::string name)
const {
135 "The embedded blob code section starts here. It contains the builtin");
136 w->
Comment(
"instruction streams.");
139#if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64
142 static const char* kCodeStartForProfilerSymbolName =
143 "v8_code_start_for_profiler_";
144 static constexpr int kDummyFunctionLength = 1;
145 static constexpr int kDummyFunctionData = 0xcc;
147 kDummyFunctionLength);
150 WriteDirectiveOrSeparator(w, 0,
kByte);
164 Builtin builtin = blob->GetBuiltinId(embedded_index);
176 embedded_blob_code_size_symbol;
180 w->
Comment(
"The size of the embedded blob code in bytes.");
187 embedded_blob_data_size_symbol;
191 w->
Comment(
"The size of the embedded blob data section in bytes.");
196#if defined(V8_OS_WIN64)
204 reinterpret_cast<const void*
>(&unwind_infos_[0]));
218 uint32_t chunks = (size + 31) / 32;
221 for (
i = 0;
i < chunks; ++
i) {
222 fprintf(w->
fp(),
" DC x'");
223 for (j = 0;
offset < size && j < 32; ++j) {
224 fprintf(w->
fp(),
"%02x", data[
offset++]);
226 fprintf(w->
fp(),
"'\n");
229 int current_line_length = 0;
235 for (;
i + byte_chunk_size <
size;
i += byte_chunk_size) {
236 current_line_length =
237 WriteDirectiveOrSeparator(w, current_line_length, directive);
239 current_line_length =
240 WriteLineEndIfNeeded(w, current_line_length, byte_chunk_size);
242 if (current_line_length != 0) w->
Newline();
243 current_line_length = 0;
247 current_line_length =
248 WriteDirectiveOrSeparator(w, current_line_length,
kByte);
250 current_line_length = WriteLineEndIfNeeded(w, current_line_length, 1);
253 if (current_line_length != 0) w->
Newline();
289 if (!code->has_source_position_table())
continue;
291 code->source_position_table();
292 std::vector<unsigned char>
data(source_position_table->begin(),
293 source_position_table->end());
union v8::internal::@341::BuiltinMetadata::KindSpecificData data
constexpr T * begin() const
static constexpr int kBuiltinCount
static constexpr Builtin kFirst
static constexpr bool kAllBuiltinsAreIsolateIndependent
static constexpr Builtin kLast
void PrepareBuiltinSourcePositionMap(Builtins *builtins) override
void WriteCodeSection(PlatformEmbeddedFileWriterBase *w, const i::EmbeddedData *blob) const
std::vector< LabelInfo > label_info_[Builtins::kBuiltinCount]
void WriteFileEpilogue(PlatformEmbeddedFileWriterBase *w, const i::EmbeddedData *blob) const
std::string EmbeddedBlobCodeSymbol() const
std::vector< uint8_t > source_positions_[Builtins::kBuiltinCount]
static int ExternalFilenameIdToIndex(int id)
static int ExternalFilenameIndexToId(int index)
std::vector< const char * > external_filenames_by_index_
int GetExternallyCompiledFilenameCount() const override
std::map< const char *, int > external_filenames_
static void WriteBinaryContentsAsInlineAssembly(PlatformEmbeddedFileWriterBase *w, const uint8_t *data, uint32_t size)
const char * embedded_variant_
void WriteBuiltinLabels(PlatformEmbeddedFileWriterBase *w, std::string name) const
int LookupOrAddExternallyCompiledFilename(const char *filename) override
void WriteBuiltin(PlatformEmbeddedFileWriterBase *w, const i::EmbeddedData *blob, const Builtin builtin) const
const char * GetExternallyCompiledFilename(int fileid) const override
ZoneVector< RpoNumber > & result
int SNPrintF(Vector< char > str, const char *format,...)
int DataDirectiveSize(DataDirective directive)
uint32_t ReorderedBuiltinIndex
static constexpr char kDefaultEmbeddedVariant[]
#define CHECK_GE(lhs, rhs)
#define DCHECK_GE(v1, v2)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)