| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 392 |
| 393 | 393 |
| 394 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { | 394 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { |
| 395 Generate_JSConstructStubHelper(masm, true, false); | 395 Generate_JSConstructStubHelper(masm, true, false); |
| 396 } | 396 } |
| 397 | 397 |
| 398 | 398 |
| 399 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, | 399 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, |
| 400 bool is_construct) { | 400 bool is_construct) { |
| 401 // Clear the context before we push it when entering the JS frame. | 401 // Clear the context before we push it when entering the JS frame. |
| 402 __ xor_(esi, Operand(esi)); // clear esi | 402 __ Set(esi, Immediate(0)); |
| 403 | 403 |
| 404 // Enter an internal frame. | 404 // Enter an internal frame. |
| 405 __ EnterInternalFrame(); | 405 __ EnterInternalFrame(); |
| 406 | 406 |
| 407 // Load the previous frame pointer (ebx) to access C arguments | 407 // Load the previous frame pointer (ebx) to access C arguments |
| 408 __ mov(ebx, Operand(ebp, 0)); | 408 __ mov(ebx, Operand(ebp, 0)); |
| 409 | 409 |
| 410 // Get the function from the frame and setup the context. | 410 // Get the function from the frame and setup the context. |
| 411 __ mov(ecx, Operand(ebx, EntryFrameConstants::kFunctionArgOffset)); | 411 __ mov(ecx, Operand(ebx, EntryFrameConstants::kFunctionArgOffset)); |
| 412 __ mov(esi, FieldOperand(ecx, JSFunction::kContextOffset)); | 412 __ mov(esi, FieldOperand(ecx, JSFunction::kContextOffset)); |
| 413 | 413 |
| 414 // Push the function and the receiver onto the stack. | 414 // Push the function and the receiver onto the stack. |
| 415 __ push(ecx); | 415 __ push(ecx); |
| 416 __ push(Operand(ebx, EntryFrameConstants::kReceiverArgOffset)); | 416 __ push(Operand(ebx, EntryFrameConstants::kReceiverArgOffset)); |
| 417 | 417 |
| 418 // Load the number of arguments and setup pointer to the arguments. | 418 // Load the number of arguments and setup pointer to the arguments. |
| 419 __ mov(eax, Operand(ebx, EntryFrameConstants::kArgcOffset)); | 419 __ mov(eax, Operand(ebx, EntryFrameConstants::kArgcOffset)); |
| 420 __ mov(ebx, Operand(ebx, EntryFrameConstants::kArgvOffset)); | 420 __ mov(ebx, Operand(ebx, EntryFrameConstants::kArgvOffset)); |
| 421 | 421 |
| 422 // Copy arguments to the stack in a loop. | 422 // Copy arguments to the stack in a loop. |
| 423 Label loop, entry; | 423 Label loop, entry; |
| 424 __ xor_(ecx, Operand(ecx)); // clear ecx | 424 __ Set(ecx, Immediate(0)); |
| 425 __ jmp(&entry); | 425 __ jmp(&entry); |
| 426 __ bind(&loop); | 426 __ bind(&loop); |
| 427 __ mov(edx, Operand(ebx, ecx, times_4, 0)); // push parameter from argv | 427 __ mov(edx, Operand(ebx, ecx, times_4, 0)); // push parameter from argv |
| 428 __ push(Operand(edx, 0)); // dereference handle | 428 __ push(Operand(edx, 0)); // dereference handle |
| 429 __ inc(Operand(ecx)); | 429 __ inc(Operand(ecx)); |
| 430 __ bind(&entry); | 430 __ bind(&entry); |
| 431 __ cmp(ecx, Operand(eax)); | 431 __ cmp(ecx, Operand(eax)); |
| 432 __ j(not_equal, &loop); | 432 __ j(not_equal, &loop); |
| 433 | 433 |
| 434 // Get the function from the stack and call it. | 434 // Get the function from the stack and call it. |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 __ jmp(&shift_arguments); | 637 __ jmp(&shift_arguments); |
| 638 } | 638 } |
| 639 | 639 |
| 640 // 3b. Patch the first argument when calling a non-function. The | 640 // 3b. Patch the first argument when calling a non-function. The |
| 641 // CALL_NON_FUNCTION builtin expects the non-function callee as | 641 // CALL_NON_FUNCTION builtin expects the non-function callee as |
| 642 // receiver, so overwrite the first argument which will ultimately | 642 // receiver, so overwrite the first argument which will ultimately |
| 643 // become the receiver. | 643 // become the receiver. |
| 644 __ bind(&non_function); | 644 __ bind(&non_function); |
| 645 __ mov(Operand(esp, eax, times_4, 0), edi); | 645 __ mov(Operand(esp, eax, times_4, 0), edi); |
| 646 // Clear edi to indicate a non-function being called. | 646 // Clear edi to indicate a non-function being called. |
| 647 __ xor_(edi, Operand(edi)); | 647 __ Set(edi, Immediate(0)); |
| 648 | 648 |
| 649 // 4. Shift arguments and return address one slot down on the stack | 649 // 4. Shift arguments and return address one slot down on the stack |
| 650 // (overwriting the original receiver). Adjust argument count to make | 650 // (overwriting the original receiver). Adjust argument count to make |
| 651 // the original first argument the new receiver. | 651 // the original first argument the new receiver. |
| 652 __ bind(&shift_arguments); | 652 __ bind(&shift_arguments); |
| 653 { Label loop; | 653 { Label loop; |
| 654 __ mov(ecx, eax); | 654 __ mov(ecx, eax); |
| 655 __ bind(&loop); | 655 __ bind(&loop); |
| 656 __ mov(ebx, Operand(esp, ecx, times_4, 0)); | 656 __ mov(ebx, Operand(esp, ecx, times_4, 0)); |
| 657 __ mov(Operand(esp, ecx, times_4, kPointerSize), ebx); | 657 __ mov(Operand(esp, ecx, times_4, kPointerSize), ebx); |
| 658 __ dec(ecx); | 658 __ dec(ecx); |
| 659 __ j(not_sign, &loop); // While non-negative (to copy return address). | 659 __ j(not_sign, &loop); // While non-negative (to copy return address). |
| 660 __ pop(ebx); // Discard copy of return address. | 660 __ pop(ebx); // Discard copy of return address. |
| 661 __ dec(eax); // One fewer argument (first argument is new receiver). | 661 __ dec(eax); // One fewer argument (first argument is new receiver). |
| 662 } | 662 } |
| 663 | 663 |
| 664 // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin. | 664 // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin. |
| 665 { Label function; | 665 { Label function; |
| 666 __ test(edi, Operand(edi)); | 666 __ test(edi, Operand(edi)); |
| 667 __ j(not_zero, &function, taken); | 667 __ j(not_zero, &function, taken); |
| 668 __ xor_(ebx, Operand(ebx)); | 668 __ Set(ebx, Immediate(0)); |
| 669 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION); | 669 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION); |
| 670 __ jmp(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)), | 670 __ jmp(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)), |
| 671 RelocInfo::CODE_TARGET); | 671 RelocInfo::CODE_TARGET); |
| 672 __ bind(&function); | 672 __ bind(&function); |
| 673 } | 673 } |
| 674 | 674 |
| 675 // 5b. Get the code to call from the function and check that the number of | 675 // 5b. Get the code to call from the function and check that the number of |
| 676 // expected arguments matches what we're providing. If so, jump | 676 // expected arguments matches what we're providing. If so, jump |
| 677 // (tail-call) to the code in register edx without checking arguments. | 677 // (tail-call) to the code in register edx without checking arguments. |
| 678 __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 678 __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
| (...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1566 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); | 1566 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); |
| 1567 generator.Generate(); | 1567 generator.Generate(); |
| 1568 } | 1568 } |
| 1569 | 1569 |
| 1570 | 1570 |
| 1571 #undef __ | 1571 #undef __ |
| 1572 | 1572 |
| 1573 } } // namespace v8::internal | 1573 } } // namespace v8::internal |
| 1574 | 1574 |
| 1575 #endif // V8_TARGET_ARCH_IA32 | 1575 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |