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

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: 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 1879 matching lines...) Expand 10 before | Expand all | Expand 10 after
1890 1890
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
rmcilroy 2016/02/12 14:21:03 Add a comment here that eax contains arg_count if
mythria 2016/02/17 11:02:48 Done.
1901 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); 1901 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx);
1902 __ cmp(edi, ecx); 1902 __ cmp(edi, ecx);
1903 __ j(not_equal, miss); 1903 __ j(not_equal, miss);
1904 1904
1905 __ mov(eax, arg_count()); 1905 if (!argc_in_register()) {
1906 __ mov(eax, arg_count());
1907 }
1906 // Reload ecx. 1908 // Reload ecx.
1907 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, 1909 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size,
1908 FixedArray::kHeaderSize)); 1910 FixedArray::kHeaderSize));
1909 1911
1910 // Increment the call count for monomorphic function calls. 1912 // Increment the call count for monomorphic function calls.
1911 __ add(FieldOperand(ebx, edx, times_half_pointer_size, 1913 __ add(FieldOperand(ebx, edx, times_half_pointer_size,
1912 FixedArray::kHeaderSize + kPointerSize), 1914 FixedArray::kHeaderSize + kPointerSize),
1913 Immediate(Smi::FromInt(CallICNexus::kCallCountIncrement))); 1915 Immediate(Smi::FromInt(CallICNexus::kCallCountIncrement)));
1914 1916
1915 __ mov(ebx, ecx); 1917 __ mov(ebx, ecx);
1916 __ mov(edx, edi); 1918 __ mov(edx, edi);
1917 ArrayConstructorStub stub(masm->isolate(), arg_count()); 1919 if (argc_in_register()) {
1918 __ TailCallStub(&stub); 1920 ArrayConstructorStub stub(masm->isolate());
1919 1921 __ TailCallStub(&stub);
1922 } else {
1923 ArrayConstructorStub stub(masm->isolate(), arg_count());
1924 __ TailCallStub(&stub);
1925 }
1920 // Unreachable. 1926 // Unreachable.
1921 } 1927 }
1922 1928
1923 1929
1924 void CallICStub::Generate(MacroAssembler* masm) { 1930 void CallICStub::Generate(MacroAssembler* masm) {
1925 // edi - function 1931 // edi - function
1926 // edx - slot id 1932 // edx - slot id
1927 // ebx - vector 1933 // ebx - vector
1934 // eax - number of arguments - if argc_in_register() is true.
1928 Isolate* isolate = masm->isolate(); 1935 Isolate* isolate = masm->isolate();
1929 Label extra_checks_or_miss, call, call_function; 1936 Label extra_checks_or_miss, call, call_function;
1930 int argc = arg_count(); 1937 int argc = arg_count();
1931 ParameterCount actual(argc);
1932 1938
1933 // The checks. First, does edi match the recorded monomorphic target? 1939 // The checks. First, does edi match the recorded monomorphic target?
1934 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, 1940 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size,
1935 FixedArray::kHeaderSize)); 1941 FixedArray::kHeaderSize));
1936 1942
1937 // We don't know that we have a weak cell. We might have a private symbol 1943 // 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. 1944 // or an AllocationSite, but the memory is safe to examine.
1939 // AllocationSite::kTransitionInfoOffset - contains a Smi or pointer to 1945 // AllocationSite::kTransitionInfoOffset - contains a Smi or pointer to
1940 // FixedArray. 1946 // FixedArray.
1941 // WeakCell::kValueOffset - contains a JSFunction or Smi(0) 1947 // 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 1960 // The compare above could have been a SMI/SMI comparison. Guard against this
1955 // convincing us that we have a monomorphic JSFunction. 1961 // convincing us that we have a monomorphic JSFunction.
1956 __ JumpIfSmi(edi, &extra_checks_or_miss); 1962 __ JumpIfSmi(edi, &extra_checks_or_miss);
1957 1963
1958 // Increment the call count for monomorphic function calls. 1964 // Increment the call count for monomorphic function calls.
1959 __ add(FieldOperand(ebx, edx, times_half_pointer_size, 1965 __ add(FieldOperand(ebx, edx, times_half_pointer_size,
1960 FixedArray::kHeaderSize + kPointerSize), 1966 FixedArray::kHeaderSize + kPointerSize),
1961 Immediate(Smi::FromInt(CallICNexus::kCallCountIncrement))); 1967 Immediate(Smi::FromInt(CallICNexus::kCallCountIncrement)));
1962 1968
1963 __ bind(&call_function); 1969 __ bind(&call_function);
1964 __ Set(eax, argc); 1970 if (!argc_in_register()) {
1971 __ Set(eax, argc);
1972 }
rmcilroy 2016/02/12 14:21:03 Could we just pull this up to be below "argc = arg
mythria 2016/02/17 11:02:48 Done.
1965 __ Jump(masm->isolate()->builtins()->CallFunction(convert_mode(), 1973 __ Jump(masm->isolate()->builtins()->CallFunction(convert_mode(),
1966 tail_call_mode()), 1974 tail_call_mode()),
1967 RelocInfo::CODE_TARGET); 1975 RelocInfo::CODE_TARGET);
1968 1976
1969 __ bind(&extra_checks_or_miss); 1977 __ bind(&extra_checks_or_miss);
1970 Label uninitialized, miss, not_allocation_site; 1978 Label uninitialized, miss, not_allocation_site;
1971 1979
1972 __ cmp(ecx, Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); 1980 __ cmp(ecx, Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate)));
1973 __ j(equal, &call); 1981 __ j(equal, &call);
1974 1982
(...skipping 19 matching lines...) Expand all
1994 // We are going megamorphic. If the feedback is a JSFunction, it is fine 2002 // 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. 2003 // to handle it here. More complex cases are dealt with in the runtime.
1996 __ AssertNotSmi(ecx); 2004 __ AssertNotSmi(ecx);
1997 __ CmpObjectType(ecx, JS_FUNCTION_TYPE, ecx); 2005 __ CmpObjectType(ecx, JS_FUNCTION_TYPE, ecx);
1998 __ j(not_equal, &miss); 2006 __ j(not_equal, &miss);
1999 __ mov( 2007 __ mov(
2000 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), 2008 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize),
2001 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); 2009 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate)));
2002 2010
2003 __ bind(&call); 2011 __ bind(&call);
2004 __ Set(eax, argc); 2012 if (!argc_in_register()) {
2013 __ Set(eax, argc);
2014 }
2005 __ Jump(masm->isolate()->builtins()->Call(convert_mode(), tail_call_mode()), 2015 __ Jump(masm->isolate()->builtins()->Call(convert_mode(), tail_call_mode()),
2006 RelocInfo::CODE_TARGET); 2016 RelocInfo::CODE_TARGET);
2007 2017
2008 __ bind(&uninitialized); 2018 __ bind(&uninitialized);
2009 2019
2010 // We are going monomorphic, provided we actually have a JSFunction. 2020 // We are going monomorphic, provided we actually have a JSFunction.
2011 __ JumpIfSmi(edi, &miss); 2021 __ JumpIfSmi(edi, &miss);
2012 2022
2013 // Goto miss case if we do not have a function. 2023 // Goto miss case if we do not have a function.
2014 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); 2024 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx);
(...skipping 16 matching lines...) Expand all
2031 FixedArray::kHeaderSize + kPointerSize), 2041 FixedArray::kHeaderSize + kPointerSize),
2032 Immediate(Smi::FromInt(CallICNexus::kCallCountIncrement))); 2042 Immediate(Smi::FromInt(CallICNexus::kCallCountIncrement)));
2033 2043
2034 // Store the function. Use a stub since we need a frame for allocation. 2044 // Store the function. Use a stub since we need a frame for allocation.
2035 // ebx - vector 2045 // ebx - vector
2036 // edx - slot 2046 // edx - slot
2037 // edi - function 2047 // edi - function
2038 { 2048 {
2039 FrameScope scope(masm, StackFrame::INTERNAL); 2049 FrameScope scope(masm, StackFrame::INTERNAL);
2040 CreateWeakCellStub create_stub(isolate); 2050 CreateWeakCellStub create_stub(isolate);
2051 if (argc_in_register()) {
2052 __ SmiTag(eax);
2053 __ push(eax);
2054 }
2041 __ push(edi); 2055 __ push(edi);
2042 __ CallStub(&create_stub); 2056 __ CallStub(&create_stub);
2043 __ pop(edi); 2057 __ pop(edi);
2058 if (argc_in_register()) {
2059 __ pop(eax);
2060 __ SmiUntag(eax);
2061 }
2044 } 2062 }
2045 2063
2046 __ jmp(&call_function); 2064 __ jmp(&call_function);
2047 2065
2048 // We are here because tracing is on or we encountered a MISS case we can't 2066 // We are here because tracing is on or we encountered a MISS case we can't
2049 // handle here. 2067 // handle here.
2050 __ bind(&miss); 2068 __ bind(&miss);
2051 GenerateMiss(masm); 2069 GenerateMiss(masm);
2052 2070
2053 __ jmp(&call); 2071 __ jmp(&call);
2054 2072
2055 // Unreachable 2073 // Unreachable
2056 __ int3(); 2074 __ int3();
2057 } 2075 }
2058 2076
2059 2077
2060 void CallICStub::GenerateMiss(MacroAssembler* masm) { 2078 void CallICStub::GenerateMiss(MacroAssembler* masm) {
2061 FrameScope scope(masm, StackFrame::INTERNAL); 2079 FrameScope scope(masm, StackFrame::INTERNAL);
2062 2080 if (argc_in_register()) {
2081 __ SmiTag(eax);
2082 __ push(eax);
2083 }
2063 // Push the function and feedback info. 2084 // Push the function and feedback info.
2064 __ push(edi); 2085 __ push(edi);
2065 __ push(ebx); 2086 __ push(ebx);
2066 __ push(edx); 2087 __ push(edx);
2067 2088
2068 // Call the entry. 2089 // Call the entry.
2069 __ CallRuntime(Runtime::kCallIC_Miss); 2090 __ CallRuntime(Runtime::kCallIC_Miss);
2070 2091
2071 // Move result to edi and exit the internal frame. 2092 // Move result to edi and exit the internal frame.
2072 __ mov(edi, eax); 2093 __ mov(edi, eax);
2094 if (argc_in_register()) {
2095 __ pop(eax);
2096 __ SmiUntag(eax);
2097 }
2073 } 2098 }
2074 2099
2075 2100
2076 bool CEntryStub::NeedsImmovableCode() { 2101 bool CEntryStub::NeedsImmovableCode() {
2077 return false; 2102 return false;
2078 } 2103 }
2079 2104
2080 2105
2081 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { 2106 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) {
2082 CEntryStub::GenerateAheadOfTime(isolate); 2107 CEntryStub::GenerateAheadOfTime(isolate);
(...skipping 3738 matching lines...) Expand 10 before | Expand all | Expand 10 after
5821 return_value_operand, NULL); 5846 return_value_operand, NULL);
5822 } 5847 }
5823 5848
5824 5849
5825 #undef __ 5850 #undef __
5826 5851
5827 } // namespace internal 5852 } // namespace internal
5828 } // namespace v8 5853 } // namespace v8
5829 5854
5830 #endif // V8_TARGET_ARCH_IA32 5855 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698