Commit c0c5d131 authored by rmcilroy's avatar rmcilroy Committed by Commit bot

[Interpreter] GetExpression(0) in InterpretedFrames gets first local.

Various places assume that GetExpression returns the locals for a frame.
Modify InterpretedFrames such that GetExpression(0) returns the first
local, not the fixed parts of the interpreter frame.

BUG=v8:4690,v8:4680
LOG=N

Review URL: https://codereview.chromium.org/1697223003

Cr-Commit-Position: refs/heads/master@{#34040}
parent ccc33712
......@@ -602,23 +602,14 @@ Address StandardFrame::GetExpressionAddress(int n) const {
return fp() + offset - n * kPointerSize;
}
Object* StandardFrame::GetExpression(Address fp, int index) {
return Memory::Object_at(GetExpressionAddress(fp, index));
}
Address StandardFrame::GetExpressionAddress(Address fp, int n) {
const int offset = StandardFrameConstants::kExpressionsOffset;
return fp + offset - n * kPointerSize;
Address InterpretedFrame::GetExpressionAddress(int n) const {
const int offset = InterpreterFrameConstants::kExpressionsOffset;
return fp() + offset - n * kPointerSize;
}
int StandardFrame::ComputeExpressionsCount() const {
const int offset =
StandardFrameConstants::kExpressionsOffset + kPointerSize;
Address base = fp() + offset;
Address limit = sp();
Address base = GetExpressionAddress(0);
Address limit = sp() - kPointerSize;
DCHECK(base >= limit); // stack grows downwards
// Include register-allocated locals in number of expressions.
return static_cast<int>((base - limit) / kPointerSize);
......@@ -765,9 +756,7 @@ bool JavaScriptFrame::HasInlinedFrames() const {
int JavaScriptFrame::GetArgumentsLength() const {
// If there is an arguments adaptor frame get the arguments length from it.
if (has_adapted_arguments()) {
STATIC_ASSERT(ArgumentsAdaptorFrameConstants::kLengthOffset ==
StandardFrameConstants::kExpressionsOffset);
return Smi::cast(GetExpression(caller_fp(), 0))->value();
return ArgumentsAdaptorFrame::GetLength(caller_fp());
} else {
return GetNumberOfIncomingArguments();
}
......@@ -1138,38 +1127,43 @@ int InterpretedFrame::LookupExceptionHandlerInTable(
int InterpretedFrame::GetBytecodeOffset() const {
const int index = InterpreterFrameConstants::kBytecodeOffsetExpressionIndex;
DCHECK_EQ(InterpreterFrameConstants::kBytecodeOffsetFromFp,
StandardFrameConstants::kExpressionsOffset - index * kPointerSize);
DCHECK_EQ(
InterpreterFrameConstants::kBytecodeOffsetFromFp,
InterpreterFrameConstants::kExpressionsOffset - index * kPointerSize);
int raw_offset = Smi::cast(GetExpression(index))->value();
return raw_offset - BytecodeArray::kHeaderSize + kHeapObjectTag;
}
void InterpretedFrame::PatchBytecodeOffset(int new_offset) {
const int index = InterpreterFrameConstants::kBytecodeOffsetExpressionIndex;
DCHECK_EQ(InterpreterFrameConstants::kBytecodeOffsetFromFp,
StandardFrameConstants::kExpressionsOffset - index * kPointerSize);
DCHECK_EQ(
InterpreterFrameConstants::kBytecodeOffsetFromFp,
InterpreterFrameConstants::kExpressionsOffset - index * kPointerSize);
int raw_offset = new_offset + BytecodeArray::kHeaderSize - kHeapObjectTag;
SetExpression(index, Smi::FromInt(raw_offset));
}
Object* InterpretedFrame::GetBytecodeArray() const {
const int index = InterpreterFrameConstants::kBytecodeArrayExpressionIndex;
DCHECK_EQ(InterpreterFrameConstants::kBytecodeArrayFromFp,
StandardFrameConstants::kExpressionsOffset - index * kPointerSize);
DCHECK_EQ(
InterpreterFrameConstants::kBytecodeArrayFromFp,
InterpreterFrameConstants::kExpressionsOffset - index * kPointerSize);
return GetExpression(index);
}
void InterpretedFrame::PatchBytecodeArray(Object* bytecode_array) {
const int index = InterpreterFrameConstants::kBytecodeArrayExpressionIndex;
DCHECK_EQ(InterpreterFrameConstants::kBytecodeArrayFromFp,
StandardFrameConstants::kExpressionsOffset - index * kPointerSize);
DCHECK_EQ(
InterpreterFrameConstants::kBytecodeArrayFromFp,
InterpreterFrameConstants::kExpressionsOffset - index * kPointerSize);
SetExpression(index, bytecode_array);
}
Object* InterpretedFrame::GetInterpreterRegister(int register_index) const {
const int index = InterpreterFrameConstants::kRegisterFileExpressionIndex;
DCHECK_EQ(InterpreterFrameConstants::kRegisterFilePointerFromFp,
StandardFrameConstants::kExpressionsOffset - index * kPointerSize);
DCHECK_EQ(
InterpreterFrameConstants::kRegisterFilePointerFromFp,
InterpreterFrameConstants::kExpressionsOffset - index * kPointerSize);
return GetExpression(index + register_index);
}
......@@ -1191,19 +1185,21 @@ Address ArgumentsAdaptorFrame::GetCallerStackPointer() const {
return fp() + StandardFrameConstants::kCallerSPOffset;
}
Address InternalFrame::GetCallerStackPointer() const {
// Internal frames have no arguments. The stack pointer of the
// caller is at a fixed offset from the frame pointer.
return fp() + StandardFrameConstants::kCallerSPOffset;
int ArgumentsAdaptorFrame::GetLength(Address fp) {
const int offset = ArgumentsAdaptorFrameConstants::kLengthOffset;
return Smi::cast(Memory::Object_at(fp + offset))->value();
}
Code* ArgumentsAdaptorFrame::unchecked_code() const {
return isolate()->builtins()->builtin(
Builtins::kArgumentsAdaptorTrampoline);
}
Address InternalFrame::GetCallerStackPointer() const {
// Internal frames have no arguments. The stack pointer of the
// caller is at a fixed offset from the frame pointer.
return fp() + StandardFrameConstants::kCallerSPOffset;
}
Code* InternalFrame::unchecked_code() const {
const int offset = InternalFrameConstants::kCodeOffset;
......
......@@ -192,10 +192,12 @@ class InterpreterFrameConstants : public AllStatic {
static const int kRegisterFilePointerFromFp =
-StandardFrameConstants::kFixedFrameSizeFromFp - 4 * kPointerSize;
static const int kExpressionsOffset = kRegisterFilePointerFromFp;
// Expression index for {StandardFrame::GetExpressionAddress}.
static const int kBytecodeArrayExpressionIndex = 1;
static const int kBytecodeOffsetExpressionIndex = 2;
static const int kRegisterFileExpressionIndex = 3;
static const int kBytecodeArrayExpressionIndex = -2;
static const int kBytecodeOffsetExpressionIndex = -1;
static const int kRegisterFileExpressionIndex = 0;
// Register file pointer relative.
static const int kLastParamFromRegisterPointer =
......@@ -498,7 +500,6 @@ class StandardFrame: public StackFrame {
inline Object* GetExpression(int index) const;
inline void SetExpression(int index, Object* value);
int ComputeExpressionsCount() const;
static Object* GetExpression(Address fp, int index);
void SetCallerFp(Address caller_fp) override;
......@@ -529,8 +530,7 @@ class StandardFrame: public StackFrame {
void IterateExpressions(ObjectVisitor* v) const;
// Returns the address of the n'th expression stack element.
Address GetExpressionAddress(int n) const;
static Address GetExpressionAddress(Address fp, int n);
virtual Address GetExpressionAddress(int n) const;
// Determines if the standard frame for the given frame pointer is
// an arguments adaptor frame.
......@@ -756,6 +756,8 @@ class InterpretedFrame : public JavaScriptFrame {
protected:
inline explicit InterpretedFrame(StackFrameIteratorBase* iterator);
Address GetExpressionAddress(int n) const override;
private:
friend class StackFrameIteratorBase;
};
......@@ -780,6 +782,8 @@ class ArgumentsAdaptorFrame: public JavaScriptFrame {
void Print(StringStream* accumulator, PrintMode mode,
int index) const override;
static int GetLength(Address fp);
protected:
inline explicit ArgumentsAdaptorFrame(StackFrameIteratorBase* iterator);
......
......@@ -840,10 +840,6 @@
# TODO(rmcilroy,4680): Check failed: osr_normal_entry.
'regress/regress-123919': [FAIL],
# TODO(rmcilroy,4680): Fails due to debugger loading bytecodearray as an
# expression local.
'harmony/default-parameters-debug': [FAIL],
# TODO(rmcilroy,4680): Pass on debug, fail on release.
'compiler/regress-stacktrace-methods': [PASS, FAIL],
......@@ -866,7 +862,6 @@
'regress/regress-4266': [FAIL],
'harmony/simd': [FAIL],
'regress/regress-crbug-109362': [FAIL],
'regress/regress-1170187': [FAIL],
'regress/regress-131994': [FAIL],
'regress/regress-crbug-568477-2': [FAIL],
'regress/regress-crbug-568477-3': [FAIL],
......
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