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

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

Issue 2011573002: PPC: Collect call counts for constructor calls, too. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: added offset to load/store instr and removed the add instr Created 4 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_PPC 5 #if V8_TARGET_ARCH_PPC
6 6
7 #include "src/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/api-arguments.h" 8 #include "src/api-arguments.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 1831 matching lines...) Expand 10 before | Expand all | Expand 10 after
1842 1842
1843 static void GenerateRecordCallTarget(MacroAssembler* masm) { 1843 static void GenerateRecordCallTarget(MacroAssembler* masm) {
1844 // Cache the called function in a feedback vector slot. Cache states 1844 // Cache the called function in a feedback vector slot. Cache states
1845 // are uninitialized, monomorphic (indicated by a JSFunction), and 1845 // are uninitialized, monomorphic (indicated by a JSFunction), and
1846 // megamorphic. 1846 // megamorphic.
1847 // r3 : number of arguments to the construct function 1847 // r3 : number of arguments to the construct function
1848 // r4 : the function to call 1848 // r4 : the function to call
1849 // r5 : feedback vector 1849 // r5 : feedback vector
1850 // r6 : slot in feedback vector (Smi) 1850 // r6 : slot in feedback vector (Smi)
1851 Label initialize, done, miss, megamorphic, not_array_function; 1851 Label initialize, done, miss, megamorphic, not_array_function;
1852 Label done_initialize_count, done_increment_count;
1852 1853
1853 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), 1854 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()),
1854 masm->isolate()->heap()->megamorphic_symbol()); 1855 masm->isolate()->heap()->megamorphic_symbol());
1855 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), 1856 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()),
1856 masm->isolate()->heap()->uninitialized_symbol()); 1857 masm->isolate()->heap()->uninitialized_symbol());
1857 1858
1859 const int count_offset = FixedArray::kHeaderSize + kPointerSize;
1860
1858 // Load the cache state into r8. 1861 // Load the cache state into r8.
1859 __ SmiToPtrArrayOffset(r8, r6); 1862 __ SmiToPtrArrayOffset(r8, r6);
1860 __ add(r8, r5, r8); 1863 __ add(r8, r5, r8);
1861 __ LoadP(r8, FieldMemOperand(r8, FixedArray::kHeaderSize)); 1864 __ LoadP(r8, FieldMemOperand(r8, FixedArray::kHeaderSize));
1862 1865
1863 // A monomorphic cache hit or an already megamorphic state: invoke the 1866 // A monomorphic cache hit or an already megamorphic state: invoke the
1864 // function without changing the state. 1867 // function without changing the state.
1865 // We don't know if r8 is a WeakCell or a Symbol, but it's harmless to read at 1868 // We don't know if r8 is a WeakCell or a Symbol, but it's harmless to read at
1866 // this position in a symbol (see static asserts in type-feedback-vector.h). 1869 // this position in a symbol (see static asserts in type-feedback-vector.h).
1867 Label check_allocation_site; 1870 Label check_allocation_site;
1868 Register feedback_map = r9; 1871 Register feedback_map = r9;
1869 Register weak_value = r10; 1872 Register weak_value = r10;
1870 __ LoadP(weak_value, FieldMemOperand(r8, WeakCell::kValueOffset)); 1873 __ LoadP(weak_value, FieldMemOperand(r8, WeakCell::kValueOffset));
1871 __ cmp(r4, weak_value); 1874 __ cmp(r4, weak_value);
1872 __ beq(&done); 1875 __ beq(&done_increment_count);
1873 __ CompareRoot(r8, Heap::kmegamorphic_symbolRootIndex); 1876 __ CompareRoot(r8, Heap::kmegamorphic_symbolRootIndex);
1874 __ beq(&done); 1877 __ beq(&done);
1875 __ LoadP(feedback_map, FieldMemOperand(r8, HeapObject::kMapOffset)); 1878 __ LoadP(feedback_map, FieldMemOperand(r8, HeapObject::kMapOffset));
1876 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex); 1879 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex);
1877 __ bne(&check_allocation_site); 1880 __ bne(&check_allocation_site);
1878 1881
1879 // If the weak cell is cleared, we have a new chance to become monomorphic. 1882 // If the weak cell is cleared, we have a new chance to become monomorphic.
1880 __ JumpIfSmi(weak_value, &initialize); 1883 __ JumpIfSmi(weak_value, &initialize);
1881 __ b(&megamorphic); 1884 __ b(&megamorphic);
1882 1885
1883 __ bind(&check_allocation_site); 1886 __ bind(&check_allocation_site);
1884 // If we came here, we need to see if we are the array function. 1887 // If we came here, we need to see if we are the array function.
1885 // If we didn't have a matching function, and we didn't find the megamorph 1888 // If we didn't have a matching function, and we didn't find the megamorph
1886 // sentinel, then we have in the slot either some other function or an 1889 // sentinel, then we have in the slot either some other function or an
1887 // AllocationSite. 1890 // AllocationSite.
1888 __ CompareRoot(feedback_map, Heap::kAllocationSiteMapRootIndex); 1891 __ CompareRoot(feedback_map, Heap::kAllocationSiteMapRootIndex);
1889 __ bne(&miss); 1892 __ bne(&miss);
1890 1893
1891 // Make sure the function is the Array() function 1894 // Make sure the function is the Array() function
1892 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8); 1895 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8);
1893 __ cmp(r4, r8); 1896 __ cmp(r4, r8);
1894 __ bne(&megamorphic); 1897 __ bne(&megamorphic);
1895 __ b(&done); 1898 __ b(&done_increment_count);
1896 1899
1897 __ bind(&miss); 1900 __ bind(&miss);
1898 1901
1899 // A monomorphic miss (i.e, here the cache is not uninitialized) goes 1902 // A monomorphic miss (i.e, here the cache is not uninitialized) goes
1900 // megamorphic. 1903 // megamorphic.
1901 __ CompareRoot(r8, Heap::kuninitialized_symbolRootIndex); 1904 __ CompareRoot(r8, Heap::kuninitialized_symbolRootIndex);
1902 __ beq(&initialize); 1905 __ beq(&initialize);
1903 // MegamorphicSentinel is an immortal immovable object (undefined) so no 1906 // MegamorphicSentinel is an immortal immovable object (undefined) so no
1904 // write-barrier is needed. 1907 // write-barrier is needed.
1905 __ bind(&megamorphic); 1908 __ bind(&megamorphic);
1906 __ SmiToPtrArrayOffset(r8, r6); 1909 __ SmiToPtrArrayOffset(r8, r6);
1907 __ add(r8, r5, r8); 1910 __ add(r8, r5, r8);
1908 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex); 1911 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex);
1909 __ StoreP(ip, FieldMemOperand(r8, FixedArray::kHeaderSize), r0); 1912 __ StoreP(ip, FieldMemOperand(r8, FixedArray::kHeaderSize), r0);
1910 __ jmp(&done); 1913 __ jmp(&done);
1911 1914
1912 // An uninitialized cache is patched with the function 1915 // An uninitialized cache is patched with the function
1913 __ bind(&initialize); 1916 __ bind(&initialize);
1914 1917
1915 // Make sure the function is the Array() function. 1918 // Make sure the function is the Array() function.
1916 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8); 1919 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8);
1917 __ cmp(r4, r8); 1920 __ cmp(r4, r8);
1918 __ bne(&not_array_function); 1921 __ bne(&not_array_function);
1919 1922
1920 // The target function is the Array constructor, 1923 // The target function is the Array constructor,
1921 // Create an AllocationSite if we don't already have it, store it in the 1924 // Create an AllocationSite if we don't already have it, store it in the
1922 // slot. 1925 // slot.
1923 CreateAllocationSiteStub create_stub(masm->isolate()); 1926 CreateAllocationSiteStub create_stub(masm->isolate());
1924 CallStubInRecordCallTarget(masm, &create_stub); 1927 CallStubInRecordCallTarget(masm, &create_stub);
1925 __ b(&done); 1928 __ b(&done_initialize_count);
1926 1929
1927 __ bind(&not_array_function); 1930 __ bind(&not_array_function);
1928 1931
1929 CreateWeakCellStub weak_cell_stub(masm->isolate()); 1932 CreateWeakCellStub weak_cell_stub(masm->isolate());
1930 CallStubInRecordCallTarget(masm, &weak_cell_stub); 1933 CallStubInRecordCallTarget(masm, &weak_cell_stub);
1934
1935 __ bind(&done_initialize_count);
1936 // Initialize the call counter.
1937 __ LoadSmiLiteral(r8, Smi::FromInt(1));
1938 __ SmiToPtrArrayOffset(r7, r6);
1939 __ add(r7, r5, r7);
1940 __ StoreP(r8, FieldMemOperand(r7, count_offset), r0);
1941 __ b(&done);
1942
1943 __ bind(&done_increment_count);
1944
1945 // Increment the call count for monomorphic function calls.
1946 __ SmiToPtrArrayOffset(r8, r6);
1947 __ add(r8, r5, r8);
1948
1949 __ LoadP(r7, FieldMemOperand(r8, count_offset));
1950 __ AddSmiLiteral(r7, r7, Smi::FromInt(1), r0);
1951 __ StoreP(r7, FieldMemOperand(r8, count_offset), r0);
1952
1931 __ bind(&done); 1953 __ bind(&done);
1932 } 1954 }
1933 1955
1934 1956
1935 void CallConstructStub::Generate(MacroAssembler* masm) { 1957 void CallConstructStub::Generate(MacroAssembler* masm) {
1936 // r3 : number of arguments 1958 // r3 : number of arguments
1937 // r4 : the function to call 1959 // r4 : the function to call
1938 // r5 : feedback vector 1960 // r5 : feedback vector
1939 // r6 : slot in feedback vector (Smi, for RecordCallTarget) 1961 // r6 : slot in feedback vector (Smi, for RecordCallTarget)
1940 1962
(...skipping 3731 matching lines...) Expand 10 before | Expand all | Expand 10 after
5672 fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); 5694 fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize);
5673 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, 5695 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref,
5674 kStackUnwindSpace, NULL, return_value_operand, NULL); 5696 kStackUnwindSpace, NULL, return_value_operand, NULL);
5675 } 5697 }
5676 5698
5677 #undef __ 5699 #undef __
5678 } // namespace internal 5700 } // namespace internal
5679 } // namespace v8 5701 } // namespace v8
5680 5702
5681 #endif // V8_TARGET_ARCH_PPC 5703 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698