| OLD | NEW | 
|    1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |    1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 
|    2 // Redistribution and use in source and binary forms, with or without |    2 // Redistribution and use in source and binary forms, with or without | 
|    3 // modification, are permitted provided that the following conditions are |    3 // modification, are permitted provided that the following conditions are | 
|    4 // met: |    4 // met: | 
|    5 // |    5 // | 
|    6 //     * Redistributions of source code must retain the above copyright |    6 //     * Redistributions of source code must retain the above copyright | 
|    7 //       notice, this list of conditions and the following disclaimer. |    7 //       notice, this list of conditions and the following disclaimer. | 
|    8 //     * Redistributions in binary form must reproduce the above |    8 //     * Redistributions in binary form must reproduce the above | 
|    9 //       copyright notice, this list of conditions and the following |    9 //       copyright notice, this list of conditions and the following | 
|   10 //       disclaimer in the documentation and/or other materials provided |   10 //       disclaimer in the documentation and/or other materials provided | 
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   51  |   51  | 
|   52  |   52  | 
|   53 void Builtins::Generate_JSConstructCall(MacroAssembler* masm) { |   53 void Builtins::Generate_JSConstructCall(MacroAssembler* masm) { | 
|   54   // ----------- S t a t e ------------- |   54   // ----------- S t a t e ------------- | 
|   55   //  -- r0     : number of arguments |   55   //  -- r0     : number of arguments | 
|   56   //  -- r1     : constructor function |   56   //  -- r1     : constructor function | 
|   57   //  -- lr     : return address |   57   //  -- lr     : return address | 
|   58   //  -- sp[...]: constructor arguments |   58   //  -- sp[...]: constructor arguments | 
|   59   // ----------------------------------- |   59   // ----------------------------------- | 
|   60  |   60  | 
 |   61   Label non_function_call; | 
 |   62   // Check that the function is not a smi. | 
 |   63   __ tst(r1, Operand(kSmiTagMask)); | 
 |   64   __ b(eq, &non_function_call); | 
 |   65   // Check that the function is a JSFunction. | 
 |   66   __ ldr(r2, FieldMemOperand(r1, HeapObject::kMapOffset)); | 
 |   67   __ ldrb(r2, FieldMemOperand(r2, Map::kInstanceTypeOffset)); | 
 |   68   __ cmp(r2, Operand(JS_FUNCTION_TYPE)); | 
 |   69   __ b(ne, &non_function_call); | 
 |   70  | 
|   61   // Enter a construct frame. |   71   // Enter a construct frame. | 
|   62   __ EnterConstructFrame(); |   72   __ EnterConstructFrame(); | 
|   63  |   73  | 
|   64   // Preserve the two incoming parameters |   74   // Preserve the two incoming parameters | 
|   65   __ mov(r0, Operand(r0, LSL, kSmiTagSize)); |   75   __ mov(r0, Operand(r0, LSL, kSmiTagSize)); | 
|   66   __ push(r0);  // smi-tagged arguments count |   76   __ push(r0);  // smi-tagged arguments count | 
|   67   __ push(r1);  // constructor function |   77   __ push(r1);  // constructor function | 
|   68  |   78  | 
|   69   // Allocate the new receiver object. |   79   // Allocate the new receiver object. | 
|   70   __ push(r1);  // argument for Runtime_NewObject |   80   __ push(r1);  // argument for Runtime_NewObject | 
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  162   // return. |  172   // return. | 
|  163   __ bind(&exit); |  173   __ bind(&exit); | 
|  164   // r0: result |  174   // r0: result | 
|  165   // sp[0]: receiver (newly allocated object) |  175   // sp[0]: receiver (newly allocated object) | 
|  166   // sp[1]: constructor function |  176   // sp[1]: constructor function | 
|  167   // sp[2]: number of arguments (smi-tagged) |  177   // sp[2]: number of arguments (smi-tagged) | 
|  168   __ ldr(r1, MemOperand(sp, 2 * kPointerSize)); |  178   __ ldr(r1, MemOperand(sp, 2 * kPointerSize)); | 
|  169   __ LeaveConstructFrame(); |  179   __ LeaveConstructFrame(); | 
|  170   __ add(sp, sp, Operand(r1, LSL, kPointerSizeLog2 - 1)); |  180   __ add(sp, sp, Operand(r1, LSL, kPointerSizeLog2 - 1)); | 
|  171   __ add(sp, sp, Operand(kPointerSize)); |  181   __ add(sp, sp, Operand(kPointerSize)); | 
|  172   __ mov(pc, Operand(lr)); |  182   __ Jump(lr); | 
 |  183  | 
 |  184   // r0: number of arguments | 
 |  185   // r1: called object | 
 |  186   __ bind(&non_function_call); | 
 |  187  | 
 |  188   // Set expected number of arguments to zero (not changing r0). | 
 |  189   __ mov(r2, Operand(0)); | 
 |  190   __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); | 
 |  191   __ Jump(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)), | 
 |  192           RelocInfo::CODE_TARGET); | 
