| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 4685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4696 __ j(equal, &done, Label::kNear); | 4696 __ j(equal, &done, Label::kNear); |
| 4697 __ cmp(ecx, Immediate(TypeFeedbackCells::MegamorphicSentinel(isolate))); | 4697 __ cmp(ecx, Immediate(TypeFeedbackCells::MegamorphicSentinel(isolate))); |
| 4698 __ j(equal, &done, Label::kNear); | 4698 __ j(equal, &done, Label::kNear); |
| 4699 | 4699 |
| 4700 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 4700 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
| 4701 // megamorphic. | 4701 // megamorphic. |
| 4702 __ cmp(ecx, Immediate(TypeFeedbackCells::UninitializedSentinel(isolate))); | 4702 __ cmp(ecx, Immediate(TypeFeedbackCells::UninitializedSentinel(isolate))); |
| 4703 __ j(equal, &initialize, Label::kNear); | 4703 __ j(equal, &initialize, Label::kNear); |
| 4704 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 4704 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
| 4705 // write-barrier is needed. | 4705 // write-barrier is needed. |
| 4706 __ mov(FieldOperand(ebx, JSGlobalPropertyCell::kValueOffset), | 4706 __ mov(FieldOperand(ebx, Cell::kValueOffset), |
| 4707 Immediate(TypeFeedbackCells::MegamorphicSentinel(isolate))); | 4707 Immediate(TypeFeedbackCells::MegamorphicSentinel(isolate))); |
| 4708 __ jmp(&done, Label::kNear); | 4708 __ jmp(&done, Label::kNear); |
| 4709 | 4709 |
| 4710 // An uninitialized cache is patched with the function. | 4710 // An uninitialized cache is patched with the function. |
| 4711 __ bind(&initialize); | 4711 __ bind(&initialize); |
| 4712 __ mov(FieldOperand(ebx, JSGlobalPropertyCell::kValueOffset), edi); | 4712 __ mov(FieldOperand(ebx, Cell::kValueOffset), edi); |
| 4713 // No need for a write barrier here - cells are rescanned. | 4713 // No need for a write barrier here - cells are rescanned. |
| 4714 | 4714 |
| 4715 __ bind(&done); | 4715 __ bind(&done); |
| 4716 } | 4716 } |
| 4717 | 4717 |
| 4718 | 4718 |
| 4719 static void GenerateRecordCallTarget(MacroAssembler* masm) { | 4719 static void GenerateRecordCallTarget(MacroAssembler* masm) { |
| 4720 // Cache the called function in a global property cell. Cache states | 4720 // Cache the called function in a global property cell. Cache states |
| 4721 // are uninitialized, monomorphic (indicated by a JSFunction), and | 4721 // are uninitialized, monomorphic (indicated by a JSFunction), and |
| 4722 // megamorphic. | 4722 // megamorphic. |
| 4723 // ebx : cache cell for call target | 4723 // ebx : cache cell for call target |
| 4724 // edi : the function to call | 4724 // edi : the function to call |
| 4725 ASSERT(FLAG_optimize_constructed_arrays); | 4725 ASSERT(FLAG_optimize_constructed_arrays); |
| 4726 Isolate* isolate = masm->isolate(); | 4726 Isolate* isolate = masm->isolate(); |
| 4727 Label initialize, done, miss, megamorphic, not_array_function; | 4727 Label initialize, done, miss, megamorphic, not_array_function; |
| 4728 | 4728 |
| 4729 // Load the cache state into ecx. | 4729 // Load the cache state into ecx. |
| 4730 __ mov(ecx, FieldOperand(ebx, JSGlobalPropertyCell::kValueOffset)); | 4730 __ mov(ecx, FieldOperand(ebx, Cell::kValueOffset)); |
| 4731 | 4731 |
| 4732 // A monomorphic cache hit or an already megamorphic state: invoke the | 4732 // A monomorphic cache hit or an already megamorphic state: invoke the |
| 4733 // function without changing the state. | 4733 // function without changing the state. |
| 4734 __ cmp(ecx, edi); | 4734 __ cmp(ecx, edi); |
| 4735 __ j(equal, &done); | 4735 __ j(equal, &done); |
| 4736 __ cmp(ecx, Immediate(TypeFeedbackCells::MegamorphicSentinel(isolate))); | 4736 __ cmp(ecx, Immediate(TypeFeedbackCells::MegamorphicSentinel(isolate))); |
| 4737 __ j(equal, &done); | 4737 __ j(equal, &done); |
| 4738 | 4738 |
| 4739 // Special handling of the Array() function, which caches not only the | 4739 // Special handling of the Array() function, which caches not only the |
| 4740 // monomorphic Array function but the initial ElementsKind with special | 4740 // monomorphic Array function but the initial ElementsKind with special |
| (...skipping 14 matching lines...) Expand all Loading... |
| 4755 | 4755 |
| 4756 __ bind(&miss); | 4756 __ bind(&miss); |
| 4757 | 4757 |
| 4758 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 4758 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
| 4759 // megamorphic. | 4759 // megamorphic. |
| 4760 __ cmp(ecx, Immediate(TypeFeedbackCells::UninitializedSentinel(isolate))); | 4760 __ cmp(ecx, Immediate(TypeFeedbackCells::UninitializedSentinel(isolate))); |
| 4761 __ j(equal, &initialize); | 4761 __ j(equal, &initialize); |
| 4762 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 4762 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
| 4763 // write-barrier is needed. | 4763 // write-barrier is needed. |
| 4764 __ bind(&megamorphic); | 4764 __ bind(&megamorphic); |
| 4765 __ mov(FieldOperand(ebx, JSGlobalPropertyCell::kValueOffset), | 4765 __ mov(FieldOperand(ebx, Cell::kValueOffset), |
| 4766 Immediate(TypeFeedbackCells::MegamorphicSentinel(isolate))); | 4766 Immediate(TypeFeedbackCells::MegamorphicSentinel(isolate))); |
| 4767 __ jmp(&done, Label::kNear); | 4767 __ jmp(&done, Label::kNear); |
| 4768 | 4768 |
| 4769 // An uninitialized cache is patched with the function or sentinel to | 4769 // An uninitialized cache is patched with the function or sentinel to |
| 4770 // indicate the ElementsKind if function is the Array constructor. | 4770 // indicate the ElementsKind if function is the Array constructor. |
| 4771 __ bind(&initialize); | 4771 __ bind(&initialize); |
| 4772 __ LoadGlobalContext(ecx); | 4772 __ LoadGlobalContext(ecx); |
| 4773 // Make sure the function is the Array() function | 4773 // Make sure the function is the Array() function |
| 4774 __ cmp(edi, Operand(ecx, | 4774 __ cmp(edi, Operand(ecx, |
| 4775 Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX))); | 4775 Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX))); |
| 4776 __ j(not_equal, ¬_array_function); | 4776 __ j(not_equal, ¬_array_function); |
| 4777 | 4777 |
| 4778 // The target function is the Array constructor, install a sentinel value in | 4778 // The target function is the Array constructor, install a sentinel value in |
| 4779 // the constructor's type info cell that will track the initial ElementsKind | 4779 // the constructor's type info cell that will track the initial ElementsKind |
| 4780 // that should be used for the array when its constructed. | 4780 // that should be used for the array when its constructed. |
| 4781 Handle<Object> initial_kind_sentinel = | 4781 Handle<Object> initial_kind_sentinel = |
| 4782 TypeFeedbackCells::MonomorphicArraySentinel(isolate, | 4782 TypeFeedbackCells::MonomorphicArraySentinel(isolate, |
| 4783 GetInitialFastElementsKind()); | 4783 GetInitialFastElementsKind()); |
| 4784 __ mov(FieldOperand(ebx, JSGlobalPropertyCell::kValueOffset), | 4784 __ mov(FieldOperand(ebx, Cell::kValueOffset), |
| 4785 Immediate(initial_kind_sentinel)); | 4785 Immediate(initial_kind_sentinel)); |
| 4786 __ jmp(&done); | 4786 __ jmp(&done); |
| 4787 | 4787 |
| 4788 __ bind(¬_array_function); | 4788 __ bind(¬_array_function); |
| 4789 __ mov(FieldOperand(ebx, JSGlobalPropertyCell::kValueOffset), edi); | 4789 __ mov(FieldOperand(ebx, Cell::kValueOffset), edi); |
| 4790 // No need for a write barrier here - cells are rescanned. | 4790 // No need for a write barrier here - cells are rescanned. |
| 4791 | 4791 |
| 4792 __ bind(&done); | 4792 __ bind(&done); |
| 4793 } | 4793 } |
| 4794 | 4794 |
| 4795 | 4795 |
| 4796 void CallFunctionStub::Generate(MacroAssembler* masm) { | 4796 void CallFunctionStub::Generate(MacroAssembler* masm) { |
| 4797 // ebx : cache cell for call target | 4797 // ebx : cache cell for call target |
| 4798 // edi : the function to call | 4798 // edi : the function to call |
| 4799 Isolate* isolate = masm->isolate(); | 4799 Isolate* isolate = masm->isolate(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4850 JUMP_FUNCTION, | 4850 JUMP_FUNCTION, |
| 4851 NullCallWrapper(), | 4851 NullCallWrapper(), |
| 4852 CALL_AS_FUNCTION); | 4852 CALL_AS_FUNCTION); |
| 4853 | 4853 |
| 4854 // Slow-case: Non-function called. | 4854 // Slow-case: Non-function called. |
| 4855 __ bind(&slow); | 4855 __ bind(&slow); |
| 4856 if (RecordCallTarget()) { | 4856 if (RecordCallTarget()) { |
| 4857 // If there is a call target cache, mark it megamorphic in the | 4857 // If there is a call target cache, mark it megamorphic in the |
| 4858 // non-function case. MegamorphicSentinel is an immortal immovable | 4858 // non-function case. MegamorphicSentinel is an immortal immovable |
| 4859 // object (undefined) so no write barrier is needed. | 4859 // object (undefined) so no write barrier is needed. |
| 4860 __ mov(FieldOperand(ebx, JSGlobalPropertyCell::kValueOffset), | 4860 __ mov(FieldOperand(ebx, Cell::kValueOffset), |
| 4861 Immediate(TypeFeedbackCells::MegamorphicSentinel(isolate))); | 4861 Immediate(TypeFeedbackCells::MegamorphicSentinel(isolate))); |
| 4862 } | 4862 } |
| 4863 // Check for function proxy. | 4863 // Check for function proxy. |
| 4864 __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE); | 4864 __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE); |
| 4865 __ j(not_equal, &non_function); | 4865 __ j(not_equal, &non_function); |
| 4866 __ pop(ecx); | 4866 __ pop(ecx); |
| 4867 __ push(edi); // put proxy as additional argument under return address | 4867 __ push(edi); // put proxy as additional argument under return address |
| 4868 __ push(ecx); | 4868 __ push(ecx); |
| 4869 __ Set(eax, Immediate(argc_ + 1)); | 4869 __ Set(eax, Immediate(argc_ + 1)); |
| 4870 __ Set(ebx, Immediate(0)); | 4870 __ Set(ebx, Immediate(0)); |
| (...skipping 3052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7923 // builtin Array functions which always have maps. | 7923 // builtin Array functions which always have maps. |
| 7924 | 7924 |
| 7925 // Initial map for the builtin Array function should be a map. | 7925 // Initial map for the builtin Array function should be a map. |
| 7926 __ mov(ecx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); | 7926 __ mov(ecx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); |
| 7927 // Will both indicate a NULL and a Smi. | 7927 // Will both indicate a NULL and a Smi. |
| 7928 __ test(ecx, Immediate(kSmiTagMask)); | 7928 __ test(ecx, Immediate(kSmiTagMask)); |
| 7929 __ Assert(not_zero, "Unexpected initial map for Array function"); | 7929 __ Assert(not_zero, "Unexpected initial map for Array function"); |
| 7930 __ CmpObjectType(ecx, MAP_TYPE, ecx); | 7930 __ CmpObjectType(ecx, MAP_TYPE, ecx); |
| 7931 __ Assert(equal, "Unexpected initial map for Array function"); | 7931 __ Assert(equal, "Unexpected initial map for Array function"); |
| 7932 | 7932 |
| 7933 // We should either have undefined in ebx or a valid jsglobalpropertycell | 7933 // We should either have undefined in ebx or a valid cell |
| 7934 Label okay_here; | 7934 Label okay_here; |
| 7935 Handle<Map> global_property_cell_map( | 7935 Handle<Map> cell_map = masm->isolate()->factory()->cell_map(); |
| 7936 masm->isolate()->heap()->global_property_cell_map()); | |
| 7937 __ cmp(ebx, Immediate(undefined_sentinel)); | 7936 __ cmp(ebx, Immediate(undefined_sentinel)); |
| 7938 __ j(equal, &okay_here); | 7937 __ j(equal, &okay_here); |
| 7939 __ cmp(FieldOperand(ebx, 0), Immediate(global_property_cell_map)); | 7938 __ cmp(FieldOperand(ebx, 0), Immediate(cell_map)); |
| 7940 __ Assert(equal, "Expected property cell in register ebx"); | 7939 __ Assert(equal, "Expected property cell in register ebx"); |
| 7941 __ bind(&okay_here); | 7940 __ bind(&okay_here); |
| 7942 } | 7941 } |
| 7943 | 7942 |
| 7944 if (FLAG_optimize_constructed_arrays) { | 7943 if (FLAG_optimize_constructed_arrays) { |
| 7945 Label no_info, switch_ready; | 7944 Label no_info, switch_ready; |
| 7946 // Get the elements kind and case on that. | 7945 // Get the elements kind and case on that. |
| 7947 __ cmp(ebx, Immediate(undefined_sentinel)); | 7946 __ cmp(ebx, Immediate(undefined_sentinel)); |
| 7948 __ j(equal, &no_info); | 7947 __ j(equal, &no_info); |
| 7949 __ mov(edx, FieldOperand(ebx, JSGlobalPropertyCell::kValueOffset)); | 7948 __ mov(edx, FieldOperand(ebx, Cell::kValueOffset)); |
| 7950 __ JumpIfNotSmi(edx, &no_info); | 7949 __ JumpIfNotSmi(edx, &no_info); |
| 7951 __ SmiUntag(edx); | 7950 __ SmiUntag(edx); |
| 7952 __ jmp(&switch_ready); | 7951 __ jmp(&switch_ready); |
| 7953 __ bind(&no_info); | 7952 __ bind(&no_info); |
| 7954 __ mov(edx, Immediate(GetInitialFastElementsKind())); | 7953 __ mov(edx, Immediate(GetInitialFastElementsKind())); |
| 7955 __ bind(&switch_ready); | 7954 __ bind(&switch_ready); |
| 7956 | 7955 |
| 7957 if (argument_count_ == ANY) { | 7956 if (argument_count_ == ANY) { |
| 7958 Label not_zero_case, not_one_case; | 7957 Label not_zero_case, not_one_case; |
| 7959 __ test(eax, eax); | 7958 __ test(eax, eax); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8090 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); | 8089 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); |
| 8091 } | 8090 } |
| 8092 } | 8091 } |
| 8093 | 8092 |
| 8094 | 8093 |
| 8095 #undef __ | 8094 #undef __ |
| 8096 | 8095 |
| 8097 } } // namespace v8::internal | 8096 } } // namespace v8::internal |
| 8098 | 8097 |
| 8099 #endif // V8_TARGET_ARCH_IA32 | 8098 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |