Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Unified Diff: src/snapshot/code-serializer.h

Issue 2205973003: [wasm] Serialization/Deserialization of compiled module (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix silly bug Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/snapshot/code-serializer.h
diff --git a/src/snapshot/code-serializer.h b/src/snapshot/code-serializer.h
index 19489396b4641434541cfb715ecb6f6479acdc65..e1bc90b2665daa3bd8f8f540773aa390c73ef5e6 100644
--- a/src/snapshot/code-serializer.h
+++ b/src/snapshot/code-serializer.h
@@ -13,28 +13,24 @@ namespace internal {
class CodeSerializer : public Serializer {
public:
+ explicit CodeSerializer(Isolate* isolate, uint32_t source_hash)
+ : Serializer(isolate), source_hash_(source_hash) {}
+ ~CodeSerializer() override { OutputStatistics("CodeSerializer"); }
+
static ScriptData* Serialize(Isolate* isolate,
Handle<SharedFunctionInfo> info,
Handle<String> source);
+ ScriptData* Serialize(Handle<HeapObject> obj);
+
MUST_USE_RESULT static MaybeHandle<SharedFunctionInfo> Deserialize(
Isolate* isolate, ScriptData* cached_data, Handle<String> source);
- String* source() const {
- DCHECK(!AllowHeapAllocation::IsAllowed());
- return source_;
- }
-
const List<uint32_t>* stub_keys() const { return &stub_keys_; }
- private:
- CodeSerializer(Isolate* isolate, String* source)
- : Serializer(isolate), source_(source) {
- reference_map_.AddAttachedReference(source);
- }
-
- ~CodeSerializer() override { OutputStatistics("CodeSerializer"); }
+ uint32_t source_hash() const { return source_hash_; }
+ private:
void SerializeObject(HeapObject* o, HowToCode how_to_code,
WhereToPoint where_to_point, int skip) override;
@@ -46,18 +42,28 @@ class CodeSerializer : public Serializer {
WhereToPoint where_to_point);
DisallowHeapAllocation no_gc_;
- String* source_;
+ uint32_t source_hash_;
List<uint32_t> stub_keys_;
DISALLOW_COPY_AND_ASSIGN(CodeSerializer);
};
+enum SanityCheckResult {
Yang 2016/08/05 12:04:17 Can we keep this in SerializedCodeData? We can mak
Mircea Trofin 2016/08/05 15:01:29 Acknowledged.
Mircea Trofin 2016/08/06 00:31:39 Done.
+ CHECK_SUCCESS = 0,
+ MAGIC_NUMBER_MISMATCH = 1,
+ VERSION_MISMATCH = 2,
+ SOURCE_MISMATCH = 3,
+ CPU_FEATURES_MISMATCH = 4,
+ FLAGS_MISMATCH = 5,
+ CHECKSUM_MISMATCH = 6
+};
+
// Wrapper around ScriptData to provide code-serializer-specific functionality.
class SerializedCodeData : public SerializedData {
public:
// Used when consuming.
- static SerializedCodeData* FromCachedData(Isolate* isolate,
- ScriptData* cached_data,
- String* source);
+ static const SerializedCodeData FromCachedData(
+ Isolate* isolate, ScriptData* cached_data, uint32_t expected_source_hash,
+ SanityCheckResult* rejection_result);
// Used when producing.
SerializedCodeData(const List<byte>* payload, const CodeSerializer* cs);
@@ -70,23 +76,15 @@ class SerializedCodeData : public SerializedData {
Vector<const uint32_t> CodeStubKeys() const;
+ static uint32_t SourceHash(Handle<String> source);
+
private:
explicit SerializedCodeData(ScriptData* data);
+ SerializedCodeData(const byte* data, int size)
+ : SerializedData(const_cast<byte*>(data), size) {}
- enum SanityCheckResult {
- CHECK_SUCCESS = 0,
- MAGIC_NUMBER_MISMATCH = 1,
- VERSION_MISMATCH = 2,
- SOURCE_MISMATCH = 3,
- CPU_FEATURES_MISMATCH = 4,
- FLAGS_MISMATCH = 5,
- CHECKSUM_MISMATCH = 6
- };
-
- SanityCheckResult SanityCheck(Isolate* isolate, String* source) const;
-
- uint32_t SourceHash(String* source) const;
-
+ SanityCheckResult SanityCheck(Isolate* isolate,
+ uint32_t expected_source_hash) const;
// The data header consists of uint32_t-sized entries:
// [0] magic number and external reference count
// [1] version hash

Powered by Google App Engine
This is Rietveld 408576698