|  173 } |  193 } | 
|  174  |  194  | 
|  175  |  195  | 
|  176 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, |  196 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, | 
|  177                                              bool is_construct) { |  197                                              bool is_construct) { | 
|  178   // Called from Generate_JS_Entry |  198   // Called from Generate_JS_Entry | 
|  179   // r0: code entry |  199   // r0: code entry | 
|  180   // r1: function |  200   // r1: function | 
|  181   // r2: receiver |  201   // r2: receiver | 
|  182   // r3: argc |  202   // r3: argc | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  228     __ Call(Handle<Code>(Builtins::builtin(Builtins::JSConstructCall)), |  248     __ Call(Handle<Code>(Builtins::builtin(Builtins::JSConstructCall)), | 
|  229             RelocInfo::CODE_TARGET); |  249             RelocInfo::CODE_TARGET); | 
|  230   } else { |  250   } else { | 
|  231     ParameterCount actual(r0); |  251     ParameterCount actual(r0); | 
|  232     __ InvokeFunction(r1, actual, CALL_FUNCTION); |  252     __ InvokeFunction(r1, actual, CALL_FUNCTION); | 
|  233   } |  253   } | 
|  234  |  254  | 
|  235   // Exit the JS frame and remove the parameters (except function), and return. |  255   // Exit the JS frame and remove the parameters (except function), and return. | 
|  236   // Respect ABI stack constraint. |  256   // Respect ABI stack constraint. | 
|  237   __ LeaveInternalFrame(); |  257   __ LeaveInternalFrame(); | 
|  238   __ mov(pc, lr); |  258   __ Jump(lr); | 
|  239  |  259  | 
|  240   // r0: result |  260   // r0: result | 
|  241 } |  261 } | 
|  242  |  262  | 
|  243  |  263  | 
|  244 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { |  264 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { | 
|  245   Generate_JSEntryTrampolineHelper(masm, false); |  265   Generate_JSEntryTrampolineHelper(masm, false); | 
|  246 } |  266 } | 
|  247  |  267  | 
|  248  |  268  | 
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  537  |  557  | 
|  538   // Invoke the function. |  558   // Invoke the function. | 
|  539   ParameterCount actual(r0); |  559   ParameterCount actual(r0); | 
|  540   __ mov(r0, Operand(r0, ASR, kSmiTagSize)); |  560   __ mov(r0, Operand(r0, ASR, kSmiTagSize)); | 
|  541   __ ldr(r1, MemOperand(fp, kFunctionOffset)); |  561   __ ldr(r1, MemOperand(fp, kFunctionOffset)); | 
|  542   __ InvokeFunction(r1, actual, CALL_FUNCTION); |  562   __ InvokeFunction(r1, actual, CALL_FUNCTION); | 
|  543  |  563  | 
|  544   // Tear down the internal frame and remove function, receiver and args. |  564   // Tear down the internal frame and remove function, receiver and args. | 
|  545   __ LeaveInternalFrame(); |  565   __ LeaveInternalFrame(); | 
|  546   __ add(sp, sp, Operand(3 * kPointerSize)); |  566   __ add(sp, sp, Operand(3 * kPointerSize)); | 
|  547   __ mov(pc, lr); |  567   __ Jump(lr); | 
|  548 } |  568 } | 
|  549  |  569  | 
|  550  |  570  | 
|  551 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { |  571 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { | 
|  552   __ mov(r0, Operand(r0, LSL, kSmiTagSize)); |  572   __ mov(r0, Operand(r0, LSL, kSmiTagSize)); | 
|  553   __ mov(r4, Operand(ArgumentsAdaptorFrame::SENTINEL)); |  573   __ mov(r4, Operand(ArgumentsAdaptorFrame::SENTINEL)); | 
|  554   __ stm(db_w, sp, r0.bit() | r1.bit() | r4.bit() | fp.bit() | lr.bit()); |  574   __ stm(db_w, sp, r0.bit() | r1.bit() | r4.bit() | fp.bit() | lr.bit()); | 
|  555   __ add(fp, sp, Operand(3 * kPointerSize)); |  575   __ add(fp, sp, Operand(3 * kPointerSize)); | 
|  556 } |  576 } | 
|  557  |  577  | 
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  656     __ cmp(sp, r2); |  676     __ cmp(sp, r2); | 
|  657     __ b(ne, &fill); |  677     __ b(ne, &fill); | 
|  658   } |  678   } | 
|  659  |  679  | 
|  660   // Call the entry point. |  680   // Call the entry point. | 
|  661   __ bind(&invoke); |  681   __ bind(&invoke); | 
|  662   __ Call(r3); |  682   __ Call(r3); | 
|  663  |  683  | 
|  664   // Exit frame and return. |  684   // Exit frame and return. | 
|  665   LeaveArgumentsAdaptorFrame(masm); |  685   LeaveArgumentsAdaptorFrame(masm); | 
|  666   __ mov(pc, lr); |  686   __ Jump(lr); | 
|  667  |  687  | 
|  668  |  688  | 
|  669   // ------------------------------------------- |  689   // ------------------------------------------- | 
|  670   // Dont adapt arguments. |  690   // Dont adapt arguments. | 
|  671   // ------------------------------------------- |  691   // ------------------------------------------- | 
|  672   __ bind(&dont_adapt_arguments); |  692   __ bind(&dont_adapt_arguments); | 
|  673   __ mov(pc, r3); |  693   __ Jump(r3); | 
|  674 } |  694 } | 
|  675  |  695  | 
|  676  |  696  | 
|  677 #undef __ |  697 #undef __ | 
|  678  |  698  | 
|  679 } }  // namespace v8::internal |  699 } }  // namespace v8::internal | 
| OLD | NEW |