| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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_WASM_ENCODER_H_ | 5 #ifndef V8_WASM_ENCODER_H_ |
| 6 #define V8_WASM_ENCODER_H_ | 6 #define V8_WASM_ENCODER_H_ |
| 7 | 7 |
| 8 #include "src/signature.h" | 8 #include "src/signature.h" |
| 9 #include "src/zone-containers.h" | 9 #include "src/zone-containers.h" |
| 10 | 10 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 size_t offset() { return static_cast<size_t>(pos_ - buffer_); } | 86 size_t offset() { return static_cast<size_t>(pos_ - buffer_); } |
| 87 size_t size() { return static_cast<size_t>(pos_ - buffer_); } | 87 size_t size() { return static_cast<size_t>(pos_ - buffer_); } |
| 88 const byte* begin() { return buffer_; } | 88 const byte* begin() { return buffer_; } |
| 89 const byte* end() { return pos_; } | 89 const byte* end() { return pos_; } |
| 90 | 90 |
| 91 void EnsureSpace(size_t size) { | 91 void EnsureSpace(size_t size) { |
| 92 if ((pos_ + size) > end_) { | 92 if ((pos_ + size) > end_) { |
| 93 size_t new_size = 4096 + (end_ - buffer_) * 3; | 93 size_t new_size = 4096 + size + (end_ - buffer_) * 3; |
| 94 byte* new_buffer = reinterpret_cast<byte*>(zone_->New(new_size)); | 94 byte* new_buffer = reinterpret_cast<byte*>(zone_->New(new_size)); |
| 95 memcpy(new_buffer, buffer_, (pos_ - buffer_)); | 95 memcpy(new_buffer, buffer_, (pos_ - buffer_)); |
| 96 pos_ = new_buffer + (pos_ - buffer_); | 96 pos_ = new_buffer + (pos_ - buffer_); |
| 97 buffer_ = new_buffer; | 97 buffer_ = new_buffer; |
| 98 end_ = new_buffer + new_size; | 98 end_ = new_buffer + new_size; |
| 99 } | 99 } |
| 100 DCHECK(pos_ + size <= end_); |
| 100 } | 101 } |
| 101 | 102 |
| 102 byte** pos_ptr() { return &pos_; } | 103 byte** pos_ptr() { return &pos_; } |
| 103 | 104 |
| 104 private: | 105 private: |
| 105 Zone* zone_; | 106 Zone* zone_; |
| 106 byte* buffer_; | 107 byte* buffer_; |
| 107 byte* pos_; | 108 byte* pos_; |
| 108 byte* end_; | 109 byte* end_; |
| 109 }; | 110 }; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 ZoneVector<std::pair<LocalType, bool>> globals_; | 241 ZoneVector<std::pair<LocalType, bool>> globals_; |
| 241 SignatureMap signature_map_; | 242 SignatureMap signature_map_; |
| 242 int start_function_index_; | 243 int start_function_index_; |
| 243 }; | 244 }; |
| 244 | 245 |
| 245 } // namespace wasm | 246 } // namespace wasm |
| 246 } // namespace internal | 247 } // namespace internal |
| 247 } // namespace v8 | 248 } // namespace v8 |
| 248 | 249 |
| 249 #endif // V8_WASM_ENCODER_H_ | 250 #endif // V8_WASM_ENCODER_H_ |
| OLD | NEW |