Commit af76645b authored by bjaideep's avatar bjaideep Committed by Commit bot

PPC/s390: [everywhere] Custom representation for frame type

Port fd596007

Original Commit Message:

    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.

R=leszeks@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=
LOG=N

Review-Url: https://codereview.chromium.org/2709483007
Cr-Commit-Position: refs/heads/master@{#43356}
parent 3e168a1c
......@@ -2159,7 +2159,7 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) {
__ SmiTag(r3);
__ LoadSmiLiteral(r7, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
__ mov(r7, Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ mflr(r0);
__ push(r0);
if (FLAG_enable_embedded_constant_pool) {
......@@ -2347,7 +2347,7 @@ void Builtins::Generate_CallForwardVarargs(MacroAssembler* masm,
Label arguments_adaptor, arguments_done;
__ LoadP(r6, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ LoadP(ip, MemOperand(r6, CommonFrameConstants::kContextOrFrameTypeOffset));
__ CmpSmiLiteral(ip, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0);
__ cmpi(ip, Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ beq(&arguments_adaptor);
{
__ LoadP(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
......@@ -2453,7 +2453,7 @@ void PrepareForTailCall(MacroAssembler* masm, Register args_reg,
Label no_interpreter_frame;
__ LoadP(scratch3,
MemOperand(fp, CommonFrameConstants::kContextOrFrameTypeOffset));
__ CmpSmiLiteral(scratch3, Smi::FromInt(StackFrame::STUB), r0);
__ cmpi(scratch3, Operand(StackFrame::TypeToMarker(StackFrame::STUB)));
__ bne(&no_interpreter_frame);
__ LoadP(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ bind(&no_interpreter_frame);
......@@ -2466,7 +2466,8 @@ void PrepareForTailCall(MacroAssembler* masm, Register args_reg,
__ LoadP(
scratch3,
MemOperand(scratch2, CommonFrameConstants::kContextOrFrameTypeOffset));
__ CmpSmiLiteral(scratch3, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0);
__ cmpi(scratch3,
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ bne(&no_arguments_adaptor);
// Drop current frame and load arguments count from arguments adaptor frame.
......
......@@ -2161,7 +2161,7 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) {
__ SmiTag(r2);
__ LoadSmiLiteral(r6, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
__ Load(r6, Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
// Stack updated as such:
// old SP --->
// R14 Return Addr
......@@ -2359,7 +2359,7 @@ void Builtins::Generate_CallForwardVarargs(MacroAssembler* masm,
Label arguments_adaptor, arguments_done;
__ LoadP(r5, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ LoadP(ip, MemOperand(r5, CommonFrameConstants::kContextOrFrameTypeOffset));
__ CmpSmiLiteral(ip, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0);
__ CmpP(ip, Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ beq(&arguments_adaptor);
{
__ LoadP(r2, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
......@@ -2464,7 +2464,7 @@ void PrepareForTailCall(MacroAssembler* masm, Register args_reg,
Label no_interpreter_frame;
__ LoadP(scratch3,
MemOperand(fp, CommonFrameConstants::kContextOrFrameTypeOffset));
__ CmpSmiLiteral(scratch3, Smi::FromInt(StackFrame::STUB), r0);
__ CmpP(scratch3, Operand(StackFrame::TypeToMarker(StackFrame::STUB)));
__ bne(&no_interpreter_frame);
__ LoadP(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ bind(&no_interpreter_frame);
......@@ -2477,7 +2477,8 @@ void PrepareForTailCall(MacroAssembler* masm, Register args_reg,
__ LoadP(
scratch3,
MemOperand(scratch2, CommonFrameConstants::kContextOrFrameTypeOffset));
__ CmpSmiLiteral(scratch3, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0);
__ CmpP(scratch3,
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ bne(&no_arguments_adaptor);
// Drop current frame and load arguments count from arguments adaptor frame.
......
......@@ -813,7 +813,8 @@ void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg,
// Check if current frame is an arguments adaptor frame.
__ LoadP(scratch1, MemOperand(fp, StandardFrameConstants::kContextOffset));
__ CmpSmiLiteral(scratch1, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0);
__ cmpi(scratch1,
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ bne(&done);
// Load arguments count from current arguments adaptor frame (note, it
......
......@@ -1034,7 +1034,8 @@ void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg,
// Check if current frame is an arguments adaptor frame.
__ LoadP(scratch1, MemOperand(fp, StandardFrameConstants::kContextOffset));
__ CmpSmiLiteral(scratch1, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0);
__ CmpP(scratch1,
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ bne(&done);
// Load arguments count from current arguments adaptor frame (note, it
......
......@@ -287,7 +287,7 @@ bool LCodeGen::GenerateDeferredCode() {
DCHECK(!frame_is_built_);
DCHECK(info()->IsStub());
frame_is_built_ = true;
__ LoadSmiLiteral(scratch0(), Smi::FromInt(StackFrame::STUB));
__ mov(scratch0(), Operand(StackFrame::TypeToMarker(StackFrame::STUB)));
__ PushCommonFrame(scratch0());
Comment(";;; Deferred code");
}
......@@ -356,7 +356,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.
__ LoadSmiLiteral(ip, Smi::FromInt(StackFrame::STUB));
__ mov(ip, Operand(StackFrame::TypeToMarker(StackFrame::STUB)));
__ push(ip);
DCHECK(info()->IsStub());
}
......@@ -3129,7 +3129,8 @@ void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) {
__ LoadP(
result,
MemOperand(scratch, CommonFrameConstants::kContextOrFrameTypeOffset));
__ CmpSmiLiteral(result, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0);
__ cmpi(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.
......@@ -3767,7 +3768,8 @@ void LCodeGen::PrepareForTailCall(const ParameterCount& actual,
__ LoadP(scratch2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ LoadP(scratch3,
MemOperand(scratch2, StandardFrameConstants::kContextOffset));
__ CmpSmiLiteral(scratch3, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0);
__ cmpi(scratch3,
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ bne(&no_arguments_adaptor);
// Drop current frame and load arguments count from arguments adaptor frame.
......
......@@ -275,7 +275,8 @@ bool LCodeGen::GenerateDeferredCode() {
DCHECK(!frame_is_built_);
DCHECK(info()->IsStub());
frame_is_built_ = true;
__ LoadSmiLiteral(scratch0(), Smi::FromInt(StackFrame::STUB));
__ Load(scratch0(),
Operand(StackFrame::TypeToMarker(StackFrame::STUB)));
__ PushCommonFrame(scratch0());
Comment(";;; Deferred code");
}
......@@ -344,7 +345,7 @@ 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());
__ LoadSmiLiteral(ip, Smi::FromInt(StackFrame::STUB));
__ Load(ip, Operand(StackFrame::TypeToMarker(StackFrame::STUB)));
__ push(ip);
DCHECK(info()->IsStub());
}
......@@ -3095,8 +3096,8 @@ void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) {
__ LoadP(
result,
MemOperand(scratch, CommonFrameConstants::kContextOrFrameTypeOffset));
__ LoadSmiLiteral(r0, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
__ CmpP(result, r0);
__ CmpP(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.
......@@ -3673,7 +3674,8 @@ void LCodeGen::PrepareForTailCall(const ParameterCount& actual,
__ LoadP(scratch2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
__ LoadP(scratch3,
MemOperand(scratch2, StandardFrameConstants::kContextOffset));
__ CmpSmiLiteral(scratch3, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0);
__ CmpP(scratch3,
Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ bne(&no_arguments_adaptor);
// Drop current frame and load arguments count from arguments adaptor frame.
......
......@@ -1100,8 +1100,8 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
__ li(kConstantPoolRegister, Operand::Zero());
__ push(kConstantPoolRegister);
}
int marker = type();
__ LoadSmiLiteral(r0, Smi::FromInt(marker));
StackFrame::Type marker = type();
__ mov(r0, Operand(StackFrame::TypeToMarker(marker)));
__ push(r0);
__ push(r0);
// Save copies of the top frame descriptor on the stack.
......@@ -1120,11 +1120,11 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
__ cmpi(r9, Operand::Zero());
__ bne(&non_outermost_js);
__ StoreP(fp, MemOperand(r8));
__ LoadSmiLiteral(ip, Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME));
__ mov(ip, Operand(StackFrame::OUTERMOST_JSENTRY_FRAME));
Label cont;
__ b(&cont);
__ bind(&non_outermost_js);
__ LoadSmiLiteral(ip, Smi::FromInt(StackFrame::INNER_JSENTRY_FRAME));
__ mov(ip, Operand(StackFrame::INNER_JSENTRY_FRAME));
__ bind(&cont);
__ push(ip); // frame-type
......@@ -1187,7 +1187,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(r8);
__ CmpSmiLiteral(r8, Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME), r0);
__ cmpi(r8, Operand(StackFrame::OUTERMOST_JSENTRY_FRAME));
__ bne(&non_outermost_js_2);
__ mov(r9, Operand::Zero());
__ mov(r8, Operand(ExternalReference(js_entry_sp)));
......
......@@ -969,7 +969,7 @@ void MacroAssembler::StubPrologue(StackFrame::Type type, Register base,
int prologue_offset) {
{
ConstantPoolUnavailableScope constant_pool_unavailable(this);
LoadSmiLiteral(r11, Smi::FromInt(type));
mov(r11, Operand(StackFrame::TypeToMarker(type)));
PushCommonFrame(r11);
}
if (FLAG_enable_embedded_constant_pool) {
......@@ -1034,10 +1034,10 @@ void MacroAssembler::EnterFrame(StackFrame::Type type,
// This path cannot rely on ip containing code entry.
PushCommonFrame();
LoadConstantPoolPointerRegister();
LoadSmiLiteral(ip, Smi::FromInt(type));
mov(ip, Operand(StackFrame::TypeToMarker(type)));
push(ip);
} else {
LoadSmiLiteral(ip, Smi::FromInt(type));
mov(ip, Operand(StackFrame::TypeToMarker(type)));
PushCommonFrame(ip);
}
if (type == StackFrame::INTERNAL) {
......@@ -1143,7 +1143,7 @@ void MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space,
// all of the pushes that have happened inside of V8
// since we were called from C code
LoadSmiLiteral(ip, Smi::FromInt(frame_type));
mov(ip, Operand(StackFrame::TypeToMarker(frame_type)));
PushCommonFrame(ip);
// Reserve room for saved entry sp and code object.
subi(sp, fp, Operand(ExitFrameConstants::kFixedFrameSizeFromFp));
......
......@@ -1080,9 +1080,9 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
// Push a bad frame pointer to fail if it is used.
__ LoadImmP(r10, Operand(-1));
int marker = type();
__ LoadSmiLiteral(r9, Smi::FromInt(marker));
__ LoadSmiLiteral(r8, Smi::FromInt(marker));
StackFrame::Type marker = type();
__ Load(r9, Operand(StackFrame::TypeToMarker(marker)));
__ Load(r8, Operand(StackFrame::TypeToMarker(marker)));
// Save copies of the top frame descriptor on the stack.
__ mov(r7, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate())));
__ LoadP(r7, MemOperand(r7));
......@@ -1100,11 +1100,11 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
__ LoadAndTestP(r8, MemOperand(r7));
__ bne(&non_outermost_js, Label::kNear);
__ StoreP(fp, MemOperand(r7));
__ LoadSmiLiteral(ip, Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME));
__ Load(ip, Operand(StackFrame::OUTERMOST_JSENTRY_FRAME));
Label cont;
__ b(&cont, Label::kNear);
__ bind(&non_outermost_js);
__ LoadSmiLiteral(ip, Smi::FromInt(StackFrame::INNER_JSENTRY_FRAME));
__ Load(ip, Operand(StackFrame::INNER_JSENTRY_FRAME));
__ bind(&cont);
__ StoreP(ip, MemOperand(sp)); // frame-type
......@@ -1171,7 +1171,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(r7);
__ CmpSmiLiteral(r7, Smi::FromInt(StackFrame::OUTERMOST_JSENTRY_FRAME), r0);
__ CmpP(r7, Operand(StackFrame::OUTERMOST_JSENTRY_FRAME));
__ bne(&non_outermost_js_2, Label::kNear);
__ mov(r8, Operand::Zero());
__ mov(r7, Operand(ExternalReference(js_entry_sp)));
......
......@@ -933,7 +933,7 @@ void MacroAssembler::StubPrologue(StackFrame::Type type, Register base,
int prologue_offset) {
{
ConstantPoolUnavailableScope constant_pool_unavailable(this);
LoadSmiLiteral(r1, Smi::FromInt(type));
Load(r1, Operand(StackFrame::TypeToMarker(type)));
PushCommonFrame(r1);
}
}
......@@ -984,7 +984,7 @@ void MacroAssembler::EnterFrame(StackFrame::Type type,
// type
// CodeObject <-- new sp
LoadSmiLiteral(ip, Smi::FromInt(type));
Load(ip, Operand(StackFrame::TypeToMarker(type)));
PushCommonFrame(ip);
if (type == StackFrame::INTERNAL) {
......@@ -1057,7 +1057,7 @@ void MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space,
// all of the pushes that have happened inside of V8
// since we were called from C code
CleanseP(r14);
LoadSmiLiteral(r1, Smi::FromInt(frame_type));
Load(r1, Operand(StackFrame::TypeToMarker(frame_type)));
PushCommonFrame(r1);
// Reserve room for saved entry sp and code object.
lay(sp, MemOperand(fp, -ExitFrameConstants::kFixedFrameSizeFromFp));
......
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