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

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

Issue 1476413003: Provide call counts for constructor calls, surface them as a vector IC. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Created 5 years 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/x64/full-codegen-x64.cc ('k') | src/ia32/interface-descriptors-ia32.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 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 1919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1930 static void GenerateRecordCallTarget(MacroAssembler* masm) { 1930 static void GenerateRecordCallTarget(MacroAssembler* masm) {
1931 // Cache the called function in a feedback vector slot. Cache states 1931 // Cache the called function in a feedback vector slot. Cache states
1932 // are uninitialized, monomorphic (indicated by a JSFunction), and 1932 // are uninitialized, monomorphic (indicated by a JSFunction), and
1933 // megamorphic. 1933 // megamorphic.
1934 // eax : number of arguments to the construct function 1934 // eax : number of arguments to the construct function
1935 // ebx : feedback vector 1935 // ebx : feedback vector
1936 // edx : slot in feedback vector (Smi) 1936 // edx : slot in feedback vector (Smi)
1937 // edi : the function to call 1937 // edi : the function to call
1938 Isolate* isolate = masm->isolate(); 1938 Isolate* isolate = masm->isolate();
1939 Label initialize, done, miss, megamorphic, not_array_function; 1939 Label initialize, done, miss, megamorphic, not_array_function;
1940 Label done_increment_count;
1940 1941
1941 // Load the cache state into ecx. 1942 // Load the cache state into ecx.
1942 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, 1943 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size,
1943 FixedArray::kHeaderSize)); 1944 FixedArray::kHeaderSize));
1944 1945
1945 // A monomorphic cache hit or an already megamorphic state: invoke the 1946 // A monomorphic cache hit or an already megamorphic state: invoke the
1946 // function without changing the state. 1947 // function without changing the state.
1947 // We don't know if ecx is a WeakCell or a Symbol, but it's harmless to read 1948 // We don't know if ecx is a WeakCell or a Symbol, but it's harmless to read
1948 // at this position in a symbol (see static asserts in 1949 // at this position in a symbol (see static asserts in
1949 // type-feedback-vector.h). 1950 // type-feedback-vector.h).
1950 Label check_allocation_site; 1951 Label check_allocation_site;
1951 __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset)); 1952 __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset));
1952 __ j(equal, &done, Label::kFar); 1953 __ j(equal, &done_increment_count, Label::kFar);
1953 __ CompareRoot(ecx, Heap::kmegamorphic_symbolRootIndex); 1954 __ CompareRoot(ecx, Heap::kmegamorphic_symbolRootIndex);
1954 __ j(equal, &done, Label::kFar); 1955 __ j(equal, &done, Label::kFar);
1955 __ CompareRoot(FieldOperand(ecx, HeapObject::kMapOffset), 1956 __ CompareRoot(FieldOperand(ecx, HeapObject::kMapOffset),
1956 Heap::kWeakCellMapRootIndex); 1957 Heap::kWeakCellMapRootIndex);
1957 __ j(not_equal, &check_allocation_site); 1958 __ j(not_equal, &check_allocation_site);
1958 1959
1959 // If the weak cell is cleared, we have a new chance to become monomorphic. 1960 // If the weak cell is cleared, we have a new chance to become monomorphic.
1960 __ JumpIfSmi(FieldOperand(ecx, WeakCell::kValueOffset), &initialize); 1961 __ JumpIfSmi(FieldOperand(ecx, WeakCell::kValueOffset), &initialize);
1961 __ jmp(&megamorphic); 1962 __ jmp(&megamorphic);
1962 1963
1963 __ bind(&check_allocation_site); 1964 __ bind(&check_allocation_site);
1964 // If we came here, we need to see if we are the array function. 1965 // If we came here, we need to see if we are the array function.
1965 // If we didn't have a matching function, and we didn't find the megamorph 1966 // If we didn't have a matching function, and we didn't find the megamorph
1966 // sentinel, then we have in the slot either some other function or an 1967 // sentinel, then we have in the slot either some other function or an
1967 // AllocationSite. 1968 // AllocationSite.
1968 __ CompareRoot(FieldOperand(ecx, 0), Heap::kAllocationSiteMapRootIndex); 1969 __ CompareRoot(FieldOperand(ecx, 0), Heap::kAllocationSiteMapRootIndex);
1969 __ j(not_equal, &miss); 1970 __ j(not_equal, &miss);
1970 1971
1971 // Make sure the function is the Array() function 1972 // Make sure the function is the Array() function
1972 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); 1973 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx);
1973 __ cmp(edi, ecx); 1974 __ cmp(edi, ecx);
1974 __ j(not_equal, &megamorphic); 1975 __ j(not_equal, &megamorphic);
1975 __ jmp(&done, Label::kFar); 1976 __ jmp(&done_increment_count, Label::kFar);
1976 1977
1977 __ bind(&miss); 1978 __ bind(&miss);
1978 1979
1979 // A monomorphic miss (i.e, here the cache is not uninitialized) goes 1980 // A monomorphic miss (i.e, here the cache is not uninitialized) goes
1980 // megamorphic. 1981 // megamorphic.
1981 __ CompareRoot(ecx, Heap::kuninitialized_symbolRootIndex); 1982 __ CompareRoot(ecx, Heap::kuninitialized_symbolRootIndex);
1982 __ j(equal, &initialize); 1983 __ j(equal, &initialize);
1983 // MegamorphicSentinel is an immortal immovable object (undefined) so no 1984 // MegamorphicSentinel is an immortal immovable object (undefined) so no
1984 // write-barrier is needed. 1985 // write-barrier is needed.
1985 __ bind(&megamorphic); 1986 __ bind(&megamorphic);
1986 __ mov( 1987 __ mov(
1987 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), 1988 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize),
1988 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); 1989 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate)));
1989 __ jmp(&done, Label::kFar); 1990 __ jmp(&done, Label::kFar);
1990 1991
1991 // An uninitialized cache is patched with the function or sentinel to 1992 // An uninitialized cache is patched with the function or sentinel to
1992 // indicate the ElementsKind if function is the Array constructor. 1993 // indicate the ElementsKind if function is the Array constructor.
1993 __ bind(&initialize); 1994 __ bind(&initialize);
1995
1996 // Initialize the call counter.
1997 __ mov(FieldOperand(ebx, edx, times_half_pointer_size,
1998 FixedArray::kHeaderSize + kPointerSize),
1999 Immediate(Smi::FromInt(ConstructICNexus::kCallCountIncrement)));
2000
1994 // Make sure the function is the Array() function 2001 // Make sure the function is the Array() function
1995 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); 2002 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx);
1996 __ cmp(edi, ecx); 2003 __ cmp(edi, ecx);
1997 __ j(not_equal, &not_array_function); 2004 __ j(not_equal, &not_array_function);
1998 2005
1999 // The target function is the Array constructor, 2006 // The target function is the Array constructor,
2000 // Create an AllocationSite if we don't already have it, store it in the 2007 // Create an AllocationSite if we don't already have it, store it in the
2001 // slot. 2008 // slot.
2002 CreateAllocationSiteStub create_stub(isolate); 2009 CreateAllocationSiteStub create_stub(isolate);
2003 CallStubInRecordCallTarget(masm, &create_stub); 2010 CallStubInRecordCallTarget(masm, &create_stub);
2004 __ jmp(&done); 2011 __ jmp(&done);
2005 2012
2006 __ bind(&not_array_function); 2013 __ bind(&not_array_function);
2007 CreateWeakCellStub weak_cell_stub(isolate); 2014 CreateWeakCellStub weak_cell_stub(isolate);
2008 CallStubInRecordCallTarget(masm, &weak_cell_stub); 2015 CallStubInRecordCallTarget(masm, &weak_cell_stub);
2016 __ jmp(&done);
2017
2018 __ bind(&done_increment_count);
2019 __ add(FieldOperand(ebx, edx, times_half_pointer_size,
2020 FixedArray::kHeaderSize + kPointerSize),
2021 Immediate(Smi::FromInt(ConstructICNexus::kCallCountIncrement)));
2022
2009 __ bind(&done); 2023 __ bind(&done);
2010 } 2024 }
2011 2025
2012 2026
2013 void CallConstructStub::Generate(MacroAssembler* masm) { 2027 void ConstructICStub::Generate(MacroAssembler* masm) {
2014 // eax : number of arguments 2028 // eax : number of arguments
2015 // ebx : feedback vector 2029 // ebx : feedback vector
2016 // edx : slot in feedback vector (Smi, for RecordCallTarget) 2030 // edx : slot in feedback vector (Smi, for RecordCallTarget)
2017 // edi : constructor function 2031 // edi : constructor function
2018 2032
2019 Label non_function; 2033 Label non_function;
2020 // Check that function is not a smi. 2034 // Check that function is not a smi.
2021 __ JumpIfSmi(edi, &non_function); 2035 __ JumpIfSmi(edi, &non_function);
2022 // Check that function is a JSFunction. 2036 // Check that function is a JSFunction.
2023 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); 2037 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx);
(...skipping 3614 matching lines...) Expand 10 before | Expand all | Expand 10 after
5638 Operand(ebp, 7 * kPointerSize), NULL); 5652 Operand(ebp, 7 * kPointerSize), NULL);
5639 } 5653 }
5640 5654
5641 5655
5642 #undef __ 5656 #undef __
5643 5657
5644 } // namespace internal 5658 } // namespace internal
5645 } // namespace v8 5659 } // namespace v8
5646 5660
5647 #endif // V8_TARGET_ARCH_IA32 5661 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/full-codegen/x64/full-codegen-x64.cc ('k') | src/ia32/interface-descriptors-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698