From: mstarzinger Date: Tue, 10 Mar 2015 15:56:15 +0000 (-0700) Subject: Remove frame pointer from StackHandler. X-Git-Tag: upstream/4.7.83~3925 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=36e69a916f2a88664887d2b62f0eaf8400edb182;p=platform%2Fupstream%2Fv8.git Remove frame pointer from StackHandler. This reduces the size of the StackHandler by yet another word. We no longer need to keep track of the frame pointer, as the stack walk will be able to recalculate it. R=yangguo@chromium.org Review URL: https://codereview.chromium.org/991893003 Cr-Commit-Position: refs/heads/master@{#27115} --- diff --git a/src/arm/frames-arm.h b/src/arm/frames-arm.h index ce65e887f..3720a2bde 100644 --- a/src/arm/frames-arm.h +++ b/src/arm/frames-arm.h @@ -152,11 +152,6 @@ inline Object* JavaScriptFrame::function_slot_object() const { } -inline void StackHandler::SetFp(Address slot, Address fp) { - Memory::Address_at(slot) = fp; -} - - } } // namespace v8::internal #endif // V8_ARM_FRAMES_ARM_H_ diff --git a/src/arm/macro-assembler-arm.cc b/src/arm/macro-assembler-arm.cc index 057b799ff..2344c78bb 100644 --- a/src/arm/macro-assembler-arm.cc +++ b/src/arm/macro-assembler-arm.cc @@ -1399,11 +1399,10 @@ void MacroAssembler::DebugBreak() { void MacroAssembler::PushTryHandler(StackHandler::Kind kind, int handler_index) { // Adjust this code if not the case. - STATIC_ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); + STATIC_ASSERT(StackHandlerConstants::kSize == 3 * kPointerSize); STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); STATIC_ASSERT(StackHandlerConstants::kStateOffset == 1 * kPointerSize); STATIC_ASSERT(StackHandlerConstants::kContextOffset == 2 * kPointerSize); - STATIC_ASSERT(StackHandlerConstants::kFPOffset == 3 * kPointerSize); // For the JSEntry handler, we must preserve r0-r4, r5-r6 are available. // We will build up the handler from the bottom by pushing on the stack. @@ -1413,13 +1412,12 @@ void MacroAssembler::PushTryHandler(StackHandler::Kind kind, StackHandler::KindField::encode(kind); mov(r6, Operand(state)); - // Push the frame pointer, context, and state. + // Push the context and state. if (kind == StackHandler::JS_ENTRY) { mov(cp, Operand(Smi::FromInt(0))); // Indicates no context. - mov(ip, Operand::Zero()); // NULL frame pointer. - stm(db_w, sp, r6.bit() | cp.bit() | ip.bit()); + stm(db_w, sp, r6.bit() | cp.bit()); } else { - stm(db_w, sp, r6.bit() | cp.bit() | fp.bit()); + stm(db_w, sp, r6.bit() | cp.bit()); } // Link the current handler as the next handler. diff --git a/src/arm64/frames-arm64.h b/src/arm64/frames-arm64.h index 8d4ce8619..883079c9b 100644 --- a/src/arm64/frames-arm64.h +++ b/src/arm64/frames-arm64.h @@ -99,11 +99,6 @@ inline Object* JavaScriptFrame::function_slot_object() const { } -inline void StackHandler::SetFp(Address slot, Address fp) { - Memory::Address_at(slot) = fp; -} - - } } // namespace v8::internal #endif // V8_ARM64_FRAMES_ARM64_H_ diff --git a/src/arm64/macro-assembler-arm64.cc b/src/arm64/macro-assembler-arm64.cc index b6030981c..906418c99 100644 --- a/src/arm64/macro-assembler-arm64.cc +++ b/src/arm64/macro-assembler-arm64.cc @@ -3042,11 +3042,10 @@ void MacroAssembler::PushTryHandler(StackHandler::Kind kind, int handler_index) { DCHECK(jssp.Is(StackPointer())); // Adjust this code if the asserts don't hold. - STATIC_ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); + STATIC_ASSERT(StackHandlerConstants::kSize == 3 * kPointerSize); STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); STATIC_ASSERT(StackHandlerConstants::kStateOffset == 1 * kPointerSize); STATIC_ASSERT(StackHandlerConstants::kContextOffset == 2 * kPointerSize); - STATIC_ASSERT(StackHandlerConstants::kFPOffset == 3 * kPointerSize); // For the JSEntry handler, we must preserve the live registers x0-x4. // (See JSEntryStub::GenerateBody().) @@ -3058,12 +3057,12 @@ void MacroAssembler::PushTryHandler(StackHandler::Kind kind, // Set up the state for pushing. Mov(x11, state); - // Push the frame pointer, context, and state. + // Push the context and state. if (kind == StackHandler::JS_ENTRY) { DCHECK(Smi::FromInt(0) == 0); - Push(xzr, xzr, x11); + Push(xzr, x11); } else { - Push(fp, cp, x11); + Push(cp, x11); } // Link the current handler as the next handler. diff --git a/src/frames-inl.h b/src/frames-inl.h index 2efc8d8a2..221b00697 100644 --- a/src/frames-inl.h +++ b/src/frames-inl.h @@ -94,12 +94,6 @@ inline unsigned StackHandler::index() const { } -inline Address StackHandler::frame_pointer() const { - const int offset = StackHandlerConstants::kFPOffset; - return Memory::Address_at(address() + offset); -} - - inline Object** StackHandler::context_address() const { const int offset = StackHandlerConstants::kContextOffset; return reinterpret_cast(address() + offset); diff --git a/src/frames.cc b/src/frames.cc index 61fab874d..e3584476b 100644 --- a/src/frames.cc +++ b/src/frames.cc @@ -1534,17 +1534,16 @@ void StackHandler::Unwind(Isolate* isolate, FixedArray* array, int offset, int previous_handler_offset) const { - STATIC_ASSERT(StackHandlerConstants::kSlotCount >= 4); + STATIC_ASSERT(StackHandlerConstants::kSlotCount >= 3); DCHECK_LE(0, offset); DCHECK_GE(array->length(), offset + StackHandlerConstants::kSlotCount); // Unwinding a stack handler into an array chains it in the opposite // direction, re-using the "next" slot as a "previous" link, so that stack - // handlers can be later re-wound in the correct order. Decode the "state" - // slot into "index" and "kind" and store them separately, using the fp slot. - array->set(offset, Smi::FromInt(previous_handler_offset)); // next - array->set(offset + 1, Smi::FromInt(static_cast(index()))); // state - array->set(offset + 2, *context_address()); // context - array->set(offset + 3, Smi::FromInt(static_cast(kind()))); // fp + // handlers can be later re-wound in the correct order. + int s = Memory::int_at(address() + StackHandlerConstants::kStateIntOffset); + array->set(offset, Smi::FromInt(previous_handler_offset)); // next + array->set(offset + 1, Smi::FromInt(static_cast(s))); // state + array->set(offset + 2, *context_address()); // context *isolate->handler_address() = next()->address(); } @@ -1554,23 +1553,19 @@ int StackHandler::Rewind(Isolate* isolate, FixedArray* array, int offset, Address fp) { - STATIC_ASSERT(StackHandlerConstants::kSlotCount >= 4); + STATIC_ASSERT(StackHandlerConstants::kSlotCount >= 3); DCHECK_LE(0, offset); DCHECK_GE(array->length(), offset + StackHandlerConstants::kSlotCount); Smi* prev_handler_offset = Smi::cast(array->get(offset)); - Smi* smi_index = Smi::cast(array->get(offset + 1)); + Smi* smi_state = Smi::cast(array->get(offset + 1)); Object* context = array->get(offset + 2); - Smi* smi_kind = Smi::cast(array->get(offset + 3)); - - unsigned state = KindField::encode(static_cast(smi_kind->value())) | - IndexField::encode(static_cast(smi_index->value())); Memory::Address_at(address() + StackHandlerConstants::kNextOffset) = *isolate->handler_address(); - Memory::uintptr_at(address() + StackHandlerConstants::kStateOffset) = state; + Memory::int_at(address() + StackHandlerConstants::kStateIntOffset) = + smi_state->value(); Memory::Object_at(address() + StackHandlerConstants::kContextOffset) = context; - SetFp(address() + StackHandlerConstants::kFPOffset, fp); *isolate->handler_address() = address(); diff --git a/src/frames.h b/src/frames.h index 50541a9e9..d5ce9b3df 100644 --- a/src/frames.h +++ b/src/frames.h @@ -76,9 +76,8 @@ class StackHandlerConstants : public AllStatic { static const int kStateIntOffset = kStateOffset + kIntSize; #endif static const int kContextOffset = 2 * kPointerSize; - static const int kFPOffset = 3 * kPointerSize; - static const int kSize = kFPOffset + kFPOnStackSize; + static const int kSize = kContextOffset + kPointerSize; static const int kSlotCount = kSize >> kPointerSizeLog2; }; @@ -117,7 +116,6 @@ class StackHandler BASE_EMBEDDED { inline Context* context() const; inline Kind kind() const; inline unsigned index() const; - inline Address frame_pointer() const; // Testers. inline bool is_js_entry() const; @@ -131,7 +129,6 @@ class StackHandler BASE_EMBEDDED { private: inline Object** context_address() const; - inline void SetFp(Address slot, Address fp); DISALLOW_IMPLICIT_CONSTRUCTORS(StackHandler); }; diff --git a/src/ia32/frames-ia32.h b/src/ia32/frames-ia32.h index 1290ad6e0..f9d804f66 100644 --- a/src/ia32/frames-ia32.h +++ b/src/ia32/frames-ia32.h @@ -115,11 +115,6 @@ inline Object* JavaScriptFrame::function_slot_object() const { } -inline void StackHandler::SetFp(Address slot, Address fp) { - Memory::Address_at(slot) = fp; -} - - } } // namespace v8::internal #endif // V8_IA32_FRAMES_IA32_H_ diff --git a/src/ia32/macro-assembler-ia32.cc b/src/ia32/macro-assembler-ia32.cc index d39264ab9..c25b8178f 100644 --- a/src/ia32/macro-assembler-ia32.cc +++ b/src/ia32/macro-assembler-ia32.cc @@ -1026,22 +1026,16 @@ void MacroAssembler::LeaveApiExitFrame(bool restore_context) { void MacroAssembler::PushTryHandler(StackHandler::Kind kind, int handler_index) { // Adjust this code if not the case. - STATIC_ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); + STATIC_ASSERT(StackHandlerConstants::kSize == 3 * kPointerSize); STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); STATIC_ASSERT(StackHandlerConstants::kStateOffset == 1 * kPointerSize); STATIC_ASSERT(StackHandlerConstants::kContextOffset == 2 * kPointerSize); - STATIC_ASSERT(StackHandlerConstants::kFPOffset == 3 * kPointerSize); // We will build up the handler from the bottom by pushing on the stack. - // First push the frame pointer and context. + // First push the context. if (kind == StackHandler::JS_ENTRY) { - // The frame pointer does not point to a JS frame so we save NULL for - // ebp. We expect the code throwing an exception to check ebp before - // dereferencing it to restore the context. - push(Immediate(0)); // NULL frame pointer. push(Immediate(Smi::FromInt(0))); // No context. } else { - push(ebp); push(esi); } // Push the state. diff --git a/src/isolate.cc b/src/isolate.cc index 23782cd1c..45fa140b4 100644 --- a/src/isolate.cc +++ b/src/isolate.cc @@ -1093,7 +1093,7 @@ Object* Isolate::FindHandler() { context = handler->context(); offset = Smi::cast(code->handler_table()->get(handler->index()))->value(); handler_sp = handler->address() + StackHandlerConstants::kSize; - handler_fp = handler->frame_pointer(); + handler_fp = frame->fp(); break; } diff --git a/src/mips/frames-mips.h b/src/mips/frames-mips.h index 5666f642f..633a887b5 100644 --- a/src/mips/frames-mips.h +++ b/src/mips/frames-mips.h @@ -205,11 +205,6 @@ inline Object* JavaScriptFrame::function_slot_object() const { } -inline void StackHandler::SetFp(Address slot, Address fp) { - Memory::Address_at(slot) = fp; -} - - } } // namespace v8::internal #endif diff --git a/src/mips64/frames-mips64.h b/src/mips64/frames-mips64.h index eaf29c89b..be732ef5f 100644 --- a/src/mips64/frames-mips64.h +++ b/src/mips64/frames-mips64.h @@ -205,11 +205,6 @@ inline Object* JavaScriptFrame::function_slot_object() const { } -inline void StackHandler::SetFp(Address slot, Address fp) { - Memory::Address_at(slot) = fp; -} - - } } // namespace v8::internal #endif diff --git a/src/ppc/frames-ppc.h b/src/ppc/frames-ppc.h index a14e4f5b5..40a68b3a3 100644 --- a/src/ppc/frames-ppc.h +++ b/src/ppc/frames-ppc.h @@ -181,9 +181,6 @@ inline Object* JavaScriptFrame::function_slot_object() const { } -inline void StackHandler::SetFp(Address slot, Address fp) { - Memory::Address_at(slot) = fp; -} } } // namespace v8::internal diff --git a/src/x64/frames-x64.h b/src/x64/frames-x64.h index 881303028..1f8612afa 100644 --- a/src/x64/frames-x64.h +++ b/src/x64/frames-x64.h @@ -107,15 +107,6 @@ inline Object* JavaScriptFrame::function_slot_object() const { } -inline void StackHandler::SetFp(Address slot, Address fp) { - if (kFPOnStackSize == 2 * kPointerSize) { - // Zero out the high-32 bit of FP for x32 port. - Memory::Address_at(slot + kPointerSize) = 0; - } - Memory::Address_at(slot) = fp; -} - - } } // namespace v8::internal #endif // V8_X64_FRAMES_X64_H_ diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc index 89016f85a..5a17b3a6f 100644 --- a/src/x64/macro-assembler-x64.cc +++ b/src/x64/macro-assembler-x64.cc @@ -2982,23 +2982,16 @@ Operand MacroAssembler::SafepointRegisterSlot(Register reg) { void MacroAssembler::PushTryHandler(StackHandler::Kind kind, int handler_index) { // Adjust this code if not the case. - STATIC_ASSERT(StackHandlerConstants::kSize == 3 * kPointerSize + - kFPOnStackSize); + STATIC_ASSERT(StackHandlerConstants::kSize == 3 * kPointerSize); STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); STATIC_ASSERT(StackHandlerConstants::kStateOffset == 1 * kPointerSize); STATIC_ASSERT(StackHandlerConstants::kContextOffset == 2 * kPointerSize); - STATIC_ASSERT(StackHandlerConstants::kFPOffset == 3 * kPointerSize); // We will build up the handler from the bottom by pushing on the stack. - // First push the frame pointer and context. + // First push the context. if (kind == StackHandler::JS_ENTRY) { - // The frame pointer does not point to a JS frame so we save NULL for - // rbp. We expect the code throwing an exception to check rbp before - // dereferencing it to restore the context. - pushq(Immediate(0)); // NULL frame pointer. Push(Smi::FromInt(0)); // No context. } else { - pushq(rbp); Push(rsi); } diff --git a/src/x87/frames-x87.h b/src/x87/frames-x87.h index 5b91baf38..e3876bc72 100644 --- a/src/x87/frames-x87.h +++ b/src/x87/frames-x87.h @@ -115,11 +115,6 @@ inline Object* JavaScriptFrame::function_slot_object() const { } -inline void StackHandler::SetFp(Address slot, Address fp) { - Memory::Address_at(slot) = fp; -} - - } } // namespace v8::internal #endif // V8_X87_FRAMES_X87_H_