aix, builtins: Embedded builtins support on Aix

Bug: v8:8043
Change-Id: Iff786eccd2dcb63e46e331b096d91a6ddb13f851
Reviewed-on: https://chromium-review.googlesource.com/c/1351129
Reviewed-by: Junliang Yan <jyan@ca.ibm.com>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Junliang Yan <jyan@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#57913}
This commit is contained in:
Vasili Skurydzin 2018-11-26 13:38:04 -05:00 committed by Commit Bot
parent ddaa1f0a0d
commit b3e7775f82
4 changed files with 38 additions and 16 deletions

View File

@ -86,8 +86,7 @@ declare_args() {
v8_enable_fast_mksnapshot = false
# Enable embedded builtins.
# TODO(v8:8043): Support aix.
v8_enable_embedded_builtins = !is_aix
v8_enable_embedded_builtins = true
# Build-time flag for enabling nojit mode.
# TODO(v8:7777): Remove the build-time flag once the --jitless runtime flag

View File

@ -180,6 +180,13 @@ void DirectCEntryStub::Generate(MacroAssembler* masm) {
// GC safe. The RegExp backend also relies on this.
__ mflr(r0);
__ StoreP(r0, MemOperand(sp, kStackFrameExtraParamSlot * kPointerSize));
if (ABI_USES_FUNCTION_DESCRIPTORS && FLAG_embedded_builtins) {
// AIX/PPC64BE Linux use a function descriptor;
__ LoadP(ToRegister(ABI_TOC_REGISTER), MemOperand(ip, kPointerSize));
__ LoadP(ip, MemOperand(ip, 0)); // Instruction address
}
__ Call(ip); // Call the C++ function.
__ LoadP(r0, MemOperand(sp, kStackFrameExtraParamSlot * kPointerSize));
__ mtlr(r0);
@ -201,7 +208,7 @@ void DirectCEntryStub::GenerateCall(MacroAssembler* masm, Register target) {
return;
}
}
if (ABI_USES_FUNCTION_DESCRIPTORS) {
if (ABI_USES_FUNCTION_DESCRIPTORS && !FLAG_embedded_builtins) {
// AIX/PPC64BE Linux use a function descriptor.
__ LoadP(ToRegister(ABI_TOC_REGISTER), MemOperand(target, kPointerSize));
__ LoadP(ip, MemOperand(target, 0)); // Instruction address

View File

@ -54,6 +54,17 @@ const char* DirectiveAsString(DataDirective directive) {
default:
UNREACHABLE();
}
#elif defined(V8_OS_AIX)
switch (directive) {
case kByte:
return ".byte";
case kLong:
return ".long";
case kQuad:
return ".llong";
default:
UNREACHABLE();
}
#else
switch (directive) {
case kByte:
@ -152,16 +163,11 @@ int PlatformDependentEmbeddedFileWriter::IndentedDataDirective(
#elif defined(V8_OS_AIX)
// TODO(aix): Update custom logic previously contained in section header macros.
// See
// https://cs.chromium.org/chromium/src/v8/src/snapshot/macros.h?l=81&rcl=31b2546b348e864539ade15897eac971b3c0e402
void PlatformDependentEmbeddedFileWriter::SectionText() {
fprintf(fp_, ".csect .text[PR]\n");
}
void PlatformDependentEmbeddedFileWriter::SectionData() {
// TODO(aix): Confirm and update if needed.
fprintf(fp_, ".csect .data[RW]\n");
}
@ -172,15 +178,16 @@ void PlatformDependentEmbeddedFileWriter::SectionRoData() {
void PlatformDependentEmbeddedFileWriter::DeclareUint32(const char* name,
uint32_t value) {
DeclareSymbolGlobal(name);
DeclareLabel(name);
fprintf(fp_, ".align 2\n");
fprintf(fp_, "%s:\n", name);
IndentedDataDirective(kLong);
fprintf(fp_, "%d", value);
fprintf(fp_, "%d\n", value);
Newline();
}
void PlatformDependentEmbeddedFileWriter::DeclarePointerToSymbol(
const char* name, const char* target) {
DeclareSymbolGlobal(name);
AlignToCodeAlignment();
DeclareLabel(name);
fprintf(fp_, " %s %s\n", DirectiveAsString(PointerSizeDirective()), target);
Newline();
@ -192,7 +199,7 @@ void PlatformDependentEmbeddedFileWriter::DeclareSymbolGlobal(
}
void PlatformDependentEmbeddedFileWriter::AlignToCodeAlignment() {
fprintf(fp_, ".balign 32\n");
fprintf(fp_, ".align 5\n");
}
void PlatformDependentEmbeddedFileWriter::Comment(const char* string) {
@ -200,12 +207,19 @@ void PlatformDependentEmbeddedFileWriter::Comment(const char* string) {
}
void PlatformDependentEmbeddedFileWriter::DeclareLabel(const char* name) {
DeclareSymbolGlobal(name);
fprintf(fp_, "%s:\n", name);
}
void PlatformDependentEmbeddedFileWriter::DeclareFunctionBegin(
const char* name) {
DeclareLabel(name);
Newline();
DeclareSymbolGlobal(name);
fprintf(fp_, ".csect %s[DS]\n", name); // function descriptor
fprintf(fp_, "%s:\n", name);
fprintf(fp_, ".llong .%s, 0, 0\n", name);
SectionText();
fprintf(fp_, ".%s:\n", name);
}
void PlatformDependentEmbeddedFileWriter::DeclareFunctionEnd(const char* name) {

View File

@ -205,7 +205,7 @@ class EmbeddedFileWriter {
#define V8_COMPILER_IS_MSVC
#endif
#ifdef V8_COMPILER_IS_MSVC
#if defined(V8_COMPILER_IS_MSVC) || defined(V8_OS_AIX)
// Windows MASM doesn't have an .octa directive, use QWORDs instead.
// Note: MASM *really* does not like large data streams. It takes over 5
// minutes to assemble the ~350K lines of embedded.S produced when using
@ -213,6 +213,8 @@ class EmbeddedFileWriter {
// reduces assembly time to ~40 seconds. Still terrible, but much better
// than before. See also: https://crbug.com/v8/8475.
// GCC MASM on Aix doesn't have an .octa directive, use .llong instead.
static constexpr DataDirective kByteChunkDirective = kQuad;
static constexpr int kByteChunkSize = 8;
@ -221,7 +223,7 @@ class EmbeddedFileWriter {
const uint64_t* quad_ptr = reinterpret_cast<const uint64_t*>(data);
return current_line_length + w->HexLiteral(*quad_ptr);
}
#else // V8_COMPILER_IS_MSVC
#else // defined(V8_COMPILER_IS_MSVC) || defined(V8_OS_AIX)
static constexpr DataDirective kByteChunkDirective = kOcta;
static constexpr int kByteChunkSize = 16;
@ -246,7 +248,7 @@ class EmbeddedFileWriter {
}
return current_line_length;
}
#endif // V8_COMPILER_IS_MSVC
#endif // defined(V8_COMPILER_IS_MSVC) || defined(V8_OS_AIX)
#undef V8_COMPILER_IS_MSVC
static int WriteDirectiveOrSeparator(PlatformDependentEmbeddedFileWriter* w,