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

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

Issue 5899002: Fix several register allocation issues revealed by fuzzer: (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 10 years 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/ia32/lithium-ia32.cc ('k') | test/mjsunit/fuzz-natives.js » ('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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 } 578 }
579 579
580 580
581 void LAllocator::AddInitialIntervals(HBasicBlock* block, 581 void LAllocator::AddInitialIntervals(HBasicBlock* block,
582 BitVector* live_out) { 582 BitVector* live_out) {
583 // Add an interval that includes the entire block to the live range for 583 // Add an interval that includes the entire block to the live range for
584 // each live_out value. 584 // each live_out value.
585 LifetimePosition start = LifetimePosition::FromInstructionIndex( 585 LifetimePosition start = LifetimePosition::FromInstructionIndex(
586 block->first_instruction_index()); 586 block->first_instruction_index());
587 LifetimePosition end = LifetimePosition::FromInstructionIndex( 587 LifetimePosition end = LifetimePosition::FromInstructionIndex(
588 block->last_instruction_index()); 588 block->last_instruction_index()).NextInstruction();
589 BitVector::Iterator iterator(live_out); 589 BitVector::Iterator iterator(live_out);
590 while (!iterator.Done()) { 590 while (!iterator.Done()) {
591 int operand_index = iterator.Current(); 591 int operand_index = iterator.Current();
592 LiveRange* range = LiveRangeFor(operand_index); 592 LiveRange* range = LiveRangeFor(operand_index);
593 if (!range->IsEmpty() && 593 range->AddUseInterval(start, end);
594 range->Start().Value() == end.NextInstruction().Value()) {
595 range->AddUseInterval(start, end.NextInstruction());
596 } else {
597 range->AddUseInterval(start, end);
598 }
599 iterator.Advance(); 594 iterator.Advance();
600 } 595 }
601 } 596 }
602 597
603 598
604 int LAllocator::FixedDoubleLiveRangeID(int index) { 599 int LAllocator::FixedDoubleLiveRangeID(int index) {
605 return -index - 1 - Register::kNumAllocatableRegisters; 600 return -index - 1 - Register::kNumAllocatableRegisters;
606 } 601 }
607 602
608 603
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 LOperand* temp = summary->TempAt(i); 966 LOperand* temp = summary->TempAt(i);
972 if (summary->IsCall()) { 967 if (summary->IsCall()) {
973 if (temp->IsRegister()) continue; 968 if (temp->IsRegister()) continue;
974 if (temp->IsUnallocated()) { 969 if (temp->IsUnallocated()) {
975 LUnallocated* temp_unalloc = LUnallocated::cast(temp); 970 LUnallocated* temp_unalloc = LUnallocated::cast(temp);
976 if (temp_unalloc->HasFixedPolicy()) { 971 if (temp_unalloc->HasFixedPolicy()) {
977 continue; 972 continue;
978 } 973 }
979 } 974 }
980 } 975 }
981 Use(block_start_position, curr_position, temp, NULL); 976 Use(block_start_position, curr_position.InstructionEnd(), temp, NULL);
982 Define(curr_position.PrevInstruction(), temp, NULL); 977 Define(curr_position, temp, NULL);
983 } 978 }
984 } 979 }
985 } 980 }
986 981
987 index = index - 1; 982 index = index - 1;
988 } 983 }
989 } 984 }
990 985
991 986
992 void LAllocator::ResolvePhis(HBasicBlock* block) { 987 void LAllocator::ResolvePhis(HBasicBlock* block) {
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
1825 // Register reg is available at the range start but becomes blocked before 1820 // Register reg is available at the range start but becomes blocked before
1826 // the range end. Split current at position where it becomes blocked. 1821 // the range end. Split current at position where it becomes blocked.
1827 LiveRange* tail = SplitAt(current, pos); 1822 LiveRange* tail = SplitAt(current, pos);
1828 AddToUnhandledSorted(tail); 1823 AddToUnhandledSorted(tail);
1829 } 1824 }
1830 1825
1831 1826
1832 // Register reg is available at the range start and is free until 1827 // Register reg is available at the range start and is free until
1833 // the range end. 1828 // the range end.
1834 ASSERT(pos.Value() >= current->End().Value()); 1829 ASSERT(pos.Value() >= current->End().Value());
1835 TraceAlloc("Assigning reg %s to live range %d\n", 1830 TraceAlloc("Assigning free reg %s to live range %d\n",
1836 RegisterName(reg), 1831 RegisterName(reg),
1837 current->id()); 1832 current->id());
1838 current->set_assigned_register(reg, mode_); 1833 current->set_assigned_register(reg, mode_);
1839 1834
1840 return true; 1835 return true;
1841 } 1836 }
1842 1837
1843 1838
1844 void LAllocator::AllocateBlockedReg(LiveRange* current) { 1839 void LAllocator::AllocateBlockedReg(LiveRange* current) {
1845 UsePosition* register_use = current->NextRegisterPosition(current->Start()); 1840 UsePosition* register_use = current->NextRegisterPosition(current->Start());
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 // Register becomes blocked before the current range end. Split before that 1910 // Register becomes blocked before the current range end. Split before that
1916 // position. 1911 // position.
1917 LiveRange* tail = SplitBetween(current, 1912 LiveRange* tail = SplitBetween(current,
1918 current->Start(), 1913 current->Start(),
1919 block_pos[reg].InstructionStart()); 1914 block_pos[reg].InstructionStart());
1920 AddToUnhandledSorted(tail); 1915 AddToUnhandledSorted(tail);
1921 } 1916 }
1922 1917
1923 // Register reg is not blocked for the whole range. 1918 // Register reg is not blocked for the whole range.
1924 ASSERT(block_pos[reg].Value() >= current->End().Value()); 1919 ASSERT(block_pos[reg].Value() >= current->End().Value());
1925 TraceAlloc("Assigning reg %s to live range %d\n", 1920 TraceAlloc("Assigning blocked reg %s to live range %d\n",
1926 RegisterName(reg), 1921 RegisterName(reg),
1927 current->id()); 1922 current->id());
1928 current->set_assigned_register(reg, mode_); 1923 current->set_assigned_register(reg, mode_);
1929 1924
1930 // This register was not free. Thus we need to find and spill 1925 // This register was not free. Thus we need to find and spill
1931 // parts of active and inactive live regions that use the same register 1926 // parts of active and inactive live regions that use the same register
1932 // at the same lifetime positions as current. 1927 // at the same lifetime positions as current.
1933 SplitAndSpillIntersecting(current); 1928 SplitAndSpillIntersecting(current);
1934 } 1929 }
1935 1930
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
2112 LiveRange* current = live_ranges()->at(i); 2107 LiveRange* current = live_ranges()->at(i);
2113 if (current != NULL) current->Verify(); 2108 if (current != NULL) current->Verify();
2114 } 2109 }
2115 } 2110 }
2116 2111
2117 2112
2118 #endif 2113 #endif
2119 2114
2120 2115
2121 } } // namespace v8::internal 2116 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/lithium-ia32.cc ('k') | test/mjsunit/fuzz-natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698