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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // ----------------------------------- | 60 // ----------------------------------- |
61 | 61 |
62 Label non_function_call; | 62 Label non_function_call; |
63 // Check that the function is not a smi. | 63 // Check that the function is not a smi. |
64 __ tst(r1, Operand(kSmiTagMask)); | 64 __ tst(r1, Operand(kSmiTagMask)); |
65 __ b(eq, &non_function_call); | 65 __ b(eq, &non_function_call); |
66 // Check that the function is a JSFunction. | 66 // Check that the function is a JSFunction. |
67 __ CompareObjectType(r1, r2, r2, JS_FUNCTION_TYPE); | 67 __ CompareObjectType(r1, r2, r2, JS_FUNCTION_TYPE); |
68 __ b(ne, &non_function_call); | 68 __ b(ne, &non_function_call); |
69 | 69 |
| 70 // Jump to the function-specific construct stub. |
| 71 __ ldr(r2, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); |
| 72 __ ldr(r2, FieldMemOperand(r2, SharedFunctionInfo::kConstructStubOffset)); |
| 73 __ add(pc, r2, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 74 |
| 75 // r0: number of arguments |
| 76 // r1: called object |
| 77 __ bind(&non_function_call); |
| 78 |
| 79 // Set expected number of arguments to zero (not changing r0). |
| 80 __ mov(r2, Operand(0)); |
| 81 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); |
| 82 __ Jump(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)), |
| 83 RelocInfo::CODE_TARGET); |
| 84 } |
| 85 |
| 86 |
| 87 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { |
70 // Enter a construct frame. | 88 // Enter a construct frame. |
71 __ EnterConstructFrame(); | 89 __ EnterConstructFrame(); |
72 | 90 |
73 // Preserve the two incoming parameters | 91 // Preserve the two incoming parameters |
74 __ mov(r0, Operand(r0, LSL, kSmiTagSize)); | 92 __ mov(r0, Operand(r0, LSL, kSmiTagSize)); |
75 __ push(r0); // smi-tagged arguments count | 93 __ push(r0); // smi-tagged arguments count |
76 __ push(r1); // constructor function | 94 __ push(r1); // constructor function |
77 | 95 |
78 // Allocate the new receiver object. | 96 // Allocate the new receiver object. |
79 __ push(r1); // argument for Runtime_NewObject | 97 __ push(r1); // argument for Runtime_NewObject |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 __ bind(&exit); | 188 __ bind(&exit); |
171 // r0: result | 189 // r0: result |
172 // sp[0]: receiver (newly allocated object) | 190 // sp[0]: receiver (newly allocated object) |
173 // sp[1]: constructor function | 191 // sp[1]: constructor function |
174 // sp[2]: number of arguments (smi-tagged) | 192 // sp[2]: number of arguments (smi-tagged) |
175 __ ldr(r1, MemOperand(sp, 2 * kPointerSize)); | 193 __ ldr(r1, MemOperand(sp, 2 * kPointerSize)); |
176 __ LeaveConstructFrame(); | 194 __ LeaveConstructFrame(); |
177 __ add(sp, sp, Operand(r1, LSL, kPointerSizeLog2 - 1)); | 195 __ add(sp, sp, Operand(r1, LSL, kPointerSizeLog2 - 1)); |
178 __ add(sp, sp, Operand(kPointerSize)); | 196 __ add(sp, sp, Operand(kPointerSize)); |
179 __ Jump(lr); | 197 __ Jump(lr); |
180 | |
181 // r0: number of arguments | |
182 // r1: called object | |
183 __ bind(&non_function_call); | |
184 | |
185 // Set expected number of arguments to zero (not changing r0). | |
186 __ mov(r2, Operand(0)); | |
187 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); | |
188 __ Jump(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)), | |
189 RelocInfo::CODE_TARGET); | |
190 } | 198 } |
191 | 199 |
192 | 200 |
193 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, | 201 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, |
194 bool is_construct) { | 202 bool is_construct) { |
195 // Called from Generate_JS_Entry | 203 // Called from Generate_JS_Entry |
196 // r0: code entry | 204 // r0: code entry |
197 // r1: function | 205 // r1: function |
198 // r2: receiver | 206 // r2: receiver |
199 // r3: argc | 207 // r3: argc |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 // Dont adapt arguments. | 689 // Dont adapt arguments. |
682 // ------------------------------------------- | 690 // ------------------------------------------- |
683 __ bind(&dont_adapt_arguments); | 691 __ bind(&dont_adapt_arguments); |
684 __ Jump(r3); | 692 __ Jump(r3); |
685 } | 693 } |
686 | 694 |
687 | 695 |
688 #undef __ | 696 #undef __ |
689 | 697 |
690 } } // namespace v8::internal | 698 } } // namespace v8::internal |
OLD | NEW |