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

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

Issue 132963012: Pretenure call new support. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE. Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | src/x64/full-codegen-x64.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2093 matching lines...) Expand 10 before | Expand all | Expand 10 after
2104 __ movp(rcx, FieldOperand(rbx, rdx, times_pointer_size, 2104 __ movp(rcx, FieldOperand(rbx, rdx, times_pointer_size,
2105 FixedArray::kHeaderSize)); 2105 FixedArray::kHeaderSize));
2106 2106
2107 // A monomorphic cache hit or an already megamorphic state: invoke the 2107 // A monomorphic cache hit or an already megamorphic state: invoke the
2108 // function without changing the state. 2108 // function without changing the state.
2109 __ cmpq(rcx, rdi); 2109 __ cmpq(rcx, rdi);
2110 __ j(equal, &done); 2110 __ j(equal, &done);
2111 __ Cmp(rcx, TypeFeedbackInfo::MegamorphicSentinel(isolate)); 2111 __ Cmp(rcx, TypeFeedbackInfo::MegamorphicSentinel(isolate));
2112 __ j(equal, &done); 2112 __ j(equal, &done);
2113 2113
2114 // If we came here, we need to see if we are the array function. 2114 if (!FLAG_pretenuring_call_new) {
2115 // If we didn't have a matching function, and we didn't find the megamorph 2115 // If we came here, we need to see if we are the array function.
2116 // sentinel, then we have in the slot either some other function or an 2116 // If we didn't have a matching function, and we didn't find the megamorph
2117 // AllocationSite. Do a map check on the object in rcx. 2117 // sentinel, then we have in the slot either some other function or an
2118 Handle<Map> allocation_site_map = 2118 // AllocationSite. Do a map check on the object in rcx.
2119 masm->isolate()->factory()->allocation_site_map(); 2119 Handle<Map> allocation_site_map =
2120 __ Cmp(FieldOperand(rcx, 0), allocation_site_map); 2120 masm->isolate()->factory()->allocation_site_map();
2121 __ j(not_equal, &miss); 2121 __ Cmp(FieldOperand(rcx, 0), allocation_site_map);
2122 __ j(not_equal, &miss);
2122 2123
2123 // Make sure the function is the Array() function 2124 // Make sure the function is the Array() function
2124 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, rcx); 2125 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, rcx);
2125 __ cmpq(rdi, rcx); 2126 __ cmpq(rdi, rcx);
2126 __ j(not_equal, &megamorphic); 2127 __ j(not_equal, &megamorphic);
2127 __ jmp(&done); 2128 __ jmp(&done);
2129 }
2128 2130
2129 __ bind(&miss); 2131 __ bind(&miss);
2130 2132
2131 // A monomorphic miss (i.e, here the cache is not uninitialized) goes 2133 // A monomorphic miss (i.e, here the cache is not uninitialized) goes
2132 // megamorphic. 2134 // megamorphic.
2133 __ Cmp(rcx, TypeFeedbackInfo::UninitializedSentinel(isolate)); 2135 __ Cmp(rcx, TypeFeedbackInfo::UninitializedSentinel(isolate));
2134 __ j(equal, &initialize); 2136 __ j(equal, &initialize);
2135 // MegamorphicSentinel is an immortal immovable object (undefined) so no 2137 // MegamorphicSentinel is an immortal immovable object (undefined) so no
2136 // write-barrier is needed. 2138 // write-barrier is needed.
2137 __ bind(&megamorphic); 2139 __ bind(&megamorphic);
2138 __ Move(FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize), 2140 __ Move(FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize),
2139 TypeFeedbackInfo::MegamorphicSentinel(isolate)); 2141 TypeFeedbackInfo::MegamorphicSentinel(isolate));
2140 __ jmp(&done); 2142 __ jmp(&done);
2141 2143
2142 // An uninitialized cache is patched with the function or sentinel to 2144 // An uninitialized cache is patched with the function or sentinel to
2143 // indicate the ElementsKind if function is the Array constructor. 2145 // indicate the ElementsKind if function is the Array constructor.
2144 __ bind(&initialize); 2146 __ bind(&initialize);
2145 // Make sure the function is the Array() function
2146 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, rcx);
2147 __ cmpq(rdi, rcx);
2148 __ j(not_equal, &not_array_function);
2149 2147
2150 // The target function is the Array constructor, 2148 if (!FLAG_pretenuring_call_new) {
2151 // Create an AllocationSite if we don't already have it, store it in the slot. 2149 // Make sure the function is the Array() function
2152 { 2150 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, rcx);
2153 FrameScope scope(masm, StackFrame::INTERNAL); 2151 __ cmpq(rdi, rcx);
2152 __ j(not_equal, &not_array_function);
2154 2153
2155 // Arguments register must be smi-tagged to call out. 2154 {
2156 __ Integer32ToSmi(rax, rax); 2155 FrameScope scope(masm, StackFrame::INTERNAL);
2157 __ Push(rax);
2158 __ Push(rdi);
2159 __ Integer32ToSmi(rdx, rdx);
2160 __ Push(rdx);
2161 __ Push(rbx);
2162 2156
2163 CreateAllocationSiteStub create_stub; 2157 // Arguments register must be smi-tagged to call out.
2164 __ CallStub(&create_stub); 2158 __ Integer32ToSmi(rax, rax);
2159 __ Push(rax);
2160 __ Push(rdi);
2161 __ Integer32ToSmi(rdx, rdx);
2162 __ Push(rdx);
2163 __ Push(rbx);
2165 2164
2166 __ Pop(rbx); 2165 CreateAllocationSiteStub create_stub;
2167 __ Pop(rdx); 2166 __ CallStub(&create_stub);
2168 __ Pop(rdi); 2167
2169 __ Pop(rax); 2168 __ Pop(rbx);
2170 __ SmiToInteger32(rax, rax); 2169 __ Pop(rdx);
2170 __ Pop(rdi);
2171 __ Pop(rax);
2172 __ SmiToInteger32(rax, rax);
2173 }
2174 __ jmp(&done_no_smi_convert);
2175
2176 __ bind(&not_array_function);
2171 } 2177 }
2172 __ jmp(&done_no_smi_convert);
2173 2178
2174 __ bind(&not_array_function);
2175 __ movp(FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize), 2179 __ movp(FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize),
2176 rdi); 2180 rdi);
2177 2181
2178 // We won't need rdx or rbx anymore, just save rdi 2182 // We won't need rdx or rbx anymore, just save rdi
2179 __ Push(rdi); 2183 __ Push(rdi);
2180 __ Push(rbx); 2184 __ Push(rbx);
2181 __ Push(rdx); 2185 __ Push(rdx);
2182 __ RecordWriteArray(rbx, rdi, rdx, kDontSaveFPRegs, 2186 __ RecordWriteArray(rbx, rdi, rdx, kDontSaveFPRegs,
2183 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); 2187 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
2184 __ Pop(rdx); 2188 __ Pop(rdx);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2316 // rdi : constructor function 2320 // rdi : constructor function
2317 Label slow, non_function_call; 2321 Label slow, non_function_call;
2318 2322
2319 // Check that function is not a smi. 2323 // Check that function is not a smi.
2320 __ JumpIfSmi(rdi, &non_function_call); 2324 __ JumpIfSmi(rdi, &non_function_call);
2321 // Check that function is a JSFunction. 2325 // Check that function is a JSFunction.
2322 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); 2326 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx);
2323 __ j(not_equal, &slow); 2327 __ j(not_equal, &slow);
2324 2328
2325 if (RecordCallTarget()) { 2329 if (RecordCallTarget()) {
2326 Label feedback_register_initialized;
2327 GenerateRecordCallTarget(masm); 2330 GenerateRecordCallTarget(masm);
2328 // Put the AllocationSite from the feedback vector into rbx, or undefined. 2331
2329 __ SmiToInteger32(rdx, rdx); 2332 __ SmiToInteger32(rdx, rdx);
2330 __ movp(rbx, FieldOperand(rbx, rdx, times_pointer_size, 2333 if (FLAG_pretenuring_call_new) {
2331 FixedArray::kHeaderSize)); 2334 // Put the AllocationSite from the feedback vector into ebx.
2332 __ CompareRoot(FieldOperand(rbx, 0), Heap::kAllocationSiteMapRootIndex); 2335 // By adding kPointerSize we encode that we know the AllocationSite
2333 __ j(equal, &feedback_register_initialized); 2336 // entry is at the feedback vector slot given by rdx + 1.
2334 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); 2337 __ movp(rbx, FieldOperand(rbx, rdx, times_pointer_size,
2335 __ bind(&feedback_register_initialized); 2338 FixedArray::kHeaderSize + kPointerSize));
2339 } else {
2340 Label feedback_register_initialized;
2341 // Put the AllocationSite from the feedback vector into rbx, or undefined.
2342 __ movp(rbx, FieldOperand(rbx, rdx, times_pointer_size,
2343 FixedArray::kHeaderSize));
2344 __ CompareRoot(FieldOperand(rbx, 0), Heap::kAllocationSiteMapRootIndex);
2345 __ j(equal, &feedback_register_initialized);
2346 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex);
2347 __ bind(&feedback_register_initialized);
2348 }
2349
2336 __ AssertUndefinedOrAllocationSite(rbx); 2350 __ AssertUndefinedOrAllocationSite(rbx);
2337 } 2351 }
2338 2352
2339 // Jump to the function-specific construct stub. 2353 // Jump to the function-specific construct stub.
2340 Register jmp_reg = rcx; 2354 Register jmp_reg = rcx;
2341 __ movp(jmp_reg, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); 2355 __ movp(jmp_reg, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
2342 __ movp(jmp_reg, FieldOperand(jmp_reg, 2356 __ movp(jmp_reg, FieldOperand(jmp_reg,
2343 SharedFunctionInfo::kConstructStubOffset)); 2357 SharedFunctionInfo::kConstructStubOffset));
2344 __ lea(jmp_reg, FieldOperand(jmp_reg, Code::kHeaderSize)); 2358 __ lea(jmp_reg, FieldOperand(jmp_reg, Code::kHeaderSize));
2345 __ jmp(jmp_reg); 2359 __ jmp(jmp_reg);
(...skipping 2608 matching lines...) Expand 10 before | Expand all | Expand 10 after
4954 Condition not_smi = NegateCondition(masm->CheckSmi(rcx)); 4968 Condition not_smi = NegateCondition(masm->CheckSmi(rcx));
4955 __ Check(not_smi, kUnexpectedInitialMapForArrayFunction); 4969 __ Check(not_smi, kUnexpectedInitialMapForArrayFunction);
4956 __ CmpObjectType(rcx, MAP_TYPE, rcx); 4970 __ CmpObjectType(rcx, MAP_TYPE, rcx);
4957 __ Check(equal, kUnexpectedInitialMapForArrayFunction); 4971 __ Check(equal, kUnexpectedInitialMapForArrayFunction);
4958 4972
4959 // We should either have undefined in rbx or a valid AllocationSite 4973 // We should either have undefined in rbx or a valid AllocationSite
4960 __ AssertUndefinedOrAllocationSite(rbx); 4974 __ AssertUndefinedOrAllocationSite(rbx);
4961 } 4975 }
4962 4976
4963 Label no_info; 4977 Label no_info;
4964 // If the feedback slot is the megamorphic sentinel, or contains anything 4978 // If the feedback vector is the undefined value call an array constructor
4965 // other than an AllocationSite, call an array constructor that doesn't use 4979 // that doesn't use AllocationSites.
4966 // AllocationSites.
4967 __ CompareRoot(rbx, Heap::kUndefinedValueRootIndex); 4980 __ CompareRoot(rbx, Heap::kUndefinedValueRootIndex);
4968 __ j(equal, &no_info); 4981 __ j(equal, &no_info);
4969 4982
4970 // Only look at the lower 16 bits of the transition info. 4983 // Only look at the lower 16 bits of the transition info.
4971 __ movp(rdx, FieldOperand(rbx, AllocationSite::kTransitionInfoOffset)); 4984 __ movp(rdx, FieldOperand(rbx, AllocationSite::kTransitionInfoOffset));
4972 __ SmiToInteger32(rdx, rdx); 4985 __ SmiToInteger32(rdx, rdx);
4973 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0); 4986 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0);
4974 __ and_(rdx, Immediate(AllocationSite::ElementsKindBits::kMask)); 4987 __ and_(rdx, Immediate(AllocationSite::ElementsKindBits::kMask));
4975 GenerateDispatchToArrayStub(masm, DONT_OVERRIDE); 4988 GenerateDispatchToArrayStub(masm, DONT_OVERRIDE);
4976 4989
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
5243 return_value_operand, 5256 return_value_operand,
5244 NULL); 5257 NULL);
5245 } 5258 }
5246 5259
5247 5260
5248 #undef __ 5261 #undef __
5249 5262
5250 } } // namespace v8::internal 5263 } } // namespace v8::internal
5251 5264
5252 #endif // V8_TARGET_ARCH_X64 5265 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698