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

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

Issue 1245043003: Fix pushing of register in CallConstructStub outside frame. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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 | src/mips/code-stubs-mips.cc » ('j') | src/x64/code-stubs-x64.cc » ('J')
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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_IA32 7 #if V8_TARGET_ARCH_IA32
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 1898 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 1909
1910 // Call the native; it returns -1 (less), 0 (equal), or 1 (greater) 1910 // Call the native; it returns -1 (less), 0 (equal), or 1 (greater)
1911 // tagged as a small integer. 1911 // tagged as a small integer.
1912 __ InvokeBuiltin(builtin, JUMP_FUNCTION); 1912 __ InvokeBuiltin(builtin, JUMP_FUNCTION);
1913 1913
1914 __ bind(&miss); 1914 __ bind(&miss);
1915 GenerateMiss(masm); 1915 GenerateMiss(masm);
1916 } 1916 }
1917 1917
1918 1918
1919 static void CallStubInRecordCallTarget(MacroAssembler* masm, CodeStub* stub) { 1919 static void CallStubInRecordCallTarget(MacroAssembler* masm, CodeStub* stub,
1920 bool is_super) {
1920 // eax : number of arguments to the construct function 1921 // eax : number of arguments to the construct function
1921 // ebx : Feedback vector 1922 // ebx : feedback vector
1922 // edx : slot in feedback vector (Smi) 1923 // edx : slot in feedback vector (Smi)
1923 // edi : the function to call 1924 // edi : the function to call
1924 FrameScope scope(masm, StackFrame::INTERNAL); 1925 // esp[0]: original receiver (for IsSuperConstructorCall)
1926 if (is_super) {
1927 __ pop(ecx);
1928 }
1925 1929
1926 // Number-of-arguments register must be smi-tagged to call out. 1930 {
1927 __ SmiTag(eax); 1931 FrameScope scope(masm, StackFrame::INTERNAL);
1928 __ push(eax);
1929 __ push(edi);
1930 __ push(edx);
1931 __ push(ebx);
1932 1932
1933 __ CallStub(stub); 1933 // Number-of-arguments register must be smi-tagged to call out.
1934 __ SmiTag(eax);
1935 __ push(eax);
1936 __ push(edi);
1937 __ push(edx);
1938 __ push(ebx);
1939 if (is_super) {
1940 __ push(ecx);
1941 }
1934 1942
1935 __ pop(ebx); 1943 __ CallStub(stub);
1936 __ pop(edx); 1944
1937 __ pop(edi); 1945 if (is_super) {
1938 __ pop(eax); 1946 __ pop(ecx);
1939 __ SmiUntag(eax); 1947 }
1948 __ pop(ebx);
1949 __ pop(edx);
1950 __ pop(edi);
1951 __ pop(eax);
1952 __ SmiUntag(eax);
1953 }
1954
1955 if (is_super) {
1956 __ push(ecx);
1957 }
1940 } 1958 }
1941 1959
1942 1960
1943 static void GenerateRecordCallTarget(MacroAssembler* masm) { 1961 static void GenerateRecordCallTarget(MacroAssembler* masm, bool is_super) {
1944 // Cache the called function in a feedback vector slot. Cache states 1962 // Cache the called function in a feedback vector slot. Cache states
1945 // are uninitialized, monomorphic (indicated by a JSFunction), and 1963 // are uninitialized, monomorphic (indicated by a JSFunction), and
1946 // megamorphic. 1964 // megamorphic.
1947 // eax : number of arguments to the construct function 1965 // eax : number of arguments to the construct function
1948 // ebx : Feedback vector 1966 // ebx : feedback vector
1949 // edx : slot in feedback vector (Smi) 1967 // edx : slot in feedback vector (Smi)
1950 // edi : the function to call 1968 // edi : the function to call
1969 // esp[0]: original receiver (for IsSuperConstructorCall)
1951 Isolate* isolate = masm->isolate(); 1970 Isolate* isolate = masm->isolate();
1952 Label initialize, done, miss, megamorphic, not_array_function; 1971 Label initialize, done, miss, megamorphic, not_array_function;
1953 1972
1954 // Load the cache state into ecx. 1973 // Load the cache state into ecx.
1955 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, 1974 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size,
1956 FixedArray::kHeaderSize)); 1975 FixedArray::kHeaderSize));
1957 1976
1958 // A monomorphic cache hit or an already megamorphic state: invoke the 1977 // A monomorphic cache hit or an already megamorphic state: invoke the
1959 // function without changing the state. 1978 // function without changing the state.
1960 // We don't know if ecx is a WeakCell or a Symbol, but it's harmless to read 1979 // We don't know if ecx is a WeakCell or a Symbol, but it's harmless to read
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2009 if (!FLAG_pretenuring_call_new) { 2028 if (!FLAG_pretenuring_call_new) {
2010 // Make sure the function is the Array() function 2029 // Make sure the function is the Array() function
2011 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); 2030 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx);
2012 __ cmp(edi, ecx); 2031 __ cmp(edi, ecx);
2013 __ j(not_equal, &not_array_function); 2032 __ j(not_equal, &not_array_function);
2014 2033
2015 // The target function is the Array constructor, 2034 // The target function is the Array constructor,
2016 // Create an AllocationSite if we don't already have it, store it in the 2035 // Create an AllocationSite if we don't already have it, store it in the
2017 // slot. 2036 // slot.
2018 CreateAllocationSiteStub create_stub(isolate); 2037 CreateAllocationSiteStub create_stub(isolate);
2019 CallStubInRecordCallTarget(masm, &create_stub); 2038 CallStubInRecordCallTarget(masm, &create_stub, is_super);
2020 __ jmp(&done); 2039 __ jmp(&done);
2021 2040
2022 __ bind(&not_array_function); 2041 __ bind(&not_array_function);
2023 } 2042 }
2024 2043
2025 CreateWeakCellStub create_stub(isolate); 2044 CreateWeakCellStub create_stub(isolate);
2026 CallStubInRecordCallTarget(masm, &create_stub); 2045 CallStubInRecordCallTarget(masm, &create_stub, is_super);
2027 __ bind(&done); 2046 __ bind(&done);
2028 } 2047 }
2029 2048
2030 2049
2031 static void EmitContinueIfStrictOrNative(MacroAssembler* masm, Label* cont) { 2050 static void EmitContinueIfStrictOrNative(MacroAssembler* masm, Label* cont) {
2032 // Do not transform the receiver for strict mode functions. 2051 // Do not transform the receiver for strict mode functions.
2033 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); 2052 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
2034 __ test_b(FieldOperand(ecx, SharedFunctionInfo::kStrictModeByteOffset), 2053 __ test_b(FieldOperand(ecx, SharedFunctionInfo::kStrictModeByteOffset),
2035 1 << SharedFunctionInfo::kStrictModeBitWithinByte); 2054 1 << SharedFunctionInfo::kStrictModeBitWithinByte);
2036 __ j(not_equal, cont); 2055 __ j(not_equal, cont);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2156 __ push(ecx); 2175 __ push(ecx);
2157 } 2176 }
2158 2177
2159 // Check that function is not a smi. 2178 // Check that function is not a smi.
2160 __ JumpIfSmi(edi, &non_function_call); 2179 __ JumpIfSmi(edi, &non_function_call);
2161 // Check that function is a JSFunction. 2180 // Check that function is a JSFunction.
2162 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); 2181 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx);
2163 __ j(not_equal, &slow); 2182 __ j(not_equal, &slow);
2164 2183
2165 if (RecordCallTarget()) { 2184 if (RecordCallTarget()) {
2166 GenerateRecordCallTarget(masm); 2185 GenerateRecordCallTarget(masm, IsSuperConstructorCall());
2167 2186
2168 if (FLAG_pretenuring_call_new) { 2187 if (FLAG_pretenuring_call_new) {
2169 // Put the AllocationSite from the feedback vector into ebx. 2188 // Put the AllocationSite from the feedback vector into ebx.
2170 // By adding kPointerSize we encode that we know the AllocationSite 2189 // By adding kPointerSize we encode that we know the AllocationSite
2171 // entry is at the feedback vector slot given by edx + 1. 2190 // entry is at the feedback vector slot given by edx + 1.
2172 __ mov(ebx, FieldOperand(ebx, edx, times_half_pointer_size, 2191 __ mov(ebx, FieldOperand(ebx, edx, times_half_pointer_size,
2173 FixedArray::kHeaderSize + kPointerSize)); 2192 FixedArray::kHeaderSize + kPointerSize));
2174 } else { 2193 } else {
2175 Label feedback_register_initialized; 2194 Label feedback_register_initialized;
2176 // Put the AllocationSite from the feedback vector into ebx, or undefined. 2195 // Put the AllocationSite from the feedback vector into ebx, or undefined.
(...skipping 21 matching lines...) Expand all
2198 Register jmp_reg = ecx; 2217 Register jmp_reg = ecx;
2199 __ mov(jmp_reg, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); 2218 __ mov(jmp_reg, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
2200 __ mov(jmp_reg, FieldOperand(jmp_reg, 2219 __ mov(jmp_reg, FieldOperand(jmp_reg,
2201 SharedFunctionInfo::kConstructStubOffset)); 2220 SharedFunctionInfo::kConstructStubOffset));
2202 __ lea(jmp_reg, FieldOperand(jmp_reg, Code::kHeaderSize)); 2221 __ lea(jmp_reg, FieldOperand(jmp_reg, Code::kHeaderSize));
2203 __ jmp(jmp_reg); 2222 __ jmp(jmp_reg);
2204 2223
2205 // edi: called object 2224 // edi: called object
2206 // eax: number of arguments 2225 // eax: number of arguments
2207 // ecx: object map 2226 // ecx: object map
2208 // esp[0]: original receiver 2227 // esp[0]: original receiver (for IsSuperConstructorCall)
2209 Label do_call; 2228 Label do_call;
2210 __ bind(&slow); 2229 __ bind(&slow);
2211 __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE); 2230 __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE);
2212 __ j(not_equal, &non_function_call); 2231 __ j(not_equal, &non_function_call);
2213 __ GetBuiltinEntry(edx, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR); 2232 __ GetBuiltinEntry(edx, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR);
2214 __ jmp(&do_call); 2233 __ jmp(&do_call);
2215 2234
2216 __ bind(&non_function_call); 2235 __ bind(&non_function_call);
2217 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); 2236 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR);
2218 __ bind(&do_call); 2237 __ bind(&do_call);
(...skipping 3266 matching lines...) Expand 10 before | Expand all | Expand 10 after
5485 Operand(ebp, 7 * kPointerSize), NULL); 5504 Operand(ebp, 7 * kPointerSize), NULL);
5486 } 5505 }
5487 5506
5488 5507
5489 #undef __ 5508 #undef __
5490 5509
5491 } // namespace internal 5510 } // namespace internal
5492 } // namespace v8 5511 } // namespace v8
5493 5512
5494 #endif // V8_TARGET_ARCH_IA32 5513 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « no previous file | src/mips/code-stubs-mips.cc » ('j') | src/x64/code-stubs-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698