@@ -188,7 +188,7 @@ class SnapshotSerializerDeserializer {
188188
189189class SnapshotDeserializer : public SnapshotSerializerDeserializer {
190190 public:
191- explicit SnapshotDeserializer (const std::vector< char >& s)
191+ explicit SnapshotDeserializer (const std::string_view s)
192192 : SnapshotSerializerDeserializer(), sink(s) {}
193193 ~SnapshotDeserializer () {}
194194
@@ -247,7 +247,7 @@ class SnapshotDeserializer : public SnapshotSerializerDeserializer {
247247 }
248248
249249 size_t read_total = 0 ;
250- const std::vector< char >& sink;
250+ const std::string_view sink;
251251
252252 private:
253253 // Helper for reading an array of numeric types.
@@ -884,10 +884,19 @@ bool SnapshotData::FromFile(SnapshotData* out, FILE* in) {
884884}
885885
886886bool SnapshotData::FromBlob (SnapshotData* out, const std::vector<char >& in) {
887+ return FromBlob (out, std::string_view (in.data (), in.size ()));
888+ }
889+
890+ bool SnapshotData::FromBlob (SnapshotData* out, const std::string_view in) {
887891 SnapshotDeserializer r (in);
888892 r.Debug (" SnapshotData::FromBlob()\n " );
889893
890894 DCHECK_EQ (out->data_ownership , SnapshotData::DataOwnership::kOwned );
895+ // For now we don't serialize this bit.
896+ // XXX(joyeecheung): should we require snapshots being injected into
897+ // SEA to be explicitly built for SEA, and check this bit at SEA
898+ // start up?
899+ DCHECK_EQ (out->is_for_sea , SnapshotData::IsForSea::kDefault );
891900
892901 // Metadata
893902 uint32_t magic = r.Read <uint32_t >();
@@ -910,6 +919,11 @@ bool SnapshotData::FromBlob(SnapshotData* out, const std::vector<char>& in) {
910919 return true ;
911920}
912921
922+ bool SnapshotData::IsSnapshotBlob (const std::string_view data) {
923+ const uint32_t * ptr = reinterpret_cast <const uint32_t *>(data.data ());
924+ return (ptr[0 ] == kMagic );
925+ }
926+
913927bool SnapshotData::Check () const {
914928 if (metadata.node_version != per_process::metadata.versions .node ) {
915929 fprintf (stderr,
@@ -1041,6 +1055,9 @@ static const int v8_snapshot_blob_size = )"
10411055 // -- data_ownership begins --
10421056 SnapshotData::DataOwnership::kNotOwned,
10431057 // -- data_ownership ends --
1058+ // -- is_for_sea begins --
1059+ SnapshotData::IsForSea::kDefault,
1060+ // -- is_for_sea ends --
10441061 // -- metadata begins --
10451062)" << data->metadata
10461063 << R"( ,
0 commit comments