| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_SNAPSHOT_SNAPSHOT_SOURCE_SINK_H_ | 5 #ifndef V8_SNAPSHOT_SNAPSHOT_SOURCE_SINK_H_ |
| 6 #define V8_SNAPSHOT_SNAPSHOT_SOURCE_SINK_H_ | 6 #define V8_SNAPSHOT_SNAPSHOT_SOURCE_SINK_H_ |
| 7 | 7 |
| 8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
| 9 #include "src/utils.h" | 9 #include "src/utils.h" |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 bool HasMore() { return position_ < length_; } | 32 bool HasMore() { return position_ < length_; } |
| 33 | 33 |
| 34 byte Get() { | 34 byte Get() { |
| 35 DCHECK(position_ < length_); | 35 DCHECK(position_ < length_); |
| 36 return data_[position_++]; | 36 return data_[position_++]; |
| 37 } | 37 } |
| 38 | 38 |
| 39 void Advance(int by) { position_ += by; } | 39 void Advance(int by) { position_ += by; } |
| 40 | 40 |
| 41 void CopyRaw(byte* to, int number_of_bytes); | 41 void CopyRaw(byte* to, int number_of_bytes) { |
| 42 memcpy(to, data_ + position_, number_of_bytes); |
| 43 position_ += number_of_bytes; |
| 44 } |
| 42 | 45 |
| 43 inline int GetInt() { | 46 inline int GetInt() { |
| 44 // This way of decoding variable-length encoded integers does not | 47 // This way of decoding variable-length encoded integers does not |
| 45 // suffer from branch mispredictions. | 48 // suffer from branch mispredictions. |
| 46 DCHECK(position_ + 3 < length_); | 49 DCHECK(position_ + 3 < length_); |
| 47 uint32_t answer = data_[position_]; | 50 uint32_t answer = data_[position_]; |
| 48 answer |= data_[position_ + 1] << 8; | 51 answer |= data_[position_ + 1] << 8; |
| 49 answer |= data_[position_ + 2] << 16; | 52 answer |= data_[position_ + 2] << 16; |
| 50 answer |= data_[position_ + 3] << 24; | 53 answer |= data_[position_ + 3] << 24; |
| 51 int bytes = (answer & 3) + 1; | 54 int bytes = (answer & 3) + 1; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 const List<byte>* data() const { return &data_; } | 100 const List<byte>* data() const { return &data_; } |
| 98 | 101 |
| 99 private: | 102 private: |
| 100 List<byte> data_; | 103 List<byte> data_; |
| 101 }; | 104 }; |
| 102 | 105 |
| 103 } // namespace internal | 106 } // namespace internal |
| 104 } // namespace v8 | 107 } // namespace v8 |
| 105 | 108 |
| 106 #endif // V8_SNAPSHOT_SNAPSHOT_SOURCE_SINK_H_ | 109 #endif // V8_SNAPSHOT_SNAPSHOT_SOURCE_SINK_H_ |
| OLD | NEW |