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 
5 #ifndef V8_SNAPSHOT_EMBEDDED_PLATFORM_EMBEDDED_FILE_WRITER_GENERIC_H_
6 #define V8_SNAPSHOT_EMBEDDED_PLATFORM_EMBEDDED_FILE_WRITER_GENERIC_H_
7 
8 #include "src/base/macros.h"
9 #include "src/common/globals.h"  // For V8_OS_WIN_X64
10 #include "src/snapshot/embedded/platform-embedded-file-writer-base.h"
11 
12 namespace v8 {
13 namespace internal {
14 
15 class PlatformEmbeddedFileWriterGeneric
16     : public PlatformEmbeddedFileWriterBase {
17  public:
PlatformEmbeddedFileWriterGeneric(EmbeddedTargetArch target_arch, EmbeddedTargetOs target_os)18   PlatformEmbeddedFileWriterGeneric(EmbeddedTargetArch target_arch,
19                                     EmbeddedTargetOs target_os)
20       : target_arch_(target_arch), target_os_(target_os) {
21     DCHECK(target_os_ == EmbeddedTargetOs::kChromeOS ||
22            target_os_ == EmbeddedTargetOs::kFuchsia ||
23            target_os_ == EmbeddedTargetOs::kGeneric);
24   }
25 
26   void SectionText() override;
27   void SectionData() override;
28   void SectionRoData() override;
29 
30   void AlignToCodeAlignment() override;
31   void AlignToDataAlignment() override;
32 
33   void DeclareUint32(const char* name, uint32_t value) override;
34   void DeclarePointerToSymbol(const char* name, const char* target) override;
35 
36   void DeclareSymbolGlobal(const char* name) override;
37   void DeclareLabel(const char* name) override;
38 
39   void SourceInfo(int fileid, const char* filename, int line) override;
40   void DeclareFunctionBegin(const char* name, uint32_t size) override;
41   void DeclareFunctionEnd(const char* name) override;
42 
43   void Comment(const char* string) override;
44 
45   void FilePrologue() override;
46   void DeclareExternalFilename(int fileid, const char* filename) override;
47   void FileEpilogue() override;
48 
49   int IndentedDataDirective(DataDirective directive) override;
50 
51   DataDirective ByteChunkDataDirective() const override;
52 
53  private:
54   const EmbeddedTargetArch target_arch_;
55   const EmbeddedTargetOs target_os_;
56 };
57 
58 }  // namespace internal
59 }  // namespace v8
60 
61 #endif  // V8_SNAPSHOT_EMBEDDED_PLATFORM_EMBEDDED_FILE_WRITER_GENERIC_H_
62