OLD | NEW |
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/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 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 static void GenerateRecordCallTarget(MacroAssembler* masm) { | 1294 static void GenerateRecordCallTarget(MacroAssembler* masm) { |
1295 // Cache the called function in a feedback vector slot. Cache states | 1295 // Cache the called function in a feedback vector slot. Cache states |
1296 // are uninitialized, monomorphic (indicated by a JSFunction), and | 1296 // are uninitialized, monomorphic (indicated by a JSFunction), and |
1297 // megamorphic. | 1297 // megamorphic. |
1298 // eax : number of arguments to the construct function | 1298 // eax : number of arguments to the construct function |
1299 // ebx : feedback vector | 1299 // ebx : feedback vector |
1300 // edx : slot in feedback vector (Smi) | 1300 // edx : slot in feedback vector (Smi) |
1301 // edi : the function to call | 1301 // edi : the function to call |
1302 Isolate* isolate = masm->isolate(); | 1302 Isolate* isolate = masm->isolate(); |
1303 Label initialize, done, miss, megamorphic, not_array_function; | 1303 Label initialize, done, miss, megamorphic, not_array_function; |
1304 Label done_increment_count, done_initialize_count; | |
1305 | 1304 |
1306 // Load the cache state into ecx. | 1305 // Load the cache state into ecx. |
1307 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, | 1306 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, |
1308 FixedArray::kHeaderSize)); | 1307 FixedArray::kHeaderSize)); |
1309 | 1308 |
1310 // A monomorphic cache hit or an already megamorphic state: invoke the | 1309 // A monomorphic cache hit or an already megamorphic state: invoke the |
1311 // function without changing the state. | 1310 // function without changing the state. |
1312 // We don't know if ecx is a WeakCell or a Symbol, but it's harmless to read | 1311 // We don't know if ecx is a WeakCell or a Symbol, but it's harmless to read |
1313 // at this position in a symbol (see static asserts in | 1312 // at this position in a symbol (see static asserts in |
1314 // type-feedback-vector.h). | 1313 // type-feedback-vector.h). |
1315 Label check_allocation_site; | 1314 Label check_allocation_site; |
1316 __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset)); | 1315 __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset)); |
1317 __ j(equal, &done_increment_count, Label::kFar); | 1316 __ j(equal, &done, Label::kFar); |
1318 __ CompareRoot(ecx, Heap::kmegamorphic_symbolRootIndex); | 1317 __ CompareRoot(ecx, Heap::kmegamorphic_symbolRootIndex); |
1319 __ j(equal, &done, Label::kFar); | 1318 __ j(equal, &done, Label::kFar); |
1320 __ CompareRoot(FieldOperand(ecx, HeapObject::kMapOffset), | 1319 __ CompareRoot(FieldOperand(ecx, HeapObject::kMapOffset), |
1321 Heap::kWeakCellMapRootIndex); | 1320 Heap::kWeakCellMapRootIndex); |
1322 __ j(not_equal, &check_allocation_site); | 1321 __ j(not_equal, &check_allocation_site); |
1323 | 1322 |
1324 // If the weak cell is cleared, we have a new chance to become monomorphic. | 1323 // If the weak cell is cleared, we have a new chance to become monomorphic. |
1325 __ JumpIfSmi(FieldOperand(ecx, WeakCell::kValueOffset), &initialize); | 1324 __ JumpIfSmi(FieldOperand(ecx, WeakCell::kValueOffset), &initialize); |
1326 __ jmp(&megamorphic); | 1325 __ jmp(&megamorphic); |
1327 | 1326 |
1328 __ bind(&check_allocation_site); | 1327 __ bind(&check_allocation_site); |
1329 // If we came here, we need to see if we are the array function. | 1328 // If we came here, we need to see if we are the array function. |
1330 // If we didn't have a matching function, and we didn't find the megamorph | 1329 // If we didn't have a matching function, and we didn't find the megamorph |
1331 // sentinel, then we have in the slot either some other function or an | 1330 // sentinel, then we have in the slot either some other function or an |
1332 // AllocationSite. | 1331 // AllocationSite. |
1333 __ CompareRoot(FieldOperand(ecx, 0), Heap::kAllocationSiteMapRootIndex); | 1332 __ CompareRoot(FieldOperand(ecx, 0), Heap::kAllocationSiteMapRootIndex); |
1334 __ j(not_equal, &miss); | 1333 __ j(not_equal, &miss); |
1335 | 1334 |
1336 // Make sure the function is the Array() function | 1335 // Make sure the function is the Array() function |
1337 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); | 1336 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); |
1338 __ cmp(edi, ecx); | 1337 __ cmp(edi, ecx); |
1339 __ j(not_equal, &megamorphic); | 1338 __ j(not_equal, &megamorphic); |
1340 __ jmp(&done_increment_count, Label::kFar); | 1339 __ jmp(&done, Label::kFar); |
1341 | 1340 |
1342 __ bind(&miss); | 1341 __ bind(&miss); |
1343 | 1342 |
1344 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 1343 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
1345 // megamorphic. | 1344 // megamorphic. |
1346 __ CompareRoot(ecx, Heap::kuninitialized_symbolRootIndex); | 1345 __ CompareRoot(ecx, Heap::kuninitialized_symbolRootIndex); |
1347 __ j(equal, &initialize); | 1346 __ j(equal, &initialize); |
1348 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 1347 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
1349 // write-barrier is needed. | 1348 // write-barrier is needed. |
1350 __ bind(&megamorphic); | 1349 __ bind(&megamorphic); |
1351 __ mov( | 1350 __ mov( |
1352 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), | 1351 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), |
1353 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); | 1352 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); |
1354 __ jmp(&done, Label::kFar); | 1353 __ jmp(&done, Label::kFar); |
1355 | 1354 |
1356 // An uninitialized cache is patched with the function or sentinel to | 1355 // An uninitialized cache is patched with the function or sentinel to |
1357 // indicate the ElementsKind if function is the Array constructor. | 1356 // indicate the ElementsKind if function is the Array constructor. |
1358 __ bind(&initialize); | 1357 __ bind(&initialize); |
1359 // Make sure the function is the Array() function | 1358 // Make sure the function is the Array() function |
1360 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); | 1359 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); |
1361 __ cmp(edi, ecx); | 1360 __ cmp(edi, ecx); |
1362 __ j(not_equal, ¬_array_function); | 1361 __ j(not_equal, ¬_array_function); |
1363 | 1362 |
1364 // The target function is the Array constructor, | 1363 // The target function is the Array constructor, |
1365 // Create an AllocationSite if we don't already have it, store it in the | 1364 // Create an AllocationSite if we don't already have it, store it in the |
1366 // slot. | 1365 // slot. |
1367 CreateAllocationSiteStub create_stub(isolate); | 1366 CreateAllocationSiteStub create_stub(isolate); |
1368 CallStubInRecordCallTarget(masm, &create_stub); | 1367 CallStubInRecordCallTarget(masm, &create_stub); |
1369 __ jmp(&done_initialize_count); | 1368 __ jmp(&done); |
1370 | 1369 |
1371 __ bind(¬_array_function); | 1370 __ bind(¬_array_function); |
1372 CreateWeakCellStub weak_cell_stub(isolate); | 1371 CreateWeakCellStub weak_cell_stub(isolate); |
1373 CallStubInRecordCallTarget(masm, &weak_cell_stub); | 1372 CallStubInRecordCallTarget(masm, &weak_cell_stub); |
1374 __ bind(&done_initialize_count); | |
1375 | 1373 |
1376 // Initialize the call counter. | 1374 __ bind(&done); |
1377 __ mov(FieldOperand(ebx, edx, times_half_pointer_size, | 1375 // Increment the call count for all function calls. |
1378 FixedArray::kHeaderSize + kPointerSize), | |
1379 Immediate(Smi::FromInt(1))); | |
1380 __ jmp(&done); | |
1381 | |
1382 __ bind(&done_increment_count); | |
1383 // Increment the call count for monomorphic function calls. | |
1384 __ add(FieldOperand(ebx, edx, times_half_pointer_size, | 1376 __ add(FieldOperand(ebx, edx, times_half_pointer_size, |
1385 FixedArray::kHeaderSize + kPointerSize), | 1377 FixedArray::kHeaderSize + kPointerSize), |
1386 Immediate(Smi::FromInt(1))); | 1378 Immediate(Smi::FromInt(1))); |
1387 | |
1388 __ bind(&done); | |
1389 } | 1379 } |
1390 | 1380 |
1391 | 1381 |
1392 void CallConstructStub::Generate(MacroAssembler* masm) { | 1382 void CallConstructStub::Generate(MacroAssembler* masm) { |
1393 // eax : number of arguments | 1383 // eax : number of arguments |
1394 // ebx : feedback vector | 1384 // ebx : feedback vector |
1395 // edx : slot in feedback vector (Smi, for RecordCallTarget) | 1385 // edx : slot in feedback vector (Smi, for RecordCallTarget) |
1396 // edi : constructor function | 1386 // edi : constructor function |
1397 | 1387 |
1398 Label non_function; | 1388 Label non_function; |
(...skipping 4059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5458 kStackUnwindSpace, nullptr, return_value_operand, | 5448 kStackUnwindSpace, nullptr, return_value_operand, |
5459 NULL); | 5449 NULL); |
5460 } | 5450 } |
5461 | 5451 |
5462 #undef __ | 5452 #undef __ |
5463 | 5453 |
5464 } // namespace internal | 5454 } // namespace internal |
5465 } // namespace v8 | 5455 } // namespace v8 |
5466 | 5456 |
5467 #endif // V8_TARGET_ARCH_IA32 | 5457 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |