| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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_CODE_SERIALIZER_H_ | 5 #ifndef V8_SNAPSHOT_CODE_SERIALIZER_H_ |
| 6 #define V8_SNAPSHOT_CODE_SERIALIZER_H_ | 6 #define V8_SNAPSHOT_CODE_SERIALIZER_H_ |
| 7 | 7 |
| 8 #include "src/parsing/preparse-data.h" | 8 #include "src/parsing/preparse-data.h" |
| 9 #include "src/snapshot/serializer.h" | 9 #include "src/snapshot/serializer.h" |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 class WasmCompiledModuleSerializer : public CodeSerializer { | 58 class WasmCompiledModuleSerializer : public CodeSerializer { |
| 59 public: | 59 public: |
| 60 static std::unique_ptr<ScriptData> SerializeWasmModule( | 60 static std::unique_ptr<ScriptData> SerializeWasmModule( |
| 61 Isolate* isolate, Handle<FixedArray> compiled_module); | 61 Isolate* isolate, Handle<FixedArray> compiled_module); |
| 62 static MaybeHandle<FixedArray> DeserializeWasmModule( | 62 static MaybeHandle<FixedArray> DeserializeWasmModule( |
| 63 Isolate* isolate, ScriptData* data, Vector<const byte> wire_bytes); | 63 Isolate* isolate, ScriptData* data, Vector<const byte> wire_bytes); |
| 64 | 64 |
| 65 protected: | 65 protected: |
| 66 void SerializeCodeObject(Code* code_object, HowToCode how_to_code, | 66 void SerializeCodeObject(Code* code_object, HowToCode how_to_code, |
| 67 WhereToPoint where_to_point) override { | 67 WhereToPoint where_to_point) override; |
| 68 Code::Kind kind = code_object->kind(); | 68 bool ElideObject(Object* obj) override; |
| 69 if (kind == Code::WASM_FUNCTION || kind == Code::WASM_TO_JS_FUNCTION || | |
| 70 kind == Code::JS_TO_WASM_FUNCTION) { | |
| 71 SerializeGeneric(code_object, how_to_code, where_to_point); | |
| 72 } else { | |
| 73 UNREACHABLE(); | |
| 74 } | |
| 75 } | |
| 76 | |
| 77 bool ElideObject(Object* obj) override { | |
| 78 return obj->IsWeakCell() || obj->IsForeign(); | |
| 79 }; | |
| 80 | 69 |
| 81 private: | 70 private: |
| 82 WasmCompiledModuleSerializer(Isolate* isolate, uint32_t source_hash) | 71 WasmCompiledModuleSerializer(Isolate* isolate, uint32_t source_hash, |
| 83 : CodeSerializer(isolate, source_hash) {} | 72 Handle<Context> native_context, |
| 73 Handle<SeqOneByteString> module_bytes); |
| 84 DISALLOW_COPY_AND_ASSIGN(WasmCompiledModuleSerializer); | 74 DISALLOW_COPY_AND_ASSIGN(WasmCompiledModuleSerializer); |
| 85 }; | 75 }; |
| 86 | 76 |
| 87 // Wrapper around ScriptData to provide code-serializer-specific functionality. | 77 // Wrapper around ScriptData to provide code-serializer-specific functionality. |
| 88 class SerializedCodeData : public SerializedData { | 78 class SerializedCodeData : public SerializedData { |
| 89 public: | 79 public: |
| 90 enum SanityCheckResult { | 80 enum SanityCheckResult { |
| 91 CHECK_SUCCESS = 0, | 81 CHECK_SUCCESS = 0, |
| 92 MAGIC_NUMBER_MISMATCH = 1, | 82 MAGIC_NUMBER_MISMATCH = 1, |
| 93 VERSION_MISMATCH = 2, | 83 VERSION_MISMATCH = 2, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } | 141 } |
| 152 | 142 |
| 153 SanityCheckResult SanityCheck(Isolate* isolate, | 143 SanityCheckResult SanityCheck(Isolate* isolate, |
| 154 uint32_t expected_source_hash) const; | 144 uint32_t expected_source_hash) const; |
| 155 }; | 145 }; |
| 156 | 146 |
| 157 } // namespace internal | 147 } // namespace internal |
| 158 } // namespace v8 | 148 } // namespace v8 |
| 159 | 149 |
| 160 #endif // V8_SNAPSHOT_CODE_SERIALIZER_H_ | 150 #endif // V8_SNAPSHOT_CODE_SERIALIZER_H_ |
| OLD | NEW |