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

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: Fixed cctest.status, and addressed mips64 comment. 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 | « src/ast/ast.h ('k') | src/mips/code-stubs-mips.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 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 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 static void GenerateRecordCallTarget(MacroAssembler* masm) { 1450 static void GenerateRecordCallTarget(MacroAssembler* masm) {
1451 // Cache the called function in a feedback vector slot. Cache states 1451 // Cache the called function in a feedback vector slot. Cache states
1452 // are uninitialized, monomorphic (indicated by a JSFunction), and 1452 // are uninitialized, monomorphic (indicated by a JSFunction), and
1453 // megamorphic. 1453 // megamorphic.
1454 // eax : number of arguments to the construct function 1454 // eax : number of arguments to the construct function
1455 // ebx : feedback vector 1455 // ebx : feedback vector
1456 // edx : slot in feedback vector (Smi) 1456 // edx : slot in feedback vector (Smi)
1457 // edi : the function to call 1457 // edi : the function to call
1458 Isolate* isolate = masm->isolate(); 1458 Isolate* isolate = masm->isolate();
1459 Label initialize, done, miss, megamorphic, not_array_function; 1459 Label initialize, done, miss, megamorphic, not_array_function;
1460 Label done_increment_count, done_initialize_count;
1460 1461
1461 // Load the cache state into ecx. 1462 // Load the cache state into ecx.
1462 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, 1463 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size,
1463 FixedArray::kHeaderSize)); 1464 FixedArray::kHeaderSize));
1464 1465
1465 // A monomorphic cache hit or an already megamorphic state: invoke the 1466 // A monomorphic cache hit or an already megamorphic state: invoke the
1466 // function without changing the state. 1467 // function without changing the state.
1467 // We don't know if ecx is a WeakCell or a Symbol, but it's harmless to read 1468 // We don't know if ecx is a WeakCell or a Symbol, but it's harmless to read
1468 // at this position in a symbol (see static asserts in 1469 // at this position in a symbol (see static asserts in
1469 // type-feedback-vector.h). 1470 // type-feedback-vector.h).
1470 Label check_allocation_site; 1471 Label check_allocation_site;
1471 __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset)); 1472 __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset));
1472 __ j(equal, &done, Label::kFar); 1473 __ j(equal, &done_increment_count, Label::kFar);
1473 __ CompareRoot(ecx, Heap::kmegamorphic_symbolRootIndex); 1474 __ CompareRoot(ecx, Heap::kmegamorphic_symbolRootIndex);
1474 __ j(equal, &done, Label::kFar); 1475 __ j(equal, &done, Label::kFar);
1475 __ CompareRoot(FieldOperand(ecx, HeapObject::kMapOffset), 1476 __ CompareRoot(FieldOperand(ecx, HeapObject::kMapOffset),
1476 Heap::kWeakCellMapRootIndex); 1477 Heap::kWeakCellMapRootIndex);
1477 __ j(not_equal, &check_allocation_site); 1478 __ j(not_equal, &check_allocation_site);
1478 1479
1479 // If the weak cell is cleared, we have a new chance to become monomorphic. 1480 // If the weak cell is cleared, we have a new chance to become monomorphic.
1480 __ JumpIfSmi(FieldOperand(ecx, WeakCell::kValueOffset), &initialize); 1481 __ JumpIfSmi(FieldOperand(ecx, WeakCell::kValueOffset), &initialize);
1481 __ jmp(&megamorphic); 1482 __ jmp(&megamorphic);
1482 1483
1483 __ bind(&check_allocation_site); 1484 __ bind(&check_allocation_site);
1484 // If we came here, we need to see if we are the array function. 1485 // If we came here, we need to see if we are the array function.
1485 // If we didn't have a matching function, and we didn't find the megamorph 1486 // If we didn't have a matching function, and we didn't find the megamorph
1486 // sentinel, then we have in the slot either some other function or an 1487 // sentinel, then we have in the slot either some other function or an
1487 // AllocationSite. 1488 // AllocationSite.
1488 __ CompareRoot(FieldOperand(ecx, 0), Heap::kAllocationSiteMapRootIndex); 1489 __ CompareRoot(FieldOperand(ecx, 0), Heap::kAllocationSiteMapRootIndex);
1489 __ j(not_equal, &miss); 1490 __ j(not_equal, &miss);
1490 1491
1491 // Make sure the function is the Array() function 1492 // Make sure the function is the Array() function
1492 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); 1493 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx);
1493 __ cmp(edi, ecx); 1494 __ cmp(edi, ecx);
1494 __ j(not_equal, &megamorphic); 1495 __ j(not_equal, &megamorphic);
1495 __ jmp(&done, Label::kFar); 1496 __ jmp(&done_increment_count, Label::kFar);
1496 1497
1497 __ bind(&miss); 1498 __ bind(&miss);
1498 1499
1499 // A monomorphic miss (i.e, here the cache is not uninitialized) goes 1500 // A monomorphic miss (i.e, here the cache is not uninitialized) goes
1500 // megamorphic. 1501 // megamorphic.
1501 __ CompareRoot(ecx, Heap::kuninitialized_symbolRootIndex); 1502 __ CompareRoot(ecx, Heap::kuninitialized_symbolRootIndex);
1502 __ j(equal, &initialize); 1503 __ j(equal, &initialize);
1503 // MegamorphicSentinel is an immortal immovable object (undefined) so no 1504 // MegamorphicSentinel is an immortal immovable object (undefined) so no
1504 // write-barrier is needed. 1505 // write-barrier is needed.
1505 __ bind(&megamorphic); 1506 __ bind(&megamorphic);
1506 __ mov( 1507 __ mov(
1507 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), 1508 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize),
1508 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); 1509 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate)));
1509 __ jmp(&done, Label::kFar); 1510 __ jmp(&done, Label::kFar);
1510 1511
1511 // An uninitialized cache is patched with the function or sentinel to 1512 // An uninitialized cache is patched with the function or sentinel to
1512 // indicate the ElementsKind if function is the Array constructor. 1513 // indicate the ElementsKind if function is the Array constructor.
1513 __ bind(&initialize); 1514 __ bind(&initialize);
1514 // Make sure the function is the Array() function 1515 // Make sure the function is the Array() function
1515 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); 1516 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx);
1516 __ cmp(edi, ecx); 1517 __ cmp(edi, ecx);
1517 __ j(not_equal, &not_array_function); 1518 __ j(not_equal, &not_array_function);
1518 1519
1519 // The target function is the Array constructor, 1520 // The target function is the Array constructor,
1520 // Create an AllocationSite if we don't already have it, store it in the 1521 // Create an AllocationSite if we don't already have it, store it in the
1521 // slot. 1522 // slot.
1522 CreateAllocationSiteStub create_stub(isolate); 1523 CreateAllocationSiteStub create_stub(isolate);
1523 CallStubInRecordCallTarget(masm, &create_stub); 1524 CallStubInRecordCallTarget(masm, &create_stub);
1524 __ jmp(&done); 1525 __ jmp(&done_initialize_count);
1525 1526
1526 __ bind(&not_array_function); 1527 __ bind(&not_array_function);
1527 CreateWeakCellStub weak_cell_stub(isolate); 1528 CreateWeakCellStub weak_cell_stub(isolate);
1528 CallStubInRecordCallTarget(masm, &weak_cell_stub); 1529 CallStubInRecordCallTarget(masm, &weak_cell_stub);
1530 __ bind(&done_initialize_count);
1531
1532 // Initialize the call counter.
1533 __ mov(FieldOperand(ebx, edx, times_half_pointer_size,
1534 FixedArray::kHeaderSize + kPointerSize),
1535 Immediate(Smi::FromInt(1)));
1536 __ jmp(&done);
1537
1538 __ bind(&done_increment_count);
1539 // Increment the call count for monomorphic function calls.
1540 __ add(FieldOperand(ebx, edx, times_half_pointer_size,
1541 FixedArray::kHeaderSize + kPointerSize),
1542 Immediate(Smi::FromInt(1)));
1543
1529 __ bind(&done); 1544 __ bind(&done);
1530 } 1545 }
1531 1546
1532 1547
1533 void CallConstructStub::Generate(MacroAssembler* masm) { 1548 void CallConstructStub::Generate(MacroAssembler* masm) {
1534 // eax : number of arguments 1549 // eax : number of arguments
1535 // ebx : feedback vector 1550 // ebx : feedback vector
1536 // edx : slot in feedback vector (Smi, for RecordCallTarget) 1551 // edx : slot in feedback vector (Smi, for RecordCallTarget)
1537 // edi : constructor function 1552 // edi : constructor function
1538 1553
(...skipping 4171 matching lines...) Expand 10 before | Expand all | Expand 10 after
5710 kStackUnwindSpace, nullptr, return_value_operand, 5725 kStackUnwindSpace, nullptr, return_value_operand,
5711 NULL); 5726 NULL);
5712 } 5727 }
5713 5728
5714 #undef __ 5729 #undef __
5715 5730
5716 } // namespace internal 5731 } // namespace internal
5717 } // namespace v8 5732 } // namespace v8
5718 5733
5719 #endif // V8_TARGET_ARCH_IA32 5734 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ast/ast.h ('k') | src/mips/code-stubs-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698