| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 T* position = current_chunk_.start() + index_; | 523 T* position = current_chunk_.start() + index_; |
| 524 index_ += size; | 524 index_ += size; |
| 525 size_ += size; | 525 size_ += size; |
| 526 for (int i = 0; i < size; i++) { | 526 for (int i = 0; i < size; i++) { |
| 527 position[i] = initial_value; | 527 position[i] = initial_value; |
| 528 } | 528 } |
| 529 return Vector<T>(position, size); | 529 return Vector<T>(position, size); |
| 530 } | 530 } |
| 531 | 531 |
| 532 | 532 |
| 533 // Add a contiguous block of elements and return a vector backed |
| 534 // by the added block. |
| 535 // A basic Collector will keep this vector valid as long as the Collector |
| 536 // is alive. |
| 537 inline Vector<T> AddBlock(Vector<const T> source) { |
| 538 if (source.length() > current_chunk_.length() - index_) { |
| 539 Grow(source.length()); |
| 540 } |
| 541 T* position = current_chunk_.start() + index_; |
| 542 index_ += source.length(); |
| 543 size_ += source.length(); |
| 544 for (int i = 0; i < source.length(); i++) { |
| 545 position[i] = source[i]; |
| 546 } |
| 547 return Vector<T>(position, source.length()); |
| 548 } |
| 549 |
| 550 |
| 533 // Write the contents of the collector into the provided vector. | 551 // Write the contents of the collector into the provided vector. |
| 534 void WriteTo(Vector<T> destination) { | 552 void WriteTo(Vector<T> destination) { |
| 535 ASSERT(size_ <= destination.length()); | 553 ASSERT(size_ <= destination.length()); |
| 536 int position = 0; | 554 int position = 0; |
| 537 for (int i = 0; i < chunks_.length(); i++) { | 555 for (int i = 0; i < chunks_.length(); i++) { |
| 538 Vector<T> chunk = chunks_.at(i); | 556 Vector<T> chunk = chunks_.at(i); |
| 539 for (int j = 0; j < chunk.length(); j++) { | 557 for (int j = 0; j < chunk.length(); j++) { |
| 540 destination[position] = chunk[j]; | 558 destination[position] = chunk[j]; |
| 541 position++; | 559 position++; |
| 542 } | 560 } |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 } | 772 } |
| 755 | 773 |
| 756 template <class Dest, class Source> | 774 template <class Dest, class Source> |
| 757 inline Dest BitCast(Source* source) { | 775 inline Dest BitCast(Source* source) { |
| 758 return BitCast<Dest>(reinterpret_cast<uintptr_t>(source)); | 776 return BitCast<Dest>(reinterpret_cast<uintptr_t>(source)); |
| 759 } | 777 } |
| 760 | 778 |
| 761 } } // namespace v8::internal | 779 } } // namespace v8::internal |
| 762 | 780 |
| 763 #endif // V8_UTILS_H_ | 781 #endif // V8_UTILS_H_ |
| OLD | NEW |