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

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

Issue 2629853004: [wasm] Skip serialization of breakpoints and certion stubs (Closed)
Patch Set: Move implementation to .cc file Created 3 years, 11 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/wasm-module.cc » ('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"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 if (result->script()->IsScript()) { 222 if (result->script()->IsScript()) {
223 Script* script = Script::cast(result->script()); 223 Script* script = Script::cast(result->script());
224 if (script->name()->IsString()) name = String::cast(script->name()); 224 if (script->name()->IsString()) name = String::cast(script->name());
225 } 225 }
226 PROFILE(isolate, CodeCreateEvent(CodeEventListener::SCRIPT_TAG, 226 PROFILE(isolate, CodeCreateEvent(CodeEventListener::SCRIPT_TAG,
227 result->abstract_code(), *result, name)); 227 result->abstract_code(), *result, name));
228 } 228 }
229 return scope.CloseAndEscape(result); 229 return scope.CloseAndEscape(result);
230 } 230 }
231 231
232 WasmCompiledModuleSerializer::WasmCompiledModuleSerializer(
233 Isolate* isolate, uint32_t source_hash, Handle<Context> native_context,
234 Handle<SeqOneByteString> module_bytes)
235 : CodeSerializer(isolate, source_hash) {
236 reference_map()->AddAttachedReference(*isolate->native_context());
237 reference_map()->AddAttachedReference(*module_bytes);
238 }
239
232 std::unique_ptr<ScriptData> WasmCompiledModuleSerializer::SerializeWasmModule( 240 std::unique_ptr<ScriptData> WasmCompiledModuleSerializer::SerializeWasmModule(
233 Isolate* isolate, Handle<FixedArray> input) { 241 Isolate* isolate, Handle<FixedArray> input) {
234 Handle<WasmCompiledModule> compiled_module = 242 Handle<WasmCompiledModule> compiled_module =
235 Handle<WasmCompiledModule>::cast(input); 243 Handle<WasmCompiledModule>::cast(input);
236 WasmCompiledModuleSerializer wasm_cs(isolate, 0); 244 WasmCompiledModuleSerializer wasm_cs(isolate, 0, isolate->native_context(),
237 wasm_cs.reference_map()->AddAttachedReference(*isolate->native_context()); 245 handle(compiled_module->module_bytes()));
238 wasm_cs.reference_map()->AddAttachedReference(
239 compiled_module->module_bytes());
240 ScriptData* data = wasm_cs.Serialize(compiled_module); 246 ScriptData* data = wasm_cs.Serialize(compiled_module);
241 return std::unique_ptr<ScriptData>(data); 247 return std::unique_ptr<ScriptData>(data);
242 } 248 }
243 249
244 MaybeHandle<FixedArray> WasmCompiledModuleSerializer::DeserializeWasmModule( 250 MaybeHandle<FixedArray> WasmCompiledModuleSerializer::DeserializeWasmModule(
245 Isolate* isolate, ScriptData* data, Vector<const byte> wire_bytes) { 251 Isolate* isolate, ScriptData* data, Vector<const byte> wire_bytes) {
246 SerializedCodeData::SanityCheckResult sanity_check_result = 252 SerializedCodeData::SanityCheckResult sanity_check_result =
247 SerializedCodeData::CHECK_SUCCESS; 253 SerializedCodeData::CHECK_SUCCESS;
248 MaybeHandle<FixedArray> nothing; 254 MaybeHandle<FixedArray> nothing;
249 const SerializedCodeData scd = SerializedCodeData::FromCachedData( 255 const SerializedCodeData scd = SerializedCodeData::FromCachedData(
(...skipping 20 matching lines...) Expand all
270 deserializer.AddAttachedObject( 276 deserializer.AddAttachedObject(
271 CodeStub::GetCode(isolate, stub_keys[i]).ToHandleChecked()); 277 CodeStub::GetCode(isolate, stub_keys[i]).ToHandleChecked());
272 } 278 }
273 279
274 MaybeHandle<HeapObject> obj = deserializer.DeserializeObject(isolate); 280 MaybeHandle<HeapObject> obj = deserializer.DeserializeObject(isolate);
275 if (obj.is_null() || !obj.ToHandleChecked()->IsFixedArray()) return nothing; 281 if (obj.is_null() || !obj.ToHandleChecked()->IsFixedArray()) return nothing;
276 // Cast without type checks, as the module wrapper is not there yet. 282 // Cast without type checks, as the module wrapper is not there yet.
277 Handle<WasmCompiledModule> compiled_module( 283 Handle<WasmCompiledModule> compiled_module(
278 static_cast<WasmCompiledModule*>(*obj.ToHandleChecked()), isolate); 284 static_cast<WasmCompiledModule*>(*obj.ToHandleChecked()), isolate);
279 285
280 WasmCompiledModule::RecreateModuleWrapper(isolate, compiled_module); 286 WasmCompiledModule::ReinitializeAfterDeserialization(isolate,
287 compiled_module);
281 DCHECK(WasmCompiledModule::IsWasmCompiledModule(*compiled_module)); 288 DCHECK(WasmCompiledModule::IsWasmCompiledModule(*compiled_module));
282 return compiled_module; 289 return compiled_module;
283 } 290 }
284 291
292 void WasmCompiledModuleSerializer::SerializeCodeObject(
293 Code* code_object, HowToCode how_to_code, WhereToPoint where_to_point) {
294 Code::Kind kind = code_object->kind();
295 switch (kind) {
296 case Code::WASM_FUNCTION:
297 case Code::JS_TO_WASM_FUNCTION:
298 // Just serialize the code_object.
299 break;
300 case Code::WASM_TO_JS_FUNCTION:
301 // Serialize the illegal builtin instead. On instantiation of a
302 // deserialized module, these will be replaced again.
303 code_object = *isolate()->builtins()->Illegal();
304 break;
305 default:
306 UNREACHABLE();
307 }
308 SerializeGeneric(code_object, how_to_code, where_to_point);
309 }
310
311 bool WasmCompiledModuleSerializer::ElideObject(Object* obj) {
312 return obj->IsWeakCell() || obj->IsForeign() || obj->IsBreakPointInfo();
313 }
314
285 class Checksum { 315 class Checksum {
286 public: 316 public:
287 explicit Checksum(Vector<const byte> payload) { 317 explicit Checksum(Vector<const byte> payload) {
288 #ifdef MEMORY_SANITIZER 318 #ifdef MEMORY_SANITIZER
289 // Computing the checksum includes padding bytes for objects like strings. 319 // Computing the checksum includes padding bytes for objects like strings.
290 // Mark every object as initialized in the code serializer. 320 // Mark every object as initialized in the code serializer.
291 MSAN_MEMORY_IS_INITIALIZED(payload.start(), payload.length()); 321 MSAN_MEMORY_IS_INITIALIZED(payload.start(), payload.length());
292 #endif // MEMORY_SANITIZER 322 #endif // MEMORY_SANITIZER
293 // Fletcher's checksum. Modified to reduce 64-bit sums to 32-bit. 323 // Fletcher's checksum. Modified to reduce 64-bit sums to 32-bit.
294 uintptr_t a = 1; 324 uintptr_t a = 1;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 *rejection_result = scd.SanityCheck(isolate, expected_source_hash); 472 *rejection_result = scd.SanityCheck(isolate, expected_source_hash);
443 if (*rejection_result != CHECK_SUCCESS) { 473 if (*rejection_result != CHECK_SUCCESS) {
444 cached_data->Reject(); 474 cached_data->Reject();
445 return SerializedCodeData(nullptr, 0); 475 return SerializedCodeData(nullptr, 0);
446 } 476 }
447 return scd; 477 return scd;
448 } 478 }
449 479
450 } // namespace internal 480 } // namespace internal
451 } // namespace v8 481 } // namespace v8
OLDNEW
« no previous file with comments | « src/snapshot/code-serializer.h ('k') | src/wasm/wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698