Chromium Code Reviews

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

Issue 1969783002: Collect call counts for constructor calls, too. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Updated status file. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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/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 1451 matching lines...)
1462 static void GenerateRecordCallTarget(MacroAssembler* masm) { 1462 static void GenerateRecordCallTarget(MacroAssembler* masm) {
1463 // Cache the called function in a feedback vector slot. Cache states 1463 // Cache the called function in a feedback vector slot. Cache states
1464 // are uninitialized, monomorphic (indicated by a JSFunction), and 1464 // are uninitialized, monomorphic (indicated by a JSFunction), and
1465 // megamorphic. 1465 // megamorphic.
1466 // eax : number of arguments to the construct function 1466 // eax : number of arguments to the construct function
1467 // ebx : feedback vector 1467 // ebx : feedback vector
1468 // edx : slot in feedback vector (Smi) 1468 // edx : slot in feedback vector (Smi)
1469 // edi : the function to call 1469 // edi : the function to call
1470 Isolate* isolate = masm->isolate(); 1470 Isolate* isolate = masm->isolate();
1471 Label initialize, done, miss, megamorphic, not_array_function; 1471 Label initialize, done, miss, megamorphic, not_array_function;
1472 Label done_increment_count, done_initialize_count;
1472 1473
1473 // Load the cache state into ecx. 1474 // Load the cache state into ecx.
1474 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, 1475 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size,
1475 FixedArray::kHeaderSize)); 1476 FixedArray::kHeaderSize));
1476 1477
1477 // A monomorphic cache hit or an already megamorphic state: invoke the 1478 // A monomorphic cache hit or an already megamorphic state: invoke the
1478 // function without changing the state. 1479 // function without changing the state.
1479 // We don't know if ecx is a WeakCell or a Symbol, but it's harmless to read 1480 // We don't know if ecx is a WeakCell or a Symbol, but it's harmless to read
1480 // at this position in a symbol (see static asserts in 1481 // at this position in a symbol (see static asserts in
1481 // type-feedback-vector.h). 1482 // type-feedback-vector.h).
1482 Label check_allocation_site; 1483 Label check_allocation_site;
1483 __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset)); 1484 __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset));
1484 __ j(equal, &done, Label::kFar); 1485 __ j(equal, &done_increment_count, Label::kFar);
1485 __ CompareRoot(ecx, Heap::kmegamorphic_symbolRootIndex); 1486 __ CompareRoot(ecx, Heap::kmegamorphic_symbolRootIndex);
1486 __ j(equal, &done, Label::kFar); 1487 __ j(equal, &done, Label::kFar);
1487 __ CompareRoot(FieldOperand(ecx, HeapObject::kMapOffset), 1488 __ CompareRoot(FieldOperand(ecx, HeapObject::kMapOffset),
1488 Heap::kWeakCellMapRootIndex); 1489 Heap::kWeakCellMapRootIndex);
1489 __ j(not_equal, &check_allocation_site); 1490 __ j(not_equal, &check_allocation_site);
1490 1491
1491 // If the weak cell is cleared, we have a new chance to become monomorphic. 1492 // If the weak cell is cleared, we have a new chance to become monomorphic.
1492 __ JumpIfSmi(FieldOperand(ecx, WeakCell::kValueOffset), &initialize); 1493 __ JumpIfSmi(FieldOperand(ecx, WeakCell::kValueOffset), &initialize);
1493 __ jmp(&megamorphic); 1494 __ jmp(&megamorphic);
1494 1495
1495 __ bind(&check_allocation_site); 1496 __ bind(&check_allocation_site);
1496 // If we came here, we need to see if we are the array function. 1497 // If we came here, we need to see if we are the array function.
1497 // If we didn't have a matching function, and we didn't find the megamorph 1498 // If we didn't have a matching function, and we didn't find the megamorph
1498 // sentinel, then we have in the slot either some other function or an 1499 // sentinel, then we have in the slot either some other function or an
1499 // AllocationSite. 1500 // AllocationSite.
1500 __ CompareRoot(FieldOperand(ecx, 0), Heap::kAllocationSiteMapRootIndex); 1501 __ CompareRoot(FieldOperand(ecx, 0), Heap::kAllocationSiteMapRootIndex);
1501 __ j(not_equal, &miss); 1502 __ j(not_equal, &miss);
1502 1503
1503 // Make sure the function is the Array() function 1504 // Make sure the function is the Array() function
1504 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); 1505 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx);
1505 __ cmp(edi, ecx); 1506 __ cmp(edi, ecx);
1506 __ j(not_equal, &megamorphic); 1507 __ j(not_equal, &megamorphic);
1507 __ jmp(&done, Label::kFar); 1508 __ jmp(&done_increment_count, Label::kFar);
1508 1509
1509 __ bind(&miss); 1510 __ bind(&miss);
1510 1511
1511 // A monomorphic miss (i.e, here the cache is not uninitialized) goes 1512 // A monomorphic miss (i.e, here the cache is not uninitialized) goes
1512 // megamorphic. 1513 // megamorphic.
1513 __ CompareRoot(ecx, Heap::kuninitialized_symbolRootIndex); 1514 __ CompareRoot(ecx, Heap::kuninitialized_symbolRootIndex);
1514 __ j(equal, &initialize); 1515 __ j(equal, &initialize);
1515 // MegamorphicSentinel is an immortal immovable object (undefined) so no 1516 // MegamorphicSentinel is an immortal immovable object (undefined) so no
1516 // write-barrier is needed. 1517 // write-barrier is needed.
1517 __ bind(&megamorphic); 1518 __ bind(&megamorphic);
1518 __ mov( 1519 __ mov(
1519 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), 1520 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize),
1520 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); 1521 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate)));
1521 __ jmp(&done, Label::kFar); 1522 __ jmp(&done, Label::kFar);
1522 1523
1523 // An uninitialized cache is patched with the function or sentinel to 1524 // An uninitialized cache is patched with the function or sentinel to
1524 // indicate the ElementsKind if function is the Array constructor. 1525 // indicate the ElementsKind if function is the Array constructor.
1525 __ bind(&initialize); 1526 __ bind(&initialize);
1526 // Make sure the function is the Array() function 1527 // Make sure the function is the Array() function
1527 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); 1528 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx);
1528 __ cmp(edi, ecx); 1529 __ cmp(edi, ecx);
1529 __ j(not_equal, &not_array_function); 1530 __ j(not_equal, &not_array_function);
1530 1531
1531 // The target function is the Array constructor, 1532 // The target function is the Array constructor,
1532 // Create an AllocationSite if we don't already have it, store it in the 1533 // Create an AllocationSite if we don't already have it, store it in the
1533 // slot. 1534 // slot.
1534 CreateAllocationSiteStub create_stub(isolate); 1535 CreateAllocationSiteStub create_stub(isolate);
1535 CallStubInRecordCallTarget(masm, &create_stub); 1536 CallStubInRecordCallTarget(masm, &create_stub);
1536 __ jmp(&done); 1537 __ jmp(&done_initialize_count);
1537 1538
1538 __ bind(&not_array_function); 1539 __ bind(&not_array_function);
1539 CreateWeakCellStub weak_cell_stub(isolate); 1540 CreateWeakCellStub weak_cell_stub(isolate);
1540 CallStubInRecordCallTarget(masm, &weak_cell_stub); 1541 CallStubInRecordCallTarget(masm, &weak_cell_stub);
1542 __ bind(&done_initialize_count);
1543
1544 // Initialize the call counter.
1545 __ mov(FieldOperand(ebx, edx, times_half_pointer_size,
1546 FixedArray::kHeaderSize + kPointerSize),
1547 Immediate(Smi::FromInt(1)));
1548 __ jmp(&done);
1549
1550 __ bind(&done_increment_count);
1551 // Increment the call count for monomorphic function calls.
1552 __ add(FieldOperand(ebx, edx, times_half_pointer_size,
1553 FixedArray::kHeaderSize + kPointerSize),
1554 Immediate(Smi::FromInt(1)));
1555
1541 __ bind(&done); 1556 __ bind(&done);
1542 } 1557 }
1543 1558
1544 1559
1545 void CallConstructStub::Generate(MacroAssembler* masm) { 1560 void CallConstructStub::Generate(MacroAssembler* masm) {
1546 // eax : number of arguments 1561 // eax : number of arguments
1547 // ebx : feedback vector 1562 // ebx : feedback vector
1548 // edx : slot in feedback vector (Smi, for RecordCallTarget) 1563 // edx : slot in feedback vector (Smi, for RecordCallTarget)
1549 // edi : constructor function 1564 // edi : constructor function
1550 1565
(...skipping 4171 matching lines...)
5722 kStackUnwindSpace, nullptr, return_value_operand, 5737 kStackUnwindSpace, nullptr, return_value_operand,
5723 NULL); 5738 NULL);
5724 } 5739 }
5725 5740
5726 #undef __ 5741 #undef __
5727 5742
5728 } // namespace internal 5743 } // namespace internal
5729 } // namespace v8 5744 } // namespace v8
5730 5745
5731 #endif // V8_TARGET_ARCH_IA32 5746 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ast/ast.h ('k') | src/mips/code-stubs-mips.cc » ('j') | src/mips64/code-stubs-mips64.cc » ('J')

Powered by Google App Engine