OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_DATASTREAM_H_ | 5 #ifndef VM_DATASTREAM_H_ |
6 #define VM_DATASTREAM_H_ | 6 #define VM_DATASTREAM_H_ |
7 | 7 |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "platform/utils.h" | 9 #include "platform/utils.h" |
10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 void Write(T value) { | 211 void Write(T value) { |
212 T v = value; | 212 T v = value; |
213 while (v < kMinDataPerByte || | 213 while (v < kMinDataPerByte || |
214 v > kMaxDataPerByte) { | 214 v > kMaxDataPerByte) { |
215 WriteByte(static_cast<uint8_t>(v & kByteMask)); | 215 WriteByte(static_cast<uint8_t>(v & kByteMask)); |
216 v = v >> kDataBitsPerByte; | 216 v = v >> kDataBitsPerByte; |
217 } | 217 } |
218 WriteByte(static_cast<uint8_t>(v + kEndByteMarker)); | 218 WriteByte(static_cast<uint8_t>(v + kEndByteMarker)); |
219 } | 219 } |
220 | 220 |
221 void WriteByte(uint8_t value) { | 221 DART_FORCE_INLINE void WriteByte(uint8_t value) { |
222 if (current_ >= end_) { | 222 if (current_ >= end_) { |
223 Resize(1); | 223 Resize(1); |
224 } | 224 } |
225 ASSERT(current_ < end_); | 225 ASSERT(current_ < end_); |
226 *current_++ = value; | 226 *current_++ = value; |
227 } | 227 } |
228 | 228 |
229 void Resize(intptr_t size_needed) { | 229 void Resize(intptr_t size_needed) { |
230 intptr_t position = current_ - *buffer_; | 230 intptr_t position = current_ - *buffer_; |
231 intptr_t new_size = current_size_ + | 231 intptr_t new_size = current_size_ + |
(...skipping 15 matching lines...) Expand all Loading... |
247 intptr_t current_size_; | 247 intptr_t current_size_; |
248 ReAlloc alloc_; | 248 ReAlloc alloc_; |
249 intptr_t increment_size_; | 249 intptr_t increment_size_; |
250 | 250 |
251 DISALLOW_COPY_AND_ASSIGN(WriteStream); | 251 DISALLOW_COPY_AND_ASSIGN(WriteStream); |
252 }; | 252 }; |
253 | 253 |
254 } // namespace dart | 254 } // namespace dart |
255 | 255 |
256 #endif // VM_DATASTREAM_H_ | 256 #endif // VM_DATASTREAM_H_ |
OLD | NEW |