[everywhere] Custom representation for frame type

Use an opaque format for the frame type marker on the stack, where the
marker is simply shifted left by 1 instead of being a Smi. This allows
us to generate simpler code for frame initialisation, as we can push a
smaller value, decreasing the prologue by 4 bytes and one instruction.

Drive-by: Use the same format for JsFrameMarker.

Change-Id: I812dde9b37869fe20de4148a665d06cf23ce7372
Reviewed-on: https://chromium-review.googlesource.com/443426
Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43347}
This commit is contained in:
Leszek Swirski 2017-02-21 11:21:15 +00:00 committed by Commit Bot
parent c65e620237
commit fd596007f2
39 changed files with 223 additions and 165 deletions

View File

@ -1023,12 +1023,12 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
// r2: receiver
// r3: argc
// r4: argv
int marker = type();
StackFrame::Type marker = type();
if (FLAG_enable_embedded_constant_pool) {
__ mov(r8, Operand::Zero());
}
__ mov(r7, Operand(Smi::FromInt(marker)));
__ mov(r6, Operand(Smi::FromInt(marker)));
__ mov(r7, Operand(StackFrame::TypeToMarker(marker)));
__ mov(r6, Operand(StackFrame::TypeToMarker(marker)));
__ mov(r5,
Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate())));
__ ldr(r5, MemOperand(r5));
@ -1048,11 +1048,11 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
__ cmp(r6, Operand::Zero());
__ b(ne, &non_outermost_js);
__ str(fp, MemOperand(r5));
__ mov(ip, Operand(Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME)));
__ mov(ip, Operand(StackFrame::OUTERMOST_JSENTRY_FRAME));
Label cont;
__ b(&cont);
__ bind(&non_outermost_js);
__ mov(ip, Operand(Smi::FromInt(StackFrame::INNER_JSENTRY_FRAME)));
__ mov(ip, Operand(StackFrame::INNER_JSENTRY_FRAME));
__ bind(&cont);
__ push(ip);
@ -1118,7 +1118,7 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
// Check if the current stack frame is marked as the outermost JS frame.
Label non_outermost_js_2;
__ pop(r5);
__ cmp(r5, Operand(Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME)));
__ cmp(r5, Operand(StackFrame::OUTERMOST_JSENTRY_FRAME));
__ b(ne, &non_outermost_js_2);
__ mov(r6, Operand::Zero());
__ mov(r5, Operand(ExternalReference(js_entry_sp)));

View File

