Revision: 21329
Author:   [email protected]
Date:     Thu May 15 12:10:00 2014 UTC
Log:      Refactor MacroAssembler::Prologue.

[email protected]

Review URL: https://codereview.chromium.org/288213002
http://code.google.com/p/v8/source/detail?r=21329

Modified:
 /branches/bleeding_edge/src/arm/full-codegen-arm.cc
 /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc
 /branches/bleeding_edge/src/arm/macro-assembler-arm.cc
 /branches/bleeding_edge/src/arm/macro-assembler-arm.h
 /branches/bleeding_edge/src/arm64/full-codegen-arm64.cc
 /branches/bleeding_edge/src/arm64/lithium-codegen-arm64.cc
 /branches/bleeding_edge/src/arm64/macro-assembler-arm64.cc
 /branches/bleeding_edge/src/arm64/macro-assembler-arm64.h
 /branches/bleeding_edge/src/full-codegen.h
 /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc
 /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc
 /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc
 /branches/bleeding_edge/src/ia32/macro-assembler-ia32.h
 /branches/bleeding_edge/src/mips/full-codegen-mips.cc
 /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc
 /branches/bleeding_edge/src/mips/macro-assembler-mips.cc
 /branches/bleeding_edge/src/mips/macro-assembler-mips.h
 /branches/bleeding_edge/src/x64/full-codegen-x64.cc
 /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc
 /branches/bleeding_edge/src/x64/macro-assembler-x64.cc
 /branches/bleeding_edge/src/x64/macro-assembler-x64.h

=======================================
--- /branches/bleeding_edge/src/arm/full-codegen-arm.cc Mon May 12 13:47:01 2014 UTC +++ /branches/bleeding_edge/src/arm/full-codegen-arm.cc Thu May 15 12:10:00 2014 UTC
@@ -171,8 +171,7 @@
   FrameScope frame_scope(masm_, StackFrame::MANUAL);

   info->set_prologue_offset(masm_->pc_offset());
-  ASSERT(!info->IsStub());
-  __ Prologue(info);
+  __ Prologue(info->IsCodePreAgingActive());
   info->AddNoFrameRange(0, masm_->pc_offset());

   { Comment cmnt(masm_, "[ Allocate locals");
=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Wed May 14 14:34:37 2014 UTC +++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Thu May 15 12:10:00 2014 UTC
@@ -140,7 +140,11 @@

   info()->set_prologue_offset(masm_->pc_offset());
   if (NeedsEagerFrame()) {
-    __ Prologue(info());
+    if (info()->IsStub()) {
+      __ StubPrologue();
+    } else {
+      __ Prologue(info()->IsCodePreAgingActive());
+    }
     frame_is_built_ = true;
     info_->AddNoFrameRange(0, masm_->pc_offset());
   }
=======================================
--- /branches/bleeding_edge/src/arm/macro-assembler-arm.cc Mon May 12 13:47:01 2014 UTC +++ /branches/bleeding_edge/src/arm/macro-assembler-arm.cc Thu May 15 12:10:00 2014 UTC
@@ -902,29 +902,34 @@
 }


