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

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

Issue 6312057: Fix control flow resolution bug in lithium register allocator. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: add assertion Created 9 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 | « 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 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 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 HBasicBlock* block = blocks->at(block_id); 1061 HBasicBlock* block = blocks->at(block_id);
1062 ResolvePhis(block); 1062 ResolvePhis(block);
1063 } 1063 }
1064 } 1064 }
1065 1065
1066 1066
1067 void LAllocator::ResolveControlFlow(LiveRange* range, 1067 void LAllocator::ResolveControlFlow(LiveRange* range,
1068 HBasicBlock* block, 1068 HBasicBlock* block,
1069 HBasicBlock* pred) { 1069 HBasicBlock* pred) {
1070 LifetimePosition pred_end = 1070 LifetimePosition pred_end =
1071 LifetimePosition::FromInstructionIndex(pred->last_instruction_index()). 1071 LifetimePosition::FromInstructionIndex(pred->last_instruction_index());
1072 PrevInstruction();
1073
1074 LifetimePosition cur_start = 1072 LifetimePosition cur_start =
1075 LifetimePosition::FromInstructionIndex(block->first_instruction_index()); 1073 LifetimePosition::FromInstructionIndex(block->first_instruction_index());
1076 LiveRange* pred_cover = NULL; 1074 LiveRange* pred_cover = NULL;
1077 LiveRange* cur_cover = NULL; 1075 LiveRange* cur_cover = NULL;
1078 LiveRange* cur_range = range; 1076 LiveRange* cur_range = range;
1079 while (cur_range != NULL && (cur_cover == NULL || pred_cover == NULL)) { 1077 while (cur_range != NULL && (cur_cover == NULL || pred_cover == NULL)) {
1080 if (cur_range->CanCover(cur_start)) { 1078 if (cur_range->CanCover(cur_start)) {
1081 ASSERT(cur_cover == NULL); 1079 ASSERT(cur_cover == NULL);
1082 cur_cover = cur_range; 1080 cur_cover = cur_range;
1083 } 1081 }
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 if (block->IsLoopHeader()) { 1236 if (block->IsLoopHeader()) {
1239 // TODO(kmillikin): Need to be able to get the last block of the loop 1237 // TODO(kmillikin): Need to be able to get the last block of the loop
1240 // in the loop information. Add a live range stretching from the first 1238 // in the loop information. Add a live range stretching from the first
1241 // loop instruction to the last for each value live on entry to the 1239 // loop instruction to the last for each value live on entry to the
1242 // header. 1240 // header.
1243 HBasicBlock* back_edge = block->loop_information()->GetLastBackEdge(); 1241 HBasicBlock* back_edge = block->loop_information()->GetLastBackEdge();
1244 BitVector::Iterator iterator(live); 1242 BitVector::Iterator iterator(live);
1245 LifetimePosition start = LifetimePosition::FromInstructionIndex( 1243 LifetimePosition start = LifetimePosition::FromInstructionIndex(
1246 block->first_instruction_index()); 1244 block->first_instruction_index());
1247 LifetimePosition end = LifetimePosition::FromInstructionIndex( 1245 LifetimePosition end = LifetimePosition::FromInstructionIndex(
1248 back_edge->last_instruction_index()); 1246 back_edge->last_instruction_index()).NextInstruction();
1249 while (!iterator.Done()) { 1247 while (!iterator.Done()) {
1250 int operand_index = iterator.Current(); 1248 int operand_index = iterator.Current();
1251 LiveRange* range = LiveRangeFor(operand_index); 1249 LiveRange* range = LiveRangeFor(operand_index);
1252 range->EnsureInterval(start, end); 1250 range->EnsureInterval(start, end);
1253 iterator.Advance(); 1251 iterator.Advance();
1254 } 1252 }
1255 1253
1256 for (int i = block->block_id() + 1; i <= back_edge->block_id(); ++i) { 1254 for (int i = block->block_id() + 1; i <= back_edge->block_id(); ++i) {
1257 live_in_sets_[i]->Union(*live); 1255 live_in_sets_[i]->Union(*live);
1258 } 1256 }
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
2012 chunk_->instructions()->at(pos.InstructionIndex())->IsLabel(); 2010 chunk_->instructions()->at(pos.InstructionIndex())->IsLabel();
2013 } 2011 }
2014 2012
2015 2013
2016 LiveRange* LAllocator::SplitAt(LiveRange* range, LifetimePosition pos) { 2014 LiveRange* LAllocator::SplitAt(LiveRange* range, LifetimePosition pos) {
2017 ASSERT(!range->IsFixed()); 2015 ASSERT(!range->IsFixed());
2018 TraceAlloc("Splitting live range %d at %d\n", range->id(), pos.Value()); 2016 TraceAlloc("Splitting live range %d at %d\n", range->id(), pos.Value());
2019 2017
2020 if (pos.Value() <= range->Start().Value()) return range; 2018 if (pos.Value() <= range->Start().Value()) return range;
2021 2019
2020 // We can't properly connect liveranges if split occured at the end
2021 // of control instruction.
2022 ASSERT(pos.IsInstructionStart() ||
2023 !chunk_->instructions()->at(pos.InstructionIndex())->IsControl());
2024
2022 LiveRange* result = LiveRangeFor(next_virtual_register_++); 2025 LiveRange* result = LiveRangeFor(next_virtual_register_++);
2023 range->SplitAt(pos, result); 2026 range->SplitAt(pos, result);
2024 return result; 2027 return result;
2025 } 2028 }
2026 2029
2027 2030
2028 LiveRange* LAllocator::SplitBetween(LiveRange* range, 2031 LiveRange* LAllocator::SplitBetween(LiveRange* range,
2029 LifetimePosition start, 2032 LifetimePosition start,
2030 LifetimePosition end) { 2033 LifetimePosition end) {
2031 ASSERT(!range->IsFixed()); 2034 ASSERT(!range->IsFixed());
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
2132 LiveRange* current = live_ranges()->at(i); 2135 LiveRange* current = live_ranges()->at(i);
2133 if (current != NULL) current->Verify(); 2136 if (current != NULL) current->Verify();
2134 } 2137 }
2135 } 2138 }
2136 2139
2137 2140
2138 #endif 2141 #endif
2139 2142
2140 2143
2141 } } // namespace v8::internal 2144 } } // namespace v8::internal
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