Commit e0aa8ebf authored by mstarzinger's avatar mstarzinger Committed by Commit bot

Remove code object from StackHandler.

This reduces the size of the StackHandler by one word. We no longer
need to keep track of the code object, as the stack walk finds it.

R=yangguo@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#27103}
parent 507c11a0
......@@ -1399,29 +1399,27 @@ void MacroAssembler::DebugBreak() {
void MacroAssembler::PushTryHandler(StackHandler::Kind kind,
int handler_index) {
// Adjust this code if not the case.
STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * 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.
// Set up the code object (r5) and the state (r6) for pushing.
// Set up the the state (r6) for pushing.
unsigned state =
StackHandler::IndexField::encode(handler_index) |
StackHandler::KindField::encode(kind);
mov(r5, Operand(CodeObject()));
mov(r6, Operand(state));
// Push the frame pointer, context, state, and code object.
// Push the frame pointer, 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, r5.bit() | r6.bit() | cp.bit() | ip.bit());
stm(db_w, sp, r6.bit() | cp.bit() | ip.bit());
} else {
stm(db_w, sp, r5.bit() | r6.bit() | cp.bit() | fp.bit());
stm(db_w, sp, r6.bit() | cp.bit() | fp.bit());
}
// Link the current handler as the next handler.
......
......@@ -3042,12 +3042,11 @@ 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 == 5 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * 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().)
......@@ -3056,16 +3055,15 @@ void MacroAssembler::PushTryHandler(StackHandler::Kind kind,
StackHandler::IndexField::encode(handler_index) |
StackHandler::KindField::encode(kind);
// Set up the code object and the state for pushing.
Mov(x10, Operand(CodeObject()));
// Set up the state for pushing.
Mov(x11, state);
// Push the frame pointer, context, state, and code object.
// Push the frame pointer, context, and state.
if (kind == StackHandler::JS_ENTRY) {
DCHECK(Smi::FromInt(0) == 0);
Push(xzr, xzr, x11, x10);
Push(xzr, xzr, x11);
} else {
Push(fp, cp, x11, x10);
Push(fp, cp, x11);
}
// Link the current handler as the next handler.
......
......@@ -53,7 +53,6 @@ inline bool StackHandler::includes(Address address) const {
inline void StackHandler::Iterate(ObjectVisitor* v, Code* holder) const {
v->VisitPointer(context_address());
v->VisitPointer(code_address());
}
......@@ -83,12 +82,6 @@ inline Context* StackHandler::context() const {
}
inline Code* StackHandler::code() const {
const int offset = StackHandlerConstants::kCodeOffset;
return Code::cast(Memory::Object_at(address() + offset));
}
inline StackHandler::Kind StackHandler::kind() const {
const int offset = StackHandlerConstants::kStateIntOffset;
return KindField::decode(Memory::unsigned_at(address() + offset));
......@@ -113,12 +106,6 @@ inline Object** StackHandler::context_address() const {
}
inline Object** StackHandler::code_address() const {
const int offset = StackHandlerConstants::kCodeOffset;
return reinterpret_cast<Object**>(address() + offset);
}
inline StackFrame::StackFrame(StackFrameIteratorBase* iterator)
: iterator_(iterator), isolate_(iterator_->isolate()) {
}
......
......@@ -1534,7 +1534,7 @@ void StackHandler::Unwind(Isolate* isolate,
FixedArray* array,
int offset,
int previous_handler_offset) const {
STATIC_ASSERT(StackHandlerConstants::kSlotCount >= 5);
STATIC_ASSERT(StackHandlerConstants::kSlotCount >= 4);
DCHECK_LE(0, offset);
DCHECK_GE(array->length(), offset + StackHandlerConstants::kSlotCount);
// Unwinding a stack handler into an array chains it in the opposite
......@@ -1542,10 +1542,9 @@ void StackHandler::Unwind(Isolate* isolate,
// 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, *code_address()); // code
array->set(offset + 2, Smi::FromInt(static_cast<int>(index()))); // state
array->set(offset + 3, *context_address()); // context
array->set(offset + 4, Smi::FromInt(static_cast<int>(kind()))); // fp
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
*isolate->handler_address() = next()->address();
}
......@@ -1555,21 +1554,19 @@ int StackHandler::Rewind(Isolate* isolate,
FixedArray* array,
int offset,
Address fp) {
STATIC_ASSERT(StackHandlerConstants::kSlotCount >= 5);
STATIC_ASSERT(StackHandlerConstants::kSlotCount >= 4);
DCHECK_LE(0, offset);
DCHECK_GE(array->length(), offset + StackHandlerConstants::kSlotCount);
Smi* prev_handler_offset = Smi::cast(array->get(offset));
Code* code = Code::cast(array->get(offset + 1));
Smi* smi_index = Smi::cast(array->get(offset + 2));
Object* context = array->get(offset + 3);
Smi* smi_kind = Smi::cast(array->get(offset + 4));
Smi* smi_index = 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::Object_at(address() + StackHandlerConstants::kCodeOffset) = code;
Memory::uintptr_at(address() + StackHandlerConstants::kStateOffset) = state;
Memory::Object_at(address() + StackHandlerConstants::kContextOffset) =
context;
......
......@@ -69,15 +69,14 @@ class InnerPointerToCodeCache {
class StackHandlerConstants : public AllStatic {
public:
static const int kNextOffset = 0 * kPointerSize;
static const int kCodeOffset = 1 * kPointerSize;
static const int kStateOffset = 2 * kPointerSize;
static const int kStateOffset = 1 * kPointerSize;
#if V8_TARGET_LITTLE_ENDIAN || !V8_HOST_ARCH_64_BIT
static const int kStateIntOffset = kStateOffset;
#else
static const int kStateIntOffset = kStateOffset + kIntSize;
#endif
static const int kContextOffset = 3 * kPointerSize;
static const int kFPOffset = 4 * kPointerSize;
static const int kContextOffset = 2 * kPointerSize;
static const int kFPOffset = 3 * kPointerSize;
static const int kSize = kFPOffset + kFPOnStackSize;
static const int kSlotCount = kSize >> kPointerSizeLog2;
......@@ -116,7 +115,6 @@ class StackHandler BASE_EMBEDDED {
// Accessors.
inline Context* context() const;
inline Code* code() const;
inline Kind kind() const;
inline unsigned index() const;
inline Address frame_pointer() const;
......@@ -133,7 +131,6 @@ class StackHandler BASE_EMBEDDED {
private:
inline Object** context_address() const;
inline Object** code_address() const;
inline void SetFp(Address slot, Address fp);
DISALLOW_IMPLICIT_CONSTRUCTORS(StackHandler);
......
......@@ -1026,12 +1026,11 @@ 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 == 5 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0);
STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize);
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.
......@@ -1045,12 +1044,11 @@ void MacroAssembler::PushTryHandler(StackHandler::Kind kind,
push(ebp);
push(esi);
}
// Push the state and the code object.
// Push the state.
unsigned state =
StackHandler::IndexField::encode(handler_index) |
StackHandler::KindField::encode(kind);
push(Immediate(state));
Push(CodeObject());
// Link the current handler as the next handler.
ExternalReference handler_address(Isolate::kHandlerAddress, isolate());
......
......@@ -1076,7 +1076,7 @@ Object* Isolate::FindHandler() {
thread_local_top()->handler_ = handler->next()->address();
// Gather information from the handler.
code = handler->code();
code = frame->LookupCode();
handler_sp = handler->address() + StackHandlerConstants::kSize;
offset = Smi::cast(code->handler_table()->get(0))->value();
break;
......@@ -1091,7 +1091,7 @@ Object* Isolate::FindHandler() {
thread_local_top()->handler_ = handler->next()->address();
// Gather information from the handler.
code = handler->code();
code = frame->LookupCode();
context = handler->context();
offset = Smi::cast(code->handler_table()->get(handler->index()))->value();
handler_sp = handler->address() + StackHandlerConstants::kSize;
......
......@@ -2982,13 +2982,12 @@ 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 == 4 * kPointerSize +
STATIC_ASSERT(StackHandlerConstants::kSize == 3 * kPointerSize +
kFPOnStackSize);
STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0);
STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize);
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.
......@@ -3003,12 +3002,11 @@ void MacroAssembler::PushTryHandler(StackHandler::Kind kind,
Push(rsi);
}
// Push the state and the code object.
// Push the state.
unsigned state =
StackHandler::IndexField::encode(handler_index) |
StackHandler::KindField::encode(kind);
Push(Immediate(state));
Push(CodeObject());
// Link the current handler as the next handler.
ExternalReference handler_address(Isolate::kHandlerAddress, isolate());
......
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