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

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

Issue 2013453003: X87: Collect call counts for constructor calls, too. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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 | no next file » | 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_X87 5 #if V8_TARGET_ARCH_X87
6 6
7 #include "src/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/api-arguments.h" 8 #include "src/api-arguments.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 static void GenerateRecordCallTarget(MacroAssembler* masm) { 1159 static void GenerateRecordCallTarget(MacroAssembler* masm) {
1160 // Cache the called function in a feedback vector slot. Cache states 1160 // Cache the called function in a feedback vector slot. Cache states
1161 // are uninitialized, monomorphic (indicated by a JSFunction), and 1161 // are uninitialized, monomorphic (indicated by a JSFunction), and
1162 // megamorphic. 1162 // megamorphic.
1163 // eax : number of arguments to the construct function 1163 // eax : number of arguments to the construct function
1164 // ebx : feedback vector 1164 // ebx : feedback vector
1165 // edx : slot in feedback vector (Smi) 1165 // edx : slot in feedback vector (Smi)
1166 // edi : the function to call 1166 // edi : the function to call
1167 Isolate* isolate = masm->isolate(); 1167 Isolate* isolate = masm->isolate();
1168 Label initialize, done, miss, megamorphic, not_array_function; 1168 Label initialize, done, miss, megamorphic, not_array_function;
1169 Label done_increment_count, done_initialize_count;
1169 1170
1170 // Load the cache state into ecx. 1171 // Load the cache state into ecx.
1171 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, 1172 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size,
1172 FixedArray::kHeaderSize)); 1173 FixedArray::kHeaderSize));
1173 1174
1174 // A monomorphic cache hit or an already megamorphic state: invoke the 1175 // A monomorphic cache hit or an already megamorphic state: invoke the
1175 // function without changing the state. 1176 // function without changing the state.
1176 // We don't know if ecx is a WeakCell or a Symbol, but it's harmless to read 1177 // We don't know if ecx is a WeakCell or a Symbol, but it's harmless to read
1177 // at this position in a symbol (see static asserts in 1178 // at this position in a symbol (see static asserts in
1178 // type-feedback-vector.h). 1179 // type-feedback-vector.h).
1179 Label check_allocation_site; 1180 Label check_allocation_site;
1180 __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset)); 1181 __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset));
1181 __ j(equal, &done, Label::kFar); 1182 __ j(equal, &done_increment_count, Label::kFar);
1182 __ CompareRoot(ecx, Heap::kmegamorphic_symbolRootIndex); 1183 __ CompareRoot(ecx, Heap::kmegamorphic_symbolRootIndex);
1183 __ j(equal, &done, Label::kFar); 1184 __ j(equal, &done, Label::kFar);
1184 __ CompareRoot(FieldOperand(ecx, HeapObject::kMapOffset), 1185 __ CompareRoot(FieldOperand(ecx, HeapObject::kMapOffset),
1185 Heap::kWeakCellMapRootIndex); 1186 Heap::kWeakCellMapRootIndex);
1186 __ j(not_equal, &check_allocation_site); 1187 __ j(not_equal, &check_allocation_site);
1187 1188
1188 // If the weak cell is cleared, we have a new chance to become monomorphic. 1189 // If the weak cell is cleared, we have a new chance to become monomorphic.
1189 __ JumpIfSmi(FieldOperand(ecx, WeakCell::kValueOffset), &initialize); 1190 __ JumpIfSmi(FieldOperand(ecx, WeakCell::kValueOffset), &initialize);
1190 __ jmp(&megamorphic); 1191 __ jmp(&megamorphic);
1191 1192
1192 __ bind(&check_allocation_site); 1193 __ bind(&check_allocation_site);
1193 // If we came here, we need to see if we are the array function. 1194 // If we came here, we need to see if we are the array function.
1194 // If we didn't have a matching function, and we didn't find the megamorph 1195 // If we didn't have a matching function, and we didn't find the megamorph
1195 // sentinel, then we have in the slot either some other function or an 1196 // sentinel, then we have in the slot either some other function or an
1196 // AllocationSite. 1197 // AllocationSite.
1197 __ CompareRoot(FieldOperand(ecx, 0), Heap::kAllocationSiteMapRootIndex); 1198 __ CompareRoot(FieldOperand(ecx, 0), Heap::kAllocationSiteMapRootIndex);
1198 __ j(not_equal, &miss); 1199 __ j(not_equal, &miss);
1199 1200
1200 // Make sure the function is the Array() function 1201 // Make sure the function is the Array() function
1201 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); 1202 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx);
1202 __ cmp(edi, ecx); 1203 __ cmp(edi, ecx);
1203 __ j(not_equal, &megamorphic); 1204 __ j(not_equal, &megamorphic);
1204 __ jmp(&done, Label::kFar); 1205 __ jmp(&done_increment_count, Label::kFar);
1205 1206
1206 __ bind(&miss); 1207 __ bind(&miss);
1207 1208
1208 // A monomorphic miss (i.e, here the cache is not uninitialized) goes 1209 // A monomorphic miss (i.e, here the cache is not uninitialized) goes
1209 // megamorphic. 1210 // megamorphic.
1210 __ CompareRoot(ecx, Heap::kuninitialized_symbolRootIndex); 1211 __ CompareRoot(ecx, Heap::kuninitialized_symbolRootIndex);
1211 __ j(equal, &initialize); 1212 __ j(equal, &initialize);
1212 // MegamorphicSentinel is an immortal immovable object (undefined) so no 1213 // MegamorphicSentinel is an immortal immovable object (undefined) so no
1213 // write-barrier is needed. 1214 // write-barrier is needed.
1214 __ bind(&megamorphic); 1215 __ bind(&megamorphic);
1215 __ mov( 1216 __ mov(
1216 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), 1217 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize),
1217 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); 1218 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate)));
1218 __ jmp(&done, Label::kFar); 1219 __ jmp(&done, Label::kFar);
1219 1220
1220 // An uninitialized cache is patched with the function or sentinel to 1221 // An uninitialized cache is patched with the function or sentinel to
1221 // indicate the ElementsKind if function is the Array constructor. 1222 // indicate the ElementsKind if function is the Array constructor.
1222 __ bind(&initialize); 1223 __ bind(&initialize);
1223 // Make sure the function is the Array() function 1224 // Make sure the function is the Array() function
1224 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); 1225 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx);
1225 __ cmp(edi, ecx); 1226 __ cmp(edi, ecx);
1226 __ j(not_equal, &not_array_function); 1227 __ j(not_equal, &not_array_function);
1227 1228
1228 // The target function is the Array constructor, 1229 // The target function is the Array constructor,
1229 // Create an AllocationSite if we don't already have it, store it in the 1230 // Create an AllocationSite if we don't already have it, store it in the
1230 // slot. 1231 // slot.
1231 CreateAllocationSiteStub create_stub(isolate); 1232 CreateAllocationSiteStub create_stub(isolate);
1232 CallStubInRecordCallTarget(masm, &create_stub); 1233 CallStubInRecordCallTarget(masm, &create_stub);
1233 __ jmp(&done); 1234 __ jmp(&done_initialize_count);
1234 1235
1235 __ bind(&not_array_function); 1236 __ bind(&not_array_function);
1236 CreateWeakCellStub weak_cell_stub(isolate); 1237 CreateWeakCellStub weak_cell_stub(isolate);
1237 CallStubInRecordCallTarget(masm, &weak_cell_stub); 1238 CallStubInRecordCallTarget(masm, &weak_cell_stub);
1239 __ bind(&done_initialize_count);
1240
1241 // Initialize the call counter.
1242 __ mov(FieldOperand(ebx, edx, times_half_pointer_size,
1243 FixedArray::kHeaderSize + kPointerSize),
1244 Immediate(Smi::FromInt(1)));
1245 __ jmp(&done);
1246
1247 __ bind(&done_increment_count);
1248 // Increment the call count for monomorphic function calls.
1249 __ add(FieldOperand(ebx, edx, times_half_pointer_size,
1250 FixedArray::kHeaderSize + kPointerSize),
1251 Immediate(Smi::FromInt(1)));
1252
1238 __ bind(&done); 1253 __ bind(&done);
1239 } 1254 }
1240 1255
1241 1256
1242 void CallConstructStub::Generate(MacroAssembler* masm) { 1257 void CallConstructStub::Generate(MacroAssembler* masm) {
1243 // eax : number of arguments 1258 // eax : number of arguments
1244 // ebx : feedback vector 1259 // ebx : feedback vector
1245 // edx : slot in feedback vector (Smi, for RecordCallTarget) 1260 // edx : slot in feedback vector (Smi, for RecordCallTarget)
1246 // edi : constructor function 1261 // edi : constructor function
1247 1262
(...skipping 4130 matching lines...) Expand 10 before | Expand all | Expand 10 after
5378 kStackUnwindSpace, nullptr, return_value_operand, 5393 kStackUnwindSpace, nullptr, return_value_operand,
5379 NULL); 5394 NULL);
5380 } 5395 }
5381 5396
5382 #undef __ 5397 #undef __
5383 5398
5384 } // namespace internal 5399 } // namespace internal
5385 } // namespace v8 5400 } // namespace v8
5386 5401
5387 #endif // V8_TARGET_ARCH_X87 5402 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698