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

Side by Side Diff: src/lithium-allocator.cc

Issue 11659022: Generate the TransitionElementsStub using Crankshaft (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review feedback Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/lithium-allocator.h ('k') | src/lithium-allocator-inl.h » ('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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 return operand; 636 return operand;
637 } 637 }
638 638
639 639
640 LiveRange* LAllocator::FixedLiveRangeFor(int index) { 640 LiveRange* LAllocator::FixedLiveRangeFor(int index) {
641 ASSERT(index < Register::kMaxNumAllocatableRegisters); 641 ASSERT(index < Register::kMaxNumAllocatableRegisters);
642 LiveRange* result = fixed_live_ranges_[index]; 642 LiveRange* result = fixed_live_ranges_[index];
643 if (result == NULL) { 643 if (result == NULL) {
644 result = new(zone_) LiveRange(FixedLiveRangeID(index), zone_); 644 result = new(zone_) LiveRange(FixedLiveRangeID(index), zone_);
645 ASSERT(result->IsFixed()); 645 ASSERT(result->IsFixed());
646 result->set_assigned_register(index, GENERAL_REGISTERS, zone_); 646 SetLiveRangeAssignedRegister(result, index, GENERAL_REGISTERS, zone_);
647 fixed_live_ranges_[index] = result; 647 fixed_live_ranges_[index] = result;
648 } 648 }
649 return result; 649 return result;
650 } 650 }
651 651
652 652
653 LiveRange* LAllocator::FixedDoubleLiveRangeFor(int index) { 653 LiveRange* LAllocator::FixedDoubleLiveRangeFor(int index) {
654 ASSERT(index < DoubleRegister::NumAllocatableRegisters()); 654 ASSERT(index < DoubleRegister::NumAllocatableRegisters());
655 LiveRange* result = fixed_double_live_ranges_[index]; 655 LiveRange* result = fixed_double_live_ranges_[index];
656 if (result == NULL) { 656 if (result == NULL) {
657 result = new(zone_) LiveRange(FixedDoubleLiveRangeID(index), zone_); 657 result = new(zone_) LiveRange(FixedDoubleLiveRangeID(index), zone_);
658 ASSERT(result->IsFixed()); 658 ASSERT(result->IsFixed());
659 result->set_assigned_register(index, DOUBLE_REGISTERS, zone_); 659 SetLiveRangeAssignedRegister(result, index, DOUBLE_REGISTERS, zone_);
660 fixed_double_live_ranges_[index] = result; 660 fixed_double_live_ranges_[index] = result;
661 } 661 }
662 return result; 662 return result;
663 } 663 }
664 664
665 665
666 LiveRange* LAllocator::LiveRangeFor(int index) { 666 LiveRange* LAllocator::LiveRangeFor(int index) {
667 if (index >= live_ranges_.length()) { 667 if (index >= live_ranges_.length()) {
668 live_ranges_.AddBlock(NULL, index - live_ranges_.length() + 1, zone()); 668 live_ranges_.AddBlock(NULL, index - live_ranges_.length() + 1, zone());
669 } 669 }
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 label->GetOrCreateParallelMove(LGap::START, zone())-> 1059 label->GetOrCreateParallelMove(LGap::START, zone())->
1060 AddMove(phi_operand, live_range->GetSpillOperand(), zone()); 1060 AddMove(phi_operand, live_range->GetSpillOperand(), zone());
1061 live_range->SetSpillStartIndex(phi->block()->first_instruction_index()); 1061 live_range->SetSpillStartIndex(phi->block()->first_instruction_index());
1062 } 1062 }
1063 } 1063 }
1064 1064
1065 1065
1066 bool LAllocator::Allocate(LChunk* chunk) { 1066 bool LAllocator::Allocate(LChunk* chunk) {
1067 ASSERT(chunk_ == NULL); 1067 ASSERT(chunk_ == NULL);
1068 chunk_ = static_cast<LPlatformChunk*>(chunk); 1068 chunk_ = static_cast<LPlatformChunk*>(chunk);
1069 assigned_registers_ =
1070 new(zone()) BitVector(Register::NumAllocatableRegisters(), zone());
1071 assigned_registers_->Clear();
1072 assigned_double_registers_ =
1073 new(zone()) BitVector(DoubleRegister::NumAllocatableRegisters(),
1074 zone());
1075 assigned_double_registers_->Clear();
1069 MeetRegisterConstraints(); 1076 MeetRegisterConstraints();
1070 if (!AllocationOk()) return false; 1077 if (!AllocationOk()) return false;
1071 ResolvePhis(); 1078 ResolvePhis();
1072 BuildLiveRanges(); 1079 BuildLiveRanges();
1073 AllocateGeneralRegisters(); 1080 AllocateGeneralRegisters();
1074 if (!AllocationOk()) return false; 1081 if (!AllocationOk()) return false;
1075 AllocateDoubleRegisters(); 1082 AllocateDoubleRegisters();
1076 if (!AllocationOk()) return false; 1083 if (!AllocationOk()) return false;
1077 PopulatePointerMaps(); 1084 PopulatePointerMaps();
1078 if (has_osr_entry_) ProcessOsrEntry(); 1085 if (has_osr_entry_) ProcessOsrEntry();
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 RegisterName(register_index), 1808 RegisterName(register_index),
1802 free_until_pos[register_index].Value(), 1809 free_until_pos[register_index].Value(),
1803 current->id(), 1810 current->id(),
1804 current->End().Value()); 1811 current->End().Value());
1805 1812
1806 // The desired register is free until the end of the current live range. 1813 // The desired register is free until the end of the current live range.
1807 if (free_until_pos[register_index].Value() >= current->End().Value()) { 1814 if (free_until_pos[register_index].Value() >= current->End().Value()) {
1808 TraceAlloc("Assigning preferred reg %s to live range %d\n", 1815 TraceAlloc("Assigning preferred reg %s to live range %d\n",
1809 RegisterName(register_index), 1816 RegisterName(register_index),
1810 current->id()); 1817 current->id());
1811 current->set_assigned_register(register_index, mode_, zone_); 1818 SetLiveRangeAssignedRegister(current, register_index, mode_, zone_);
1812 return true; 1819 return true;
1813 } 1820 }
1814 } 1821 }
1815 } 1822 }
1816 1823
1817 // Find the register which stays free for the longest time. 1824 // Find the register which stays free for the longest time.
1818 int reg = 0; 1825 int reg = 0;
1819 for (int i = 1; i < RegisterCount(); ++i) { 1826 for (int i = 1; i < RegisterCount(); ++i) {
1820 if (free_until_pos[i].Value() > free_until_pos[reg].Value()) { 1827 if (free_until_pos[i].Value() > free_until_pos[reg].Value()) {
1821 reg = i; 1828 reg = i;
(...skipping 15 matching lines...) Expand all
1837 AddToUnhandledSorted(tail); 1844 AddToUnhandledSorted(tail);
1838 } 1845 }
1839 1846
1840 1847
1841 // Register reg is available at the range start and is free until 1848 // Register reg is available at the range start and is free until
1842 // the range end. 1849 // the range end.
1843 ASSERT(pos.Value() >= current->End().Value()); 1850 ASSERT(pos.Value() >= current->End().Value());
1844 TraceAlloc("Assigning free reg %s to live range %d\n", 1851 TraceAlloc("Assigning free reg %s to live range %d\n",
1845 RegisterName(reg), 1852 RegisterName(reg),
1846 current->id()); 1853 current->id());
1847 current->set_assigned_register(reg, mode_, zone_); 1854 SetLiveRangeAssignedRegister(current, reg, mode_, zone_);
1848 1855
1849 return true; 1856 return true;
1850 } 1857 }
1851 1858
1852 1859
1853 void LAllocator::AllocateBlockedReg(LiveRange* current) { 1860 void LAllocator::AllocateBlockedReg(LiveRange* current) {
1854 UsePosition* register_use = current->NextRegisterPosition(current->Start()); 1861 UsePosition* register_use = current->NextRegisterPosition(current->Start());
1855 if (register_use == NULL) { 1862 if (register_use == NULL) {
1856 // There is no use in the current live range that requires a register. 1863 // There is no use in the current live range that requires a register.
1857 // We can just spill it. 1864 // We can just spill it.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1927 current->Start(), 1934 current->Start(),
1928 block_pos[reg].InstructionStart()); 1935 block_pos[reg].InstructionStart());
1929 AddToUnhandledSorted(tail); 1936 AddToUnhandledSorted(tail);
1930 } 1937 }
1931 1938
1932 // Register reg is not blocked for the whole range. 1939 // Register reg is not blocked for the whole range.
1933 ASSERT(block_pos[reg].Value() >= current->End().Value()); 1940 ASSERT(block_pos[reg].Value() >= current->End().Value());
1934 TraceAlloc("Assigning blocked reg %s to live range %d\n", 1941 TraceAlloc("Assigning blocked reg %s to live range %d\n",
1935 RegisterName(reg), 1942 RegisterName(reg),
1936 current->id()); 1943 current->id());
1937 current->set_assigned_register(reg, mode_, zone_); 1944 SetLiveRangeAssignedRegister(current, reg, mode_, zone_);
1938 1945
1939 // This register was not free. Thus we need to find and spill 1946 // This register was not free. Thus we need to find and spill
1940 // parts of active and inactive live regions that use the same register 1947 // parts of active and inactive live regions that use the same register
1941 // at the same lifetime positions as current. 1948 // at the same lifetime positions as current.
1942 SplitAndSpillIntersecting(current); 1949 SplitAndSpillIntersecting(current);
1943 } 1950 }
1944 1951
1945 1952
1946 void LAllocator::SplitAndSpillIntersecting(LiveRange* current) { 1953 void LAllocator::SplitAndSpillIntersecting(LiveRange* current) {
1947 ASSERT(current->HasRegisterAssigned()); 1954 ASSERT(current->HasRegisterAssigned());
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 LiveRange* current = live_ranges()->at(i); 2124 LiveRange* current = live_ranges()->at(i);
2118 if (current != NULL) current->Verify(); 2125 if (current != NULL) current->Verify();
2119 } 2126 }
2120 } 2127 }
2121 2128
2122 2129
2123 #endif 2130 #endif
2124 2131
2125 2132
2126 } } // namespace v8::internal 2133 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/lithium-allocator.h ('k') | src/lithium-allocator-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698