OLD | NEW |
---|---|
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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 } | 289 } |
290 | 290 |
291 | 291 |
292 void LiveRange::SplitAt(LifetimePosition position, LiveRange* result) { | 292 void LiveRange::SplitAt(LifetimePosition position, LiveRange* result) { |
293 ASSERT(Start().Value() < position.Value()); | 293 ASSERT(Start().Value() < position.Value()); |
294 ASSERT(result->IsEmpty()); | 294 ASSERT(result->IsEmpty()); |
295 // Find the last interval that ends before the position. If the | 295 // Find the last interval that ends before the position. If the |
296 // position is contained in one of the intervals in the chain, we | 296 // position is contained in one of the intervals in the chain, we |
297 // split that interval and use the first part. | 297 // split that interval and use the first part. |
298 UseInterval* current = FirstSearchIntervalForPosition(position); | 298 UseInterval* current = FirstSearchIntervalForPosition(position); |
299 | |
300 // If split position coincides with the beginning of use interval | |
Kevin Millikin (Chromium)
2010/12/15 14:01:52
"the split position"..."a use interval" :)
| |
301 // we need to split use positons in a special way. | |
302 bool split_at_start = false; | |
303 | |
299 while (current != NULL) { | 304 while (current != NULL) { |
300 if (current->Contains(position)) { | 305 if (current->Contains(position)) { |
301 current->SplitAt(position); | 306 current->SplitAt(position); |
302 break; | 307 break; |
303 } | 308 } |
304 UseInterval* next = current->next(); | 309 UseInterval* next = current->next(); |
305 if (next->start().Value() >= position.Value()) break; | 310 if (next->start().Value() >= position.Value()) { |
311 split_at_start = (next->start().Value() == position.Value()); | |
312 break; | |
313 } | |
306 current = next; | 314 current = next; |
307 } | 315 } |
308 | 316 |
309 // Partition original use intervals to the two live ranges. | 317 // Partition original use intervals to the two live ranges. |
310 UseInterval* before = current; | 318 UseInterval* before = current; |
311 UseInterval* after = before->next(); | 319 UseInterval* after = before->next(); |
312 result->last_interval_ = (last_interval_ == before) | 320 result->last_interval_ = (last_interval_ == before) |
313 ? after // Only interval in the range after split. | 321 ? after // Only interval in the range after split. |
314 : last_interval_; // Last interval of the original range. | 322 : last_interval_; // Last interval of the original range. |
315 result->first_interval_ = after; | 323 result->first_interval_ = after; |
316 last_interval_ = before; | 324 last_interval_ = before; |
317 | 325 |
318 // Find the last use position before the split and the first use | 326 // Find the last use position before the split and the first use |
319 // position after it. | 327 // position after it. |
320 UsePosition* use_after = first_pos_; | 328 UsePosition* use_after = first_pos_; |
321 UsePosition* use_before = NULL; | 329 UsePosition* use_before = NULL; |
322 while (use_after != NULL && use_after->pos().Value() <= position.Value()) { | 330 if (split_at_start) { |
323 use_before = use_after; | 331 while (use_after != NULL && use_after->pos().Value() < position.Value()) { |
Kevin Millikin (Chromium)
2010/12/15 14:01:52
Maybe this case needs a short comment too, somethi
| |
324 use_after = use_after->next(); | 332 use_before = use_after; |
333 use_after = use_after->next(); | |
334 } | |
335 } else { | |
336 while (use_after != NULL && use_after->pos().Value() <= position.Value()) { | |
337 use_before = use_after; | |
338 use_after = use_after->next(); | |
339 } | |
325 } | 340 } |
326 | 341 |
327 // Partition original use positions to the two live ranges. | 342 // Partition original use positions to the two live ranges. |
328 if (use_before != NULL) { | 343 if (use_before != NULL) { |
329 use_before->next_ = NULL; | 344 use_before->next_ = NULL; |
330 } else { | 345 } else { |
331 first_pos_ = NULL; | 346 first_pos_ = NULL; |
332 } | 347 } |
333 result->first_pos_ = use_after; | 348 result->first_pos_ = use_after; |
334 | 349 |
(...skipping 1759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2094 LiveRange* current = live_ranges()->at(i); | 2109 LiveRange* current = live_ranges()->at(i); |
2095 if (current != NULL) current->Verify(); | 2110 if (current != NULL) current->Verify(); |
2096 } | 2111 } |
2097 } | 2112 } |
2098 | 2113 |
2099 | 2114 |
2100 #endif | 2115 #endif |
2101 | 2116 |
2102 | 2117 |
2103 } } // namespace v8::internal | 2118 } } // namespace v8::internal |
OLD | NEW |