v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
platform-embedded-file-writer-mac.cc
Go to the documentation of this file.
1// Copyright 2019 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
8
9namespace v8 {
10namespace internal {
11
12namespace {
13
14const char* DirectiveAsString(DataDirective directive) {
15 switch (directive) {
16 case kByte:
17 return ".byte";
18 case kLong:
19 return ".long";
20 case kQuad:
21 return ".quad";
22 case kOcta:
23 return ".octa";
24 }
26}
27
28} // namespace
29
30void PlatformEmbeddedFileWriterMac::SectionText() { fprintf(fp_, ".text\n"); }
31
33 fprintf(fp_, ".const_data\n");
34}
35
37 uint32_t value) {
39 DeclareLabel(name);
41 fprintf(fp_, "%d", value);
42 Newline();
43}
44
46 // TODO(jgruber): Investigate switching to .globl. Using .private_extern
47 // prevents something along the compilation chain from messing with the
48 // embedded blob. Using .global here causes embedded blob hash verification
49 // failures at runtime.
50 fprintf(fp_, ".private_extern _%s\n", name);
51}
52
54#if V8_TARGET_ARCH_X64
55 // On x64 use 64-bytes code alignment to allow 64-bytes loop header alignment.
56 static_assert(64 >= kCodeAlignment);
57 fprintf(fp_, ".balign 64\n");
58#elif V8_TARGET_ARCH_PPC64
59 // 64 byte alignment is needed on ppc64 to make sure p10 prefixed instructions
60 // don't cross 64-byte boundaries.
61 static_assert(64 >= kCodeAlignment);
62 fprintf(fp_, ".balign 64\n");
63#elif V8_TARGET_ARCH_ARM64
64 // ARM64 macOS has a 16kiB page size. Since we want to remap it on the heap,
65 // needs to be page-aligned.
66 fprintf(fp_, ".balign 16384\n");
67#else
68 static_assert(32 >= kCodeAlignment);
69 fprintf(fp_, ".balign 32\n");
70#endif
71}
72
74#if V8_TARGET_ARCH_ARM64
75 // ARM64 macOS has a 16kiB page size. Since we want to remap builtins on the
76 // heap, make sure that the trailing part of the page doesn't contain anything
77 // dangerous.
78 fprintf(fp_, ".balign 16384\n");
79#endif
80}
81
83 static_assert(8 >= InstructionStream::kMetadataAlignment);
84 fprintf(fp_, ".balign 8\n");
85}
86
88 fprintf(fp_, "// %s\n", string);
89}
90
92 fprintf(fp_, "_%s:\n", name);
93}
94
96 int line) {
97 fprintf(fp_, ".loc %d %d\n", fileid, line);
98}
99
100// TODO(mmarchini): investigate emitting size annotations for OS X
102 uint32_t size) {
103 DeclareLabel(name);
104
105 // TODO(mvstanton): Investigate the proper incantations to mark the label as
106 // a function on OSX.
107}
108
110
112
114 int fileid, const char* filename) {
115 fprintf(fp_, ".file %d \"%s\"\n", fileid, filename);
116}
117
119
121 DataDirective directive) {
122 return fprintf(fp_, " %s ", DirectiveAsString(directive));
123}
124
125} // namespace internal
126} // namespace v8
static constexpr int kMetadataAlignment
void DeclareFunctionBegin(const char *name, uint32_t size) override
void DeclareExternalFilename(int fileid, const char *filename) override
void SourceInfo(int fileid, const char *filename, int line) override
void DeclareUint32(const char *name, uint32_t value) override
std::string filename
constexpr intptr_t kCodeAlignment
Definition globals.h:964