Commit b3e7775f authored by Vasili Skurydzin's avatar Vasili Skurydzin Committed by Commit Bot

aix, builtins: Embedded builtins support on Aix

Bug: v8:8043
Change-Id: Iff786eccd2dcb63e46e331b096d91a6ddb13f851
Reviewed-on: https://chromium-review.googlesource.com/c/1351129Reviewed-by: 's avatarJunliang Yan <jyan@ca.ibm.com>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Junliang Yan <jyan@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#57913}
parent ddaa1f0a
...@@ -86,8 +86,7 @@ declare_args() { ...@@ -86,8 +86,7 @@ declare_args() {
v8_enable_fast_mksnapshot = false v8_enable_fast_mksnapshot = false
# Enable embedded builtins. # Enable embedded builtins.
# TODO(v8:8043): Support aix. v8_enable_embedded_builtins = true
v8_enable_embedded_builtins = !is_aix
# Build-time flag for enabling nojit mode. # Build-time flag for enabling nojit mode.
# TODO(v8:7777): Remove the build-time flag once the --jitless runtime flag # TODO(v8:7777): Remove the build-time flag once the --jitless runtime flag
......
...@@ -180,6 +180,13 @@ void DirectCEntryStub::Generate(MacroAssembler* masm) { ...@@ -180,6 +180,13 @@ void DirectCEntryStub::Generate(MacroAssembler* masm) {
// GC safe. The RegExp backend also relies on this. // GC safe. The RegExp backend also relies on this.
__ mflr(r0); __ mflr(r0);
__ StoreP(r0, MemOperand(sp, kStackFrameExtraParamSlot * kPointerSize)); __ 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. __ Call(ip); // Call the C++ function.
__ LoadP(r0, MemOperand(sp, kStackFrameExtraParamSlot * kPointerSize)); __ LoadP(r0, MemOperand(sp, kStackFrameExtraParamSlot * kPointerSize));
__ mtlr(r0); __ mtlr(r0);
...@@ -201,7 +208,7 @@ void DirectCEntryStub::GenerateCall(MacroAssembler* masm, Register target) { ...@@ -201,7 +208,7 @@ void DirectCEntryStub::GenerateCall(MacroAssembler* masm, Register target) {
return; return;
} }
} }
if (ABI_USES_FUNCTION_DESCRIPTORS) { if (ABI_USES_FUNCTION_DESCRIPTORS && !FLAG_embedded_builtins) {
// AIX/PPC64BE Linux use a function descriptor. // AIX/PPC64BE Linux use a function descriptor.
__ LoadP(ToRegister(ABI_TOC_REGISTER), MemOperand(target, kPointerSize)); __ LoadP(ToRegister(ABI_TOC_REGISTER), MemOperand(target, kPointerSize));
__ LoadP(ip, MemOperand(target, 0)); // Instruction address __ LoadP(ip, MemOperand(target, 0)); // Instruction address
......
...@@ -54,6 +54,17 @@ const char* DirectiveAsString(DataDirective directive) { ...@@ -54,6 +54,17 @@ const char* DirectiveAsString(DataDirective directive) {
default: default:
UNREACHABLE(); UNREACHABLE();
} }
#elif defined(V8_OS_AIX)
switch (directive) {
case kByte:
return ".byte";
case kLong:
return ".long";
case kQuad:
return ".llong";
default:
UNREACHABLE();
}
#else #else
switch (directive) { switch (directive) {
case kByte: case kByte:
...@@ -152,16 +163,11 @@ int PlatformDependentEmbeddedFileWriter::IndentedDataDirective( ...@@ -152,16 +163,11 @@ int PlatformDependentEmbeddedFileWriter::IndentedDataDirective(
#elif defined(V8_OS_AIX) #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() { void PlatformDependentEmbeddedFileWriter::SectionText() {
fprintf(fp_, ".csect .text[PR]\n"); fprintf(fp_, ".csect .text[PR]\n");
} }
void PlatformDependentEmbeddedFileWriter::SectionData() { void PlatformDependentEmbeddedFileWriter::SectionData() {
// TODO(aix): Confirm and update if needed.
fprintf(fp_, ".csect .data[RW]\n"); fprintf(fp_, ".csect .data[RW]\n");
} }
...@@ -172,15 +178,16 @@ void PlatformDependentEmbeddedFileWriter::SectionRoData() { ...@@ -172,15 +178,16 @@ void PlatformDependentEmbeddedFileWriter::SectionRoData() {
void PlatformDependentEmbeddedFileWriter::DeclareUint32(const char* name, void PlatformDependentEmbeddedFileWriter::DeclareUint32(const char* name,
uint32_t value) { uint32_t value) {
DeclareSymbolGlobal(name); DeclareSymbolGlobal(name);
DeclareLabel(name); fprintf(fp_, ".align 2\n");
fprintf(fp_, "%s:\n", name);
IndentedDataDirective(kLong); IndentedDataDirective(kLong);
fprintf(fp_, "%d", value); fprintf(fp_, "%d\n", value);
Newline(); Newline();
} }
void PlatformDependentEmbeddedFileWriter::DeclarePointerToSymbol( void PlatformDependentEmbeddedFileWriter::DeclarePointerToSymbol(
const char* name, const char* target) { const char* name, const char* target) {
DeclareSymbolGlobal(name); AlignToCodeAlignment();
DeclareLabel(name); DeclareLabel(name);
fprintf(fp_, " %s %s\n", DirectiveAsString(PointerSizeDirective()), target); fprintf(fp_, " %s %s\n", DirectiveAsString(PointerSizeDirective()), target);
Newline(); Newline();
...@@ -192,7 +199,7 @@ void PlatformDependentEmbeddedFileWriter::DeclareSymbolGlobal( ...@@ -192,7 +199,7 @@ void PlatformDependentEmbeddedFileWriter::DeclareSymbolGlobal(
} }
void PlatformDependentEmbeddedFileWriter::AlignToCodeAlignment() { void PlatformDependentEmbeddedFileWriter::AlignToCodeAlignment() {
fprintf(fp_, ".balign 32\n"); fprintf(fp_, ".align 5\n");
} }
void PlatformDependentEmbeddedFileWriter::Comment(const char* string) { void PlatformDependentEmbeddedFileWriter::Comment(const char* string) {
...@@ -200,12 +207,19 @@ void PlatformDependentEmbeddedFileWriter::Comment(const char* string) { ...@@ -200,12 +207,19 @@ void PlatformDependentEmbeddedFileWriter::Comment(const char* string) {
} }
void PlatformDependentEmbeddedFileWriter::DeclareLabel(const char* name) { void PlatformDependentEmbeddedFileWriter::DeclareLabel(const char* name) {
DeclareSymbolGlobal(name);
fprintf(fp_, "%s:\n", name); fprintf(fp_, "%s:\n", name);
} }
void PlatformDependentEmbeddedFileWriter::DeclareFunctionBegin( void PlatformDependentEmbeddedFileWriter::DeclareFunctionBegin(
const char* name) { 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) { void PlatformDependentEmbeddedFileWriter::DeclareFunctionEnd(const char* name) {
......
...@@ -205,7 +205,7 @@ class EmbeddedFileWriter { ...@@ -205,7 +205,7 @@ class EmbeddedFileWriter {
#define V8_COMPILER_IS_MSVC #define V8_COMPILER_IS_MSVC
#endif #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. // Windows MASM doesn't have an .octa directive, use QWORDs instead.
// Note: MASM *really* does not like large data streams. It takes over 5 // 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 // minutes to assemble the ~350K lines of embedded.S produced when using
...@@ -213,6 +213,8 @@ class EmbeddedFileWriter { ...@@ -213,6 +213,8 @@ class EmbeddedFileWriter {
// reduces assembly time to ~40 seconds. Still terrible, but much better // reduces assembly time to ~40 seconds. Still terrible, but much better
// than before. See also: https://crbug.com/v8/8475. // 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 DataDirective kByteChunkDirective = kQuad;
static constexpr int kByteChunkSize = 8; static constexpr int kByteChunkSize = 8;
...@@ -221,7 +223,7 @@ class EmbeddedFileWriter { ...@@ -221,7 +223,7 @@ class EmbeddedFileWriter {
const uint64_t* quad_ptr = reinterpret_cast<const uint64_t*>(data); const uint64_t* quad_ptr = reinterpret_cast<const uint64_t*>(data);
return current_line_length + w->HexLiteral(*quad_ptr); 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 DataDirective kByteChunkDirective = kOcta;
static constexpr int kByteChunkSize = 16; static constexpr int kByteChunkSize = 16;
...@@ -246,7 +248,7 @@ class EmbeddedFileWriter { ...@@ -246,7 +248,7 @@ class EmbeddedFileWriter {
} }
return current_line_length; return current_line_length;
} }
#endif // V8_COMPILER_IS_MSVC #endif // defined(V8_COMPILER_IS_MSVC) || defined(V8_OS_AIX)
#undef V8_COMPILER_IS_MSVC #undef V8_COMPILER_IS_MSVC
static int WriteDirectiveOrSeparator(PlatformDependentEmbeddedFileWriter* w, static int WriteDirectiveOrSeparator(PlatformDependentEmbeddedFileWriter* w,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment