summaryrefslogtreecommitdiff
path: root/deps/v8/src/codegen
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2019-10-23 15:01:12 +0200
committerMichaël Zasso <targos@protonmail.com>2019-11-08 15:53:20 +0100
commita9bed0b72b088b5ae8eef625a41b76225686c3f7 (patch)
treef8ea194ed1f9896c36c8c1805041b7149ec075b4 /deps/v8/src/codegen
parentd9fab1fdb76ae3a69b5812a7f2190cf3e58f6d75 (diff)
downloadandroid-node-v8-a9bed0b72b088b5ae8eef625a41b76225686c3f7.tar.gz
android-node-v8-a9bed0b72b088b5ae8eef625a41b76225686c3f7.tar.bz2
android-node-v8-a9bed0b72b088b5ae8eef625a41b76225686c3f7.zip
deps: V8: backport 07ee86a5a28b
Original commit message: PPC: allow for calling CFunctions without function descriptors on AIX. The calling conventions on AIX uses function descriptors, which means that pointers to functions do not point to code, but instead point to metadata about them. When calling JITed code, we must assure to use function descriptors instead of raw pointers when needed. Before this CL 213504b, all CallCFunction on AIX were guaranteed to have function descriptors. Starting form the CL mentioned above, CallCFunction can also Jump to a Trampoline which does not have a function descriptor, hence a new "CallCFunctionWithoutFunctionDescriptor" method is proposed to deal with this issue. BUG= v8:9766 Change-Id: I9343c31c812f5d4dda8503a5adf024b24dbde072 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1825961 Commit-Queue: Milad Farazmand <miladfar@ca.ibm.com> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#64357} Refs: https://github.com/v8/v8/commit/07ee86a5a28b7f9526748ca8f765c1b704f93c0c PR-URL: https://github.com/nodejs/node/pull/30020 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'deps/v8/src/codegen')
-rw-r--r--deps/v8/src/codegen/ppc/assembler-ppc.cc14
-rw-r--r--deps/v8/src/codegen/ppc/assembler-ppc.h2
-rw-r--r--deps/v8/src/codegen/ppc/constants-ppc.h6
-rw-r--r--deps/v8/src/codegen/ppc/macro-assembler-ppc.cc33
-rw-r--r--deps/v8/src/codegen/ppc/macro-assembler-ppc.h15
5 files changed, 39 insertions, 31 deletions
diff --git a/deps/v8/src/codegen/ppc/assembler-ppc.cc b/deps/v8/src/codegen/ppc/assembler-ppc.cc
index 17a3aba1b2..03dbb2edaa 100644
--- a/deps/v8/src/codegen/ppc/assembler-ppc.cc
+++ b/deps/v8/src/codegen/ppc/assembler-ppc.cc
@@ -1121,20 +1121,6 @@ void Assembler::divdu(Register dst, Register src1, Register src2, OEBit o,
}
#endif
-// Function descriptor for AIX.
-// Code address skips the function descriptor "header".
-// TOC and static chain are ignored and set to 0.
-void Assembler::function_descriptor() {
- if (ABI_USES_FUNCTION_DESCRIPTORS) {
- Label instructions;
- DCHECK_EQ(pc_offset(), 0);
- emit_label_addr(&instructions);
- dp(0);
- dp(0);
- bind(&instructions);
- }
-}
-
int Assembler::instructions_required_for_mov(Register dst,
const Operand& src) const {
bool canOptimize =
diff --git a/deps/v8/src/codegen/ppc/assembler-ppc.h b/deps/v8/src/codegen/ppc/assembler-ppc.h
index 42eda72d4d..c056de9f2f 100644
--- a/deps/v8/src/codegen/ppc/assembler-ppc.h
+++ b/deps/v8/src/codegen/ppc/assembler-ppc.h
@@ -840,8 +840,6 @@ class Assembler : public AssemblerBase {
void mtfprwa(DoubleRegister dst, Register src);
#endif
- void function_descriptor();
-
// Exception-generating instructions and debugging support
void stop(Condition cond = al, int32_t code = kDefaultStopCode,
CRegister cr = cr7);
diff --git a/deps/v8/src/codegen/ppc/constants-ppc.h b/deps/v8/src/codegen/ppc/constants-ppc.h
index f6ebc6a7ba..2e499fd2c4 100644
--- a/deps/v8/src/codegen/ppc/constants-ppc.h
+++ b/deps/v8/src/codegen/ppc/constants-ppc.h
@@ -60,6 +60,12 @@ namespace internal {
// TODO(sigurds): Change this value once we use relative jumps.
constexpr size_t kMaxPCRelativeCodeRangeInMB = 0;
+// Used to encode a boolean value when emitting 32 bit
+// opcodes which will indicate the presence of function descriptors
+constexpr int kHasFunctionDescriptorBitShift = 9;
+constexpr int kHasFunctionDescriptorBitMask = 1
+ << kHasFunctionDescriptorBitShift;
+
// Number of registers
const int kNumRegisters = 32;
diff --git a/deps/v8/src/codegen/ppc/macro-assembler-ppc.cc b/deps/v8/src/codegen/ppc/macro-assembler-ppc.cc
index 9e41dec2a8..08fb85dd2c 100644
--- a/deps/v8/src/codegen/ppc/macro-assembler-ppc.cc
+++ b/deps/v8/src/codegen/ppc/macro-assembler-ppc.cc
@@ -209,6 +209,12 @@ void TurboAssembler::Jump(const ExternalReference& reference) {
UseScratchRegisterScope temps(this);
Register scratch = temps.Acquire();
Move(scratch, reference);
+ if (ABI_USES_FUNCTION_DESCRIPTORS) {
+ // AIX uses a function descriptor. When calling C code be
+ // aware of this descriptor and pick up values from it.
+ LoadP(ToRegister(ABI_TOC_REGISTER), MemOperand(scratch, kPointerSize));
+ LoadP(scratch, MemOperand(scratch, 0));
+ }
Jump(scratch);
}
@@ -1930,28 +1936,35 @@ void TurboAssembler::MovToFloatParameters(DoubleRegister src1,
void TurboAssembler::CallCFunction(ExternalReference function,
int num_reg_arguments,
- int num_double_arguments) {
+ int num_double_arguments,
+ bool has_function_descriptor) {
Move(ip, function);
- CallCFunctionHelper(ip, num_reg_arguments, num_double_arguments);
+ CallCFunctionHelper(ip, num_reg_arguments, num_double_arguments,
+ has_function_descriptor);
}
void TurboAssembler::CallCFunction(Register function, int num_reg_arguments,
- int num_double_arguments) {
- CallCFunctionHelper(function, num_reg_arguments, num_double_arguments);
+ int num_double_arguments,
+ bool has_function_descriptor) {
+ CallCFunctionHelper(function, num_reg_arguments, num_double_arguments,
+ has_function_descriptor);
}
void TurboAssembler::CallCFunction(ExternalReference function,
- int num_arguments) {
- CallCFunction(function, num_arguments, 0);
+ int num_arguments,
+ bool has_function_descriptor) {
+ CallCFunction(function, num_arguments, 0, has_function_descriptor);
}
-void TurboAssembler::CallCFunction(Register function, int num_arguments) {
- CallCFunction(function, num_arguments, 0);
+void TurboAssembler::CallCFunction(Register function, int num_arguments,
+ bool has_function_descriptor) {
+ CallCFunction(function, num_arguments, 0, has_function_descriptor);
}
void TurboAssembler::CallCFunctionHelper(Register function,
int num_reg_arguments,
- int num_double_arguments) {
+ int num_double_arguments,
+ bool has_function_descriptor) {
DCHECK_LE(num_reg_arguments + num_double_arguments, kMaxCParameters);
DCHECK(has_frame());
@@ -1976,7 +1989,7 @@ void TurboAssembler::CallCFunctionHelper(Register function,
// allow preemption, so the return address in the link register
// stays correct.
Register dest = function;
- if (ABI_USES_FUNCTION_DESCRIPTORS) {
+ if (ABI_USES_FUNCTION_DESCRIPTORS && has_function_descriptor) {
// AIX/PPC64BE Linux uses a function descriptor. When calling C code be
// aware of this descriptor and pick up values from it
LoadP(ToRegister(ABI_TOC_REGISTER), MemOperand(function, kPointerSize));
diff --git a/deps/v8/src/codegen/ppc/macro-assembler-ppc.h b/deps/v8/src/codegen/ppc/macro-assembler-ppc.h
index 7ff5a6bb4b..1c88558fc4 100644
--- a/deps/v8/src/codegen/ppc/macro-assembler-ppc.h
+++ b/deps/v8/src/codegen/ppc/macro-assembler-ppc.h
@@ -350,12 +350,16 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
// garbage collection, since that might move the code and invalidate the
// return address (unless this is somehow accounted for by the called
// function).
- void CallCFunction(ExternalReference function, int num_arguments);
- void CallCFunction(Register function, int num_arguments);
+ void CallCFunction(ExternalReference function, int num_arguments,
+ bool has_function_descriptor = kHasFunctionDescriptor);
+ void CallCFunction(Register function, int num_arguments,
+ bool has_function_descriptor = kHasFunctionDescriptor);
void CallCFunction(ExternalReference function, int num_reg_arguments,
- int num_double_arguments);
+ int num_double_arguments,
+ bool has_function_descriptor = kHasFunctionDescriptor);
void CallCFunction(Register function, int num_reg_arguments,
- int num_double_arguments);
+ int num_double_arguments,
+ bool has_function_descriptor = kHasFunctionDescriptor);
// Call a runtime routine. This expects {centry} to contain a fitting CEntry
// builtin for the target runtime function and uses an indirect call.
@@ -642,7 +646,8 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
int CalculateStackPassedWords(int num_reg_arguments,
int num_double_arguments);
void CallCFunctionHelper(Register function, int num_reg_arguments,
- int num_double_arguments);
+ int num_double_arguments,
+ bool has_function_descriptor);
void CallRecordWriteStub(Register object, Register address,
RememberedSetAction remembered_set_action,
SaveFPRegsMode fp_mode, Handle<Code> code_target,