@ -1397,7 +1397,7 @@ void MacroAssembler::LoadConstantPoolPointerRegister() {
}
void MacroAssembler::StubPrologue(StackFrame::Type type) {
mov(ip, Operand(Smi::FromInt(type)));
mov(ip, Operand(StackFrame::TypeToMarker(type)));
PushCommonFrame(ip);
if (FLAG_enable_embedded_constant_pool) {
LoadConstantPoolPointerRegister();
@ -1437,7 +1437,7 @@ void MacroAssembler::EmitLoadFeedbackVector(Register vector) {
void MacroAssembler::EnterFrame(StackFrame::Type type,
bool load_constant_pool_pointer_reg) {
// r0-r3: preserved
mov(ip, Operand(Smi::FromInt(type)));
mov(ip, Operand(StackFrame::TypeToMarker(type)));
PushCommonFrame(ip);
if (FLAG_enable_embedded_constant_pool && load_constant_pool_pointer_reg) {
LoadConstantPoolPointerRegister();
@ -1492,7 +1492,7 @@ void MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space,
DCHECK_EQ(2 * kPointerSize, ExitFrameConstants::kCallerSPDisplacement);
DCHECK_EQ(1 * kPointerSize, ExitFrameConstants::kCallerPCOffset);
DCHECK_EQ(0 * kPointerSize, ExitFrameConstants::kCallerFPOffset);
mov(ip, Operand(Smi::FromInt(frame_type)));
mov(ip, Operand(StackFrame::TypeToMarker(frame_type)));
PushCommonFrame(ip);
// Reserve room for saved entry sp and code object.
sub(sp, fp, Operand(ExitFrameConstants::kFixedFrameSizeFromFp));

View File

@ -1133,10 +1133,10 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
__ Fmov(fp_zero, 0.0);
// Build an entry frame (see layout below).
int marker = type();
StackFrame::Type marker = type();
int64_t bad_frame_pointer = -1L; // Bad frame pointer to fail if it is used.
__ Mov(x13, bad_frame_pointer);
__ Mov(x12, Smi::FromInt(marker));
__ Mov(x12, StackFrame::TypeToMarker(marker));
__ Mov(x11, ExternalReference(Isolate::kCEntryFPAddress, isolate()));
__ Ldr(x10, MemOperand(x11));
@ -1152,12 +1152,12 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
__ Ldr(x11, MemOperand(x10));
__ Cbnz(x11, &non_outermost_js);
__ Str(fp, MemOperand(x10));
__ Mov(x12, Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME));
__ Mov(x12, StackFrame::OUTERMOST_JSENTRY_FRAME);
__ Push(x12);
__ B(&done);
__ Bind(&non_outermost_js);
// We spare one instruction by pushing xzr since the marker is 0.
DCHECK(Smi::FromInt(StackFrame::INNER_JSENTRY_FRAME) == NULL);
DCHECK(StackFrame::INNER_JSENTRY_FRAME == 0);
__ Push(xzr);
__ Bind(&done);
@ -1239,7 +1239,7 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
// Check if the current stack frame is marked as the outermost JS frame.
Label non_outermost_js_2;
__ Pop(x10);
__ Cmp(x10, Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME));
__ Cmp(x10, StackFrame::OUTERMOST_JSENTRY_FRAME);
__ B(ne, &non_outermost_js_2);
__ Mov(x11, ExternalReference(js_entry_sp));
__ Str(xzr, MemOperand(x11));

View File

@ -2601,7 +2601,7 @@ void MacroAssembler::StubPrologue(StackFrame::Type type, int frame_slots) {
UseScratchRegisterScope temps(this);
frame_slots -= TypedFrameConstants::kFixedSlotCountAboveFp;
Register temp = temps.AcquireX();
Mov(temp, Smi::FromInt(type));
Mov(temp, StackFrame::TypeToMarker(type));
Push(lr, fp);
Mov(fp, StackPointer());
Claim(frame_slots);
@ -2638,7 +2638,7 @@ void MacroAssembler::EnterFrame(StackFrame::Type type) {
if (type == StackFrame::INTERNAL) {
DCHECK(jssp.Is(StackPointer()));
Mov(type_reg, Smi::FromInt(type));
Mov(type_reg, StackFrame::TypeToMarker(type));
Push(lr, fp);
Push(type_reg);
Mov(code_reg, Operand(CodeObject()));
@ -2650,7 +2650,7 @@ void MacroAssembler::EnterFrame(StackFrame::Type type) {
// jssp[0] : [code object]
} else if (type == StackFrame::WASM_COMPILED) {
DCHECK(csp.Is(StackPointer()));
Mov(type_reg, Smi::FromInt(type));
Mov(type_reg, StackFrame::TypeToMarker(type));
Push(lr, fp);
Mov(fp, csp);
Push(type_reg, xzr);
@ -2660,7 +2660,7 @@ void MacroAssembler::EnterFrame(StackFrame::Type type) {
// csp[0] : for alignment
} else {
DCHECK(jssp.Is(StackPointer()));
Mov(type_reg, Smi::FromInt(type));
Mov(type_reg, StackFrame::TypeToMarker(type));
Push(lr, fp);
Push(type_reg);
Add(fp, jssp, TypedFrameConstants::kFixedFrameSizeFromFp);
@ -2731,7 +2731,7 @@ void MacroAssembler::EnterExitFrame(bool save_doubles, const Register& scratch,
// Set up the new stack frame.
Push(lr, fp);
Mov(fp, StackPointer());
Mov(scratch, Smi::FromInt(frame_type));
Mov(scratch, StackFrame::TypeToMarker(frame_type));
Push(scratch);
Push(xzr);
Mov(scratch, Operand(CodeObject()));

View File

@ -2106,7 +2106,7 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) {
__ SmiTag(r0);
__ mov(r4, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
__ mov(r4, Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ stm(db_w, sp, r0.bit() | r1.bit() | r4.bit() |
(FLAG_enable_embedded_constant_pool ? pp.bit() : 0) |
fp.bit() | lr.bit());
@ -2288,7 +2288,7 @@ void Builtins::Generate_CallForwardVarargs(MacroAssembler* masm,
Label arguments_adaptor, arguments_done;
__ ldr(r3, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ ldr(ip, MemOperand(r3, CommonFrameConstants::kContextOrFrameTypeOffset));
__ cmp(ip, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
__ cmp(ip, Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ b(eq, &arguments_adaptor);
{
__ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
@ -2390,7 +2390,7 @@ void PrepareForTailCall(MacroAssembler* masm, Register args_reg,
Label no_interpreter_frame;
__ ldr(scratch3,
MemOperand(fp, CommonFrameConstants::kContextOrFrameTypeOffset));
__ cmp(scratch3, Operand(Smi::FromInt(StackFrame::STUB)));
__ cmp(scratch3, Operand(StackFrame::TypeToMarker(StackFrame::STUB)));
__ b(ne, &no_interpreter_frame);
__ ldr(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ bind(&no_interpreter_frame);
@ -2402,7 +2402,8 @@ void PrepareForTailCall(MacroAssembler* masm, Register args_reg,
__ ldr(scratch2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ ldr(scratch3,
MemOperand(scratch2, CommonFrameConstants::kContextOrFrameTypeOffset));
__ cmp(scratch3, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
__ cmp(scratch3,
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ b(ne, &no_arguments_adaptor);
// Drop current frame and load arguments count from arguments adaptor frame.

View File

@ -2161,7 +2161,7 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) {
__ SmiTag(x10, x0);
__ Mov(x11, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
__ Mov(x11, StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR));
__ Push(lr, fp);
__ Push(x11, x1, x10);
__ Add(fp, jssp,
@ -2373,7 +2373,7 @@ void Builtins::Generate_CallForwardVarargs(MacroAssembler* masm,
Label arguments_adaptor, arguments_done;
__ Ldr(x3, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ Ldr(x4, MemOperand(x3, CommonFrameConstants::kContextOrFrameTypeOffset));
__ Cmp(x4, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
__ Cmp(x4, StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR));
__ B(eq, &arguments_adaptor);
{
__ Ldr(x0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
@ -2475,7 +2475,7 @@ void PrepareForTailCall(MacroAssembler* masm, Register args_reg,
Label no_interpreter_frame;
__ Ldr(scratch3,
MemOperand(fp, CommonFrameConstants::kContextOrFrameTypeOffset));
__ Cmp(scratch3, Operand(Smi::FromInt(StackFrame::STUB)));
__ Cmp(scratch3, Operand(StackFrame::TypeToMarker(StackFrame::STUB)));
__ B(ne, &no_interpreter_frame);
__ Ldr(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ bind(&no_interpreter_frame);
@ -2487,7 +2487,8 @@ void PrepareForTailCall(MacroAssembler* masm, Register args_reg,
__ Ldr(scratch2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ Ldr(scratch3,
MemOperand(scratch2, CommonFrameConstants::kContextOrFrameTypeOffset));
__ Cmp(scratch3, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
__ Cmp(scratch3,
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ B(ne, &no_arguments_adaptor);
// Drop current frame and load arguments count from arguments adaptor frame.

View File

@ -42,9 +42,9 @@ ArgumentsBuiltinsAssembler::GetArgumentsFrameAndCount(Node* function,
argument_count.Bind(formal_parameter_count);
Node* marker_or_function = LoadBufferObject(
frame_ptr_above, CommonFrameConstants::kContextOrFrameTypeOffset);
GotoIf(SmiNotEqual(marker_or_function,
SmiConstant(StackFrame::ARGUMENTS_ADAPTOR)),
&done_argument_count);
GotoIf(
MarkerIsNotFrameType(marker_or_function, StackFrame::ARGUMENTS_ADAPTOR),
&done_argument_count);
Node* adapted_parameter_count = LoadBufferObject(
frame_ptr_above, ArgumentsAdaptorFrameConstants::kLengthOffset);
frame_ptr.Bind(frame_ptr_above);

View File

@ -247,11 +247,9 @@ void Builtins::Generate_NewUnmappedArgumentsElements(
assembler.Load(MachineType::AnyTagged(), parent_frame,
assembler.IntPtrConstant(
CommonFrameConstants::kContextOrFrameTypeOffset));
assembler.GotoIfNot(
assembler.WordEqual(
parent_frame_type,
assembler.SmiConstant(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))),
&done);
assembler.GotoIfNot(assembler.MarkerIsFrameType(
parent_frame_type, StackFrame::ARGUMENTS_ADAPTOR),
&done);
{
// Determine the length from the ArgumentsAdaptorFrame.
Node* length = assembler.LoadAndUntagSmi(
@ -290,8 +288,7 @@ void Builtins::Generate_NewRestParameterElements(
assembler.IntPtrConstant(
CommonFrameConstants::kContextOrFrameTypeOffset));
assembler.GotoIfNot(
assembler.WordEqual(frame_type, assembler.SmiConstant(Smi::FromInt(
StackFrame::ARGUMENTS_ADAPTOR))),
assembler.MarkerIsFrameType(frame_type, StackFrame::ARGUMENTS_ADAPTOR),
&if_empty);
// Determine the length from the ArgumentsAdaptorFrame.

View File

@ -2134,7 +2134,7 @@ static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) {
__ mov(ebp, esp);
// Store the arguments adaptor context sentinel.
__ push(Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
__ push(Immediate(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
// Push the function on the stack.
__ push(edi);
@ -2332,7 +2332,7 @@ void Builtins::Generate_CallForwardVarargs(MacroAssembler* masm,
Label arguments_adaptor, arguments_done;
__ mov(ebx, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
__ cmp(Operand(ebx, CommonFrameConstants::kContextOrFrameTypeOffset),
Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
Immediate(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ j(equal, &arguments_adaptor, Label::kNear);
{
__ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
@ -2448,7 +2448,7 @@ void PrepareForTailCall(MacroAssembler* masm, Register args_reg,
{
Label no_interpreter_frame;
__ cmp(Operand(ebp, CommonFrameConstants::kContextOrFrameTypeOffset),
Immediate(Smi::FromInt(StackFrame::STUB)));
Immediate(StackFrame::TypeToMarker(StackFrame::STUB)));
__ j(not_equal, &no_interpreter_frame, Label::kNear);
__ mov(ebp, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
__ bind(&no_interpreter_frame);
@ -2459,7 +2459,7 @@ void PrepareForTailCall(MacroAssembler* masm, Register args_reg,
Label no_arguments_adaptor, formal_parameter_count_loaded;
__ mov(scratch2, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
__ cmp(Operand(scratch2, CommonFrameConstants::kContextOrFrameTypeOffset),
Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
Immediate(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ j(not_equal, &no_arguments_adaptor, Label::kNear);
// Drop current frame and load arguments count from arguments adaptor frame.

View File

@ -2133,7 +2133,7 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) {
__ sll(a0, a0, kSmiTagSize);
__ li(t0, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
__ li(t0, Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ MultiPush(a0.bit() | a1.bit() | t0.bit() | fp.bit() | ra.bit());
__ Addu(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp +
kPointerSize));
@ -2310,7 +2310,7 @@ void Builtins::Generate_CallForwardVarargs(MacroAssembler* masm,
__ lw(a3, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ lw(a0, MemOperand(a3, CommonFrameConstants::kContextOrFrameTypeOffset));
__ Branch(&arguments_adaptor, eq, a0,
Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
{
__ lw(a0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
__ lw(a0, FieldMemOperand(a0, JSFunction::kSharedFunctionInfoOffset));
@ -2411,7 +2411,7 @@ void PrepareForTailCall(MacroAssembler* masm, Register args_reg,
__ lw(scratch3,
MemOperand(fp, CommonFrameConstants::kContextOrFrameTypeOffset));
__ Branch(&no_interpreter_frame, ne, scratch3,
Operand(Smi::FromInt(StackFrame::STUB)));
Operand(StackFrame::TypeToMarker(StackFrame::STUB)));
__ lw(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ bind(&no_interpreter_frame);
}
@ -2423,7 +2423,7 @@ void PrepareForTailCall(MacroAssembler* masm, Register args_reg,
__ lw(scratch3,
MemOperand(scratch2, CommonFrameConstants::kContextOrFrameTypeOffset));
__ Branch(&no_arguments_adaptor, ne, scratch3,
Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
// Drop current frame and load arguments count from arguments adaptor frame.
__ mov(fp, scratch2);

View File

@ -2138,7 +2138,7 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) {
// __ sll(a0, a0, kSmiTagSize);
__ dsll32(a0, a0, 0);
__ li(a4, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
__ li(a4, Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ MultiPush(a0.bit() | a1.bit() | a4.bit() | fp.bit() | ra.bit());
__ Daddu(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp +
kPointerSize));
@ -2341,7 +2341,7 @@ void Builtins::Generate_CallForwardVarargs(MacroAssembler* masm,
__ ld(a3, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ ld(a0, MemOperand(a3, CommonFrameConstants::kContextOrFrameTypeOffset));
__ Branch(&arguments_adaptor, eq, a0,
Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
{
__ ld(a0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
__ ld(a0, FieldMemOperand(a0, JSFunction::kSharedFunctionInfoOffset));
@ -2442,7 +2442,7 @@ void PrepareForTailCall(MacroAssembler* masm, Register args_reg,
__ ld(scratch3,
MemOperand(fp, CommonFrameConstants::kContextOrFrameTypeOffset));
__ Branch(&no_interpreter_frame, ne, scratch3,
Operand(Smi::FromInt(StackFrame::STUB)));
Operand(StackFrame::TypeToMarker(StackFrame::STUB)));
__ ld(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ bind(&no_interpreter_frame);
}
@ -2454,7 +2454,7 @@ void PrepareForTailCall(MacroAssembler* masm, Register args_reg,
__ ld(scratch3,
MemOperand(scratch2, CommonFrameConstants::kContextOrFrameTypeOffset));
__ Branch(&no_arguments_adaptor, ne, scratch3,
Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
// Drop current frame and load arguments count from arguments adaptor frame.
__ mov(fp, scratch2);

View File

@ -2081,7 +2081,7 @@ static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) {
__ movp(rbp, rsp);
// Store the arguments adaptor context sentinel.
__ Push(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
__ Push(Immediate(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
// Push the function on the stack.
__ Push(rdi);
@ -2414,8 +2414,8 @@ void Builtins::Generate_CallForwardVarargs(MacroAssembler* masm,
// Check if we have an arguments adaptor frame below the function frame.
Label arguments_adaptor, arguments_done;
__ movp(rbx, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
__ Cmp(Operand(rbx, CommonFrameConstants::kContextOrFrameTypeOffset),
Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
__ cmpp(Operand(rbx, CommonFrameConstants::kContextOrFrameTypeOffset),
Immediate(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ j(equal, &arguments_adaptor, Label::kNear);
{
__ movp(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
@ -2515,8 +2515,8 @@ void PrepareForTailCall(MacroAssembler* masm, Register args_reg,
// Drop possible interpreter handler/stub frame.
{
Label no_interpreter_frame;
__ Cmp(Operand(rbp, CommonFrameConstants::kContextOrFrameTypeOffset),
Smi::FromInt(StackFrame::STUB));
__ cmpp(Operand(rbp, CommonFrameConstants::kContextOrFrameTypeOffset),
Immediate(StackFrame::TypeToMarker(StackFrame::STUB)));
__ j(not_equal, &no_interpreter_frame, Label::kNear);
__ movp(rbp, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
__ bind(&no_interpreter_frame);
@ -2526,8 +2526,8 @@ void PrepareForTailCall(MacroAssembler* masm, Register args_reg,
Register caller_args_count_reg = scratch1;
Label no_arguments_adaptor, formal_parameter_count_loaded;
__ movp(scratch2, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
__ Cmp(Operand(scratch2, CommonFrameConstants::kContextOrFrameTypeOffset),
Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
__ cmpp(Operand(scratch2, CommonFrameConstants::kContextOrFrameTypeOffset),
Immediate(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ j(not_equal, &no_arguments_adaptor, Label::kNear);
// Drop current frame and load arguments count from arguments adaptor frame.

View File

@ -8344,6 +8344,20 @@ Node* CodeStubAssembler::AllocatePromiseReactionJobInfo(
return result;
}
Node* CodeStubAssembler::MarkerIsFrameType(Node* marker_or_function,
StackFrame::Type frame_type) {
return WordEqual(
marker_or_function,
IntPtrConstant(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
}
Node* CodeStubAssembler::MarkerIsNotFrameType(Node* marker_or_function,
StackFrame::Type frame_type) {
return WordNotEqual(
marker_or_function,
IntPtrConstant(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
}
void CodeStubAssembler::Print(const char* s) {
#ifdef DEBUG
std::string formatted(s);

View File

@ -1237,6 +1237,12 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
Node* deferred_on_resolve,
Node* deferred_on_reject, Node* context);
// Helpers for StackFrame markers.
Node* MarkerIsFrameType(Node* marker_or_function,
StackFrame::Type frame_type);
Node* MarkerIsNotFrameType(Node* marker_or_function,
StackFrame::Type frame_type);
// Support for printf-style debugging
void Print(const char* s);
void Print(const char* prefix, Node* tagged_value);

View File

@ -474,7 +474,8 @@ void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg,
// Check if current frame is an arguments adaptor frame.
__ ldr(scratch1, MemOperand(fp, StandardFrameConstants::kContextOffset));
__ cmp(scratch1, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
__ cmp(scratch1,
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ b(ne, &done);
// Load arguments count from current arguments adaptor frame (note, it

View File

@ -570,7 +570,8 @@ void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg,
// Check if current frame is an arguments adaptor frame.
__ Ldr(scratch1, MemOperand(fp, StandardFrameConstants::kContextOffset));
__ Cmp(scratch1, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
__ Cmp(scratch1,
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ B(ne, &done);
// Load arguments count from current arguments adaptor frame (note, it
@ -1903,7 +1904,7 @@ void CodeGenerator::AssembleConstructFrame() {
if (is_stub_frame) {
UseScratchRegisterScope temps(masm());
Register temp = temps.AcquireX();
__ Mov(temp, Smi::FromInt(info()->GetOutputStackFrameType()));
__ Mov(temp, StackFrame::TypeToMarker(info()->GetOutputStackFrameType()));
__ Str(temp, MemOperand(fp, TypedFrameConstants::kFrameTypeOffset));
}
}

View File

@ -786,7 +786,7 @@ void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg,
// Check if current frame is an arguments adaptor frame.
__ cmp(Operand(ebp, StandardFrameConstants::kContextOffset),
Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
Immediate(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ j(not_equal, &done, Label::kNear);
__ push(scratch1);

View File

@ -562,7 +562,7 @@ void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg,
// Check if current frame is an arguments adaptor frame.
__ lw(scratch1, MemOperand(fp, StandardFrameConstants::kContextOffset));
__ Branch(&done, ne, scratch1,
Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
// Load arguments count from current arguments adaptor frame (note, it
// does not include receiver).

View File

@ -599,7 +599,7 @@ void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg,
// Check if current frame is an arguments adaptor frame.
__ ld(scratch3, MemOperand(fp, StandardFrameConstants::kContextOffset));
__ Branch(&done, ne, scratch3,
Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
// Load arguments count from current arguments adaptor frame (note, it
// does not include receiver).

View File

@ -724,8 +724,8 @@ void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg,
Label done;
// Check if current frame is an arguments adaptor frame.
__ Cmp(Operand(rbp, StandardFrameConstants::kContextOffset),
Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
__ cmpp(Operand(rbp, CommonFrameConstants::kContextOrFrameTypeOffset),
Immediate(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ j(not_equal, &done, Label::kNear);
// Load arguments count from current arguments adaptor frame (note, it

View File

@ -270,7 +270,7 @@ bool LCodeGen::GenerateDeferredCode() {
DCHECK(!frame_is_built_);
DCHECK(info()->IsStub());
frame_is_built_ = true;
__ Move(scratch0(), Smi::FromInt(StackFrame::STUB));
__ mov(scratch0(), Operand(StackFrame::TypeToMarker(StackFrame::STUB)));
__ PushCommonFrame(scratch0());
Comment(";;; Deferred code");
}
@ -344,7 +344,7 @@ bool LCodeGen::GenerateJumpTable() {
// This variant of deopt can only be used with stubs. Since we don't
// have a function pointer to install in the stack frame that we're
// building, install a special marker there instead.
__ mov(ip, Operand(Smi::FromInt(StackFrame::STUB)));
__ mov(ip, Operand(StackFrame::TypeToMarker(StackFrame::STUB)));
__ push(ip);
DCHECK(info()->IsStub());
}
@ -2935,7 +2935,8 @@ void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) {
__ ldr(scratch, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ ldr(result, MemOperand(scratch,
CommonFrameConstants::kContextOrFrameTypeOffset));
__ cmp(result, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
__ cmp(result,
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
// Result is the frame pointer for the frame if not adapted and for the real
// frame below the adaptor frame if adapted.
@ -3499,7 +3500,8 @@ void LCodeGen::PrepareForTailCall(const ParameterCount& actual,
__ ldr(scratch2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ ldr(scratch3,
MemOperand(scratch2, StandardFrameConstants::kContextOffset));
__ cmp(scratch3, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
__ cmp(scratch3,
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ b(ne, &no_arguments_adaptor);
// Drop current frame and load arguments count from arguments adaptor frame.

View File

@ -724,7 +724,7 @@ bool LCodeGen::GenerateDeferredCode() {
DCHECK(info()->IsStub());
frame_is_built_ = true;
__ Push(lr, fp);
__ Mov(fp, Smi::FromInt(StackFrame::STUB));
__ Mov(fp, StackFrame::TypeToMarker(StackFrame::STUB));
__ Push(fp);
__ Add(fp, __ StackPointer(),
TypedFrameConstants::kFixedFrameSizeFromFp);
@ -803,7 +803,7 @@ bool LCodeGen::GenerateJumpTable() {
UseScratchRegisterScope temps(masm());
Register stub_marker = temps.AcquireX();
__ Bind(&needs_frame);
__ Mov(stub_marker, Smi::FromInt(StackFrame::STUB));
__ Mov(stub_marker, StackFrame::TypeToMarker(StackFrame::STUB));
__ Push(cp, stub_marker);
__ Add(fp, __ StackPointer(), 2 * kPointerSize);
}
@ -1618,7 +1618,7 @@ void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) {
MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ Ldr(result, MemOperand(previous_fp,
CommonFrameConstants::kContextOrFrameTypeOffset));
__ Cmp(result, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
__ Cmp(result, StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR));
__ Csel(result, fp, previous_fp, ne);
} else {
__ Mov(result, fp);
@ -2840,7 +2840,8 @@ void LCodeGen::PrepareForTailCall(const ParameterCount& actual,
__ Ldr(scratch2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ Ldr(scratch3,
MemOperand(scratch2, StandardFrameConstants::kContextOffset));
__ Cmp(scratch3, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
__ Cmp(scratch3,
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ B(ne, &no_arguments_adaptor);
// Drop current frame and load arguments count from arguments adaptor frame.

View File

@ -309,7 +309,7 @@ bool LCodeGen::GenerateJumpTable() {
// building, install a special marker there instead.
DCHECK(info()->IsStub());
__ mov(MemOperand(esp, 2 * kPointerSize),
Immediate(Smi::FromInt(StackFrame::STUB)));
Immediate(StackFrame::TypeToMarker(StackFrame::STUB)));
/* stack layout
3: old ebp
@ -346,7 +346,7 @@ bool LCodeGen::GenerateDeferredCode() {
frame_is_built_ = true;
// Build the frame in such a way that esi isn't trashed.
__ push(ebp); // Caller's frame pointer.
__ push(Immediate(Smi::FromInt(StackFrame::STUB)));
__ push(Immediate(StackFrame::TypeToMarker(StackFrame::STUB)));
__ lea(ebp, Operand(esp, TypedFrameConstants::kFixedFrameSizeFromFp));
Comment(";;; Deferred code");
}
@ -2690,7 +2690,7 @@ void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) {
__ mov(result,
Operand(result, CommonFrameConstants::kContextOrFrameTypeOffset));
__ cmp(Operand(result),
Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
Immediate(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ j(equal, &adapted, Label::kNear);
// No arguments adaptor frame.
@ -3392,7 +3392,7 @@ void LCodeGen::PrepareForTailCall(const ParameterCount& actual,
Label no_arguments_adaptor, formal_parameter_count_loaded;
__ mov(scratch2, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
__ cmp(Operand(scratch2, StandardFrameConstants::kContextOffset),
Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
Immediate(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ j(not_equal, &no_arguments_adaptor, Label::kNear);
// Drop current frame and load arguments count from arguments adaptor frame.

View File

@ -303,7 +303,7 @@ bool LCodeGen::GenerateDeferredCode() {
DCHECK(!frame_is_built_);
DCHECK(info()->IsStub());
frame_is_built_ = true;
__ li(scratch0(), Operand(Smi::FromInt(StackFrame::STUB)));
__ li(scratch0(), Operand(StackFrame::TypeToMarker(StackFrame::STUB)));
__ PushCommonFrame(scratch0());
Comment(";;; Deferred code");
}
@ -362,7 +362,7 @@ bool LCodeGen::GenerateJumpTable() {
// This variant of deopt can only be used with stubs. Since we don't
// have a function pointer to install in the stack frame that we're
// building, install a special marker there instead.
__ li(at, Operand(Smi::FromInt(StackFrame::STUB)));
__ li(at, Operand(StackFrame::TypeToMarker(StackFrame::STUB)));
__ push(at);
DCHECK(info()->IsStub());
}
@ -2866,7 +2866,8 @@ void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) {
__ lw(scratch, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ lw(result,
MemOperand(scratch, CommonFrameConstants::kContextOrFrameTypeOffset));
__ Xor(temp, result, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
__ Xor(temp, result,
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
// Result is the frame pointer for the frame if not adapted and for the real
// frame below the adaptor frame if adapted.
@ -3478,7 +3479,7 @@ void LCodeGen::PrepareForTailCall(const ParameterCount& actual,
__ lw(scratch2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ lw(scratch3, MemOperand(scratch2, StandardFrameConstants::kContextOffset));
__ Branch(&no_arguments_adaptor, ne, scratch3,
Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
// Drop current frame and load arguments count from arguments adaptor frame.
__ mov(fp, scratch2);

View File

@ -279,7 +279,7 @@ bool LCodeGen::GenerateDeferredCode() {
DCHECK(!frame_is_built_);
DCHECK(info()->IsStub());
frame_is_built_ = true;
__ li(scratch0(), Operand(Smi::FromInt(StackFrame::STUB)));
__ li(scratch0(), Operand(StackFrame::TypeToMarker(StackFrame::STUB)));
__ PushCommonFrame(scratch0());
Comment(";;; Deferred code");
}
@ -347,7 +347,7 @@ bool LCodeGen::GenerateJumpTable() {
// This variant of deopt can only be used with stubs. Since we don't
// have a function pointer to install in the stack frame that we're
// building, install a special marker there instead.
__ li(at, Operand(Smi::FromInt(StackFrame::STUB)));
__ li(at, Operand(StackFrame::TypeToMarker(StackFrame::STUB)));
__ push(at);
DCHECK(info()->IsStub());
}
@ -3048,7 +3048,8 @@ void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) {
__ ld(scratch, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ ld(result,
MemOperand(scratch, CommonFrameConstants::kContextOrFrameTypeOffset));
__ Xor(temp, result, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
__ Xor(temp, result,
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
// Result is the frame pointer for the frame if not adapted and for the real
// frame below the adaptor frame if adapted.
@ -3684,7 +3685,7 @@ void LCodeGen::PrepareForTailCall(const ParameterCount& actual,
__ ld(scratch2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ ld(scratch3, MemOperand(scratch2, StandardFrameConstants::kContextOffset));
__ Branch(&no_arguments_adaptor, ne, scratch3,
Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
// Drop current frame and load arguments count from arguments adaptor frame.
__ mov(fp, scratch2);

View File

@ -337,7 +337,8 @@ bool LCodeGen::GenerateJumpTable() {
// have a function pointer to install in the stack frame that we're
// building, install a special marker there instead.
DCHECK(info()->IsStub());
__ Move(MemOperand(rsp, 2 * kPointerSize), Smi::FromInt(StackFrame::STUB));
__ movp(MemOperand(rsp, 2 * kPointerSize),
Immediate(StackFrame::TypeToMarker(StackFrame::STUB)));
/* stack layout
3: old rbp
@ -375,7 +376,7 @@ bool LCodeGen::GenerateDeferredCode() {
frame_is_built_ = true;
// Build the frame in such a way that esi isn't trashed.
__ pushq(rbp); // Caller's frame pointer.
__ Push(Smi::FromInt(StackFrame::STUB));
__ Push(Immediate(StackFrame::TypeToMarker(StackFrame::STUB)));
__ leap(rbp, Operand(rsp, TypedFrameConstants::kFixedFrameSizeFromFp));
Comment(";;; Deferred code");
}
@ -2881,8 +2882,8 @@ void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) {
// Check for arguments adapter frame.
Label done, adapted;
__ movp(result, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
__ Cmp(Operand(result, CommonFrameConstants::kContextOrFrameTypeOffset),
Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
__ cmpp(Operand(result, CommonFrameConstants::kContextOrFrameTypeOffset),
Immediate(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ j(equal, &adapted, Label::kNear);
// No arguments adaptor frame.
@ -3557,8 +3558,8 @@ void LCodeGen::PrepareForTailCall(const ParameterCount& actual,
Register caller_args_count_reg = scratch1;
Label no_arguments_adaptor, formal_parameter_count_loaded;
__ movp(scratch2, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
__ Cmp(Operand(scratch2, StandardFrameConstants::kContextOffset),
Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
__ cmpp(Operand(scratch2, CommonFrameConstants::kContextOrFrameTypeOffset),
Immediate(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ j(not_equal, &no_arguments_adaptor, Label::kNear);
// Drop current frame and load arguments count from arguments adaptor frame.

View File

@ -1396,8 +1396,7 @@ void Deoptimizer::DoComputeArgumentsAdaptorFrame(
// A marker value is used in place of the context.
output_offset -= kPointerSize;
intptr_t context = reinterpret_cast<intptr_t>(
Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
intptr_t context = StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR);
output_frame->SetFrameSlot(output_offset, context);
DebugPrintOutputSlot(context, frame_index, output_offset,
"context (adaptor sentinel)\n");
@ -1453,8 +1452,8 @@ void Deoptimizer::DoComputeTailCallerFrame(TranslatedFrame* translated_frame,
Address adaptor_fp_address =
Memory::Address_at(fp_address + CommonFrameConstants::kCallerFPOffset);
if (Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR) !=
Memory::Object_at(adaptor_fp_address +
if (StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR) !=
Memory::intptr_at(adaptor_fp_address +
CommonFrameConstants::kContextOrFrameTypeOffset)) {
return;
}
@ -1593,7 +1592,7 @@ void Deoptimizer::DoComputeConstructStubFrame(TranslatedFrame* translated_frame,
// A marker value is used to mark the frame.
output_offset -= kPointerSize;
value = reinterpret_cast<intptr_t>(Smi::FromInt(StackFrame::CONSTRUCT));
value = StackFrame::TypeToMarker(StackFrame::CONSTRUCT);
output_frame->SetFrameSlot(output_offset, value);
DebugPrintOutputSlot(value, frame_index, output_offset,
"typed frame marker\n");
@ -1780,7 +1779,7 @@ void Deoptimizer::DoComputeAccessorStubFrame(TranslatedFrame* translated_frame,
// Set the frame type.
output_offset -= kPointerSize;
value = reinterpret_cast<intptr_t>(Smi::FromInt(StackFrame::INTERNAL));
value = StackFrame::TypeToMarker(StackFrame::INTERNAL);
output_frame->SetFrameSlot(output_offset, value);
DebugPrintOutputSlot(value, frame_index, output_offset, "frame type ");
if (trace_scope_ != nullptr) {
@ -1977,8 +1976,7 @@ void Deoptimizer::DoComputeCompiledStubFrame(TranslatedFrame* translated_frame,
// The marker for the typed stack frame
output_frame_offset -= kPointerSize;
value = reinterpret_cast<intptr_t>(
Smi::FromInt(StackFrame::STUB_FAILURE_TRAMPOLINE));
value = StackFrame::TypeToMarker(StackFrame::STUB_FAILURE_TRAMPOLINE);
output_frame->SetFrameSlot(output_frame_offset, value);
DebugPrintOutputSlot(value, frame_index, output_frame_offset,
"function (stub failure sentinel)\n");

View File

@ -166,16 +166,16 @@ inline Address StandardFrame::ComputeConstantPoolAddress(Address fp) {
inline bool StandardFrame::IsArgumentsAdaptorFrame(Address fp) {
Object* frame_type =
Memory::Object_at(fp + TypedFrameConstants::kFrameTypeOffset);
return frame_type == Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR);
intptr_t frame_type =
Memory::intptr_at(fp + TypedFrameConstants::kFrameTypeOffset);
return frame_type == StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR);
}
inline bool StandardFrame::IsConstructFrame(Address fp) {
Object* frame_type =
Memory::Object_at(fp + TypedFrameConstants::kFrameTypeOffset);
return frame_type == Smi::FromInt(StackFrame::CONSTRUCT);
intptr_t frame_type =
Memory::intptr_at(fp + TypedFrameConstants::kFrameTypeOffset);
return frame_type == StackFrame::TypeToMarker(StackFrame::CONSTRUCT);
}
inline JavaScriptFrame::JavaScriptFrame(StackFrameIteratorBase* iterator)

View File

@ -437,7 +437,7 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator,
MSAN_MEMORY_IS_INITIALIZED(
state->fp + CommonFrameConstants::kContextOrFrameTypeOffset,
kPointerSize);
Object* marker = Memory::Object_at(
intptr_t marker = Memory::intptr_at(
state->fp + CommonFrameConstants::kContextOrFrameTypeOffset);
if (!iterator->can_access_heap_objects_) {
// TODO(titzer): "can_access_heap_objects" is kind of bogus. It really
@ -449,7 +449,7 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator,
state->fp + StandardFrameConstants::kFunctionOffset, kPointerSize);
Object* maybe_function =
Memory::Object_at(state->fp + StandardFrameConstants::kFunctionOffset);
if (!marker->IsSmi()) {
if (!StackFrame::IsTypeMarker(marker)) {
if (maybe_function->IsSmi()) {
return NONE;
} else if (IsInterpreterFramePc(iterator->isolate(),
@ -466,7 +466,7 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator,
if (code_obj != nullptr) {
switch (code_obj->kind()) {
case Code::BUILTIN:
if (marker->IsSmi()) break;
if (StackFrame::IsTypeMarker(marker)) break;
if (code_obj->is_interpreter_trampoline_builtin()) {
return INTERPRETED;
}
@ -499,9 +499,8 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator,
}
}
DCHECK(marker->IsSmi());
StackFrame::Type candidate =
static_cast<StackFrame::Type>(Smi::cast(marker)->value());
DCHECK(StackFrame::IsTypeMarker(marker));
StackFrame::Type candidate = StackFrame::MarkerToType(marker);
switch (candidate) {
case ENTRY:
case ENTRY_CONSTRUCT:
@ -636,8 +635,9 @@ StackFrame::Type ExitFrame::ComputeFrameType(Address fp) {
return EXIT;
}
StackFrame::Type frame_type =
static_cast<StackFrame::Type>(Smi::cast(marker)->value());
intptr_t marker_int = bit_cast<intptr_t>(marker);
StackFrame::Type frame_type = static_cast<StackFrame::Type>(marker_int >> 1);
if (frame_type == EXIT || frame_type == BUILTIN_EXIT) {
return frame_type;
}
@ -797,11 +797,10 @@ void StandardFrame::IterateCompiledFrame(ObjectVisitor* v) const {
// Determine the fixed header and spill slot area size.
int frame_header_size = StandardFrameConstants::kFixedFrameSizeFromFp;
Object* marker =
Memory::Object_at(fp() + CommonFrameConstants::kContextOrFrameTypeOffset);
if (marker->IsSmi()) {
StackFrame::Type candidate =
static_cast<StackFrame::Type>(Smi::cast(marker)->value());
intptr_t marker =
Memory::intptr_at(fp() + CommonFrameConstants::kContextOrFrameTypeOffset);
if (StackFrame::IsTypeMarker(marker)) {
StackFrame::Type candidate = StackFrame::MarkerToType(marker);
switch (candidate) {
case ENTRY:
case ENTRY_CONSTRUCT:

View File

@ -437,10 +437,16 @@ class StackFrame BASE_EMBEDDED {
};
// Used to mark the outermost JS entry frame.
//
// The mark is an opaque value that should be pushed onto the stack directly,
// carefully crafted to not be interpreted as a tagged pointer.
enum JsFrameMarker {
INNER_JSENTRY_FRAME = 0,
OUTERMOST_JSENTRY_FRAME = 1
INNER_JSENTRY_FRAME = (0 << kSmiTagSize) | kSmiTag,
OUTERMOST_JSENTRY_FRAME = (1 << kSmiTagSize) | kSmiTag
};
STATIC_ASSERT((INNER_JSENTRY_FRAME & kHeapObjectTagMask) != kHeapObjectTag);
STATIC_ASSERT((OUTERMOST_JSENTRY_FRAME & kHeapObjectTagMask) !=
kHeapObjectTag);
struct State {
Address sp = nullptr;
@ -450,6 +456,40 @@ class StackFrame BASE_EMBEDDED {
Address* constant_pool_address = nullptr;
};
// Convert a stack frame type to a marker that can be stored on the stack.
//
// The marker is an opaque value, not intended to be interpreted in any way
// except being checked by IsTypeMarker or converted by MarkerToType.
// It has the same tagging as Smis, so any marker value that does not pass
// IsTypeMarker can instead be interpreted as a tagged pointer.
//
// Note that the marker is not a Smi: Smis on 64-bit architectures are stored
// in the top 32 bits of a 64-bit value, which in turn makes them expensive
// (in terms of code/instruction size) to push as immediates onto the stack.
static int32_t TypeToMarker(Type type) {
DCHECK_GE(type, 0);
return (type << kSmiTagSize) | kSmiTag;
}
// Convert a marker back to a stack frame type.
//
// Unlike the return value of TypeToMarker, this takes an intptr_t, as that is
// the type of the value on the stack.
static Type MarkerToType(intptr_t marker) {
DCHECK(IsTypeMarker(marker));
return static_cast<Type>(marker >> kSmiTagSize);
}
// Check if a marker is a stack frame type marker or a tagged pointer.
//
// Returns true if the given marker is tagged as a stack frame type marker,
// and should be converted back to a stack frame type using MarkerToType.
// Otherwise, the value is a tagged function pointer.
static bool IsTypeMarker(intptr_t function_or_marker) {
bool is_marker = ((function_or_marker & kSmiTagMask) == kSmiTag);
return is_marker;
}
// Copy constructor; it breaks the connection to host iterator
// (as an iterator usually lives on stack).
StackFrame(const StackFrame& original) {

View File

@ -1546,8 +1546,8 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
__ mov(ebp, esp);
// Push marker in two places.
int marker = type();
__ push(Immediate(Smi::FromInt(marker))); // marker
StackFrame::Type marker = type();
__ push(Immediate(StackFrame::TypeToMarker(marker))); // marker
ExternalReference context_address(Isolate::kContextAddress, isolate());
__ push(Operand::StaticVariable(context_address)); // context
// Save callee-saved registers (C calling conventions).
@ -1564,10 +1564,10 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
__ cmp(Operand::StaticVariable(js_entry_sp), Immediate(0));
__ j(not_equal, &not_outermost_js, Label::kNear);
__ mov(Operand::StaticVariable(js_entry_sp), ebp);
__ push(Immediate(Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME)));
__ push(Immediate(StackFrame::OUTERMOST_JSENTRY_FRAME));
__ jmp(&invoke, Label::kNear);
__ bind(&not_outermost_js);
__ push(Immediate(Smi::FromInt(StackFrame::INNER_JSENTRY_FRAME)));
__ push(Immediate(StackFrame::INNER_JSENTRY_FRAME));
// Jump to a faked try block that does the invoke, with a faked catch
// block that sets the pending exception.
@ -1611,7 +1611,7 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
__ bind(&exit);
// Check if the current stack frame is marked as the outermost JS frame.
__ pop(ebx);
__ cmp(ebx, Immediate(Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME)));
__ cmp(ebx, Immediate(StackFrame::OUTERMOST_JSENTRY_FRAME));
__ j(not_equal, &not_outermost_js_2);
__ mov(Operand::StaticVariable(js_entry_sp), Immediate(0));
__ bind(&not_outermost_js_2);

View File

@ -1007,7 +1007,7 @@ void MacroAssembler::AssertNotSmi(Register object) {
void MacroAssembler::StubPrologue(StackFrame::Type type) {
push(ebp); // Caller's frame pointer.
mov(ebp, esp);
push(Immediate(Smi::FromInt(type)));
push(Immediate(StackFrame::TypeToMarker(type)));
}
void MacroAssembler::Prologue(bool code_pre_aging) {
@ -1043,7 +1043,7 @@ void MacroAssembler::EnterFrame(StackFrame::Type type,
void MacroAssembler::EnterFrame(StackFrame::Type type) {
push(ebp);
mov(ebp, esp);
push(Immediate(Smi::FromInt(type)));
push(Immediate(StackFrame::TypeToMarker(type)));
if (type == StackFrame::INTERNAL) {
push(Immediate(CodeObject()));
}
@ -1057,7 +1057,7 @@ void MacroAssembler::EnterFrame(StackFrame::Type type) {
void MacroAssembler::LeaveFrame(StackFrame::Type type) {
if (emit_debug_code()) {
cmp(Operand(ebp, CommonFrameConstants::kContextOrFrameTypeOffset),
Immediate(Smi::FromInt(type)));
Immediate(StackFrame::TypeToMarker(type)));
Check(equal, kStackFrameTypesMustMatch);
}
leave();
@ -1092,7 +1092,7 @@ void MacroAssembler::EnterExitFramePrologue(StackFrame::Type frame_type) {
mov(ebp, esp);
// Reserve room for entry stack pointer and push the code object.
push(Immediate(Smi::FromInt(frame_type)));
push(Immediate(StackFrame::TypeToMarker(frame_type)));
DCHECK_EQ(-2 * kPointerSize, ExitFrameConstants::kSPOffset);
push(Immediate(0)); // Saved entry sp, patched before call.
DCHECK_EQ(-3 * kPointerSize, ExitFrameConstants::kCodeOffset);

View File

@ -217,9 +217,9 @@ IC::IC(FrameDepth depth, Isolate* isolate, FeedbackNexus* nexus)
// function's frame. Check if the there is an additional frame, and if there
// is skip this frame. However, the pc should not be updated. The call to
// ICs happen from bytecode handlers.
Object* frame_type =
Memory::Object_at(fp + TypedFrameConstants::kFrameTypeOffset);
if (frame_type == Smi::FromInt(StackFrame::STUB)) {
intptr_t frame_marker =
Memory::intptr_at(fp + TypedFrameConstants::kFrameTypeOffset);
if (frame_marker == StackFrame::TypeToMarker(StackFrame::STUB)) {
fp = Memory::Address_at(fp + TypedFrameConstants::kCallerFPOffset);
}
fp_ = fp;

View File

@ -1142,9 +1142,9 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
// We build an EntryFrame.
__ li(t3, Operand(-1)); // Push a bad frame pointer to fail if it is used.
int marker = type();
__ li(t2, Operand(Smi::FromInt(marker)));
__ li(t1, Operand(Smi::FromInt(marker)));
StackFrame::Type marker = type();
__ li(t2, Operand(StackFrame::TypeToMarker(marker)));
__ li(t1, Operand(StackFrame::TypeToMarker(marker)));
__ li(t0, Operand(ExternalReference(Isolate::kCEntryFPAddress,
isolate)));
__ lw(t0, MemOperand(t0));
@ -1175,12 +1175,12 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
__ lw(t2, MemOperand(t1));
__ Branch(&non_outermost_js, ne, t2, Operand(zero_reg));
__ sw(fp, MemOperand(t1));
__ li(t0, Operand(Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME)));
__ li(t0, Operand(StackFrame::OUTERMOST_JSENTRY_FRAME));
Label cont;
__ b(&cont);
__ nop(); // Branch delay slot nop.
__ bind(&non_outermost_js);
__ li(t0, Operand(Smi::FromInt(StackFrame::INNER_JSENTRY_FRAME)));
__ li(t0, Operand(StackFrame::INNER_JSENTRY_FRAME));
__ bind(&cont);
__ push(t0);
@ -1247,10 +1247,8 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
// Check if the current stack frame is marked as the outermost JS frame.
Label non_outermost_js_2;
__ pop(t1);
__ Branch(&non_outermost_js_2,
ne,
t1,
Operand(Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME)));
__ Branch(&non_outermost_js_2, ne, t1,
Operand(StackFrame::OUTERMOST_JSENTRY_FRAME));
__ li(t1, Operand(ExternalReference(js_entry_sp)));
__ sw(zero_reg, MemOperand(t1));
__ bind(&non_outermost_js_2);

View File

@ -5294,7 +5294,7 @@ void MacroAssembler::LoadGlobalFunctionInitialMap(Register function,
}
void MacroAssembler::StubPrologue(StackFrame::Type type) {
li(at, Operand(Smi::FromInt(type)));
li(at, Operand(StackFrame::TypeToMarker(type)));
PushCommonFrame(at);
}
@ -5352,7 +5352,7 @@ void MacroAssembler::EnterFrame(StackFrame::Type type) {
stack_offset -= kPointerSize;
sw(fp, MemOperand(sp, stack_offset));
stack_offset -= kPointerSize;
li(t9, Operand(Smi::FromInt(type)));
li(t9, Operand(StackFrame::TypeToMarker(type)));
sw(t9, MemOperand(sp, stack_offset));
if (type == StackFrame::INTERNAL) {
DCHECK_EQ(stack_offset, kPointerSize);
@ -5409,7 +5409,7 @@ void MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space,
addiu(sp, sp, -2 * kPointerSize - ExitFrameConstants::kFixedFrameSizeFromFp);
sw(ra, MemOperand(sp, 4 * kPointerSize));
sw(fp, MemOperand(sp, 3 * kPointerSize));
li(at, Operand(Smi::FromInt(frame_type)));
li(at, Operand(StackFrame::TypeToMarker(frame_type)));
sw(at, MemOperand(sp, 2 * kPointerSize));
// Set up new frame pointer.
addiu(fp, sp, ExitFrameConstants::kFixedFrameSizeFromFp);

View File

@ -1138,9 +1138,9 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
// We build an EntryFrame.
__ li(a7, Operand(-1)); // Push a bad frame pointer to fail if it is used.
int marker = type();
__ li(a6, Operand(Smi::FromInt(marker)));
__ li(a5, Operand(Smi::FromInt(marker)));
StackFrame::Type marker = type();
__ li(a6, Operand(StackFrame::TypeToMarker(marker)));
__ li(a5, Operand(StackFrame::TypeToMarker(marker)));
ExternalReference c_entry_fp(Isolate::kCEntryFPAddress, isolate);
__ li(a4, Operand(c_entry_fp));
__ ld(a4, MemOperand(a4));
@ -1171,12 +1171,12 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
__ ld(a6, MemOperand(a5));
__ Branch(&non_outermost_js, ne, a6, Operand(zero_reg));
__ sd(fp, MemOperand(a5));
__ li(a4, Operand(Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME)));
__ li(a4, Operand(StackFrame::OUTERMOST_JSENTRY_FRAME));
Label cont;
__ b(&cont);
__ nop(); // Branch delay slot nop.
__ bind(&non_outermost_js);
__ li(a4, Operand(Smi::FromInt(StackFrame::INNER_JSENTRY_FRAME)));
__ li(a4, Operand(StackFrame::INNER_JSENTRY_FRAME));
__ bind(&cont);
__ push(a4);
@ -1242,10 +1242,8 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
// Check if the current stack frame is marked as the outermost JS frame.
Label non_outermost_js_2;
__ pop(a5);
__ Branch(&non_outermost_js_2,
ne,
a5,
Operand(Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME)));
__ Branch(&non_outermost_js_2, ne, a5,
Operand(StackFrame::OUTERMOST_JSENTRY_FRAME));
__ li(a5, Operand(ExternalReference(js_entry_sp)));
__ sd(zero_reg, MemOperand(a5));
__ bind(&non_outermost_js_2);

View File

@ -5636,7 +5636,7 @@ void MacroAssembler::LoadGlobalFunctionInitialMap(Register function,
}
void MacroAssembler::StubPrologue(StackFrame::Type type) {
li(at, Operand(Smi::FromInt(type)));
li(at, Operand(StackFrame::TypeToMarker(type)));
PushCommonFrame(at);
}
@ -5696,7 +5696,7 @@ void MacroAssembler::EnterFrame(StackFrame::Type type) {
stack_offset -= kPointerSize;
sd(fp, MemOperand(sp, stack_offset));
stack_offset -= kPointerSize;
li(t9, Operand(Smi::FromInt(type)));
li(t9, Operand(StackFrame::TypeToMarker(type)));
sd(t9, MemOperand(sp, stack_offset));
if (type == StackFrame::INTERNAL) {
DCHECK_EQ(stack_offset, kPointerSize);
@ -5753,7 +5753,7 @@ void MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space,
daddiu(sp, sp, -2 * kPointerSize - ExitFrameConstants::kFixedFrameSizeFromFp);
sd(ra, MemOperand(sp, 4 * kPointerSize));
sd(fp, MemOperand(sp, 3 * kPointerSize));
li(at, Operand(Smi::FromInt(frame_type)));
li(at, Operand(StackFrame::TypeToMarker(frame_type)));
sd(at, MemOperand(sp, 2 * kPointerSize));
// Set up new frame pointer.
daddiu(fp, sp, ExitFrameConstants::kFixedFrameSizeFromFp);

View File

@ -1453,8 +1453,7 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
__ movp(rbp, rsp);
// Push the stack frame type.
int marker = type();
__ Push(Smi::FromInt(marker)); // context slot
__ Push(Immediate(StackFrame::TypeToMarker(type()))); // context slot
ExternalReference context_address(Isolate::kContextAddress, isolate());
__ Load(kScratchRegister, context_address);
__ Push(kScratchRegister); // context
@ -1501,13 +1500,13 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
__ Load(rax, js_entry_sp);
__ testp(rax, rax);
__ j(not_zero, &not_outermost_js);
__ Push(Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME));
__ Push(Immediate(StackFrame::OUTERMOST_JSENTRY_FRAME));
__ movp(rax, rbp);
__ Store(js_entry_sp, rax);
Label cont;
__ jmp(&cont);
__ bind(&not_outermost_js);
__ Push(Smi::FromInt(StackFrame::INNER_JSENTRY_FRAME));
__ Push(Immediate(StackFrame::INNER_JSENTRY_FRAME));
__ bind(&cont);
// Jump to a faked try block that does the invoke, with a faked catch
@ -1552,7 +1551,7 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
__ bind(&exit);
// Check if the current stack frame is marked as the outermost JS frame.
__ Pop(rbx);
__ Cmp(rbx, Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME));
__ cmpp(rbx, Immediate(StackFrame::OUTERMOST_JSENTRY_FRAME));
__ j(not_equal, &not_outermost_js_2);
__ Move(kScratchRegister, js_entry_sp);
__ movp(Operand(kScratchRegister, 0), Immediate(0));

View File

@ -4351,7 +4351,7 @@ void MacroAssembler::CheckDebugHook(Register fun, Register new_target,
void MacroAssembler::StubPrologue(StackFrame::Type type) {
pushq(rbp); // Caller's frame pointer.
movp(rbp, rsp);
Push(Smi::FromInt(type));
Push(Immediate(StackFrame::TypeToMarker(type)));
}
void MacroAssembler::Prologue(bool code_pre_aging) {
@ -4387,7 +4387,7 @@ void MacroAssembler::EnterFrame(StackFrame::Type type,
void MacroAssembler::EnterFrame(StackFrame::Type type) {
pushq(rbp);
movp(rbp, rsp);
Push(Smi::FromInt(type));
Push(Immediate(StackFrame::TypeToMarker(type)));
if (type == StackFrame::INTERNAL) {
Move(kScratchRegister, CodeObject(), RelocInfo::EMBEDDED_OBJECT);
Push(kScratchRegister);
@ -4404,9 +4404,8 @@ void MacroAssembler::EnterFrame(StackFrame::Type type) {
void MacroAssembler::LeaveFrame(StackFrame::Type type) {
if (emit_debug_code()) {
Move(kScratchRegister, Smi::FromInt(type));
cmpp(Operand(rbp, CommonFrameConstants::kContextOrFrameTypeOffset),
kScratchRegister);
Immediate(StackFrame::TypeToMarker(type)));
Check(equal, kStackFrameTypesMustMatch);
}
movp(rsp, rbp);
@ -4445,7 +4444,7 @@ void MacroAssembler::EnterExitFramePrologue(bool save_rax,
movp(rbp, rsp);
// Reserve room for entry stack pointer and push the code object.
Push(Smi::FromInt(frame_type));
Push(Immediate(StackFrame::TypeToMarker(frame_type)));
DCHECK_EQ(-2 * kPointerSize, ExitFrameConstants::kSPOffset);
Push(Immediate(0)); // Saved entry sp, patched before call.
Move(kScratchRegister, CodeObject(), RelocInfo::EMBEDDED_OBJECT);