| 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_SOURCE_SINK_H_ | 5 #ifndef V8_SNAPSHOT_SOURCE_SINK_H_ |
| 6 #define V8_SNAPSHOT_SOURCE_SINK_H_ | 6 #define V8_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 21 matching lines...) Expand all Loading... |
| 32 int32_t GetUnalignedInt(); | 32 int32_t GetUnalignedInt(); |
| 33 | 33 |
| 34 void Advance(int by) { position_ += by; } | 34 void Advance(int by) { position_ += by; } |
| 35 | 35 |
| 36 void CopyRaw(byte* to, int number_of_bytes); | 36 void CopyRaw(byte* to, int number_of_bytes); |
| 37 | 37 |
| 38 inline int GetInt() { | 38 inline int GetInt() { |
| 39 // This way of variable-length encoding integers does not suffer from branch | 39 // This way of variable-length encoding integers does not suffer from branch |
| 40 // mispredictions. | 40 // mispredictions. |
| 41 uint32_t answer = GetUnalignedInt(); | 41 uint32_t answer = GetUnalignedInt(); |
| 42 int bytes = answer & 3; | 42 int bytes = (answer & 3) + 1; |
| 43 Advance(bytes); | 43 Advance(bytes); |
| 44 uint32_t mask = 0xffffffffu; | 44 uint32_t mask = 0xffffffffu; |
| 45 mask >>= 32 - (bytes << 3); | 45 mask >>= 32 - (bytes << 3); |
| 46 answer &= mask; | 46 answer &= mask; |
| 47 answer >>= 2; | 47 answer >>= 2; |
| 48 return answer; | 48 return answer; |
| 49 } | 49 } |
| 50 | 50 |
| 51 bool GetBlob(const byte** data, int* number_of_bytes); | 51 bool GetBlob(const byte** data, int* number_of_bytes); |
| 52 | 52 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 virtual int Position() OVERRIDE { return data_->length(); } | 116 virtual int Position() OVERRIDE { return data_->length(); } |
| 117 | 117 |
| 118 private: | 118 private: |
| 119 i::List<byte>* data_; | 119 i::List<byte>* data_; |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 } // namespace v8::internal | 122 } // namespace v8::internal |
| 123 } // namespace v8 | 123 } // namespace v8 |
| 124 | 124 |
| 125 #endif // V8_SNAPSHOT_SOURCE_SINK_H_ | 125 #endif // V8_SNAPSHOT_SOURCE_SINK_H_ |
| OLD | NEW |