| OLD | NEW | 
|     1 // Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file |     1 // Copyright (c) 2012, 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_SNAPSHOT_H_ |     5 #ifndef RUNTIME_VM_SNAPSHOT_H_ | 
|     6 #define RUNTIME_VM_SNAPSHOT_H_ |     6 #define RUNTIME_VM_SNAPSHOT_H_ | 
|     7  |     7  | 
|     8 #include "platform/assert.h" |     8 #include "platform/assert.h" | 
|     9 #include "vm/allocation.h" |     9 #include "vm/allocation.h" | 
|    10 #include "vm/bitfield.h" |    10 #include "vm/bitfield.h" | 
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   145  |   145  | 
|   146  |   146  | 
|   147 // Structure capturing the raw snapshot. |   147 // Structure capturing the raw snapshot. | 
|   148 // |   148 // | 
|   149 // TODO(turnidge): Remove this class once the snapshot does not have a |   149 // TODO(turnidge): Remove this class once the snapshot does not have a | 
|   150 // header anymore.  This is pending on making the embedder pass in the |   150 // header anymore.  This is pending on making the embedder pass in the | 
|   151 // length of their snapshot. |   151 // length of their snapshot. | 
|   152 class Snapshot { |   152 class Snapshot { | 
|   153  public: |   153  public: | 
|   154   enum Kind { |   154   enum Kind { | 
|   155     kCore = 0,    // Full snapshot of core libraries. No root library, no code. |   155     kCore = 0,  // Full snapshot of core libraries. No root library, no code. | 
|   156     kScript,      // A partial snapshot of only the application script. |   156     kScript,    // A partial snapshot of only the application script. | 
|   157     kMessage,     // A partial snapshot used only for isolate messaging. |   157     kMessage,   // A partial snapshot used only for isolate messaging. | 
|   158     kAppWithJIT,  // Full snapshot of core libraries and application. Has some |   158     kAppJIT,    // Full snapshot of core libraries and application. Has some | 
|   159                   // code, but may compile in the future because we haven't |   159                 // code, but may compile in the future because we haven't | 
|   160                   // necessarily included code for every function or to |   160                 // necessarily included code for every function or to | 
|   161                   // (de)optimize. |   161                 // (de)optimize. | 
|   162     kAppNoJIT,    // Full snapshot of core libraries and application. Has |   162     kAppAOT,    // Full snapshot of core libraries and application. Has | 
|   163                   // complete code for the application that never deopts. Will |   163                 // complete code for the application that never deopts. Will | 
|   164                   // not compile in the future. |   164                 // not compile in the future. | 
|   165     kNone,        // dart_bootstrap/gen_snapshot |   165     kNone,      // dart_bootstrap/gen_snapshot | 
|   166     kInvalid |   166     kInvalid | 
|   167   }; |   167   }; | 
|   168   static const char* KindToCString(Kind kind); |   168   static const char* KindToCString(Kind kind); | 
|   169  |   169  | 
|   170   static const int kHeaderSize = 2 * sizeof(int64_t); |   170   static const int kHeaderSize = 2 * sizeof(int64_t); | 
|   171   static const int kLengthIndex = 0; |   171   static const int kLengthIndex = 0; | 
|   172   static const int kSnapshotFlagIndex = 1; |   172   static const int kSnapshotFlagIndex = 1; | 
|   173  |   173  | 
|   174   static const Snapshot* SetupFromBuffer(const void* raw_memory); |   174   static const Snapshot* SetupFromBuffer(const void* raw_memory); | 
|   175  |   175  | 
|   176   // Getters. |   176   // Getters. | 
|   177   const uint8_t* content() const { OPEN_ARRAY_START(uint8_t, uint8_t); } |   177   const uint8_t* content() const { OPEN_ARRAY_START(uint8_t, uint8_t); } | 
|   178   intptr_t length() const { |   178   intptr_t length() const { | 
|   179     return static_cast<intptr_t>(ReadUnaligned(&unaligned_length_)); |   179     return static_cast<intptr_t>(ReadUnaligned(&unaligned_length_)); | 
|   180   } |   180   } | 
|   181   Kind kind() const { |   181   Kind kind() const { | 
|   182     return static_cast<Kind>(ReadUnaligned(&unaligned_kind_)); |   182     return static_cast<Kind>(ReadUnaligned(&unaligned_kind_)); | 
|   183   } |   183   } | 
|   184  |   184  | 
|   185   static bool IsFull(Kind kind) { |   185   static bool IsFull(Kind kind) { | 
|   186     return (kind == kCore) || (kind == kAppWithJIT) || (kind == kAppNoJIT); |   186     return (kind == kCore) || (kind == kAppJIT) || (kind == kAppAOT); | 
|   187   } |   187   } | 
|   188   static bool IncludesCode(Kind kind) { |   188   static bool IncludesCode(Kind kind) { | 
|   189     return (kind == kAppWithJIT) || (kind == kAppNoJIT); |   189     return (kind == kAppJIT) || (kind == kAppAOT); | 
|   190   } |   190   } | 
|   191  |   191  | 
|   192   uint8_t* Addr() { return reinterpret_cast<uint8_t*>(this); } |   192   uint8_t* Addr() { return reinterpret_cast<uint8_t*>(this); } | 
|   193  |   193  | 
|   194   static intptr_t length_offset() { |   194   static intptr_t length_offset() { | 
|   195     return OFFSET_OF(Snapshot, unaligned_length_); |   195     return OFFSET_OF(Snapshot, unaligned_length_); | 
|   196   } |   196   } | 
|   197   static intptr_t kind_offset() { return OFFSET_OF(Snapshot, unaligned_kind_); } |   197   static intptr_t kind_offset() { return OFFSET_OF(Snapshot, unaligned_kind_); } | 
|   198  |   198  | 
|   199  private: |   199  private: | 
| (...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1016  private: |  1016  private: | 
|  1017   SnapshotWriter* writer_; |  1017   SnapshotWriter* writer_; | 
|  1018   bool as_references_; |  1018   bool as_references_; | 
|  1019  |  1019  | 
|  1020   DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); |  1020   DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); | 
|  1021 }; |  1021 }; | 
|  1022  |  1022  | 
|  1023 }  // namespace dart |  1023 }  // namespace dart | 
|  1024  |  1024  | 
|  1025 #endif  // RUNTIME_VM_SNAPSHOT_H_ |  1025 #endif  // RUNTIME_VM_SNAPSHOT_H_ | 
| OLD | NEW |