Commit 5f27695a authored by Victor Gomes's avatar Victor Gomes Committed by Commit Bot

[runtime] Update frame/frame-constant to support V8_REVERSE_JSARGS

Bug: v8:10201
Change-Id: I7c91e912feab227378810c91afe3de61e0e2fda8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2081817
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66523}
parent 7d144a67
......@@ -21,6 +21,9 @@ namespace internal {
// header, with slot index 2 corresponding to the current function context and 3
// corresponding to the frame marker/JSFunction.
//
// If V8_REVERSE_JSARGS is set, then the parameters are reversed in the stack,
// i.e., the first parameter (the receiver) is just above the return address.
//
// slot JS frame
// +-----------------+--------------------------------
// -n-1 | parameter 0 | ^
......@@ -326,8 +329,13 @@ class InterpreterFrameConstants : public AllStatic {
StandardFrameConstants::kFixedFrameSizeFromFp + 2 * kSystemPointerSize;
// FP-relative.
#ifdef V8_REVERSE_JSARGS
static constexpr int kFirstParamFromFp =
StandardFrameConstants::kCallerSPOffset;
#else
static constexpr int kLastParamFromFp =
StandardFrameConstants::kCallerSPOffset;
#endif
static constexpr int kCallerPCOffsetFromFp =
StandardFrameConstants::kCallerPCOffset;
static constexpr int kBytecodeArrayFromFp =
......
......@@ -190,10 +190,15 @@ inline JavaScriptFrame::JavaScriptFrame(StackFrameIteratorBase* iterator)
: StandardFrame(iterator) {}
Address JavaScriptFrame::GetParameterSlot(int index) const {
int param_count = ComputeParametersCount();
DCHECK(-1 <= index &&
(index < param_count || param_count == kDontAdaptArgumentsSentinel));
(index < ComputeParametersCount() ||
ComputeParametersCount() == kDontAdaptArgumentsSentinel));
#ifdef V8_REVERSE_JSARGS
int parameter_offset = (index + 1) * kSystemPointerSize;
#else
int param_count = ComputeParametersCount();
int parameter_offset = (param_count - index - 1) * kSystemPointerSize;
#endif
return caller_sp() + parameter_offset;
}
......
......@@ -1668,6 +1668,7 @@ DeoptimizationData OptimizedFrame::GetDeoptimizationData(
return DeoptimizationData();
}
#ifndef V8_REVERSE_JSARGS
Object OptimizedFrame::receiver() const {
Code code = LookupCode();
if (code.kind() == Code::BUILTIN) {
......@@ -1682,6 +1683,7 @@ Object OptimizedFrame::receiver() const {
return JavaScriptFrame::receiver();
}
}
#endif
void OptimizedFrame::GetFunctions(
std::vector<SharedFunctionInfo>* functions) const {
......
......@@ -819,7 +819,11 @@ class OptimizedFrame : public JavaScriptFrame {
DeoptimizationData GetDeoptimizationData(int* deopt_index) const;
#ifndef V8_REVERSE_JSARGS
// When the arguments are reversed in the stack, receiver() is
// inherited from JavaScriptFrame.
Object receiver() const override;
#endif
int ComputeParametersCount() const override;
static int StackSlotOffsetRelativeToFp(int slot_index);
......
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