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 18 matching lines...) Expand all Loading... |
29 protected: | 29 protected: |
30 explicit CodeSerializer(Isolate* isolate, uint32_t source_hash) | 30 explicit CodeSerializer(Isolate* isolate, uint32_t source_hash) |
31 : Serializer(isolate), source_hash_(source_hash) {} | 31 : Serializer(isolate), source_hash_(source_hash) {} |
32 ~CodeSerializer() override { OutputStatistics("CodeSerializer"); } | 32 ~CodeSerializer() override { OutputStatistics("CodeSerializer"); } |
33 | 33 |
34 virtual void SerializeCodeObject(Code* code_object, HowToCode how_to_code, | 34 virtual void SerializeCodeObject(Code* code_object, HowToCode how_to_code, |
35 WhereToPoint where_to_point) { | 35 WhereToPoint where_to_point) { |
36 UNREACHABLE(); | 36 UNREACHABLE(); |
37 } | 37 } |
38 | 38 |
39 virtual bool SkipOver(Object* obj) { return false; } | |
40 void SerializeGeneric(HeapObject* heap_object, HowToCode how_to_code, | 39 void SerializeGeneric(HeapObject* heap_object, HowToCode how_to_code, |
41 WhereToPoint where_to_point); | 40 WhereToPoint where_to_point); |
42 | 41 |
43 private: | 42 private: |
44 void SerializeObject(HeapObject* o, HowToCode how_to_code, | 43 void SerializeObject(HeapObject* o, HowToCode how_to_code, |
45 WhereToPoint where_to_point, int skip) override; | 44 WhereToPoint where_to_point, int skip) override; |
46 | 45 |
47 void SerializeBuiltin(int builtin_index, HowToCode how_to_code, | 46 void SerializeBuiltin(int builtin_index, HowToCode how_to_code, |
48 WhereToPoint where_to_point); | 47 WhereToPoint where_to_point); |
49 void SerializeCodeStub(Code* code_stub, HowToCode how_to_code, | 48 void SerializeCodeStub(Code* code_stub, HowToCode how_to_code, |
(...skipping 17 matching lines...) Expand all Loading... |
67 WhereToPoint where_to_point) override { | 66 WhereToPoint where_to_point) override { |
68 Code::Kind kind = code_object->kind(); | 67 Code::Kind kind = code_object->kind(); |
69 if (kind == Code::WASM_FUNCTION || kind == Code::WASM_TO_JS_FUNCTION || | 68 if (kind == Code::WASM_FUNCTION || kind == Code::WASM_TO_JS_FUNCTION || |
70 kind == Code::JS_TO_WASM_FUNCTION) { | 69 kind == Code::JS_TO_WASM_FUNCTION) { |
71 SerializeGeneric(code_object, how_to_code, where_to_point); | 70 SerializeGeneric(code_object, how_to_code, where_to_point); |
72 } else { | 71 } else { |
73 UNREACHABLE(); | 72 UNREACHABLE(); |
74 } | 73 } |
75 } | 74 } |
76 | 75 |
77 bool SkipOver(Object* obj) override { return obj->IsWeakCell(); }; | |
78 | |
79 private: | 76 private: |
80 WasmCompiledModuleSerializer(Isolate* isolate, uint32_t source_hash) | 77 WasmCompiledModuleSerializer(Isolate* isolate, uint32_t source_hash) |
81 : CodeSerializer(isolate, source_hash) {} | 78 : CodeSerializer(isolate, source_hash) {} |
82 DISALLOW_COPY_AND_ASSIGN(WasmCompiledModuleSerializer); | 79 DISALLOW_COPY_AND_ASSIGN(WasmCompiledModuleSerializer); |
83 }; | 80 }; |
84 | 81 |
85 // Wrapper around ScriptData to provide code-serializer-specific functionality. | 82 // Wrapper around ScriptData to provide code-serializer-specific functionality. |
86 class SerializedCodeData : public SerializedData { | 83 class SerializedCodeData : public SerializedData { |
87 public: | 84 public: |
88 enum SanityCheckResult { | 85 enum SanityCheckResult { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; | 144 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; |
148 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; | 145 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; |
149 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; | 146 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; |
150 static const int kHeaderSize = kChecksum2Offset + kInt32Size; | 147 static const int kHeaderSize = kChecksum2Offset + kInt32Size; |
151 }; | 148 }; |
152 | 149 |
153 } // namespace internal | 150 } // namespace internal |
154 } // namespace v8 | 151 } // namespace v8 |
155 | 152 |
156 #endif // V8_SNAPSHOT_CODE_SERIALIZER_H_ | 153 #endif // V8_SNAPSHOT_CODE_SERIALIZER_H_ |
OLD | NEW |