Revision: 9929
Author:   [email protected]
Date:     Wed Nov  9 04:19:26 2011
Log:      MIPS: Make _CallFunction proxy-aware.

Port r9916 (d2195670)

Original commit message:
Change calling convention for CallFunction stub. Some fixes regarding strict mode call traps.

BUG=
TEST=

Review URL: http://codereview.chromium.org/8509004
Patch from Gergely Kis <[email protected]>.
http://code.google.com/p/v8/source/detail?r=9929

Modified:
 /branches/bleeding_edge/src/mips/code-stubs-mips.cc
 /branches/bleeding_edge/src/mips/debug-mips.cc
 /branches/bleeding_edge/src/mips/full-codegen-mips.cc
 /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc
 /branches/bleeding_edge/src/mips/lithium-mips.cc
 /branches/bleeding_edge/src/mips/lithium-mips.h

=======================================
--- /branches/bleeding_edge/src/mips/code-stubs-mips.cc Mon Nov 7 00:41:47 2011 +++ /branches/bleeding_edge/src/mips/code-stubs-mips.cc Wed Nov 9 04:19:26 2011
@@ -5120,6 +5120,7 @@


 void CallFunctionStub::Generate(MacroAssembler* masm) {
+  // a1 : the function to call
   Label slow, non_function;

   // The receiver might implicitly be the global object. This is
@@ -5134,15 +5135,11 @@
     __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
     __ Branch(&call, ne, t0, Operand(at));
     // Patch the receiver on the stack with the global receiver object.
-    __ lw(a1, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX)));
-    __ lw(a1, FieldMemOperand(a1, GlobalObject::kGlobalReceiverOffset));
-    __ sw(a1, MemOperand(sp, argc_ * kPointerSize));
+    __ lw(a2, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX)));
+    __ lw(a2, FieldMemOperand(a2, GlobalObject::kGlobalReceiverOffset));
+    __ sw(a2, MemOperand(sp, argc_ * kPointerSize));
     __ bind(&call);
   }
-
-  // Get the function to call from the stack.
-  // function, receiver [, arguments]
-  __ lw(a1, MemOperand(sp, (argc_ + 1) * kPointerSize));

   // Check that the function is really a JavaScript function.
   // a1: pushed function (to be verified)
@@ -5180,7 +5177,7 @@
   __ li(a0, Operand(argc_ + 1, RelocInfo::NONE));
   __ li(a2, Operand(0, RelocInfo::NONE));
   __ GetBuiltinEntry(a3, Builtins::CALL_FUNCTION_PROXY);
-  __ SetCallKind(t1, CALL_AS_FUNCTION);
+  __ SetCallKind(t1, CALL_AS_METHOD);
   {
     Handle<Code> adaptor =
       masm->isolate()->builtins()->ArgumentsAdaptorTrampoline();
=======================================
--- /branches/bleeding_edge/src/mips/debug-mips.cc      Thu Sep 15 04:30:45 2011
+++ /branches/bleeding_edge/src/mips/debug-mips.cc      Wed Nov  9 04:19:26 2011
@@ -259,11 +259,11 @@
 }


-void Debug::GenerateStubNoRegistersDebugBreak(MacroAssembler* masm) {
+void Debug::GenerateCallFunctionStubDebugBreak(MacroAssembler* masm) {
   // ----------- S t a t e -------------
-  //  No registers used on entry.
+  //  -- a1 : function
   // -----------------------------------
-  Generate_DebugBreakCallHelper(masm, 0, 0);
+  Generate_DebugBreakCallHelper(masm, a1.bit(), 0);
 }


=======================================
--- /branches/bleeding_edge/src/mips/full-codegen-mips.cc Tue Nov 8 05:28:53 2011 +++ /branches/bleeding_edge/src/mips/full-codegen-mips.cc Wed Nov 9 04:19:26 2011
@@ -2242,6 +2242,7 @@
   // Record source position for debugger.
   SetSourcePosition(expr->position());
   CallFunctionStub stub(arg_count, flags);
+  __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize));
   __ CallStub(&stub);
   RecordJSReturnSite(expr);
   // Restore context register.
@@ -2318,6 +2319,7 @@
     // Record source position for debugger.
     SetSourcePosition(expr->position());
     CallFunctionStub stub(arg_count, RECEIVER_MIGHT_BE_IMPLICIT);
+    __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize));
     __ CallStub(&stub);
     RecordJSReturnSite(expr);
     // Restore context register.
@@ -3230,12 +3232,24 @@
   }
   VisitForAccumulatorValue(args->last());  // Function.

+  // Check for proxy.
+  Label proxy, done;
+  __ GetObjectType(v0, a1, a1);
+  __ Branch(&proxy, eq, a1, Operand(JS_FUNCTION_PROXY_TYPE));
+
   // InvokeFunction requires the function in a1. Move it in there.
   __ mov(a1, result_register());
   ParameterCount count(arg_count);
   __ InvokeFunction(a1, count, CALL_FUNCTION,
                     NullCallWrapper(), CALL_AS_METHOD);
   __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
+  __ jmp(&done);
+
+  __ bind(&proxy);
+  __ push(v0);
+  __ CallRuntime(Runtime::kCall, args->length());
+  __ bind(&done);
+
   context()->Plug(v0);
 }

=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Tue Nov 8 01:56:09 2011 +++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Wed Nov 9 04:19:26 2011
@@ -3171,12 +3171,12 @@


 void LCodeGen::DoCallFunction(LCallFunction* instr) {
+  ASSERT(ToRegister(instr->function()).is(a1));
   ASSERT(ToRegister(instr->result()).is(v0));

   int arity = instr->arity();
   CallFunctionStub stub(arity, NO_CALL_FUNCTION_FLAGS);
   CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
-  __ Drop(1);
   __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
 }

=======================================
--- /branches/bleeding_edge/src/mips/lithium-mips.cc Tue Nov 8 01:56:09 2011 +++ /branches/bleeding_edge/src/mips/lithium-mips.cc Wed Nov 9 04:19:26 2011
@@ -1195,8 +1195,9 @@


 LInstruction* LChunkBuilder::DoCallFunction(HCallFunction* instr) {
+  LOperand* function = UseFixed(instr->function(), a1);
   argument_count_ -= instr->argument_count();
-  return MarkAsCall(DefineFixed(new LCallFunction, v0), instr);
+  return MarkAsCall(DefineFixed(new LCallFunction(function), v0), instr);
 }


=======================================
--- /branches/bleeding_edge/src/mips/lithium-mips.h     Tue Nov  8 01:56:09 2011
+++ /branches/bleeding_edge/src/mips/lithium-mips.h     Wed Nov  9 04:19:26 2011
@@ -1379,12 +1379,17 @@
 };


-class LCallFunction: public LTemplateInstruction<1, 0, 0> {
+class LCallFunction: public LTemplateInstruction<1, 1, 0> {
  public:
+  explicit LCallFunction(LOperand* function) {
+    inputs_[0] = function;
+  }
+
   DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
   DECLARE_HYDROGEN_ACCESSOR(CallFunction)

-  int arity() const { return hydrogen()->argument_count() - 2; }
+  LOperand* function() { return inputs_[0]; }
+  int arity() const { return hydrogen()->argument_count() - 1; }
 };


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to