Remove frame pointer from StackHandler.
authormstarzinger <mstarzinger@chromium.org>
Tue, 10 Mar 2015 15:56:15 +0000 (08:56 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 10 Mar 2015 15:56:27 +0000 (15:56 +0000)
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}

16 files changed:
src/arm/frames-arm.h
src/arm/macro-assembler-arm.cc
src/arm64/frames-arm64.h
src/arm64/macro-assembler-arm64.cc
src/frames-inl.h
src/frames.cc
src/frames.h
src/ia32/frames-ia32.h
src/ia32/macro-assembler-ia32.cc
src/isolate.cc
src/mips/frames-mips.h
src/mips64/frames-mips64.h
src/ppc/frames-ppc.h
src/x64/frames-x64.h
src/x64/macro-assembler-x64.cc
src/x87/frames-x87.h

index ce65e88..3720a2b 100644 (file)
@@ -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_
index 057b799..2344c78 100644 (file)
@@ -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.
index 8d4ce86..883079c 100644 (file)
@@ -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_
index b603098..906418c 100644 (file)
@@ -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.
index 2efc8d8..221b006 100644 (file)
@@ -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<Object**>(address() + offset);
index 61fab87..e358447 100644 (file)
@@ -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<int>(index())));  // state
-  array->set(offset + 2, *context_address());                       // context
-  array->set(offset + 3, Smi::FromInt(static_cast<int>(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<int>(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<Kind>(smi_kind->value())) |
-      IndexField::encode(static_cast<unsigned>(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();
 
index 50541a9..d5ce9b3 100644 (file)
@@ -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);
 };
index 1290ad6..f9d804f 100644 (file)
@@ -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_
index d39264a..c25b817 100644 (file)
@@ -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.
index 23782cd..45fa140 100644 (file)
@@ -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;
     }
 
index 5666f64..633a887 100644 (file)
@@ -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
index eaf29c8..be732ef 100644 (file)
@@ -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
index a14e4f5..40a68b3 100644 (file)
@@ -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
 
index 8813030..1f8612a 100644 (file)
@@ -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_
index 89016f8..5a17b3a 100644 (file)
@@ -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);
   }
 
index 5b91baf..e3876bc 100644 (file)
@@ -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_