| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 | 5 |
| 6 #include "src/snapshot/snapshot-source-sink.h" | 6 #include "src/snapshot/snapshot-source-sink.h" |
| 7 | 7 |
| 8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
| 9 #include "src/handles-inl.h" | 9 #include "src/handles-inl.h" |
| 10 #include "src/snapshot/serialize.h" // for SerializerDeserializer::nop() | 10 #include "src/snapshot/serialize.h" // for SerializerDeserializer::nop() |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 if (bytes > 3) Put(static_cast<int>((integer >> 24) & 0xff), "IntPart4"); | 33 if (bytes > 3) Put(static_cast<int>((integer >> 24) & 0xff), "IntPart4"); |
| 34 } | 34 } |
| 35 | 35 |
| 36 | 36 |
| 37 void SnapshotByteSink::PutRaw(const byte* data, int number_of_bytes, | 37 void SnapshotByteSink::PutRaw(const byte* data, int number_of_bytes, |
| 38 const char* description) { | 38 const char* description) { |
| 39 data_.AddAll(Vector<byte>(const_cast<byte*>(data), number_of_bytes)); | 39 data_.AddAll(Vector<byte>(const_cast<byte*>(data), number_of_bytes)); |
| 40 } | 40 } |
| 41 | 41 |
| 42 | 42 |
| 43 bool SnapshotByteSource::AtEOF() { | 43 int SnapshotByteSource::GetBlob(const byte** data) { |
| 44 if (0u + length_ - position_ > 2 * sizeof(uint32_t)) return false; | |
| 45 for (int x = position_; x < length_; x++) { | |
| 46 if (data_[x] != SerializerDeserializer::nop()) return false; | |
| 47 } | |
| 48 return true; | |
| 49 } | |
| 50 | |
| 51 | |
| 52 bool SnapshotByteSource::GetBlob(const byte** data, int* number_of_bytes) { | |
| 53 int size = GetInt(); | 44 int size = GetInt(); |
| 54 *number_of_bytes = size; | 45 CHECK(position_ + size <= length_); |
| 55 | 46 *data = &data_[position_]; |
| 56 if (position_ + size <= length_) { | 47 Advance(size); |
| 57 *data = &data_[position_]; | 48 return size; |
| 58 Advance(size); | |
| 59 return true; | |
| 60 } else { | |
| 61 Advance(length_ - position_); // proceed until end. | |
| 62 return false; | |
| 63 } | |
| 64 } | 49 } |
| 65 } // namespace internal | 50 } // namespace internal |
| 66 } // namespace v8 | 51 } // namespace v8 |
| OLD | NEW |