Revision: 17057
Author:   [email protected]
Date:     Tue Oct  1 19:03:47 2013 UTC
Log: MIPS: Lazily save double registers for HCallRuntime instructions within Hydrogen code stubs.

Port r17044 (94843cc)

Original commit message:
Right now we eagerly save all allocatable double registers upon
entry to every Hydrogen code stub that uses HCallRuntime, and
restore them when we return. Since the HCallRuntime is on the
fallback path for code stubs, this is both a waste of time and
stack space in almost every case.

This patch adds a flag to the HCallRuntime, which controls whether
the instruction saves the double register itself (using the save
doubles flag for the CEntryStub), or whether its up the surrounding
code to handle the clobbering of double registers.

BUG=
[email protected]

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

Patch from Balazs Kilvady <[email protected]>.
http://code.google.com/p/v8/source/detail?r=17057

Modified:
 /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc
 /branches/bleeding_edge/src/mips/lithium-codegen-mips.h
 /branches/bleeding_edge/src/mips/lithium-mips.cc
 /branches/bleeding_edge/src/mips/lithium-mips.h
 /branches/bleeding_edge/src/mips/macro-assembler-mips.cc
 /branches/bleeding_edge/src/mips/macro-assembler-mips.h

=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Fri Sep 27 16:16:40 2013 UTC +++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Tue Oct 1 19:03:47 2013 UTC
@@ -712,13 +712,15 @@

 void LCodeGen::CallRuntime(const Runtime::Function* function,
                            int num_arguments,
-                           LInstruction* instr) {
+                           LInstruction* instr,
+                           SaveFPRegsMode save_doubles) {
   ASSERT(instr != NULL);
   LPointerMap* pointers = instr->pointer_map();
   ASSERT(pointers != NULL);
   RecordPosition(pointers->position());

-  __ CallRuntime(function, num_arguments);
+  __ CallRuntime(function, num_arguments, save_doubles);
+
   RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT);
 }

=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.h Thu Sep 12 21:17:43 2013 UTC +++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.h Tue Oct 1 19:03:47 2013 UTC
@@ -245,7 +245,8 @@

   void CallRuntime(const Runtime::Function* function,
                    int num_arguments,
-                   LInstruction* instr);
+                   LInstruction* instr,
+                   SaveFPRegsMode save_doubles = kDontSaveFPRegs);

   void CallRuntime(Runtime::FunctionId id,
                    int num_arguments,
=======================================
--- /branches/bleeding_edge/src/mips/lithium-mips.cc Sat Sep 28 00:48:08 2013 UTC +++ /branches/bleeding_edge/src/mips/lithium-mips.cc Tue Oct 1 19:03:47 2013 UTC
@@ -867,6 +867,10 @@
   LInstruction* instr = current->CompileToLithium(this);

   if (instr != NULL) {
+    // Associate the hydrogen instruction first, since we may need it for
+    // the ClobbersRegisters() or ClobbersDoubleRegisters() calls below.
+    instr->set_hydrogen_value(current);
+
 #if DEBUG
     // Make sure that the lithium instruction has either no fixed register
     // constraints in temps or the result OR no uses that are only used at
@@ -903,7 +907,6 @@
     if (FLAG_stress_environments && !instr->HasEnvironment()) {
       instr = AssignEnvironment(instr);
     }
-    instr->set_hydrogen_value(current);
     chunk_->AddInstruction(instr, current_block_);
   }
   current_instruction_ = old_current;
=======================================
--- /branches/bleeding_edge/src/mips/lithium-mips.h Sat Sep 28 00:48:08 2013 UTC +++ /branches/bleeding_edge/src/mips/lithium-mips.h Tue Oct 1 19:03:47 2013 UTC
@@ -274,7 +274,7 @@
   // Interface to the register allocator and iterators.
   bool ClobbersTemps() const { return IsCall(); }
   bool ClobbersRegisters() const { return IsCall(); }
-  bool ClobbersDoubleRegisters() const { return IsCall(); }
+  virtual bool ClobbersDoubleRegisters() const { return IsCall(); }

   // Interface to the register allocator and iterators.
   bool IsMarkedAsCall() const { return IsCall(); }
@@ -1963,8 +1963,13 @@
   DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
   DECLARE_HYDROGEN_ACCESSOR(CallRuntime)

+  virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
+    return save_doubles() == kDontSaveFPRegs;
+  }
+
const Runtime::Function* function() const { return hydrogen()->function(); }
   int arity() const { return hydrogen()->argument_count(); }
+ SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
 };


=======================================
--- /branches/bleeding_edge/src/mips/macro-assembler-mips.cc Mon Sep 23 19:38:54 2013 UTC +++ /branches/bleeding_edge/src/mips/macro-assembler-mips.cc Tue Oct 1 19:03:47 2013 UTC
@@ -4136,7 +4136,8 @@


 void MacroAssembler::CallRuntime(const Runtime::Function* f,
-                                 int num_arguments) {
+                                 int num_arguments,
+                                 SaveFPRegsMode save_doubles) {
   // All parameters are on the stack. v0 has the return value after call.

   // If the expected number of arguments of the runtime function is
@@ -4153,23 +4154,9 @@
   // smarter.
   PrepareCEntryArgs(num_arguments);
   PrepareCEntryFunction(ExternalReference(f, isolate()));
-  CEntryStub stub(1);
+  CEntryStub stub(1, save_doubles);
   CallStub(&stub);
 }
-
-
-void MacroAssembler::CallRuntimeSaveDoubles(Runtime::FunctionId id) {
-  const Runtime::Function* function = Runtime::FunctionForId(id);
-  PrepareCEntryArgs(function->nargs);
-  PrepareCEntryFunction(ExternalReference(function, isolate()));
-  CEntryStub stub(1, kSaveFPRegs);
-  CallStub(&stub);
-}
-
-
-void MacroAssembler::CallRuntime(Runtime::FunctionId fid, int num_arguments) {
-  CallRuntime(Runtime::FunctionForId(fid), num_arguments);
-}


 void MacroAssembler::CallExternalReference(const ExternalReference& ext,
=======================================
--- /branches/bleeding_edge/src/mips/macro-assembler-mips.h Thu Sep 19 15:31:51 2013 UTC +++ /branches/bleeding_edge/src/mips/macro-assembler-mips.h Tue Oct 1 19:03:47 2013 UTC
@@ -1201,11 +1201,18 @@
   void CallJSExitStub(CodeStub* stub);

   // Call a runtime routine.
-  void CallRuntime(const Runtime::Function* f, int num_arguments);
-  void CallRuntimeSaveDoubles(Runtime::FunctionId id);
+  void CallRuntime(const Runtime::Function* f,
+                   int num_arguments,
+                   SaveFPRegsMode save_doubles = kDontSaveFPRegs);
+  void CallRuntimeSaveDoubles(Runtime::FunctionId id) {
+    const Runtime::Function* function = Runtime::FunctionForId(id);
+    CallRuntime(function, function->nargs, kSaveFPRegs);
+  }

   // Convenience function: Same as above, but takes the fid instead.
-  void CallRuntime(Runtime::FunctionId fid, int num_arguments);
+  void CallRuntime(Runtime::FunctionId id, int num_arguments) {
+    CallRuntime(Runtime::FunctionForId(id), num_arguments);
+  }

   // Convenience function: call an external reference.
   void CallExternalReference(const ExternalReference& ext,

--
--
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/groups/opt_out.

Reply via email to