| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 RUNTIME_VM_KERNEL_BINARY_H_ | 5 #ifndef RUNTIME_VM_KERNEL_BINARY_H_ |
| 6 #define RUNTIME_VM_KERNEL_BINARY_H_ | 6 #define RUNTIME_VM_KERNEL_BINARY_H_ |
| 7 | 7 |
| 8 #if !defined(DART_PRECOMPILED_RUNTIME) | 8 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 | 11 |
| 12 #include "vm/kernel.h" | 12 #include "vm/kernel.h" |
| 13 #include "vm/kernel_to_il.h" | 13 #include "vm/kernel_to_il.h" |
| 14 #include "vm/object.h" | 14 #include "vm/object.h" |
| 15 | 15 |
| 16 namespace dart { | 16 namespace dart { |
| 17 namespace kernel { | 17 namespace kernel { |
| 18 | 18 |
| 19 | |
| 20 static const uint32_t kMagicProgramFile = 0x90ABCDEFu; | 19 static const uint32_t kMagicProgramFile = 0x90ABCDEFu; |
| 21 | 20 |
| 22 | |
| 23 // Keep in sync with package:dynamo/lib/binary/tag.dart | 21 // Keep in sync with package:dynamo/lib/binary/tag.dart |
| 24 enum Tag { | 22 enum Tag { |
| 25 kNothing = 0, | 23 kNothing = 0, |
| 26 kSomething = 1, | 24 kSomething = 1, |
| 27 | 25 |
| 28 kClass = 2, | 26 kClass = 2, |
| 29 | 27 |
| 30 kFunctionNode = 3, | 28 kFunctionNode = 3, |
| 31 kField = 4, | 29 kField = 4, |
| 32 kConstructor = 5, | 30 kConstructor = 5, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 125 |
| 128 kSpecializedTagHighBit = 0x80, // 10000000 | 126 kSpecializedTagHighBit = 0x80, // 10000000 |
| 129 kSpecializedTagMask = 0xF8, // 11111000 | 127 kSpecializedTagMask = 0xF8, // 11111000 |
| 130 kSpecializedPayloadMask = 0x7, // 00000111 | 128 kSpecializedPayloadMask = 0x7, // 00000111 |
| 131 | 129 |
| 132 kSpecializedVariableGet = 128, | 130 kSpecializedVariableGet = 128, |
| 133 kSpecializedVariableSet = 136, | 131 kSpecializedVariableSet = 136, |
| 134 kSpecialIntLiteral = 144, | 132 kSpecialIntLiteral = 144, |
| 135 }; | 133 }; |
| 136 | 134 |
| 137 | |
| 138 static const int SpecializedIntLiteralBias = 3; | 135 static const int SpecializedIntLiteralBias = 3; |
| 139 | 136 |
| 140 | |
| 141 class Reader { | 137 class Reader { |
| 142 public: | 138 public: |
| 143 Reader(const uint8_t* buffer, intptr_t size) | 139 Reader(const uint8_t* buffer, intptr_t size) |
| 144 : buffer_(buffer), size_(size), offset_(0) {} | 140 : buffer_(buffer), size_(size), offset_(0) {} |
| 145 | 141 |
| 146 uint32_t ReadUInt32() { | 142 uint32_t ReadUInt32() { |
| 147 ASSERT(offset_ + 4 <= size_); | 143 ASSERT(offset_ + 4 <= size_); |
| 148 | 144 |
| 149 uint32_t value = (buffer_[offset_ + 0] << 24) | | 145 uint32_t value = (buffer_[offset_ + 0] << 24) | |
| 150 (buffer_[offset_ + 1] << 16) | | 146 (buffer_[offset_ + 1] << 16) | |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 intptr_t size_; | 286 intptr_t size_; |
| 291 intptr_t offset_; | 287 intptr_t offset_; |
| 292 TokenPosition max_position_; | 288 TokenPosition max_position_; |
| 293 TokenPosition min_position_; | 289 TokenPosition min_position_; |
| 294 intptr_t current_script_id_; | 290 intptr_t current_script_id_; |
| 295 | 291 |
| 296 friend class PositionScope; | 292 friend class PositionScope; |
| 297 friend class Program; | 293 friend class Program; |
| 298 }; | 294 }; |
| 299 | 295 |
| 300 | |
| 301 // A helper class that resets the readers min and max positions both upon | 296 // A helper class that resets the readers min and max positions both upon |
| 302 // initialization and upon destruction, i.e. when created the min an max | 297 // initialization and upon destruction, i.e. when created the min an max |
| 303 // positions will be reset to "noSource", when destructing the min and max will | 298 // positions will be reset to "noSource", when destructing the min and max will |
| 304 // be reset to have they value they would have had, if they hadn't been reset in | 299 // be reset to have they value they would have had, if they hadn't been reset in |
| 305 // the first place. | 300 // the first place. |
| 306 class PositionScope { | 301 class PositionScope { |
| 307 public: | 302 public: |
| 308 explicit PositionScope(Reader* reader) | 303 explicit PositionScope(Reader* reader) |
| 309 : reader_(reader), | 304 : reader_(reader), |
| 310 min_(reader->min_position_), | 305 min_(reader->min_position_), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 325 Reader* reader_; | 320 Reader* reader_; |
| 326 TokenPosition min_; | 321 TokenPosition min_; |
| 327 TokenPosition max_; | 322 TokenPosition max_; |
| 328 }; | 323 }; |
| 329 | 324 |
| 330 } // namespace kernel | 325 } // namespace kernel |
| 331 } // namespace dart | 326 } // namespace dart |
| 332 | 327 |
| 333 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 328 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| 334 #endif // RUNTIME_VM_KERNEL_BINARY_H_ | 329 #endif // RUNTIME_VM_KERNEL_BINARY_H_ |
| OLD | NEW |