-void MacroAssembler::Prologue(CompilationInfo* info) {
-  if (info->IsStub()) {
-    PushFixedFrame();
-    Push(Smi::FromInt(StackFrame::STUB));
+void MacroAssembler::StubPrologue() {
+  PushFixedFrame();
+  Push(Smi::FromInt(StackFrame::STUB));
+  // Adjust FP to point to saved FP.
+  add(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
+  if (FLAG_enable_ool_constant_pool) {
+    LoadConstantPoolPointerRegister();
+    set_constant_pool_available(true);
+  }
+}
+
+
+void MacroAssembler::Prologue(bool code_pre_aging) {
+  PredictableCodeSizeScope predictible_code_size_scope(
+      this, kNoCodeAgeSequenceLength);
+  // The following three instructions must remain together and unmodified
+  // for code aging to work properly.
+  if (code_pre_aging) {
+    // Pre-age the code.
+    Code* stub = Code::GetPreAgedCodeAgeStub(isolate());
+    add(r0, pc, Operand(-8));
+    ldr(pc, MemOperand(pc, -4));
+    emit_code_stub_address(stub);
+  } else {
+    PushFixedFrame(r1);
+    nop(ip.code());
     // Adjust FP to point to saved FP.
     add(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
-  } else {
-    PredictableCodeSizeScope predictible_code_size_scope(
-        this, kNoCodeAgeSequenceLength);
-    // The following three instructions must remain together and unmodified
-    // for code aging to work properly.
-    if (info->IsCodePreAgingActive()) {
-      // Pre-age the code.
-      Code* stub = Code::GetPreAgedCodeAgeStub(isolate());
-      add(r0, pc, Operand(-8));
-      ldr(pc, MemOperand(pc, -4));
-      emit_code_stub_address(stub);
-    } else {
-      PushFixedFrame(r1);
-      nop(ip.code());
-      // Adjust FP to point to saved FP.
-      add(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
-    }
   }
   if (FLAG_enable_ool_constant_pool) {
     LoadConstantPoolPointerRegister();
=======================================
--- /branches/bleeding_edge/src/arm/macro-assembler-arm.h Mon May 12 13:47:01 2014 UTC +++ /branches/bleeding_edge/src/arm/macro-assembler-arm.h Thu May 15 12:10:00 2014 UTC
@@ -519,7 +519,8 @@
                          Label* not_int32);

   // Generates function and stub prologue code.
-  void Prologue(CompilationInfo* info);
+  void StubPrologue();
+  void Prologue(bool code_pre_aging);

   // Enter exit frame.
   // stack_space - extra stack space, used for alignment before call to C.
=======================================
--- /branches/bleeding_edge/src/arm64/full-codegen-arm64.cc Mon May 12 13:47:01 2014 UTC +++ /branches/bleeding_edge/src/arm64/full-codegen-arm64.cc Thu May 15 12:10:00 2014 UTC
@@ -170,8 +170,7 @@
   //  Push(lr, fp, cp, x1);
   //  Add(fp, jssp, 2 * kPointerSize);
   info->set_prologue_offset(masm_->pc_offset());
-  ASSERT(!info->IsStub());
-  __ Prologue(info);
+  __ Prologue(info->IsCodePreAgingActive());
   info->AddNoFrameRange(0, masm_->pc_offset());

   // Reserve space on the stack for locals.
=======================================
--- /branches/bleeding_edge/src/arm64/lithium-codegen-arm64.cc Wed May 14 14:34:37 2014 UTC +++ /branches/bleeding_edge/src/arm64/lithium-codegen-arm64.cc Thu May 15 12:10:00 2014 UTC
@@ -671,7 +671,11 @@
   ASSERT(__ StackPointer().Is(jssp));
   info()->set_prologue_offset(masm_->pc_offset());
   if (NeedsEagerFrame()) {
-    __ Prologue(info());
+    if (info()->IsStub()) {
+      __ StubPrologue();
+    } else {
+      __ Prologue(info()->IsCodePreAgingActive());
+    }
     frame_is_built_ = true;
     info_->AddNoFrameRange(0, masm_->pc_offset());
   }
=======================================
--- /branches/bleeding_edge/src/arm64/macro-assembler-arm64.cc Wed May 14 14:01:29 2014 UTC +++ /branches/bleeding_edge/src/arm64/macro-assembler-arm64.cc Thu May 15 12:10:00 2014 UTC
@@ -2992,23 +2992,24 @@
 }


-void MacroAssembler::Prologue(CompilationInfo* info) {
-  if (info->IsStub()) {
-    ASSERT(StackPointer().Is(jssp));
-    UseScratchRegisterScope temps(this);
-    Register temp = temps.AcquireX();
-    __ Mov(temp, Smi::FromInt(StackFrame::STUB));
- // Compiled stubs don't age, and so they don't need the predictable code
-    // ageing sequence.
-    __ Push(lr, fp, cp, temp);
-    __ Add(fp, jssp, StandardFrameConstants::kFixedFrameSizeFromFp);
+void MacroAssembler::StubPrologue() {
+  ASSERT(StackPointer().Is(jssp));
+  UseScratchRegisterScope temps(this);
+  Register temp = temps.AcquireX();
+  __ Mov(temp, Smi::FromInt(StackFrame::STUB));
+  // Compiled stubs don't age, and so they don't need the predictable code
+  // ageing sequence.
+  __ Push(lr, fp, cp, temp);
+  __ Add(fp, jssp, StandardFrameConstants::kFixedFrameSizeFromFp);
+}
+
+
+void MacroAssembler::Prologue(bool code_pre_aging) {
+  if (code_pre_aging) {
+    Code* stub = Code::GetPreAgedCodeAgeStub(isolate());
+    __ EmitCodeAgeSequence(stub);
   } else {
-    if (info->IsCodePreAgingActive()) {
-      Code* stub = Code::GetPreAgedCodeAgeStub(isolate());
-      __ EmitCodeAgeSequence(stub);
-    } else {
-      __ EmitFrameSetupForCodeAgePatching();
-    }
+    __ EmitFrameSetupForCodeAgePatching();
   }
 }

=======================================
--- /branches/bleeding_edge/src/arm64/macro-assembler-arm64.h Wed May 14 14:01:29 2014 UTC +++ /branches/bleeding_edge/src/arm64/macro-assembler-arm64.h Thu May 15 12:10:00 2014 UTC
@@ -1652,7 +1652,8 @@
   void ExitFrameRestoreFPRegs();

   // Generates function and stub prologue code.
-  void Prologue(CompilationInfo* info);
+  void StubPrologue();
+  void Prologue(bool code_pre_aging);

// Enter exit frame. Exit frames are used when calling C code from generated
   // (JavaScript) code.
=======================================
--- /branches/bleeding_edge/src/full-codegen.h  Fri May  9 12:59:24 2014 UTC
+++ /branches/bleeding_edge/src/full-codegen.h  Thu May 15 12:10:00 2014 UTC
@@ -74,6 +74,7 @@
                          info->zone()),
         back_edges_(2, info->zone()),
         ic_total_count_(0) {
+    ASSERT(!info->IsStub());
     Initialize();
   }

=======================================
--- /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc Mon May 12 13:47:01 2014 UTC +++ /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc Thu May 15 12:10:00 2014 UTC
@@ -157,8 +157,7 @@
   FrameScope frame_scope(masm_, StackFrame::MANUAL);

   info->set_prologue_offset(masm_->pc_offset());
-  ASSERT(!info->IsStub());
-  __ Prologue(info);
+  __ Prologue(info->IsCodePreAgingActive());
   info->AddNoFrameRange(0, masm_->pc_offset());

   { Comment cmnt(masm_, "[ Allocate locals");
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Mon May 12 13:47:01 2014 UTC +++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Thu May 15 12:10:00 2014 UTC
@@ -188,7 +188,11 @@
   if (NeedsEagerFrame()) {
     ASSERT(!frame_is_built_);
     frame_is_built_ = true;
-    __ Prologue(info());
+    if (info()->IsStub()) {
+      __ StubPrologue();
+    } else {
+      __ Prologue(info()->IsCodePreAgingActive());
+    }
     info()->AddNoFrameRange(0, masm_->pc_offset());
   }

=======================================
--- /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc Tue May 13 09:05:00 2014 UTC +++ /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc Thu May 15 12:10:00 2014 UTC
@@ -900,26 +900,27 @@
 }


-void MacroAssembler::Prologue(CompilationInfo* info) {
-  if (info->IsStub()) {
+void MacroAssembler::StubPrologue() {
+  push(ebp);  // Caller's frame pointer.
+  mov(ebp, esp);
+  push(esi);  // Callee's context.
+  push(Immediate(Smi::FromInt(StackFrame::STUB)));
+}
+
+
+void MacroAssembler::Prologue(bool code_pre_aging) {
+  PredictableCodeSizeScope predictible_code_size_scope(this,
+      kNoCodeAgeSequenceLength);
+  if (code_pre_aging) {
+      // Pre-age the code.
+    call(isolate()->builtins()->MarkCodeAsExecutedOnce(),
+        RelocInfo::CODE_AGE_SEQUENCE);
+    Nop(kNoCodeAgeSequenceLength - Assembler::kCallInstructionLength);
+  } else {
     push(ebp);  // Caller's frame pointer.
     mov(ebp, esp);
     push(esi);  // Callee's context.
-    push(Immediate(Smi::FromInt(StackFrame::STUB)));
-  } else {
-    PredictableCodeSizeScope predictible_code_size_scope(this,
-        kNoCodeAgeSequenceLength);
-    if (info->IsCodePreAgingActive()) {
-        // Pre-age the code.
-      call(isolate()->builtins()->MarkCodeAsExecutedOnce(),
-          RelocInfo::CODE_AGE_SEQUENCE);
-      Nop(kNoCodeAgeSequenceLength - Assembler::kCallInstructionLength);
-    } else {
-      push(ebp);  // Caller's frame pointer.
-      mov(ebp, esp);
-      push(esi);  // Callee's context.
-      push(edi);  // Callee's JS function.
-    }
+    push(edi);  // Callee's JS function.
   }
 }

=======================================
--- /branches/bleeding_edge/src/ia32/macro-assembler-ia32.h Mon May 12 13:47:01 2014 UTC +++ /branches/bleeding_edge/src/ia32/macro-assembler-ia32.h Thu May 15 12:10:00 2014 UTC
@@ -204,7 +204,8 @@
   void DebugBreak();

   // Generates function and stub prologue code.
-  void Prologue(CompilationInfo* info);
+  void StubPrologue();
+  void Prologue(bool code_pre_aging);

   // Enter specific kind of exit frame. Expects the number of
   // arguments in register eax and sets up the number of arguments in
=======================================
--- /branches/bleeding_edge/src/mips/full-codegen-mips.cc Mon May 12 13:47:01 2014 UTC +++ /branches/bleeding_edge/src/mips/full-codegen-mips.cc Thu May 15 12:10:00 2014 UTC
@@ -176,8 +176,7 @@
   FrameScope frame_scope(masm_, StackFrame::MANUAL);

   info->set_prologue_offset(masm_->pc_offset());
-  ASSERT(!info->IsStub());
-  __ Prologue(info);
+  __ Prologue(info->IsCodePreAgingActive());
   info->AddNoFrameRange(0, masm_->pc_offset());

   { Comment cmnt(masm_, "[ Allocate locals");
=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Wed May 14 17:34:09 2014 UTC +++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Thu May 15 12:10:00 2014 UTC
@@ -162,7 +162,11 @@

   info()->set_prologue_offset(masm_->pc_offset());
   if (NeedsEagerFrame()) {
-    __ Prologue(info());
+    if (info()->IsStub()) {
+      __ StubPrologue();
+    } else {
+      __ Prologue(info()->IsCodePreAgingActive());
+    }
     frame_is_built_ = true;
     info_->AddNoFrameRange(0, masm_->pc_offset());
   }
=======================================
--- /branches/bleeding_edge/src/mips/macro-assembler-mips.cc Mon May 12 13:47:01 2014 UTC +++ /branches/bleeding_edge/src/mips/macro-assembler-mips.cc Thu May 15 12:10:00 2014 UTC
@@ -4452,36 +4452,37 @@
 }


-void MacroAssembler::Prologue(CompilationInfo* info) {
-  if (info->IsStub()) {
+void MacroAssembler::StubPrologue() {
     Push(ra, fp, cp);
     Push(Smi::FromInt(StackFrame::STUB));
     // Adjust FP to point to saved FP.
     Addu(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
+}
+
+
+void MacroAssembler::Prologue(bool code_pre_aging) {
+  PredictableCodeSizeScope predictible_code_size_scope(
+      this, kNoCodeAgeSequenceLength);
+  // The following three instructions must remain together and unmodified
+  // for code aging to work properly.
+  if (code_pre_aging) {
+    // Pre-age the code.
+    Code* stub = Code::GetPreAgedCodeAgeStub(isolate());
+    nop(Assembler::CODE_AGE_MARKER_NOP);
+    // Load the stub address to t9 and call it,
+ // GetCodeAgeAndParity() extracts the stub address from this instruction.
+    li(t9,
+       Operand(reinterpret_cast<uint32_t>(stub->instruction_start())),
+       CONSTANT_SIZE);
+    nop();  // Prevent jalr to jal optimization.
+    jalr(t9, a0);
+    nop();  // Branch delay slot nop.
+    nop();  // Pad the empty space.
   } else {
-    PredictableCodeSizeScope predictible_code_size_scope(
-      this, kNoCodeAgeSequenceLength);
-    // The following three instructions must remain together and unmodified
-    // for code aging to work properly.
-    if (info->IsCodePreAgingActive()) {
-      // Pre-age the code.
-      Code* stub = Code::GetPreAgedCodeAgeStub(isolate());
-      nop(Assembler::CODE_AGE_MARKER_NOP);
-      // Load the stub address to t9 and call it,
- // GetCodeAgeAndParity() extracts the stub address from this instruction.
-      li(t9,
-         Operand(reinterpret_cast<uint32_t>(stub->instruction_start())),
-         CONSTANT_SIZE);
-      nop();  // Prevent jalr to jal optimization.
-      jalr(t9, a0);
-      nop();  // Branch delay slot nop.
-      nop();  // Pad the empty space.
-    } else {
-      Push(ra, fp, cp, a1);
-      nop(Assembler::CODE_AGE_SEQUENCE_NOP);
-      // Adjust fp to point to caller's fp.
-      Addu(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
-    }
+    Push(ra, fp, cp, a1);
+    nop(Assembler::CODE_AGE_SEQUENCE_NOP);
+    // Adjust fp to point to caller's fp.
+    Addu(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
   }
 }

=======================================
--- /branches/bleeding_edge/src/mips/macro-assembler-mips.h Mon May 12 13:47:01 2014 UTC +++ /branches/bleeding_edge/src/mips/macro-assembler-mips.h Thu May 15 12:10:00 2014 UTC
@@ -1492,7 +1492,8 @@
   }

   // Generates function and stub prologue code.
-  void Prologue(CompilationInfo* info);
+  void StubPrologue();
+  void Prologue(bool code_pre_aging);

   // Activation support.
   void EnterFrame(StackFrame::Type type);
=======================================
--- /branches/bleeding_edge/src/x64/full-codegen-x64.cc Mon May 12 13:47:01 2014 UTC +++ /branches/bleeding_edge/src/x64/full-codegen-x64.cc Thu May 15 12:10:00 2014 UTC
@@ -157,8 +157,7 @@
   FrameScope frame_scope(masm_, StackFrame::MANUAL);

   info->set_prologue_offset(masm_->pc_offset());
-  ASSERT(!info->IsStub());
-  __ Prologue(info);
+  __ Prologue(info->IsCodePreAgingActive());
   info->AddNoFrameRange(0, masm_->pc_offset());

   { Comment cmnt(masm_, "[ Allocate locals");
=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Mon May 12 13:47:01 2014 UTC +++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Thu May 15 12:10:00 2014 UTC
@@ -149,7 +149,11 @@
   if (NeedsEagerFrame()) {
     ASSERT(!frame_is_built_);
     frame_is_built_ = true;
-    __ Prologue(info());
+    if (info()->IsStub()) {
+      __ StubPrologue();
+    } else {
+      __ Prologue(info()->IsCodePreAgingActive());
+    }
     info()->AddNoFrameRange(0, masm_->pc_offset());
   }

=======================================
--- /branches/bleeding_edge/src/x64/macro-assembler-x64.cc Mon May 12 13:47:01 2014 UTC +++ /branches/bleeding_edge/src/x64/macro-assembler-x64.cc Thu May 15 12:10:00 2014 UTC
@@ -3889,26 +3889,27 @@
 }


-void MacroAssembler::Prologue(CompilationInfo* info) {
-  if (info->IsStub()) {
+void MacroAssembler::StubPrologue() {
     pushq(rbp);  // Caller's frame pointer.
     movp(rbp, rsp);
     Push(rsi);  // Callee's context.
     Push(Smi::FromInt(StackFrame::STUB));
+}
+
+
+void MacroAssembler::Prologue(bool code_pre_aging) {
+  PredictableCodeSizeScope predictible_code_size_scope(this,
+      kNoCodeAgeSequenceLength);
+  if (code_pre_aging) {
+      // Pre-age the code.
+    Call(isolate()->builtins()->MarkCodeAsExecutedOnce(),
+         RelocInfo::CODE_AGE_SEQUENCE);
+    Nop(kNoCodeAgeSequenceLength - Assembler::kShortCallInstructionLength);
   } else {
-    PredictableCodeSizeScope predictible_code_size_scope(this,
-        kNoCodeAgeSequenceLength);
-    if (info->IsCodePreAgingActive()) {
-        // Pre-age the code.
-      Call(isolate()->builtins()->MarkCodeAsExecutedOnce(),
-           RelocInfo::CODE_AGE_SEQUENCE);
- Nop(kNoCodeAgeSequenceLength - Assembler::kShortCallInstructionLength);
-    } else {
-      pushq(rbp);  // Caller's frame pointer.
-      movp(rbp, rsp);
-      Push(rsi);  // Callee's context.
-      Push(rdi);  // Callee's JS function.
-    }
+    pushq(rbp);  // Caller's frame pointer.
+    movp(rbp, rsp);
+    Push(rsi);  // Callee's context.
+    Push(rdi);  // Callee's JS function.
   }
 }

=======================================
--- /branches/bleeding_edge/src/x64/macro-assembler-x64.h Mon May 12 13:47:01 2014 UTC +++ /branches/bleeding_edge/src/x64/macro-assembler-x64.h Thu May 15 12:10:00 2014 UTC
@@ -274,7 +274,8 @@
   void DebugBreak();

   // Generates function and stub prologue code.
-  void Prologue(CompilationInfo* info);
+  void StubPrologue();
+  void Prologue(bool code_pre_aging);

   // Enter specific kind of exit frame; either in normal or
   // debug mode. Expects the number of arguments in register rax and

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to