Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: src/ia32/code-stubs-ia32.cc

Issue 17091002: Hydrogen array constructor cleanup and improvements (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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));
4708 __ j(above, &miss);
4709 // Load the global or builtins object from the current context 4704 // Load the global or builtins object from the current context
4710 __ LoadGlobalContext(ecx); 4705 __ LoadGlobalContext(ecx);
4711 // Make sure the function is the Array() function 4706 // Make sure the function is the Array() function
4712 __ cmp(edi, Operand(ecx, 4707 __ cmp(edi, Operand(ecx,
4713 Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX))); 4708 Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX)));
4714 __ j(not_equal, &megamorphic); 4709 __ j(not_equal, &megamorphic);
4715 __ jmp(&done); 4710 __ jmp(&done);
4716 4711
4717 __ bind(&miss); 4712 __ bind(&miss);
4718 4713
(...skipping 3067 matching lines...) Expand 10 before | Expand all | Expand 10 after
7786 __ mov(ecx, Operand(esp, kPointerSize)); 7781 __ mov(ecx, Operand(esp, kPointerSize));
7787 __ test(ecx, ecx); 7782 __ test(ecx, ecx);
7788 __ j(zero, &normal_sequence); 7783 __ j(zero, &normal_sequence);
7789 7784
7790 // We are going to create a holey array, but our kind is non-holey. 7785 // We are going to create a holey array, but our kind is non-holey.
7791 // Fix kind and retry 7786 // Fix kind and retry
7792 __ inc(edx); 7787 __ inc(edx);
7793 __ cmp(ebx, Immediate(undefined_sentinel)); 7788 __ cmp(ebx, Immediate(undefined_sentinel));
7794 __ j(equal, &normal_sequence); 7789 __ j(equal, &normal_sequence);
7795 7790
7791 // The type cell may have gone megamorphic, don't overwrite if so
7792 __ mov(ecx, FieldOperand(ebx, kPointerSize));
7793 __ JumpIfNotSmi(ecx, &normal_sequence);
7794
7796 // Save the resulting elements kind in type info 7795 // Save the resulting elements kind in type info
7797 __ SmiTag(edx); 7796 __ SmiTag(edx);
7798 __ mov(FieldOperand(ebx, kPointerSize), edx); 7797 __ mov(FieldOperand(ebx, kPointerSize), edx);
7799 __ SmiUntag(edx); 7798 __ SmiUntag(edx);
7800 7799
7801 __ bind(&normal_sequence); 7800 __ bind(&normal_sequence);
7802 int last_index = GetSequenceIndexFromFastElementsKind( 7801 int last_index = GetSequenceIndexFromFastElementsKind(
7803 TERMINAL_FAST_ELEMENTS_KIND); 7802 TERMINAL_FAST_ELEMENTS_KIND);
7804 for (int i = 0; i <= last_index; ++i) { 7803 for (int i = 0; i <= last_index; ++i) {
7805 Label next; 7804 Label next;
7806 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); 7805 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i);
7807 __ cmp(edx, kind); 7806 __ cmp(edx, kind);
7808 __ j(not_equal, &next); 7807 __ j(not_equal, &next);
7809 ArraySingleArgumentConstructorStub stub(kind); 7808 ArraySingleArgumentConstructorStub stub(kind);
7810 __ TailCallStub(&stub); 7809 __ TailCallStub(&stub);
7811 __ bind(&next); 7810 __ bind(&next);
7812 } 7811 }
7813 7812
7814 // If we reached this point there is a problem. 7813 // If we reached this point there is a problem.
7815 __ Abort("Unexpected ElementsKind in array constructor"); 7814 __ Abort("Unexpected ElementsKind in array constructor");
7816 } 7815 }
7817 7816
7818 7817
7819 template<class T> 7818 template<class T>
7820 static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) { 7819 static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) {
7821 int to_index = GetSequenceIndexFromFastElementsKind( 7820 int to_index = GetSequenceIndexFromFastElementsKind(
7822 TERMINAL_FAST_ELEMENTS_KIND); 7821 TERMINAL_FAST_ELEMENTS_KIND);
7823 for (int i = 0; i <= to_index; ++i) { 7822 for (int i = 0; i <= to_index; ++i) {
7824 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); 7823 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i);
7825 T stub(kind, false); 7824 T stub(kind, true, false);
7826 stub.GetCode(isolate)->set_is_pregenerated(true); 7825 stub.GetCode(isolate)->set_is_pregenerated(true);
7827 if (AllocationSiteInfo::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) { 7826 if (AllocationSiteInfo::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) {
7828 T stub1(kind, true); 7827 T stub1(kind, true, true);
7829 stub1.GetCode(isolate)->set_is_pregenerated(true); 7828 stub1.GetCode(isolate)->set_is_pregenerated(true);
7830 } 7829 }
7831 } 7830 }
7832 } 7831 }
7833 7832
7834 7833
7835 void ArrayConstructorStubBase::GenerateStubsAheadOfTime(Isolate* isolate) { 7834 void ArrayConstructorStubBase::GenerateStubsAheadOfTime(Isolate* isolate) {
7836 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>( 7835 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>(
7837 isolate); 7836 isolate);
7838 ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>( 7837 ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>(
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
8014 __ bind(&fast_elements_case); 8013 __ bind(&fast_elements_case);
8015 GenerateCase(masm, FAST_ELEMENTS); 8014 GenerateCase(masm, FAST_ELEMENTS);
8016 } 8015 }
8017 8016
8018 8017
8019 #undef __ 8018 #undef __
8020 8019
8021 } } // namespace v8::internal 8020 } } // namespace v8::internal
8022 8021
8023 #endif // V8_TARGET_ARCH_IA32 8022 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698