| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 // ----------------------------------- | 56 // ----------------------------------- |
| 57 | 57 |
| 58 Label non_function_call; | 58 Label non_function_call; |
| 59 // Check that function is not a smi. | 59 // Check that function is not a smi. |
| 60 __ test(edi, Immediate(kSmiTagMask)); | 60 __ test(edi, Immediate(kSmiTagMask)); |
| 61 __ j(zero, &non_function_call); | 61 __ j(zero, &non_function_call); |
| 62 // Check that function is a JSFunction. | 62 // Check that function is a JSFunction. |
| 63 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); | 63 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); |
| 64 __ j(not_equal, &non_function_call); | 64 __ j(not_equal, &non_function_call); |
| 65 | 65 |
| 66 // Jump to the function-specific construct stub. |
| 67 __ mov(ebx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
| 68 __ mov(ebx, FieldOperand(ebx, SharedFunctionInfo::kConstructStubOffset)); |
| 69 __ lea(ebx, FieldOperand(ebx, Code::kHeaderSize)); |
| 70 __ jmp(Operand(ebx)); |
| 71 |
| 72 // edi: called object |
| 73 // eax: number of arguments |
| 74 __ bind(&non_function_call); |
| 75 |
| 76 // Set expected number of arguments to zero (not changing eax). |
| 77 __ Set(ebx, Immediate(0)); |
| 78 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); |
| 79 __ jmp(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)), |
| 80 RelocInfo::CODE_TARGET); |
| 81 } |
| 82 |
| 83 |
| 84 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { |
| 66 // Enter a construct frame. | 85 // Enter a construct frame. |
| 67 __ EnterConstructFrame(); | 86 __ EnterConstructFrame(); |
| 68 | 87 |
| 69 // Store a smi-tagged arguments count on the stack. | 88 // Store a smi-tagged arguments count on the stack. |
| 70 __ shl(eax, kSmiTagSize); | 89 __ shl(eax, kSmiTagSize); |
| 71 __ push(eax); | 90 __ push(eax); |
| 72 | 91 |
| 73 // Push the function to invoke on the stack. | 92 // Push the function to invoke on the stack. |
| 74 __ push(edi); | 93 __ push(edi); |
| 75 | 94 |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 __ bind(&exit); | 317 __ bind(&exit); |
| 299 __ mov(ebx, Operand(esp, kPointerSize)); // get arguments count | 318 __ mov(ebx, Operand(esp, kPointerSize)); // get arguments count |
| 300 __ LeaveConstructFrame(); | 319 __ LeaveConstructFrame(); |
| 301 | 320 |
| 302 // Remove caller arguments from the stack and return. | 321 // Remove caller arguments from the stack and return. |
| 303 ASSERT(kSmiTagSize == 1 && kSmiTag == 0); | 322 ASSERT(kSmiTagSize == 1 && kSmiTag == 0); |
| 304 __ pop(ecx); | 323 __ pop(ecx); |
| 305 __ lea(esp, Operand(esp, ebx, times_2, 1 * kPointerSize)); // 1 ~ receiver | 324 __ lea(esp, Operand(esp, ebx, times_2, 1 * kPointerSize)); // 1 ~ receiver |
| 306 __ push(ecx); | 325 __ push(ecx); |
| 307 __ ret(0); | 326 __ ret(0); |
| 308 | |
| 309 // edi: called object | |
| 310 // eax: number of arguments | |
| 311 __ bind(&non_function_call); | |
| 312 | |
| 313 // Set expected number of arguments to zero (not changing eax). | |
| 314 __ Set(ebx, Immediate(0)); | |
| 315 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); | |
| 316 __ jmp(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)), | |
| 317 RelocInfo::CODE_TARGET); | |
| 318 } | 327 } |
| 319 | 328 |
| 320 | 329 |
| 321 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, | 330 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, |
| 322 bool is_construct) { | 331 bool is_construct) { |
| 323 // Clear the context before we push it when entering the JS frame. | 332 // Clear the context before we push it when entering the JS frame. |
| 324 __ xor_(esi, Operand(esi)); // clear esi | 333 __ xor_(esi, Operand(esi)); // clear esi |
| 325 | 334 |
| 326 // Enter an internal frame. | 335 // Enter an internal frame. |
| 327 __ EnterInternalFrame(); | 336 __ EnterInternalFrame(); |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 // Dont adapt arguments. | 771 // Dont adapt arguments. |
| 763 // ------------------------------------------- | 772 // ------------------------------------------- |
| 764 __ bind(&dont_adapt_arguments); | 773 __ bind(&dont_adapt_arguments); |
| 765 __ jmp(Operand(edx)); | 774 __ jmp(Operand(edx)); |
| 766 } | 775 } |
| 767 | 776 |
| 768 | 777 |
| 769 #undef __ | 778 #undef __ |
| 770 | 779 |
| 771 } } // namespace v8::internal | 780 } } // namespace v8::internal |
| OLD | NEW |