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

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

Issue 1688283003: [Interpreter] Implements calls through CallICStub in the interpreter. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixes comments I missed in last patch. Created 4 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_IA32 5 #if V8_TARGET_ARCH_IA32
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 1880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1891 __ bind(&non_function); 1891 __ bind(&non_function);
1892 __ mov(edx, edi); 1892 __ mov(edx, edi);
1893 __ Jump(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); 1893 __ Jump(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
1894 } 1894 }
1895 1895
1896 1896
1897 void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) { 1897 void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) {
1898 // edi - function 1898 // edi - function
1899 // edx - slot id 1899 // edx - slot id
1900 // ebx - vector 1900 // ebx - vector
1901 // eax - number of arguments - if argc_in_register() is true.
1901 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); 1902 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx);
1902 __ cmp(edi, ecx); 1903 __ cmp(edi, ecx);
1903 __ j(not_equal, miss); 1904 __ j(not_equal, miss);
1904 1905
1905 __ mov(eax, arg_count());
1906 // Reload ecx. 1906 // Reload ecx.
1907 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, 1907 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size,
1908 FixedArray::kHeaderSize)); 1908 FixedArray::kHeaderSize));
1909 1909
1910 // Increment the call count for monomorphic function calls. 1910 // Increment the call count for monomorphic function calls.
1911 __ add(FieldOperand(ebx, edx, times_half_pointer_size, 1911 __ add(FieldOperand(ebx, edx, times_half_pointer_size,
1912 FixedArray::kHeaderSize + kPointerSize), 1912 FixedArray::kHeaderSize + kPointerSize),
1913 Immediate(Smi::FromInt(CallICNexus::kCallCountIncrement))); 1913 Immediate(Smi::FromInt(CallICNexus::kCallCountIncrement)));
1914 1914
1915 __ mov(ebx, ecx); 1915 __ mov(ebx, ecx);
1916 __ mov(edx, edi); 1916 __ mov(edx, edi);
1917 ArrayConstructorStub stub(masm->isolate(), arg_count()); 1917 if (argc_in_register()) {
1918 __ TailCallStub(&stub); 1918 ArrayConstructorStub stub(masm->isolate());
1919 1919 __ TailCallStub(&stub);
1920 } else {
1921 ArrayConstructorStub stub(masm->isolate(), arg_count());
mvstanton 2016/02/15 11:13:45 Okay, so you are sure ArrayConstructorStub doesn't
mythria 2016/02/17 11:02:48 Actually, it expects in eax if arg_count() >= 2. I
1922 __ TailCallStub(&stub);
1923 }
1920 // Unreachable. 1924 // Unreachable.
1921 } 1925 }
1922 1926
1923 1927
1924 void CallICStub::Generate(MacroAssembler* masm) { 1928 void CallICStub::Generate(MacroAssembler* masm) {
1925 // edi - function 1929 // edi - function
1926 // edx - slot id 1930 // edx - slot id
1927 // ebx - vector 1931 // ebx - vector
1932 // eax - number of arguments - if argc_in_register() is true.
1928 Isolate* isolate = masm->isolate(); 1933 Isolate* isolate = masm->isolate();
1929 Label extra_checks_or_miss, call, call_function; 1934 Label extra_checks_or_miss, call, call_function;
1930 int argc = arg_count(); 1935 if (!argc_in_register()) {
1931 ParameterCount actual(argc); 1936 int argc = arg_count();
1937 __ Set(eax, argc);
1938 }
1932 1939
1933 // The checks. First, does edi match the recorded monomorphic target? 1940 // The checks. First, does edi match the recorded monomorphic target?
1934 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, 1941 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size,
1935 FixedArray::kHeaderSize)); 1942 FixedArray::kHeaderSize));
1936 1943
1937 // We don't know that we have a weak cell. We might have a private symbol 1944 // We don't know that we have a weak cell. We might have a private symbol
1938 // or an AllocationSite, but the memory is safe to examine. 1945 // or an AllocationSite, but the memory is safe to examine.
1939 // AllocationSite::kTransitionInfoOffset - contains a Smi or pointer to 1946 // AllocationSite::kTransitionInfoOffset - contains a Smi or pointer to
1940 // FixedArray. 1947 // FixedArray.
1941 // WeakCell::kValueOffset - contains a JSFunction or Smi(0) 1948 // WeakCell::kValueOffset - contains a JSFunction or Smi(0)
(...skipping 12 matching lines...) Expand all
1954 // The compare above could have been a SMI/SMI comparison. Guard against this 1961 // The compare above could have been a SMI/SMI comparison. Guard against this
1955 // convincing us that we have a monomorphic JSFunction. 1962 // convincing us that we have a monomorphic JSFunction.
1956 __ JumpIfSmi(edi, &extra_checks_or_miss); 1963 __ JumpIfSmi(edi, &extra_checks_or_miss);
1957 1964
1958 // Increment the call count for monomorphic function calls. 1965 // Increment the call count for monomorphic function calls.
1959 __ add(FieldOperand(ebx, edx, times_half_pointer_size, 1966 __ add(FieldOperand(ebx, edx, times_half_pointer_size,
1960 FixedArray::kHeaderSize + kPointerSize), 1967 FixedArray::kHeaderSize + kPointerSize),
1961 Immediate(Smi::FromInt(CallICNexus::kCallCountIncrement))); 1968 Immediate(Smi::FromInt(CallICNexus::kCallCountIncrement)));
1962 1969
1963 __ bind(&call_function); 1970 __ bind(&call_function);
1964 __ Set(eax, argc);
1965 __ Jump(masm->isolate()->builtins()->CallFunction(convert_mode(), 1971 __ Jump(masm->isolate()->builtins()->CallFunction(convert_mode(),
1966 tail_call_mode()), 1972 tail_call_mode()),
1967 RelocInfo::CODE_TARGET); 1973 RelocInfo::CODE_TARGET);
1968 1974
1969 __ bind(&extra_checks_or_miss); 1975 __ bind(&extra_checks_or_miss);
1970 Label uninitialized, miss, not_allocation_site; 1976 Label uninitialized, miss, not_allocation_site;
1971 1977
1972 __ cmp(ecx, Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); 1978 __ cmp(ecx, Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate)));
1973 __ j(equal, &call); 1979 __ j(equal, &call);
1974 1980
(...skipping 19 matching lines...) Expand all
1994 // We are going megamorphic. If the feedback is a JSFunction, it is fine 2000 // We are going megamorphic. If the feedback is a JSFunction, it is fine
1995 // to handle it here. More complex cases are dealt with in the runtime. 2001 // to handle it here. More complex cases are dealt with in the runtime.
1996 __ AssertNotSmi(ecx); 2002 __ AssertNotSmi(ecx);
1997 __ CmpObjectType(ecx, JS_FUNCTION_TYPE, ecx); 2003 __ CmpObjectType(ecx, JS_FUNCTION_TYPE, ecx);
1998 __ j(not_equal, &miss); 2004 __ j(not_equal, &miss);
1999 __ mov( 2005 __ mov(
2000 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), 2006 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize),
2001 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); 2007 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate)));
2002 2008
2003 __ bind(&call); 2009 __ bind(&call);
2004 __ Set(eax, argc);
2005 __ Jump(masm->isolate()->builtins()->Call(convert_mode(), tail_call_mode()), 2010 __ Jump(masm->isolate()->builtins()->Call(convert_mode(), tail_call_mode()),
2006 RelocInfo::CODE_TARGET); 2011 RelocInfo::CODE_TARGET);
2007 2012
2008 __ bind(&uninitialized); 2013 __ bind(&uninitialized);
2009 2014
2010 // We are going monomorphic, provided we actually have a JSFunction. 2015 // We are going monomorphic, provided we actually have a JSFunction.
2011 __ JumpIfSmi(edi, &miss); 2016 __ JumpIfSmi(edi, &miss);
2012 2017
2013 // Goto miss case if we do not have a function. 2018 // Goto miss case if we do not have a function.
2014 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); 2019 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx);
(...skipping 16 matching lines...) Expand all
2031 FixedArray::kHeaderSize + kPointerSize), 2036 FixedArray::kHeaderSize + kPointerSize),
2032 Immediate(Smi::FromInt(CallICNexus::kCallCountIncrement))); 2037 Immediate(Smi::FromInt(CallICNexus::kCallCountIncrement)));
2033 2038
2034 // Store the function. Use a stub since we need a frame for allocation. 2039 // Store the function. Use a stub since we need a frame for allocation.
2035 // ebx - vector 2040 // ebx - vector
2036 // edx - slot 2041 // edx - slot
2037 // edi - function 2042 // edi - function
2038 { 2043 {
2039 FrameScope scope(masm, StackFrame::INTERNAL); 2044 FrameScope scope(masm, StackFrame::INTERNAL);
2040 CreateWeakCellStub create_stub(isolate); 2045 CreateWeakCellStub create_stub(isolate);
2046 __ SmiTag(eax);
2047 __ push(eax);
2041 __ push(edi); 2048 __ push(edi);
2049
2042 __ CallStub(&create_stub); 2050 __ CallStub(&create_stub);
2051
2043 __ pop(edi); 2052 __ pop(edi);
2053 __ pop(eax);
2054 __ SmiUntag(eax);
2044 } 2055 }
2045 2056
2046 __ jmp(&call_function); 2057 __ jmp(&call_function);
2047 2058
2048 // We are here because tracing is on or we encountered a MISS case we can't 2059 // We are here because tracing is on or we encountered a MISS case we can't
2049 // handle here. 2060 // handle here.
2050 __ bind(&miss); 2061 __ bind(&miss);
2051 GenerateMiss(masm); 2062 GenerateMiss(masm);
2052 2063
2053 __ jmp(&call); 2064 __ jmp(&call);
2054 2065
2055 // Unreachable 2066 // Unreachable
2056 __ int3(); 2067 __ int3();
2057 } 2068 }
2058 2069
2059 2070
2060 void CallICStub::GenerateMiss(MacroAssembler* masm) { 2071 void CallICStub::GenerateMiss(MacroAssembler* masm) {
2061 FrameScope scope(masm, StackFrame::INTERNAL); 2072 FrameScope scope(masm, StackFrame::INTERNAL);
2062 2073
2074 // Store eax since we need it later.
2075 __ SmiTag(eax);
2076 __ push(eax);
2063 // Push the function and feedback info. 2077 // Push the function and feedback info.
2064 __ push(edi); 2078 __ push(edi);
2065 __ push(ebx); 2079 __ push(ebx);
2066 __ push(edx); 2080 __ push(edx);
2067 2081
2068 // Call the entry. 2082 // Call the entry.
2069 __ CallRuntime(Runtime::kCallIC_Miss); 2083 __ CallRuntime(Runtime::kCallIC_Miss);
2070 2084
2071 // Move result to edi and exit the internal frame. 2085 // Move result to edi and exit the internal frame.
2072 __ mov(edi, eax); 2086 __ mov(edi, eax);
2087
2088 // Restore eax.
2089 __ pop(eax);
2090 __ SmiUntag(eax);
2073 } 2091 }
2074 2092
2075 2093
2076 bool CEntryStub::NeedsImmovableCode() { 2094 bool CEntryStub::NeedsImmovableCode() {
2077 return false; 2095 return false;
2078 } 2096 }
2079 2097
2080 2098
2081 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { 2099 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) {
2082 CEntryStub::GenerateAheadOfTime(isolate); 2100 CEntryStub::GenerateAheadOfTime(isolate);
(...skipping 3738 matching lines...) Expand 10 before | Expand all | Expand 10 after
5821 return_value_operand, NULL); 5839 return_value_operand, NULL);
5822 } 5840 }
5823 5841
5824 5842
5825 #undef __ 5843 #undef __
5826 5844
5827 } // namespace internal 5845 } // namespace internal
5828 } // namespace v8 5846 } // namespace v8
5829 5847
5830 #endif // V8_TARGET_ARCH_IA32 5848 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698