void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) {
- ASSERT(StackHandlerConstants::kSize == 6 * kPointerSize); // adjust this code
+ // Adjust this code if not the case.
+ ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize);
ExternalReference handler_address(Top::k_handler_address);
__ mov(edx, Operand::StaticVariable(handler_address));
- __ mov(ecx, Operand(edx, -1 * kPointerSize)); // get next in chain
+ // Get next in chain.
+ __ mov(ecx, Operand(edx, StackHandlerConstants::kAddressDisplacement));
__ mov(Operand::StaticVariable(handler_address), ecx);
__ mov(esp, Operand(edx));
- __ pop(edi);
__ pop(ebp);
- __ pop(edx); // remove code pointer
- __ pop(edx); // remove state
+ __ pop(edx); // Remove state.
// Before returning we restore the context from the frame pointer if not NULL.
// The frame pointer is NULL in the exception handler of a JS entry frame.
void CEntryStub::GenerateThrowOutOfMemory(MacroAssembler* masm) {
+ // Adjust this code if not the case.
+ ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize);
+
// Fetch top stack handler.
ExternalReference handler_address(Top::k_handler_address);
__ mov(edx, Operand::StaticVariable(handler_address));
__ xor_(esi, Operand(esi));
// Restore registers from handler.
- __ pop(edi); // PP
__ pop(ebp); // FP
- __ pop(edx); // Code
__ pop(edx); // State
__ ret(0);
class StackHandlerConstants : public AllStatic {
public:
static const int kNextOffset = 0 * kPointerSize;
- static const int kPPOffset = 1 * kPointerSize;
- static const int kFPOffset = 2 * kPointerSize;
+ static const int kFPOffset = 1 * kPointerSize;
- // TODO(1233780): Get rid of the code slot in stack handlers.
- static const int kCodeOffset = 3 * kPointerSize;
-
- static const int kStateOffset = 4 * kPointerSize;
- static const int kPCOffset = 5 * kPointerSize;
+ static const int kStateOffset = 2 * kPointerSize;
+ static const int kPCOffset = 3 * kPointerSize;
static const int kAddressDisplacement = -1 * kPointerSize;
static const int kSize = kPCOffset + kPointerSize;
}
-// ----------------------------------------------------
-
-
-
-
- // C Entry frames:
-
- // lower | Stack |
- // addresses | ^ |
- // | | |
- // | |
- // +-------------+
- // | entry_pc |
- // +-------------+ <--+ entry_sp
- // . |
- // . |
- // . |
- // +-------------+ |
- // -3 | entry_sp --+----+
- // e +-------------+
- // n -2 | C function |
- // t +-------------+
- // r -1 | caller_pp |
- // y +-------------+ <--- fp (frame pointer, ebp)
- // 0 | caller_fp |
- // f +-------------+
- // r 1 | caller_pc |
- // a +-------------+ <--- caller_sp (stack pointer, esp)
- // m 2 | |
- // e | arguments |
- // | |
- // +- - - - - - -+
- // | argument0 |
- // +=============+
- // | |
- // | caller |
- // higher | expressions |
- // addresses | |
-
-
- // Proper JS frames:
-
- // lower | Stack |
- // addresses | ^ |
- // | | |
- // | |
- // ----------- +=============+ <--- sp (stack pointer, esp)
- // | function |
- // +-------------+
- // | |
- // | expressions |
- // | |
- // +-------------+
- // a | |
- // c | locals |
- // t | |
- // i +- - - - - - -+ <---
- // v -4 | local0 | ^
- // a +-------------+ |
- // t -3 | code | |
- // i +-------------+ |
- // o -2 | context | | kLocal0Offset
- // n +-------------+ |
- // -1 | caller_pp | v
- // f +-------------+ <--- fp (frame pointer, ebp)
- // r 0 | caller_fp |
- // a +-------------+
- // m 1 | caller_pc |
- // e +-------------+ <--- caller_sp (incl. parameters)
- // 2 | |
- // | parameters |
- // | |
- // +- - - - - - -+ <---
- // -2 | parameter0 | ^
- // +-------------+ | kParam0Offset
- // -1 | receiver | v
- // ----------- +=============+ <--- pp (parameter pointer, edi)
- // 0 | function |
- // +-------------+
- // | |
- // | caller |
- // higher | expressions |
- // addresses | |
-
-
- // JS entry frames: When calling from C to JS, we construct two extra
- // frames: An entry frame (C) and a trampoline frame (JS). The
- // following pictures shows the two frames:
-
- // lower | Stack |
- // addresses | ^ |
- // | | |
- // | |
- // ----------- +=============+ <--- sp (stack pointer, esp)
- // | |
- // | parameters |
- // t | |
- // r +- - - - - - -+
- // a | parameter0 |
- // m +-------------+
- // p | receiver |
- // o +-------------+ <---
- // l | function | ^
- // i +-------------+ |
- // n -3 | code | | kLocal0Offset
- // e +-------------+
- // -2 | NULL | context is always NULL
- // +-------------+
- // f -1 | NULL | caller pp is always NULL for entry frames
- // r +-------------+ <--- fp (frame pointer, ebp)
- // a 0 | caller fp |
- // m +-------------+
- // e 1 | caller pc |
- // +-------------+ <--- caller_sp (incl. parameters)
- // | 0 |
- // ----------- +=============+ <--- pp (parameter pointer, edi)
- // | 0 |
- // +-------------+ <---
- // . ^
- // . | try-handler (HandlerOffsets::kSize)
- // . v
- // +-------------+ <---
- // -5 | next top pp |
- // +-------------+
- // e -4 | next top fp |
- // n +-------------+ <---
- // t -3 | ebx | ^
- // r +-------------+ |
- // y -2 | esi | | callee-saved registers
- // +-------------+ |
- // -1 | edi | v
- // f +-------------+ <--- fp
- // r 0 | caller fp |
- // a +-------------+ pp == NULL (parameter pointer)
- // m 1 | caller pc |
- // e +-------------+ <--- caller sp
- // 2 | code entry | ^
- // +-------------+ |
- // 3 | function | |
- // +-------------+ | arguments passed from C code
- // 4 | receiver | |
- // +-------------+ |
- // 5 | argc | |
- // +-------------+ |
- // 6 | argv | v
- // +-------------+ <---
- // | |
- // higher | |
- // addresses | |
-
-
} } // namespace v8::internal
#endif // V8_IA32_FRAMES_IA32_H_
void MacroAssembler::PushTryHandler(CodeLocation try_location,
HandlerType type) {
- ASSERT(StackHandlerConstants::kSize == 6 * kPointerSize); // adjust this code
+ // Adjust this code if not the case.
+ ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize);
// The pc (return address) is already on TOS.
if (try_location == IN_JAVASCRIPT) {
if (type == TRY_CATCH_HANDLER) {
} else {
push(Immediate(StackHandler::TRY_FINALLY));
}
- push(Immediate(Smi::FromInt(StackHandler::kCodeNotPresent)));
push(ebp);
- push(edi);
} else {
ASSERT(try_location == IN_JS_ENTRY);
// The parameter pointer is meaningless here and ebp does not
// expect the code throwing an exception to check ebp before
// dereferencing it to restore the context.
push(Immediate(StackHandler::ENTRY));
- push(Immediate(Smi::FromInt(StackHandler::kCodeNotPresent)));
push(Immediate(0)); // NULL frame pointer
- push(Immediate(0)); // NULL parameter pointer
}
// Cached TOS.
mov(eax, Operand::StaticVariable(ExternalReference(Top::k_handler_address)));