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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 Isolate* isolate, | 58 Isolate* isolate, |
59 CodeStubInterfaceDescriptor* descriptor) { | 59 CodeStubInterfaceDescriptor* descriptor) { |
60 static Register registers[] = { eax, ebx, ecx, edx }; | 60 static Register registers[] = { eax, ebx, ecx, edx }; |
61 descriptor->register_param_count_ = 4; | 61 descriptor->register_param_count_ = 4; |
62 descriptor->register_params_ = registers; | 62 descriptor->register_params_ = registers; |
63 descriptor->deoptimization_handler_ = | 63 descriptor->deoptimization_handler_ = |
64 Runtime::FunctionForId(Runtime::kCreateObjectLiteralShallow)->entry; | 64 Runtime::FunctionForId(Runtime::kCreateObjectLiteralShallow)->entry; |
65 } | 65 } |
66 | 66 |
67 | 67 |
| 68 void CreateAllocationSiteStub::InitializeInterfaceDescriptor( |
| 69 Isolate* isolate, |
| 70 CodeStubInterfaceDescriptor* descriptor) { |
| 71 static Register registers[] = { ebx }; |
| 72 descriptor->register_param_count_ = 1; |
| 73 descriptor->register_params_ = registers; |
| 74 descriptor->deoptimization_handler_ = NULL; |
| 75 } |
| 76 |
| 77 |
68 void KeyedLoadFastElementStub::InitializeInterfaceDescriptor( | 78 void KeyedLoadFastElementStub::InitializeInterfaceDescriptor( |
69 Isolate* isolate, | 79 Isolate* isolate, |
70 CodeStubInterfaceDescriptor* descriptor) { | 80 CodeStubInterfaceDescriptor* descriptor) { |
71 static Register registers[] = { edx, ecx }; | 81 static Register registers[] = { edx, ecx }; |
72 descriptor->register_param_count_ = 2; | 82 descriptor->register_param_count_ = 2; |
73 descriptor->register_params_ = registers; | 83 descriptor->register_params_ = registers; |
74 descriptor->deoptimization_handler_ = | 84 descriptor->deoptimization_handler_ = |
75 FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure); | 85 FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure); |
76 } | 86 } |
77 | 87 |
(...skipping 4612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4690 // Load the cache state into ecx. | 4700 // Load the cache state into ecx. |
4691 __ mov(ecx, FieldOperand(ebx, Cell::kValueOffset)); | 4701 __ mov(ecx, FieldOperand(ebx, Cell::kValueOffset)); |
4692 | 4702 |
4693 // A monomorphic cache hit or an already megamorphic state: invoke the | 4703 // A monomorphic cache hit or an already megamorphic state: invoke the |
4694 // function without changing the state. | 4704 // function without changing the state. |
4695 __ cmp(ecx, edi); | 4705 __ cmp(ecx, edi); |
4696 __ j(equal, &done); | 4706 __ j(equal, &done); |
4697 __ cmp(ecx, Immediate(TypeFeedbackCells::MegamorphicSentinel(isolate))); | 4707 __ cmp(ecx, Immediate(TypeFeedbackCells::MegamorphicSentinel(isolate))); |
4698 __ j(equal, &done); | 4708 __ j(equal, &done); |
4699 | 4709 |
| 4710 /* |
| 4711 If we came here, we need to see if we are the array function. |
| 4712 If we didn't have a matching function, and we didn't find the megamorph |
| 4713 sentinel, then we have in the cell either some other function or an |
| 4714 AllocationSite. Do a map check on the object in ecx |
| 4715 */ |
| 4716 Handle<Map> allocation_site_map( |
| 4717 masm->isolate()->heap()->allocation_site_map(), |
| 4718 masm->isolate()); |
| 4719 __ cmp(FieldOperand(ecx, 0), Immediate(allocation_site_map)); |
| 4720 __ j(not_equal, &miss); |
| 4721 |
4700 // Special handling of the Array() function, which caches not only the | 4722 // Special handling of the Array() function, which caches not only the |
4701 // monomorphic Array function but the initial ElementsKind with special | 4723 // monomorphic Array function but the initial ElementsKind with special |
4702 // sentinels | 4724 // sentinels |
4703 __ JumpIfNotSmi(ecx, &miss); | |
4704 if (FLAG_debug_code) { | |
4705 Handle<Object> terminal_kind_sentinel = | |
4706 TypeFeedbackCells::MonomorphicArraySentinel(masm->isolate(), | |
4707 LAST_FAST_ELEMENTS_KIND); | |
4708 __ cmp(ecx, Immediate(terminal_kind_sentinel)); | |
4709 __ Assert(less_equal, "Array function sentinel is not an ElementsKind"); | |
4710 } | |
4711 | 4725 |
4712 // Load the global or builtins object from the current context | 4726 // Load the global or builtins object from the current context |
4713 __ LoadGlobalContext(ecx); | 4727 __ LoadGlobalContext(ecx); |
4714 // Make sure the function is the Array() function | 4728 // Make sure the function is the Array() function |
4715 __ cmp(edi, Operand(ecx, | 4729 __ cmp(edi, Operand(ecx, |
4716 Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX))); | 4730 Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX))); |
4717 __ j(not_equal, &megamorphic); | 4731 __ j(not_equal, &megamorphic); |
4718 __ jmp(&done); | 4732 __ jmp(&done); |
4719 | 4733 |
4720 __ bind(&miss); | 4734 __ bind(&miss); |
(...skipping 11 matching lines...) Expand all Loading... |
4732 | 4746 |
4733 // An uninitialized cache is patched with the function or sentinel to | 4747 // An uninitialized cache is patched with the function or sentinel to |
4734 // indicate the ElementsKind if function is the Array constructor. | 4748 // indicate the ElementsKind if function is the Array constructor. |
4735 __ bind(&initialize); | 4749 __ bind(&initialize); |
4736 __ LoadGlobalContext(ecx); | 4750 __ LoadGlobalContext(ecx); |
4737 // Make sure the function is the Array() function | 4751 // Make sure the function is the Array() function |
4738 __ cmp(edi, Operand(ecx, | 4752 __ cmp(edi, Operand(ecx, |
4739 Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX))); | 4753 Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX))); |
4740 __ j(not_equal, ¬_array_function); | 4754 __ j(not_equal, ¬_array_function); |
4741 | 4755 |
4742 // The target function is the Array constructor, install a sentinel value in | 4756 // The target function is the Array constructor, |
4743 // the constructor's type info cell that will track the initial ElementsKind | 4757 // Create an AllocationSite if we don't already have it, store it in the cell |
4744 // that should be used for the array when its constructed. | 4758 { |
4745 Handle<Object> initial_kind_sentinel = | 4759 FrameScope scope(masm, StackFrame::INTERNAL); |
4746 TypeFeedbackCells::MonomorphicArraySentinel(isolate, | 4760 |
4747 GetInitialFastElementsKind()); | 4761 __ push(eax); |
4748 __ mov(FieldOperand(ebx, Cell::kValueOffset), | 4762 __ push(edi); |
4749 Immediate(initial_kind_sentinel)); | 4763 __ push(ebx); |
| 4764 |
| 4765 CreateAllocationSiteStub create_stub; |
| 4766 __ CallStub(&create_stub); |
| 4767 |
| 4768 __ pop(ebx); |
| 4769 __ pop(edi); |
| 4770 __ pop(eax); |
| 4771 } |
4750 __ jmp(&done); | 4772 __ jmp(&done); |
4751 | 4773 |
4752 __ bind(¬_array_function); | 4774 __ bind(¬_array_function); |
4753 __ mov(FieldOperand(ebx, Cell::kValueOffset), edi); | 4775 __ mov(FieldOperand(ebx, Cell::kValueOffset), edi); |
4754 // No need for a write barrier here - cells are rescanned. | 4776 // No need for a write barrier here - cells are rescanned. |
4755 | 4777 |
4756 __ bind(&done); | 4778 __ bind(&done); |
4757 } | 4779 } |
4758 | 4780 |
4759 | 4781 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4905 } | 4927 } |
4906 | 4928 |
4907 | 4929 |
4908 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { | 4930 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { |
4909 CEntryStub::GenerateAheadOfTime(isolate); | 4931 CEntryStub::GenerateAheadOfTime(isolate); |
4910 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(isolate); | 4932 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(isolate); |
4911 StubFailureTrampolineStub::GenerateAheadOfTime(isolate); | 4933 StubFailureTrampolineStub::GenerateAheadOfTime(isolate); |
4912 // It is important that the store buffer overflow stubs are generated first. | 4934 // It is important that the store buffer overflow stubs are generated first. |
4913 RecordWriteStub::GenerateFixedRegStubsAheadOfTime(isolate); | 4935 RecordWriteStub::GenerateFixedRegStubsAheadOfTime(isolate); |
4914 ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); | 4936 ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); |
| 4937 CreateAllocationSiteStub::GenerateAheadOfTime(isolate); |
4915 } | 4938 } |
4916 | 4939 |
4917 | 4940 |
4918 void CodeStub::GenerateFPStubs(Isolate* isolate) { | 4941 void CodeStub::GenerateFPStubs(Isolate* isolate) { |
4919 if (CpuFeatures::IsSupported(SSE2)) { | 4942 if (CpuFeatures::IsSupported(SSE2)) { |
4920 CEntryStub save_doubles(1, kSaveFPRegs); | 4943 CEntryStub save_doubles(1, kSaveFPRegs); |
4921 // Stubs might already be in the snapshot, detect that and don't regenerate, | 4944 // Stubs might already be in the snapshot, detect that and don't regenerate, |
4922 // which would lead to code stub initialization state being messed up. | 4945 // which would lead to code stub initialization state being messed up. |
4923 Code* save_doubles_code; | 4946 Code* save_doubles_code; |
4924 if (!save_doubles.FindCodeInCache(&save_doubles_code, isolate)) { | 4947 if (!save_doubles.FindCodeInCache(&save_doubles_code, isolate)) { |
(...skipping 2862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7787 __ mov(ecx, Operand(esp, kPointerSize)); | 7810 __ mov(ecx, Operand(esp, kPointerSize)); |
7788 __ test(ecx, ecx); | 7811 __ test(ecx, ecx); |
7789 __ j(zero, &normal_sequence); | 7812 __ j(zero, &normal_sequence); |
7790 | 7813 |
7791 // We are going to create a holey array, but our kind is non-holey. | 7814 // We are going to create a holey array, but our kind is non-holey. |
7792 // Fix kind and retry | 7815 // Fix kind and retry |
7793 __ inc(edx); | 7816 __ inc(edx); |
7794 __ cmp(ebx, Immediate(undefined_sentinel)); | 7817 __ cmp(ebx, Immediate(undefined_sentinel)); |
7795 __ j(equal, &normal_sequence); | 7818 __ j(equal, &normal_sequence); |
7796 | 7819 |
7797 // The type cell may have gone megamorphic, don't overwrite if so | 7820 __ mov(ecx, FieldOperand(ebx, Cell::kValueOffset)); |
7798 __ mov(ecx, FieldOperand(ebx, kPointerSize)); | 7821 Handle<Map> allocation_site_map( |
7799 __ JumpIfNotSmi(ecx, &normal_sequence); | 7822 masm->isolate()->heap()->allocation_site_map(), |
| 7823 masm->isolate()); |
| 7824 __ cmp(FieldOperand(ecx, 0), Immediate(allocation_site_map)); |
| 7825 __ j(not_equal, &normal_sequence); |
7800 | 7826 |
7801 // Save the resulting elements kind in type info | 7827 // Save the resulting elements kind in type info |
7802 __ SmiTag(edx); | 7828 __ SmiTag(edx); |
7803 __ mov(FieldOperand(ebx, kPointerSize), edx); | 7829 __ mov(FieldOperand(ecx, AllocationSite::kPayloadOffset), edx); |
7804 __ SmiUntag(edx); | 7830 __ SmiUntag(edx); |
7805 | 7831 |
7806 __ bind(&normal_sequence); | 7832 __ bind(&normal_sequence); |
7807 int last_index = GetSequenceIndexFromFastElementsKind( | 7833 int last_index = GetSequenceIndexFromFastElementsKind( |
7808 TERMINAL_FAST_ELEMENTS_KIND); | 7834 TERMINAL_FAST_ELEMENTS_KIND); |
7809 for (int i = 0; i <= last_index; ++i) { | 7835 for (int i = 0; i <= last_index; ++i) { |
7810 Label next; | 7836 Label next; |
7811 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); | 7837 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); |
7812 __ cmp(edx, kind); | 7838 __ cmp(edx, kind); |
7813 __ j(not_equal, &next); | 7839 __ j(not_equal, &next); |
7814 ArraySingleArgumentConstructorStub stub(kind); | 7840 ArraySingleArgumentConstructorStub stub(kind); |
7815 __ TailCallStub(&stub); | 7841 __ TailCallStub(&stub); |
7816 __ bind(&next); | 7842 __ bind(&next); |
7817 } | 7843 } |
7818 | 7844 |
7819 // If we reached this point there is a problem. | 7845 // If we reached this point there is a problem. |
7820 __ Abort("Unexpected ElementsKind in array constructor"); | 7846 __ Abort("Unexpected ElementsKind in array constructor"); |
7821 } | 7847 } |
7822 | 7848 |
7823 | 7849 |
7824 template<class T> | 7850 template<class T> |
7825 static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) { | 7851 static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) { |
7826 int to_index = GetSequenceIndexFromFastElementsKind( | 7852 int to_index = GetSequenceIndexFromFastElementsKind( |
7827 TERMINAL_FAST_ELEMENTS_KIND); | 7853 TERMINAL_FAST_ELEMENTS_KIND); |
7828 for (int i = 0; i <= to_index; ++i) { | 7854 for (int i = 0; i <= to_index; ++i) { |
7829 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); | 7855 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); |
7830 T stub(kind); | 7856 T stub(kind); |
7831 stub.GetCode(isolate)->set_is_pregenerated(true); | 7857 stub.GetCode(isolate)->set_is_pregenerated(true); |
7832 if (AllocationSiteInfo::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) { | 7858 if (AllocationSite::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) { |
7833 T stub1(kind, CONTEXT_CHECK_REQUIRED, DISABLE_ALLOCATION_SITES); | 7859 T stub1(kind, CONTEXT_CHECK_REQUIRED, DISABLE_ALLOCATION_SITES); |
7834 stub1.GetCode(isolate)->set_is_pregenerated(true); | 7860 stub1.GetCode(isolate)->set_is_pregenerated(true); |
7835 } | 7861 } |
7836 } | 7862 } |
7837 } | 7863 } |
7838 | 7864 |
7839 | 7865 |
7840 void ArrayConstructorStubBase::GenerateStubsAheadOfTime(Isolate* isolate) { | 7866 void ArrayConstructorStubBase::GenerateStubsAheadOfTime(Isolate* isolate) { |
7841 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>( | 7867 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>( |
7842 isolate); | 7868 isolate); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7894 __ cmp(FieldOperand(ebx, 0), Immediate(cell_map)); | 7920 __ cmp(FieldOperand(ebx, 0), Immediate(cell_map)); |
7895 __ Assert(equal, "Expected property cell in register ebx"); | 7921 __ Assert(equal, "Expected property cell in register ebx"); |
7896 __ bind(&okay_here); | 7922 __ bind(&okay_here); |
7897 } | 7923 } |
7898 | 7924 |
7899 Label no_info, switch_ready; | 7925 Label no_info, switch_ready; |
7900 // Get the elements kind and case on that. | 7926 // Get the elements kind and case on that. |
7901 __ cmp(ebx, Immediate(undefined_sentinel)); | 7927 __ cmp(ebx, Immediate(undefined_sentinel)); |
7902 __ j(equal, &no_info); | 7928 __ j(equal, &no_info); |
7903 __ mov(edx, FieldOperand(ebx, Cell::kValueOffset)); | 7929 __ mov(edx, FieldOperand(ebx, Cell::kValueOffset)); |
7904 __ JumpIfNotSmi(edx, &no_info); | 7930 |
| 7931 // The type cell may have undefined in its value. |
| 7932 __ cmp(edx, Immediate(undefined_sentinel)); |
| 7933 __ j(equal, &no_info); |
| 7934 |
| 7935 // We should have an allocation site object |
| 7936 if (FLAG_debug_code) { |
| 7937 __ cmp(FieldOperand(edx, 0), |
| 7938 Immediate(Handle<Map>( |
| 7939 masm->isolate()->heap()->allocation_site_map()))); |
| 7940 __ Assert(equal, "Expected AllocationSite object in register edx"); |
| 7941 } |
| 7942 |
| 7943 __ mov(edx, FieldOperand(edx, AllocationSite::kPayloadOffset)); |
7905 __ SmiUntag(edx); | 7944 __ SmiUntag(edx); |
7906 __ jmp(&switch_ready); | 7945 __ jmp(&switch_ready); |
7907 __ bind(&no_info); | 7946 __ bind(&no_info); |
7908 __ mov(edx, Immediate(GetInitialFastElementsKind())); | 7947 __ mov(edx, Immediate(GetInitialFastElementsKind())); |
7909 __ bind(&switch_ready); | 7948 __ bind(&switch_ready); |
7910 | 7949 |
7911 if (argument_count_ == ANY) { | 7950 if (argument_count_ == ANY) { |
7912 Label not_zero_case, not_one_case; | 7951 Label not_zero_case, not_one_case; |
7913 __ test(eax, eax); | 7952 __ test(eax, eax); |
7914 __ j(not_zero, ¬_zero_case); | 7953 __ j(not_zero, ¬_zero_case); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8019 __ bind(&fast_elements_case); | 8058 __ bind(&fast_elements_case); |
8020 GenerateCase(masm, FAST_ELEMENTS); | 8059 GenerateCase(masm, FAST_ELEMENTS); |
8021 } | 8060 } |
8022 | 8061 |
8023 | 8062 |
8024 #undef __ | 8063 #undef __ |
8025 | 8064 |
8026 } } // namespace v8::internal | 8065 } } // namespace v8::internal |
8027 | 8066 |
8028 #endif // V8_TARGET_ARCH_IA32 | 8067 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |