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

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

Issue 1051253004: x87: v8:3539 - hold constructor feedback in weak cells (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_X87 7 #if V8_TARGET_ARCH_X87
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after
1593 1593
1594 // Call the native; it returns -1 (less), 0 (equal), or 1 (greater) 1594 // Call the native; it returns -1 (less), 0 (equal), or 1 (greater)
1595 // tagged as a small integer. 1595 // tagged as a small integer.
1596 __ InvokeBuiltin(builtin, JUMP_FUNCTION); 1596 __ InvokeBuiltin(builtin, JUMP_FUNCTION);
1597 1597
1598 __ bind(&miss); 1598 __ bind(&miss);
1599 GenerateMiss(masm); 1599 GenerateMiss(masm);
1600 } 1600 }
1601 1601
1602 1602
1603 static void CallStubInRecordCallTarget(MacroAssembler* masm, CodeStub* stub) {
1604 // eax : number of arguments to the construct function
1605 // ebx : Feedback vector
1606 // edx : slot in feedback vector (Smi)
1607 // edi : the function to call
1608 FrameScope scope(masm, StackFrame::INTERNAL);
1609
1610 // Arguments register must be smi-tagged to call out.
1611 __ SmiTag(eax);
1612 __ push(eax);
1613 __ push(edi);
1614 __ push(edx);
1615 __ push(ebx);
1616
1617 __ CallStub(stub);
1618
1619 __ pop(ebx);
1620 __ pop(edx);
1621 __ pop(edi);
1622 __ pop(eax);
1623 __ SmiUntag(eax);
1624 }
1625
1626
1603 static void GenerateRecordCallTarget(MacroAssembler* masm) { 1627 static void GenerateRecordCallTarget(MacroAssembler* masm) {
1604 // Cache the called function in a feedback vector slot. Cache states 1628 // Cache the called function in a feedback vector slot. Cache states
1605 // are uninitialized, monomorphic (indicated by a JSFunction), and 1629 // are uninitialized, monomorphic (indicated by a JSFunction), and
1606 // megamorphic. 1630 // megamorphic.
1607 // eax : number of arguments to the construct function 1631 // eax : number of arguments to the construct function
1608 // ebx : Feedback vector 1632 // ebx : Feedback vector
1609 // edx : slot in feedback vector (Smi) 1633 // edx : slot in feedback vector (Smi)
1610 // edi : the function to call 1634 // edi : the function to call
1611 Isolate* isolate = masm->isolate(); 1635 Isolate* isolate = masm->isolate();
1612 Label initialize, done, miss, megamorphic, not_array_function; 1636 Label initialize, done, miss, megamorphic, not_array_function;
1613 1637
1614 // Load the cache state into ecx. 1638 // Load the cache state into ecx.
1615 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, 1639 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size,
1616 FixedArray::kHeaderSize)); 1640 FixedArray::kHeaderSize));
1617 1641
1618 // A monomorphic cache hit or an already megamorphic state: invoke the 1642 // A monomorphic cache hit or an already megamorphic state: invoke the
1619 // function without changing the state. 1643 // function without changing the state.
1620 __ cmp(ecx, edi); 1644 Label check_allocation_site;
1645 __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset));
1621 __ j(equal, &done, Label::kFar); 1646 __ j(equal, &done, Label::kFar);
1622 __ cmp(ecx, Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); 1647 __ CompareRoot(ecx, Heap::kmegamorphic_symbolRootIndex);
1623 __ j(equal, &done, Label::kFar); 1648 __ j(equal, &done, Label::kFar);
1649 __ CompareRoot(FieldOperand(ecx, 0), Heap::kWeakCellMapRootIndex);
1650 __ j(not_equal, FLAG_pretenuring_call_new ? &miss : &check_allocation_site);
1651
1652 // If edi is not equal to the weak cell value, and the weak cell value is
1653 // cleared, we have a new chance to become monomorphic.
1654 __ JumpIfSmi(FieldOperand(ecx, WeakCell::kValueOffset), &initialize);
1655 __ jmp(&megamorphic);
1624 1656
1625 if (!FLAG_pretenuring_call_new) { 1657 if (!FLAG_pretenuring_call_new) {
1658 __ bind(&check_allocation_site);
1626 // If we came here, we need to see if we are the array function. 1659 // If we came here, we need to see if we are the array function.
1627 // If we didn't have a matching function, and we didn't find the megamorph 1660 // If we didn't have a matching function, and we didn't find the megamorph
1628 // sentinel, then we have in the slot either some other function or an 1661 // sentinel, then we have in the slot either some other function or an
1629 // AllocationSite. Do a map check on the object in ecx. 1662 // AllocationSite. Do a map check on the object in ecx.
1630 Handle<Map> allocation_site_map = isolate->factory()->allocation_site_map(); 1663 __ CompareRoot(FieldOperand(ecx, 0), Heap::kAllocationSiteMapRootIndex);
1631 __ cmp(FieldOperand(ecx, 0), Immediate(allocation_site_map));
1632 __ j(not_equal, &miss); 1664 __ j(not_equal, &miss);
1633 1665
1634 // Make sure the function is the Array() function 1666 // Make sure the function is the Array() function
1635 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); 1667 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx);
1636 __ cmp(edi, ecx); 1668 __ cmp(edi, ecx);
1637 __ j(not_equal, &megamorphic); 1669 __ j(not_equal, &megamorphic);
1638 __ jmp(&done, Label::kFar); 1670 __ jmp(&done, Label::kFar);
1639 } 1671 }
1640 1672
1641 __ bind(&miss); 1673 __ bind(&miss);
1642 1674
1643 // A monomorphic miss (i.e, here the cache is not uninitialized) goes 1675 // A monomorphic miss (i.e, here the cache is not uninitialized) goes
1644 // megamorphic. 1676 // megamorphic.
1645 __ cmp(ecx, Immediate(TypeFeedbackVector::UninitializedSentinel(isolate))); 1677 __ CompareRoot(ecx, Heap::kuninitialized_symbolRootIndex);
1646 __ j(equal, &initialize); 1678 __ j(equal, &initialize);
1647 // MegamorphicSentinel is an immortal immovable object (undefined) so no 1679 // MegamorphicSentinel is an immortal immovable object (undefined) so no
1648 // write-barrier is needed. 1680 // write-barrier is needed.
1649 __ bind(&megamorphic); 1681 __ bind(&megamorphic);
1650 __ mov( 1682 __ mov(
1651 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), 1683 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize),
1652 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); 1684 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate)));
1653 __ jmp(&done, Label::kFar); 1685 __ jmp(&done, Label::kFar);
1654 1686
1655 // An uninitialized cache is patched with the function or sentinel to 1687 // An uninitialized cache is patched with the function or sentinel to
1656 // indicate the ElementsKind if function is the Array constructor. 1688 // indicate the ElementsKind if function is the Array constructor.
1657 __ bind(&initialize); 1689 __ bind(&initialize);
1658 if (!FLAG_pretenuring_call_new) { 1690 if (!FLAG_pretenuring_call_new) {
1659 // Make sure the function is the Array() function 1691 // Make sure the function is the Array() function
1660 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); 1692 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx);
1661 __ cmp(edi, ecx); 1693 __ cmp(edi, ecx);
1662 __ j(not_equal, &not_array_function); 1694 __ j(not_equal, &not_array_function);
1663 1695
1664 // The target function is the Array constructor, 1696 // The target function is the Array constructor,
1665 // Create an AllocationSite if we don't already have it, store it in the 1697 // Create an AllocationSite if we don't already have it, store it in the
1666 // slot. 1698 // slot.
1667 { 1699 CreateAllocationSiteStub create_stub(isolate);
1668 FrameScope scope(masm, StackFrame::INTERNAL); 1700 CallStubInRecordCallTarget(masm, &create_stub);
1669
1670 // Arguments register must be smi-tagged to call out.
1671 __ SmiTag(eax);
1672 __ push(eax);
1673 __ push(edi);
1674 __ push(edx);
1675 __ push(ebx);
1676
1677 CreateAllocationSiteStub create_stub(isolate);
1678 __ CallStub(&create_stub);
1679
1680 __ pop(ebx);
1681 __ pop(edx);
1682 __ pop(edi);
1683 __ pop(eax);
1684 __ SmiUntag(eax);
1685 }
1686 __ jmp(&done); 1701 __ jmp(&done);
1687 1702
1688 __ bind(&not_array_function); 1703 __ bind(&not_array_function);
1689 } 1704 }
1690 1705
1691 __ mov(FieldOperand(ebx, edx, times_half_pointer_size, 1706 CreateWeakCellStub create_stub(isolate);
1692 FixedArray::kHeaderSize), 1707 CallStubInRecordCallTarget(masm, &create_stub);
1693 edi);
1694 // We won't need edx or ebx anymore, just save edi
1695 __ push(edi);
1696 __ push(ebx);
1697 __ push(edx);
1698 __ RecordWriteArray(ebx, edi, edx, kDontSaveFPRegs, EMIT_REMEMBERED_SET,
1699 OMIT_SMI_CHECK);
1700 __ pop(edx);
1701 __ pop(ebx);
1702 __ pop(edi);
1703
1704 __ bind(&done); 1708 __ bind(&done);
1705 } 1709 }
1706 1710
1707 1711
1708 static void EmitContinueIfStrictOrNative(MacroAssembler* masm, Label* cont) { 1712 static void EmitContinueIfStrictOrNative(MacroAssembler* masm, Label* cont) {
1709 // Do not transform the receiver for strict mode functions. 1713 // Do not transform the receiver for strict mode functions.
1710 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); 1714 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
1711 __ test_b(FieldOperand(ecx, SharedFunctionInfo::kStrictModeByteOffset), 1715 __ test_b(FieldOperand(ecx, SharedFunctionInfo::kStrictModeByteOffset),
1712 1 << SharedFunctionInfo::kStrictModeBitWithinByte); 1716 1 << SharedFunctionInfo::kStrictModeBitWithinByte);
1713 __ j(not_equal, cont); 1717 __ j(not_equal, cont);
(...skipping 3349 matching lines...) Expand 10 before | Expand all | Expand 10 after
5063 ApiParameterOperand(2), kStackSpace, nullptr, 5067 ApiParameterOperand(2), kStackSpace, nullptr,
5064 Operand(ebp, 7 * kPointerSize), NULL); 5068 Operand(ebp, 7 * kPointerSize), NULL);
5065 } 5069 }
5066 5070
5067 5071
5068 #undef __ 5072 #undef __
5069 5073
5070 } } // namespace v8::internal 5074 } } // namespace v8::internal
5071 5075
5072 #endif // V8_TARGET_ARCH_X87 5076 #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