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 4682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4693 // A monomorphic cache hit or an already megamorphic state: invoke the | 4693 // A monomorphic cache hit or an already megamorphic state: invoke the |
4694 // function without changing the state. | 4694 // function without changing the state. |
4695 __ cmp(ecx, edi); | 4695 __ cmp(ecx, edi); |
4696 __ j(equal, &done); | 4696 __ j(equal, &done); |
4697 __ cmp(ecx, Immediate(TypeFeedbackCells::MegamorphicSentinel(isolate))); | 4697 __ cmp(ecx, Immediate(TypeFeedbackCells::MegamorphicSentinel(isolate))); |
4698 __ j(equal, &done); | 4698 __ j(equal, &done); |
4699 | 4699 |
4700 // Special handling of the Array() function, which caches not only the | 4700 // Special handling of the Array() function, which caches not only the |
4701 // monomorphic Array function but the initial ElementsKind with special | 4701 // monomorphic Array function but the initial ElementsKind with special |
4702 // sentinels | 4702 // sentinels |
4703 Handle<Object> terminal_kind_sentinel = | |
4704 TypeFeedbackCells::MonomorphicArraySentinel(isolate, | |
4705 LAST_FAST_ELEMENTS_KIND); | |
4706 __ JumpIfNotSmi(ecx, &miss); | 4703 __ JumpIfNotSmi(ecx, &miss); |
4707 __ cmp(ecx, Immediate(terminal_kind_sentinel)); | 4704 if (FLAG_debug_code) { |
4708 __ j(above, &miss); | 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 |
4709 // Load the global or builtins object from the current context | 4712 // Load the global or builtins object from the current context |
4710 __ LoadGlobalContext(ecx); | 4713 __ LoadGlobalContext(ecx); |
4711 // Make sure the function is the Array() function | 4714 // Make sure the function is the Array() function |
4712 __ cmp(edi, Operand(ecx, | 4715 __ cmp(edi, Operand(ecx, |
4713 Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX))); | 4716 Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX))); |
4714 __ j(not_equal, &megamorphic); | 4717 __ j(not_equal, &megamorphic); |
4715 __ jmp(&done); | 4718 __ jmp(&done); |
4716 | 4719 |
4717 __ bind(&miss); | 4720 __ bind(&miss); |
4718 | 4721 |
(...skipping 3067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7786 __ mov(ecx, Operand(esp, kPointerSize)); | 7789 __ mov(ecx, Operand(esp, kPointerSize)); |
7787 __ test(ecx, ecx); | 7790 __ test(ecx, ecx); |
7788 __ j(zero, &normal_sequence); | 7791 __ j(zero, &normal_sequence); |
7789 | 7792 |
7790 // We are going to create a holey array, but our kind is non-holey. | 7793 // We are going to create a holey array, but our kind is non-holey. |
7791 // Fix kind and retry | 7794 // Fix kind and retry |
7792 __ inc(edx); | 7795 __ inc(edx); |
7793 __ cmp(ebx, Immediate(undefined_sentinel)); | 7796 __ cmp(ebx, Immediate(undefined_sentinel)); |
7794 __ j(equal, &normal_sequence); | 7797 __ j(equal, &normal_sequence); |
7795 | 7798 |
| 7799 // The type cell may have gone megamorphic, don't overwrite if so |
| 7800 __ mov(ecx, FieldOperand(ebx, kPointerSize)); |
| 7801 __ JumpIfNotSmi(ecx, &normal_sequence); |
| 7802 |
7796 // Save the resulting elements kind in type info | 7803 // Save the resulting elements kind in type info |
7797 __ SmiTag(edx); | 7804 __ SmiTag(edx); |
7798 __ mov(FieldOperand(ebx, kPointerSize), edx); | 7805 __ mov(FieldOperand(ebx, kPointerSize), edx); |
7799 __ SmiUntag(edx); | 7806 __ SmiUntag(edx); |
7800 | 7807 |
7801 __ bind(&normal_sequence); | 7808 __ bind(&normal_sequence); |
7802 int last_index = GetSequenceIndexFromFastElementsKind( | 7809 int last_index = GetSequenceIndexFromFastElementsKind( |
7803 TERMINAL_FAST_ELEMENTS_KIND); | 7810 TERMINAL_FAST_ELEMENTS_KIND); |
7804 for (int i = 0; i <= last_index; ++i) { | 7811 for (int i = 0; i <= last_index; ++i) { |
7805 Label next; | 7812 Label next; |
7806 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); | 7813 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); |
7807 __ cmp(edx, kind); | 7814 __ cmp(edx, kind); |
7808 __ j(not_equal, &next); | 7815 __ j(not_equal, &next); |
7809 ArraySingleArgumentConstructorStub stub(kind); | 7816 ArraySingleArgumentConstructorStub stub(kind); |
7810 __ TailCallStub(&stub); | 7817 __ TailCallStub(&stub); |
7811 __ bind(&next); | 7818 __ bind(&next); |
7812 } | 7819 } |
7813 | 7820 |
7814 // If we reached this point there is a problem. | 7821 // If we reached this point there is a problem. |
7815 __ Abort("Unexpected ElementsKind in array constructor"); | 7822 __ Abort("Unexpected ElementsKind in array constructor"); |
7816 } | 7823 } |
7817 | 7824 |
7818 | 7825 |
7819 template<class T> | 7826 template<class T> |
7820 static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) { | 7827 static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) { |
7821 int to_index = GetSequenceIndexFromFastElementsKind( | 7828 int to_index = GetSequenceIndexFromFastElementsKind( |
7822 TERMINAL_FAST_ELEMENTS_KIND); | 7829 TERMINAL_FAST_ELEMENTS_KIND); |
7823 for (int i = 0; i <= to_index; ++i) { | 7830 for (int i = 0; i <= to_index; ++i) { |
7824 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); | 7831 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); |
7825 T stub(kind, false); | 7832 T stub(kind); |
7826 stub.GetCode(isolate)->set_is_pregenerated(true); | 7833 stub.GetCode(isolate)->set_is_pregenerated(true); |
7827 if (AllocationSiteInfo::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) { | 7834 if (AllocationSiteInfo::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) { |
7828 T stub1(kind, true); | 7835 T stub1(kind, CONTEXT_CHECK_REQUIRED, DISABLE_ALLOCATION_SITES); |
7829 stub1.GetCode(isolate)->set_is_pregenerated(true); | 7836 stub1.GetCode(isolate)->set_is_pregenerated(true); |
7830 } | 7837 } |
7831 } | 7838 } |
7832 } | 7839 } |
7833 | 7840 |
7834 | 7841 |
7835 void ArrayConstructorStubBase::GenerateStubsAheadOfTime(Isolate* isolate) { | 7842 void ArrayConstructorStubBase::GenerateStubsAheadOfTime(Isolate* isolate) { |
7836 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>( | 7843 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>( |
7837 isolate); | 7844 isolate); |
7838 ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>( | 7845 ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>( |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8014 __ bind(&fast_elements_case); | 8021 __ bind(&fast_elements_case); |
8015 GenerateCase(masm, FAST_ELEMENTS); | 8022 GenerateCase(masm, FAST_ELEMENTS); |
8016 } | 8023 } |
8017 | 8024 |
8018 | 8025 |
8019 #undef __ | 8026 #undef __ |
8020 | 8027 |
8021 } } // namespace v8::internal | 8028 } } // namespace v8::internal |
8022 | 8029 |
8023 #endif // V8_TARGET_ARCH_IA32 | 8030 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |