Commit 75763183 authored by jgruber's avatar jgruber Committed by Commit Bot

[masm] Don't push CodeObject when entering INTERNAL frames

The code slot of internal frames seems to be basically unused.
As always, there are exceptions:

1. In elements.cc we check whether the current code object is the apply
builtin. We can use a heap lookup through the frame's pc instead.
2. In isolate.cc we store a reference to the frame's code object to try
and pack it into the minidump. This can safely be skipped.

Remaining use-sites in frames.cc all skip INTERNAL frames by using the
JavaScriptFrameIterator.

Bug: v8:6666
Change-Id: I93c5035812838bbae5109415450915db12497b9c
Reviewed-on: https://chromium-review.googlesource.com/1075047
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53409}
parent 502fc406
......@@ -1252,10 +1252,6 @@ void TurboAssembler::EnterFrame(StackFrame::Type type,
Register scratch = temps.Acquire();
mov(scratch, Operand(StackFrame::TypeToMarker(type)));
PushCommonFrame(scratch);
if (type == StackFrame::INTERNAL) {
Move(scratch, CodeObject());
push(scratch);
}
}
int TurboAssembler::LeaveFrame(StackFrame::Type type) {
......
......@@ -2496,16 +2496,17 @@ void TurboAssembler::EnterFrame(StackFrame::Type type) {
UseScratchRegisterScope temps(this);
if (type == StackFrame::INTERNAL) {
Register code_reg = temps.AcquireX();
Move(code_reg, CodeObject());
Register type_reg = temps.AcquireX();
Mov(type_reg, StackFrame::TypeToMarker(type));
Push(lr, fp, type_reg, code_reg);
Add(fp, sp, InternalFrameConstants::kFixedFrameSizeFromFp);
// type_reg pushed twice for alignment.
Push(lr, fp, type_reg, type_reg);
const int kFrameSize =
TypedFrameConstants::kFixedFrameSizeFromFp + kPointerSize;
Add(fp, sp, kFrameSize);
// sp[3] : lr
// sp[2] : fp
// sp[1] : type
// sp[0] : [code object]
// sp[0] : for alignment
} else if (type == StackFrame::WASM_COMPILED ||
type == StackFrame::WASM_COMPILE_LAZY) {
Register type_reg = temps.AcquireX();
......
......@@ -447,9 +447,10 @@ static void TraceTopFrame(Isolate* isolate) {
}
StackFrame* raw_frame = it.frame();
if (raw_frame->is_internal()) {
Code* apply_builtin =
isolate->builtins()->builtin(Builtins::kFunctionPrototypeApply);
if (raw_frame->unchecked_code() == apply_builtin) {
Code* current_code_object =
isolate->heap()->GcSafeFindCodeForInnerPointer(raw_frame->pc());
if (current_code_object->builtin_index() ==
Builtins::kFunctionPrototypeApply) {
PrintF("apply from ");
it.Advance();
raw_frame = it.frame();
......
......@@ -234,13 +234,6 @@ class BuiltinFrameConstants : public TypedFrameConstants {
DEFINE_TYPED_FRAME_SIZES(2);
};
class InternalFrameConstants : public TypedFrameConstants {
public:
// FP-relative.
static constexpr int kCodeOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0);
DEFINE_TYPED_FRAME_SIZES(1);
};
class ConstructFrameConstants : public TypedFrameConstants {
public:
// FP-relative.
......
......@@ -1748,13 +1748,7 @@ Address InternalFrame::GetCallerStackPointer() const {
return fp() + StandardFrameConstants::kCallerSPOffset;
}
Code* InternalFrame::unchecked_code() const {
const int offset = InternalFrameConstants::kCodeOffset;
Object* code = Memory::Object_at(fp() + offset);
DCHECK_NOT_NULL(code);
return reinterpret_cast<Code*>(code);
}
Code* InternalFrame::unchecked_code() const { UNREACHABLE(); }
void WasmCompiledFrame::Print(StringStream* accumulator, PrintMode mode,
int index) const {
......
......@@ -623,14 +623,6 @@ void TurboAssembler::EnterFrame(StackFrame::Type type) {
push(ebp);
mov(ebp, esp);
push(Immediate(StackFrame::TypeToMarker(type)));
if (type == StackFrame::INTERNAL) {
push(Immediate(CodeObject()));
// Check at runtime that this code object was patched correctly.
if (emit_debug_code()) {
cmp(Operand(esp, 0), Immediate(isolate()->factory()->undefined_value()));
Check(not_equal, AbortReason::kCodeObjectNotProperlyPatched);
}
}
}
void TurboAssembler::LeaveFrame(StackFrame::Type type) {
......
......@@ -401,6 +401,7 @@ StackTraceFailureMessage::StackTraceFailureMessage(Isolate* isolate, void* ptr1,
size_t i = 0;
StackFrameIterator it(isolate);
for (; !it.done() && i < code_objects_length; it.Advance()) {
if (it.frame()->type() == StackFrame::INTERNAL) continue;
code_objects_[i++] = it.frame()->unchecked_code();
}
}
......
......@@ -4829,8 +4829,6 @@ void TurboAssembler::EnterFrame(StackFrame::Type type) {
sw(t9, MemOperand(sp, stack_offset));
if (type == StackFrame::INTERNAL) {
DCHECK_EQ(stack_offset, kPointerSize);
li(t9, CodeObject());
sw(t9, MemOperand(sp, 0));
} else {
DCHECK_EQ(stack_offset, 0);
}
......
......@@ -5149,8 +5149,6 @@ void TurboAssembler::EnterFrame(StackFrame::Type type) {
Sd(t9, MemOperand(sp, stack_offset));
if (type == StackFrame::INTERNAL) {
DCHECK_EQ(stack_offset, kPointerSize);
li(t9, CodeObject());
Sd(t9, MemOperand(sp, 0));
} else {
DCHECK_EQ(stack_offset, 0);
}
......
......@@ -2416,17 +2416,6 @@ void TurboAssembler::EnterFrame(StackFrame::Type type) {
pushq(rbp);
movp(rbp, rsp);
Push(Immediate(StackFrame::TypeToMarker(type)));
if (type == StackFrame::INTERNAL) {
Move(kScratchRegister, CodeObject(), RelocInfo::EMBEDDED_OBJECT);
Push(kScratchRegister);
// Check at runtime that this code object was patched correctly.
if (emit_debug_code()) {
Move(kScratchRegister, isolate()->factory()->undefined_value(),
RelocInfo::EMBEDDED_OBJECT);
cmpp(Operand(rsp, 0), kScratchRegister);
Check(not_equal, AbortReason::kCodeObjectNotProperlyPatched);
}
}
}
void TurboAssembler::LeaveFrame(StackFrame::Type type) {
......
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