| OLD | NEW | 
|    1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |    1 // Copyright 2006-2008 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_SNAPSHOT_H_ |    5 #ifndef V8_SNAPSHOT_SNAPSHOT_H_ | 
|    6 #define V8_SNAPSHOT_SNAPSHOT_H_ |    6 #define V8_SNAPSHOT_SNAPSHOT_H_ | 
|    7  |    7  | 
|    8 #include "src/snapshot/partial-serializer.h" |    8 #include "src/snapshot/partial-serializer.h" | 
|    9 #include "src/snapshot/startup-serializer.h" |    9 #include "src/snapshot/startup-serializer.h" | 
|   10  |   10  | 
|   11 namespace v8 { |   11 namespace v8 { | 
|   12 namespace internal { |   12 namespace internal { | 
|   13  |   13  | 
|   14 // Forward declarations. |   14 // Forward declarations. | 
|   15 class Isolate; |   15 class Isolate; | 
|   16 class PartialSerializer; |   16 class PartialSerializer; | 
|   17 class StartupSerializer; |   17 class StartupSerializer; | 
|   18  |   18  | 
|   19 class Snapshot : public AllStatic { |   19 class Snapshot : public AllStatic { | 
|   20  public: |   20  public: | 
|   21   class Metadata { |  | 
|   22    public: |  | 
|   23     explicit Metadata(uint32_t data = 0) : data_(data) {} |  | 
|   24     bool embeds_script() { return EmbedsScriptBits::decode(data_); } |  | 
|   25     void set_embeds_script(bool v) { |  | 
|   26       data_ = EmbedsScriptBits::update(data_, v); |  | 
|   27     } |  | 
|   28  |  | 
|   29     uint32_t& RawValue() { return data_; } |  | 
|   30  |  | 
|   31    private: |  | 
|   32     class EmbedsScriptBits : public BitField<bool, 0, 1> {}; |  | 
|   33     uint32_t data_; |  | 
|   34   }; |  | 
|   35  |  | 
|   36   // Initialize the Isolate from the internal snapshot. Returns false if no |   21   // Initialize the Isolate from the internal snapshot. Returns false if no | 
|   37   // snapshot could be found. |   22   // snapshot could be found. | 
|   38   static bool Initialize(Isolate* isolate); |   23   static bool Initialize(Isolate* isolate); | 
|   39   // Create a new context using the internal partial snapshot. |   24   // Create a new context using the internal partial snapshot. | 
|   40   static MaybeHandle<Context> NewContextFromSnapshot( |   25   static MaybeHandle<Context> NewContextFromSnapshot( | 
|   41       Isolate* isolate, Handle<JSGlobalProxy> global_proxy); |   26       Isolate* isolate, Handle<JSGlobalProxy> global_proxy); | 
|   42  |   27  | 
|   43   static bool HaveASnapshotToStartFrom(Isolate* isolate); |   28   static bool HaveASnapshotToStartFrom(Isolate* isolate); | 
|   44  |   29  | 
|   45   static bool EmbedsScript(Isolate* isolate); |   30   static bool EmbedsScript(Isolate* isolate); | 
|   46  |   31  | 
|   47   static uint32_t SizeOfFirstPage(Isolate* isolate, AllocationSpace space); |   32   static uint32_t SizeOfFirstPage(Isolate* isolate, AllocationSpace space); | 
|   48  |   33  | 
|   49  |   34  | 
|   50   // To be implemented by the snapshot source. |   35   // To be implemented by the snapshot source. | 
|   51   static const v8::StartupData* DefaultSnapshotBlob(); |   36   static const v8::StartupData* DefaultSnapshotBlob(); | 
|   52  |   37  | 
|   53   static v8::StartupData CreateSnapshotBlob( |   38   static v8::StartupData CreateSnapshotBlob( | 
|   54       const StartupSerializer& startup_ser, |   39       const StartupSerializer& startup_ser, | 
|   55       const PartialSerializer& context_ser, Snapshot::Metadata metadata); |   40       const PartialSerializer& context_ser); | 
|   56  |   41  | 
|   57 #ifdef DEBUG |   42 #ifdef DEBUG | 
|   58   static bool SnapshotIsValid(v8::StartupData* snapshot_blob); |   43   static bool SnapshotIsValid(v8::StartupData* snapshot_blob); | 
|   59 #endif  // DEBUG |   44 #endif  // DEBUG | 
|   60  |   45  | 
|   61  private: |   46  private: | 
|   62   static Vector<const byte> ExtractStartupData(const v8::StartupData* data); |   47   static Vector<const byte> ExtractStartupData(const v8::StartupData* data); | 
|   63   static Vector<const byte> ExtractContextData(const v8::StartupData* data); |   48   static Vector<const byte> ExtractContextData(const v8::StartupData* data); | 
|   64   static Metadata ExtractMetadata(const v8::StartupData* data); |  | 
|   65  |   49  | 
|   66   // Snapshot blob layout: |   50   // Snapshot blob layout: | 
|   67   // [0] metadata |   51   // [0 - 5] pre-calculated first page sizes for paged spaces | 
|   68   // [1 - 6] pre-calculated first page sizes for paged spaces |   52   // [6] serialized start up data length | 
|   69   // [7] serialized start up data length |  | 
|   70   // ... serialized start up data |   53   // ... serialized start up data | 
|   71   // ... serialized context data |   54   // ... serialized context data | 
|   72  |   55  | 
|   73   static const int kNumPagedSpaces = LAST_PAGED_SPACE - FIRST_PAGED_SPACE + 1; |   56   static const int kNumPagedSpaces = LAST_PAGED_SPACE - FIRST_PAGED_SPACE + 1; | 
|   74  |   57  | 
|   75   static const int kMetadataOffset = 0; |   58   static const int kFirstPageSizesOffset = 0; | 
|   76   static const int kFirstPageSizesOffset = kMetadataOffset + kInt32Size; |  | 
|   77   static const int kStartupLengthOffset = |   59   static const int kStartupLengthOffset = | 
|   78       kFirstPageSizesOffset + kNumPagedSpaces * kInt32Size; |   60       kFirstPageSizesOffset + kNumPagedSpaces * kInt32Size; | 
|   79   static const int kStartupDataOffset = kStartupLengthOffset + kInt32Size; |   61   static const int kStartupDataOffset = kStartupLengthOffset + kInt32Size; | 
|   80  |   62  | 
|   81   static int ContextOffset(int startup_length) { |   63   static int ContextOffset(int startup_length) { | 
|   82     return kStartupDataOffset + startup_length; |   64     return kStartupDataOffset + startup_length; | 
|   83   } |   65   } | 
|   84  |   66  | 
|   85   DISALLOW_IMPLICIT_CONSTRUCTORS(Snapshot); |   67   DISALLOW_IMPLICIT_CONSTRUCTORS(Snapshot); | 
|   86 }; |   68 }; | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  121   static const int kCheckSumOffset = kMagicNumberOffset + kInt32Size; |  103   static const int kCheckSumOffset = kMagicNumberOffset + kInt32Size; | 
|  122   static const int kNumReservationsOffset = kCheckSumOffset + kInt32Size; |  104   static const int kNumReservationsOffset = kCheckSumOffset + kInt32Size; | 
|  123   static const int kPayloadLengthOffset = kNumReservationsOffset + kInt32Size; |  105   static const int kPayloadLengthOffset = kNumReservationsOffset + kInt32Size; | 
|  124   static const int kHeaderSize = kPayloadLengthOffset + kInt32Size; |  106   static const int kHeaderSize = kPayloadLengthOffset + kInt32Size; | 
|  125 }; |  107 }; | 
|  126  |  108  | 
|  127 }  // namespace internal |  109 }  // namespace internal | 
|  128 }  // namespace v8 |  110 }  // namespace v8 | 
|  129  |  111  | 
|  130 #endif  // V8_SNAPSHOT_SNAPSHOT_H_ |  112 #endif  // V8_SNAPSHOT_SNAPSHOT_H_ | 
| OLD | NEW |