Skip to content

Commit

Permalink
[snapshot] Always align embedded blob code pointer and size
Browse files Browse the repository at this point in the history
Other platforms besides ARM64 Windows may also have alignment
requirements, e.g. PPC and s390. These requirements may affect
both the code pointer field and the size field, and so they
each need alignment directives because they are stored in
different sections.

Since aligning wastes a handful of bytes at most, not making
alignment conditional on the platform type seems like a good idea.

Refs: nodejs/node#24875
Change-Id: I1f58606af294be65e74a1f107cd05fc21e032704
Reviewed-on: https://chromium-review.googlesource.com/c/1433778
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59058}
  • Loading branch information
addaleax authored and Commit Bot committed Jan 24, 2019
1 parent 6f9674e commit fc0ddf5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/snapshot/embedded-file-writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -553,13 +553,11 @@ void PlatformDependentEmbeddedFileWriter::AlignToCodeAlignment() {
}

void PlatformDependentEmbeddedFileWriter::AlignToDataAlignment() {
#if defined(V8_OS_WIN) && defined(V8_TARGET_ARCH_ARM64)
// On Windows ARM64, instruction "ldr xt,[xn,v8_Default_embedded_blob_]" is
// generated by clang-cl to load elements in v8_Default_embedded_blob_.
// The generated instruction has scale 3 which requires the load target to be
// aligned at 8 bytes (2^3).
// On Windows ARM64, s390, PPC and possibly more platforms, aligned load
// instructions are used to retrieve v8_Default_embedded_blob_ and/or
// v8_Default_embedded_blob_size_. The generated instructions require the
// load target to be aligned at 8 bytes (2^3).
fprintf(fp_, ".balign 8\n");
#endif
}

void PlatformDependentEmbeddedFileWriter::Comment(const char* string) {
Expand Down
1 change: 1 addition & 0 deletions src/snapshot/embedded-file-writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ class EmbeddedFileWriter : public EmbeddedFileWriterInterface {

w->Comment("The size of the embedded blob in bytes.");
w->SectionRoData();
w->AlignToDataAlignment();
w->DeclareUint32(embedded_blob_size_symbol, blob->size());
w->Newline();
}
Expand Down

0 comments on commit fc0ddf5

Please sign in to comment.