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

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

Issue 2670003003: PPC/s390: [stubs] Also port the CallICStub to CSA. (Closed)
Patch Set: fix mov instr Created 3 years, 10 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 | « src/full-codegen/s390/full-codegen-s390.cc ('k') | src/ppc/interface-descriptors-ppc.cc » ('j') | 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 1841 matching lines...) Expand 10 before | Expand all | Expand 10 after
1852 __ LoadP(r7, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); 1852 __ LoadP(r7, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset));
1853 __ LoadP(r7, FieldMemOperand(r7, SharedFunctionInfo::kConstructStubOffset)); 1853 __ LoadP(r7, FieldMemOperand(r7, SharedFunctionInfo::kConstructStubOffset));
1854 __ addi(ip, r7, Operand(Code::kHeaderSize - kHeapObjectTag)); 1854 __ addi(ip, r7, Operand(Code::kHeaderSize - kHeapObjectTag));
1855 __ JumpToJSEntry(ip); 1855 __ JumpToJSEntry(ip);
1856 1856
1857 __ bind(&non_function); 1857 __ bind(&non_function);
1858 __ mr(r6, r4); 1858 __ mr(r6, r4);
1859 __ Jump(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); 1859 __ Jump(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
1860 } 1860 }
1861 1861
1862 // Note: feedback_vector and slot are clobbered after the call.
1863 static void IncrementCallCount(MacroAssembler* masm, Register feedback_vector,
1864 Register slot, Register temp) {
1865 const int count_offset = FixedArray::kHeaderSize + kPointerSize;
1866 __ SmiToPtrArrayOffset(temp, slot);
1867 __ add(feedback_vector, feedback_vector, temp);
1868 __ LoadP(slot, FieldMemOperand(feedback_vector, count_offset));
1869 __ AddSmiLiteral(slot, slot, Smi::FromInt(1), temp);
1870 __ StoreP(slot, FieldMemOperand(feedback_vector, count_offset), temp);
1871 }
1872
1873 void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) {
1874 // r3 - number of arguments
1875 // r4 - function
1876 // r6 - slot id
1877 // r5 - vector
1878 // r7 - allocation site (loaded from vector[slot])
1879 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8);
1880 __ cmp(r4, r8);
1881 __ bne(miss);
1882
1883 // Increment the call count for monomorphic function calls.
1884 IncrementCallCount(masm, r5, r6, r0);
1885
1886 __ mr(r5, r7);
1887 __ mr(r6, r4);
1888 ArrayConstructorStub stub(masm->isolate());
1889 __ TailCallStub(&stub);
1890 }
1891
1892
1893 void CallICStub::Generate(MacroAssembler* masm) {
1894 // r3 - number of arguments
1895 // r4 - function
1896 // r6 - slot id (Smi)
1897 // r5 - vector
1898 Label extra_checks_or_miss, call, call_function, call_count_incremented;
1899
1900 // The checks. First, does r4 match the recorded monomorphic target?
1901 __ SmiToPtrArrayOffset(r9, r6);
1902 __ add(r9, r5, r9);
1903 __ LoadP(r7, FieldMemOperand(r9, FixedArray::kHeaderSize));
1904
1905 // We don't know that we have a weak cell. We might have a private symbol
1906 // or an AllocationSite, but the memory is safe to examine.
1907 // AllocationSite::kTransitionInfoOffset - contains a Smi or pointer to
1908 // FixedArray.
1909 // WeakCell::kValueOffset - contains a JSFunction or Smi(0)
1910 // Symbol::kHashFieldSlot - if the low bit is 1, then the hash is not
1911 // computed, meaning that it can't appear to be a pointer. If the low bit is
1912 // 0, then hash is computed, but the 0 bit prevents the field from appearing
1913 // to be a pointer.
1914 STATIC_ASSERT(WeakCell::kSize >= kPointerSize);
1915 STATIC_ASSERT(AllocationSite::kTransitionInfoOffset ==
1916 WeakCell::kValueOffset &&
1917 WeakCell::kValueOffset == Symbol::kHashFieldSlot);
1918
1919 __ LoadP(r8, FieldMemOperand(r7, WeakCell::kValueOffset));
1920 __ cmp(r4, r8);
1921 __ bne(&extra_checks_or_miss);
1922
1923 // The compare above could have been a SMI/SMI comparison. Guard against this
1924 // convincing us that we have a monomorphic JSFunction.
1925 __ JumpIfSmi(r4, &extra_checks_or_miss);
1926
1927 __ bind(&call_function);
1928
1929 // Increment the call count for monomorphic function calls.
1930 IncrementCallCount(masm, r5, r6, r0);
1931
1932 __ Jump(masm->isolate()->builtins()->CallFunction(convert_mode(),
1933 tail_call_mode()),
1934 RelocInfo::CODE_TARGET);
1935
1936 __ bind(&extra_checks_or_miss);
1937 Label uninitialized, miss, not_allocation_site;
1938
1939 __ CompareRoot(r7, Heap::kmegamorphic_symbolRootIndex);
1940 __ beq(&call);
1941
1942 // Verify that r7 contains an AllocationSite
1943 __ LoadP(r8, FieldMemOperand(r7, HeapObject::kMapOffset));
1944 __ CompareRoot(r8, Heap::kAllocationSiteMapRootIndex);
1945 __ bne(&not_allocation_site);
1946
1947 // We have an allocation site.
1948 HandleArrayCase(masm, &miss);
1949
1950 __ bind(&not_allocation_site);
1951
1952 // The following cases attempt to handle MISS cases without going to the
1953 // runtime.
1954 if (FLAG_trace_ic) {
1955 __ b(&miss);
1956 }
1957
1958 __ CompareRoot(r7, Heap::kuninitialized_symbolRootIndex);
1959 __ beq(&uninitialized);
1960
1961 // We are going megamorphic. If the feedback is a JSFunction, it is fine
1962 // to handle it here. More complex cases are dealt with in the runtime.
1963 __ AssertNotSmi(r7);
1964 __ CompareObjectType(r7, r8, r8, JS_FUNCTION_TYPE);
1965 __ bne(&miss);
1966 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex);
1967 __ StoreP(ip, FieldMemOperand(r9, FixedArray::kHeaderSize), r0);
1968
1969 __ bind(&call);
1970
1971 // Increment the call count for megamorphic function calls.
1972 IncrementCallCount(masm, r5, r6, r0);
1973
1974 __ bind(&call_count_incremented);
1975 __ Jump(masm->isolate()->builtins()->Call(convert_mode(), tail_call_mode()),
1976 RelocInfo::CODE_TARGET);
1977
1978 __ bind(&uninitialized);
1979
1980 // We are going monomorphic, provided we actually have a JSFunction.
1981 __ JumpIfSmi(r4, &miss);
1982
1983 // Goto miss case if we do not have a function.
1984 __ CompareObjectType(r4, r7, r7, JS_FUNCTION_TYPE);
1985 __ bne(&miss);
1986
1987 // Make sure the function is not the Array() function, which requires special
1988 // behavior on MISS.
1989 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r7);
1990 __ cmp(r4, r7);
1991 __ beq(&miss);
1992
1993 // Make sure the function belongs to the same native context.
1994 __ LoadP(r7, FieldMemOperand(r4, JSFunction::kContextOffset));
1995 __ LoadP(r7, ContextMemOperand(r7, Context::NATIVE_CONTEXT_INDEX));
1996 __ LoadP(ip, NativeContextMemOperand());
1997 __ cmp(r7, ip);
1998 __ bne(&miss);
1999
2000 // Store the function. Use a stub since we need a frame for allocation.
2001 // r5 - vector
2002 // r6 - slot
2003 // r4 - function
2004 {
2005 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
2006 CreateWeakCellStub create_stub(masm->isolate());
2007 __ SmiTag(r3);
2008 __ Push(r3, r5, r6, cp, r4);
2009 __ CallStub(&create_stub);
2010 __ Pop(r5, r6, cp, r4);
2011 __ Pop(r3);
2012 __ SmiUntag(r3);
2013 }
2014
2015 __ b(&call_function);
2016
2017 // We are here because tracing is on or we encountered a MISS case we can't
2018 // handle here.
2019 __ bind(&miss);
2020 GenerateMiss(masm);
2021
2022 __ b(&call_count_incremented);
2023 }
2024
2025
2026 void CallICStub::GenerateMiss(MacroAssembler* masm) {
2027 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
2028
2029 // Preserve the number of arguments as Smi.
2030 __ SmiTag(r3);
2031
2032 // Push the receiver and the function and feedback info.
2033 __ Push(r3, r4, r5, r6);
2034
2035 // Call the entry.
2036 __ CallRuntime(Runtime::kCallIC_Miss);
2037
2038 // Move result to r4 and exit the internal frame.
2039 __ mr(r4, r3);
2040
2041 // Restore number of arguments.
2042 __ Pop(r3);
2043 __ SmiUntag(r3);
2044 }
2045
2046 1862
2047 // StringCharCodeAtGenerator 1863 // StringCharCodeAtGenerator
2048 void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { 1864 void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) {
2049 // If the receiver is a smi trigger the non-string case. 1865 // If the receiver is a smi trigger the non-string case.
2050 if (check_mode_ == RECEIVER_IS_UNKNOWN) { 1866 if (check_mode_ == RECEIVER_IS_UNKNOWN) {
2051 __ JumpIfSmi(object_, receiver_not_string_); 1867 __ JumpIfSmi(object_, receiver_not_string_);
2052 1868
2053 // Fetch the instance type of the receiver into result register. 1869 // Fetch the instance type of the receiver into result register.
2054 __ LoadP(result_, FieldMemOperand(object_, HeapObject::kMapOffset)); 1870 __ LoadP(result_, FieldMemOperand(object_, HeapObject::kMapOffset));
2055 __ lbz(result_, FieldMemOperand(result_, Map::kInstanceTypeOffset)); 1871 __ lbz(result_, FieldMemOperand(result_, Map::kInstanceTypeOffset));
(...skipping 2289 matching lines...) Expand 10 before | Expand all | Expand 10 after
4345 fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); 4161 fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize);
4346 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, 4162 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref,
4347 kStackUnwindSpace, NULL, return_value_operand, NULL); 4163 kStackUnwindSpace, NULL, return_value_operand, NULL);
4348 } 4164 }
4349 4165
4350 #undef __ 4166 #undef __
4351 } // namespace internal 4167 } // namespace internal
4352 } // namespace v8 4168 } // namespace v8
4353 4169
4354 #endif // V8_TARGET_ARCH_PPC 4170 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « src/full-codegen/s390/full-codegen-s390.cc ('k') | src/ppc/interface-descriptors-ppc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698