| 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 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 const ParameterCount& arguments_; | 648 const ParameterCount& arguments_; |
| 649 Register name_; | 649 Register name_; |
| 650 }; | 650 }; |
| 651 | 651 |
| 652 | 652 |
| 653 #undef __ | 653 #undef __ |
| 654 | 654 |
| 655 #define __ ACCESS_MASM((masm())) | 655 #define __ ACCESS_MASM((masm())) |
| 656 | 656 |
| 657 | 657 |
| 658 Object* CallStubCompiler::CompileArrayPushCall(Object* object, |
| 659 JSObject* holder, |
| 660 JSFunction* function, |
| 661 String* name, |
| 662 CheckType check) { |
| 663 // ----------- S t a t e ------------- |
| 664 // rcx : function name |
| 665 // rsp[0] : return address |
| 666 // rsp[8] : argument argc |
| 667 // rsp[16] : argument argc - 1 |
| 668 // ... |
| 669 // rsp[argc * 8] : argument 1 |
| 670 // rsp[(argc + 1) * 8] : argument 0 = receiver |
| 671 // ----------------------------------- |
| 672 |
| 673 // TODO(639): faster implementation. |
| 674 ASSERT(check == RECEIVER_MAP_CHECK); |
| 675 |
| 676 Label miss; |
| 677 |
| 678 // Get the receiver from the stack. |
| 679 const int argc = arguments().immediate(); |
| 680 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); |
| 681 |
| 682 // Check that the receiver isn't a smi. |
| 683 __ JumpIfSmi(rdx, &miss); |
| 684 |
| 685 // Check that the maps haven't changed. |
| 686 CheckPrototypes(JSObject::cast(object), rdx, holder, |
| 687 rbx, rax, name, &miss); |
| 688 |
| 689 // Patch the receiver on the stack with the global proxy if |
| 690 // necessary. |
| 691 if (object->IsGlobalObject()) { |
| 692 __ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalReceiverOffset)); |
| 693 __ movq(Operand(rsp, (argc + 1) * kPointerSize), rdx); |
| 694 } |
| 695 |
| 696 __ TailCallExternalReference(ExternalReference(Builtins::c_ArrayPush), |
| 697 argc + 1, |
| 698 1); |
| 699 |
| 700 // Handle call cache miss. |
| 701 __ bind(&miss); |
| 702 Handle<Code> ic = ComputeCallMiss(arguments().immediate()); |
| 703 __ Jump(ic, RelocInfo::CODE_TARGET); |
| 704 |
| 705 // Return the generated code. |
| 706 String* function_name = NULL; |
| 707 if (function->shared()->name()->IsString()) { |
| 708 function_name = String::cast(function->shared()->name()); |
| 709 } |
| 710 return GetCode(CONSTANT_FUNCTION, function_name); |
| 711 } |
| 712 |
| 713 |
| 714 Object* CallStubCompiler::CompileArrayPopCall(Object* object, |
| 715 JSObject* holder, |
| 716 JSFunction* function, |
| 717 String* name, |
| 718 CheckType check) { |
| 719 // ----------- S t a t e ------------- |
| 720 // rcx : function name |
| 721 // rsp[0] : return address |
| 722 // rsp[8] : argument argc |
| 723 // rsp[16] : argument argc - 1 |
| 724 // ... |
| 725 // rsp[argc * 8] : argument 1 |
| 726 // rsp[(argc + 1) * 8] : argument 0 = receiver |
| 727 // ----------------------------------- |
| 728 |
| 729 // TODO(642): faster implementation. |
| 730 ASSERT(check == RECEIVER_MAP_CHECK); |
| 731 |
| 732 Label miss; |
| 733 |
| 734 // Get the receiver from the stack. |
| 735 const int argc = arguments().immediate(); |
| 736 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); |
| 737 |
| 738 // Check that the receiver isn't a smi. |
| 739 __ JumpIfSmi(rdx, &miss); |
| 740 |
| 741 // Check that the maps haven't changed. |
| 742 CheckPrototypes(JSObject::cast(object), rdx, holder, |
| 743 rbx, rax, name, &miss); |
| 744 |
| 745 // Patch the receiver on the stack with the global proxy if |
| 746 // necessary. |
| 747 if (object->IsGlobalObject()) { |
| 748 __ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalReceiverOffset)); |
| 749 __ movq(Operand(rsp, (argc + 1) * kPointerSize), rdx); |
| 750 } |
| 751 |
| 752 __ TailCallExternalReference(ExternalReference(Builtins::c_ArrayPop), |
| 753 argc + 1, |
| 754 1); |
| 755 |
| 756 // Handle call cache miss. |
| 757 __ bind(&miss); |
| 758 Handle<Code> ic = ComputeCallMiss(arguments().immediate()); |
| 759 __ Jump(ic, RelocInfo::CODE_TARGET); |
| 760 |
| 761 // Return the generated code. |
| 762 String* function_name = NULL; |
| 763 if (function->shared()->name()->IsString()) { |
| 764 function_name = String::cast(function->shared()->name()); |
| 765 } |
| 766 return GetCode(CONSTANT_FUNCTION, function_name); |
| 767 } |
| 768 |
| 769 |
| 658 Object* CallStubCompiler::CompileCallConstant(Object* object, | 770 Object* CallStubCompiler::CompileCallConstant(Object* object, |
| 659 JSObject* holder, | 771 JSObject* holder, |
| 660 JSFunction* function, | 772 JSFunction* function, |
| 661 String* name, | 773 String* name, |
| 662 StubCompiler::CheckType check) { | 774 StubCompiler::CheckType check) { |
| 663 // ----------- S t a t e ------------- | 775 // ----------- S t a t e ------------- |
| 664 // rcx : function name | 776 // rcx : function name |
| 665 // rsp[0] : return address | 777 // rsp[0] : return address |
| 666 // rsp[8] : argument argc | 778 // rsp[8] : argument argc |
| 667 // rsp[16] : argument argc - 1 | 779 // rsp[16] : argument argc - 1 |
| 668 // ... | 780 // ... |
| 669 // rsp[argc * 8] : argument 1 | 781 // rsp[argc * 8] : argument 1 |
| 670 // rsp[(argc + 1) * 8] : argument 0 = receiver | 782 // rsp[(argc + 1) * 8] : argument 0 = receiver |
| 671 // ----------------------------------- | 783 // ----------------------------------- |
| 672 | 784 |
| 785 SharedFunctionInfo* function_info = function->shared(); |
| 786 if (false && function_info->HasCustomCallGenerator()) { |
| 787 CustomCallGenerator generator = |
| 788 ToCData<CustomCallGenerator>(function_info->function_data()); |
| 789 return generator(this, object, holder, function, name, check); |
| 790 } |
| 791 |
| 673 Label miss; | 792 Label miss; |
| 674 | 793 |
| 675 // Get the receiver from the stack. | 794 // Get the receiver from the stack. |
| 676 const int argc = arguments().immediate(); | 795 const int argc = arguments().immediate(); |
| 677 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); | 796 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); |
| 678 | 797 |
| 679 // Check that the receiver isn't a smi. | 798 // Check that the receiver isn't a smi. |
| 680 if (check != NUMBER_CHECK) { | 799 if (check != NUMBER_CHECK) { |
| 681 __ JumpIfSmi(rdx, &miss); | 800 __ JumpIfSmi(rdx, &miss); |
| 682 } | 801 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 // Check that the maps starting from the prototype haven't changed. | 871 // Check that the maps starting from the prototype haven't changed. |
| 753 GenerateLoadGlobalFunctionPrototype(masm(), | 872 GenerateLoadGlobalFunctionPrototype(masm(), |
| 754 Context::BOOLEAN_FUNCTION_INDEX, | 873 Context::BOOLEAN_FUNCTION_INDEX, |
| 755 rax); | 874 rax); |
| 756 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder, | 875 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder, |
| 757 rbx, rdx, name, &miss); | 876 rbx, rdx, name, &miss); |
| 758 } | 877 } |
| 759 break; | 878 break; |
| 760 } | 879 } |
| 761 | 880 |
| 762 case JSARRAY_HAS_FAST_ELEMENTS_CHECK: | |
| 763 CheckPrototypes(JSObject::cast(object), rdx, holder, | |
| 764 rbx, rax, name, &miss); | |
| 765 // Make sure object->HasFastElements(). | |
| 766 // Get the elements array of the object. | |
| 767 __ movq(rbx, FieldOperand(rdx, JSObject::kElementsOffset)); | |
| 768 // Check that the object is in fast mode (not dictionary). | |
| 769 __ Cmp(FieldOperand(rbx, HeapObject::kMapOffset), | |
| 770 Factory::fixed_array_map()); | |
| 771 __ j(not_equal, &miss); | |
| 772 break; | |
| 773 | |
| 774 default: | 881 default: |
| 775 UNREACHABLE(); | 882 UNREACHABLE(); |
| 776 } | 883 } |
| 777 | 884 |
| 778 __ InvokeFunction(function, arguments(), JUMP_FUNCTION); | 885 __ InvokeFunction(function, arguments(), JUMP_FUNCTION); |
| 779 | 886 |
| 780 // Handle call cache miss. | 887 // Handle call cache miss. |
| 781 __ bind(&miss); | 888 __ bind(&miss); |
| 782 Handle<Code> ic = ComputeCallMiss(arguments().immediate()); | 889 Handle<Code> ic = ComputeCallMiss(arguments().immediate()); |
| 783 __ Jump(ic, RelocInfo::CODE_TARGET); | 890 __ Jump(ic, RelocInfo::CODE_TARGET); |
| (...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1853 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); | 1960 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); |
| 1854 | 1961 |
| 1855 // Return the generated code. | 1962 // Return the generated code. |
| 1856 return GetCode(); | 1963 return GetCode(); |
| 1857 } | 1964 } |
| 1858 | 1965 |
| 1859 | 1966 |
| 1860 #undef __ | 1967 #undef __ |
| 1861 | 1968 |
| 1862 } } // namespace v8::internal | 1969 } } // namespace v8::internal |
| OLD | NEW |