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

Side by Side Diff: src/snapshot/code-serializer.cc

Issue 2424623002: [wasm] Use a Managed<WasmModule> to hold metadata about modules. (Closed)
Patch Set: [wasm] Use a Managed<WasmModule> to hold metadata about modules. Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « src/snapshot/code-serializer.h ('k') | src/wasm/managed.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "src/snapshot/code-serializer.h" 5 #include "src/snapshot/code-serializer.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/log.h" 10 #include "src/log.h"
11 #include "src/macro-assembler.h" 11 #include "src/macro-assembler.h"
12 #include "src/snapshot/deserializer.h" 12 #include "src/snapshot/deserializer.h"
13 #include "src/snapshot/snapshot.h" 13 #include "src/snapshot/snapshot.h"
14 #include "src/version.h" 14 #include "src/version.h"
15 #include "src/wasm/wasm-module.h"
15 16
16 namespace v8 { 17 namespace v8 {
17 namespace internal { 18 namespace internal {
18 19
19 ScriptData* CodeSerializer::Serialize(Isolate* isolate, 20 ScriptData* CodeSerializer::Serialize(Isolate* isolate,
20 Handle<SharedFunctionInfo> info, 21 Handle<SharedFunctionInfo> info,
21 Handle<String> source) { 22 Handle<String> source) {
22 base::ElapsedTimer timer; 23 base::ElapsedTimer timer;
23 if (FLAG_profile_deserialization) timer.Start(); 24 if (FLAG_profile_deserialization) timer.Start();
24 if (FLAG_trace_serializer) { 25 if (FLAG_trace_serializer) {
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 Script* script = Script::cast(result->script()); 211 Script* script = Script::cast(result->script());
211 if (script->name()->IsString()) name = String::cast(script->name()); 212 if (script->name()->IsString()) name = String::cast(script->name());
212 } 213 }
213 PROFILE(isolate, CodeCreateEvent(CodeEventListener::SCRIPT_TAG, 214 PROFILE(isolate, CodeCreateEvent(CodeEventListener::SCRIPT_TAG,
214 result->abstract_code(), *result, name)); 215 result->abstract_code(), *result, name));
215 } 216 }
216 return scope.CloseAndEscape(result); 217 return scope.CloseAndEscape(result);
217 } 218 }
218 219
219 std::unique_ptr<ScriptData> WasmCompiledModuleSerializer::SerializeWasmModule( 220 std::unique_ptr<ScriptData> WasmCompiledModuleSerializer::SerializeWasmModule(
220 Isolate* isolate, Handle<FixedArray> compiled_module) { 221 Isolate* isolate, Handle<FixedArray> input) {
222 Handle<wasm::WasmCompiledModule> compiled_module =
223 Handle<wasm::WasmCompiledModule>::cast(input);
221 WasmCompiledModuleSerializer wasm_cs(isolate, 0); 224 WasmCompiledModuleSerializer wasm_cs(isolate, 0);
222 wasm_cs.reference_map()->AddAttachedReference(*isolate->native_context()); 225 wasm_cs.reference_map()->AddAttachedReference(*isolate->native_context());
223 ScriptData* data = wasm_cs.Serialize(compiled_module); 226 ScriptData* data = wasm_cs.Serialize(compiled_module);
224 return std::unique_ptr<ScriptData>(data); 227 return std::unique_ptr<ScriptData>(data);
225 } 228 }
226 229
227 MaybeHandle<FixedArray> WasmCompiledModuleSerializer::DeserializeWasmModule( 230 MaybeHandle<FixedArray> WasmCompiledModuleSerializer::DeserializeWasmModule(
228 Isolate* isolate, ScriptData* data) { 231 Isolate* isolate, ScriptData* data) {
229 SerializedCodeData::SanityCheckResult sanity_check_result = 232 SerializedCodeData::SanityCheckResult sanity_check_result =
230 SerializedCodeData::CHECK_SUCCESS; 233 SerializedCodeData::CHECK_SUCCESS;
231 MaybeHandle<FixedArray> nothing; 234 MaybeHandle<FixedArray> nothing;
232 const SerializedCodeData scd = SerializedCodeData::FromCachedData( 235 const SerializedCodeData scd = SerializedCodeData::FromCachedData(
233 isolate, data, 0, &sanity_check_result); 236 isolate, data, 0, &sanity_check_result);
234 237
235 if (sanity_check_result != SerializedCodeData::CHECK_SUCCESS) { 238 if (sanity_check_result != SerializedCodeData::CHECK_SUCCESS) {
236 return nothing; 239 return nothing;
237 } 240 }
238 241
239 Deserializer deserializer(&scd, true); 242 Deserializer deserializer(&scd, true);
240 deserializer.AddAttachedObject(isolate->native_context()); 243 deserializer.AddAttachedObject(isolate->native_context());
241 244
242 Vector<const uint32_t> stub_keys = scd.CodeStubKeys(); 245 Vector<const uint32_t> stub_keys = scd.CodeStubKeys();
243 for (int i = 0; i < stub_keys.length(); ++i) { 246 for (int i = 0; i < stub_keys.length(); ++i) {
244 deserializer.AddAttachedObject( 247 deserializer.AddAttachedObject(
245 CodeStub::GetCode(isolate, stub_keys[i]).ToHandleChecked()); 248 CodeStub::GetCode(isolate, stub_keys[i]).ToHandleChecked());
246 } 249 }
247 250
248 MaybeHandle<HeapObject> obj = deserializer.DeserializeObject(isolate); 251 MaybeHandle<HeapObject> obj = deserializer.DeserializeObject(isolate);
249 if (obj.is_null() || !obj.ToHandleChecked()->IsFixedArray()) return nothing; 252 if (obj.is_null() || !obj.ToHandleChecked()->IsFixedArray()) return nothing;
250 return Handle<FixedArray>::cast(obj.ToHandleChecked()); 253 Handle<FixedArray> compiled_module =
254 Handle<FixedArray>::cast(obj.ToHandleChecked());
255 wasm::WasmCompiledModule::RecreateModuleWrapper(isolate, compiled_module);
256 return compiled_module;
251 } 257 }
252 258
253 class Checksum { 259 class Checksum {
254 public: 260 public:
255 explicit Checksum(Vector<const byte> payload) { 261 explicit Checksum(Vector<const byte> payload) {
256 #ifdef MEMORY_SANITIZER 262 #ifdef MEMORY_SANITIZER
257 // Computing the checksum includes padding bytes for objects like strings. 263 // Computing the checksum includes padding bytes for objects like strings.
258 // Mark every object as initialized in the code serializer. 264 // Mark every object as initialized in the code serializer.
259 MSAN_MEMORY_IS_INITIALIZED(payload.start(), payload.length()); 265 MSAN_MEMORY_IS_INITIALIZED(payload.start(), payload.length());
260 #endif // MEMORY_SANITIZER 266 #endif // MEMORY_SANITIZER
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 *rejection_result = scd.SanityCheck(isolate, expected_source_hash); 416 *rejection_result = scd.SanityCheck(isolate, expected_source_hash);
411 if (*rejection_result != CHECK_SUCCESS) { 417 if (*rejection_result != CHECK_SUCCESS) {
412 cached_data->Reject(); 418 cached_data->Reject();
413 return SerializedCodeData(nullptr, 0); 419 return SerializedCodeData(nullptr, 0);
414 } 420 }
415 return scd; 421 return scd;
416 } 422 }
417 423
418 } // namespace internal 424 } // namespace internal
419 } // namespace v8 425 } // namespace v8
OLDNEW
« no previous file with comments | « src/snapshot/code-serializer.h ('k') | src/wasm/managed.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698