| 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 #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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 Handle<WasmCompiledModule> compiled_module = | 242 Handle<WasmCompiledModule> compiled_module = |
| 243 Handle<WasmCompiledModule>::cast(input); | 243 Handle<WasmCompiledModule>::cast(input); |
| 244 WasmCompiledModuleSerializer wasm_cs(isolate, 0, isolate->native_context(), | 244 WasmCompiledModuleSerializer wasm_cs(isolate, 0, isolate->native_context(), |
| 245 handle(compiled_module->module_bytes())); | 245 handle(compiled_module->module_bytes())); |
| 246 ScriptData* data = wasm_cs.Serialize(compiled_module); | 246 ScriptData* data = wasm_cs.Serialize(compiled_module); |
| 247 return std::unique_ptr<ScriptData>(data); | 247 return std::unique_ptr<ScriptData>(data); |
| 248 } | 248 } |
| 249 | 249 |
| 250 MaybeHandle<FixedArray> WasmCompiledModuleSerializer::DeserializeWasmModule( | 250 MaybeHandle<FixedArray> WasmCompiledModuleSerializer::DeserializeWasmModule( |
| 251 Isolate* isolate, ScriptData* data, Vector<const byte> wire_bytes) { | 251 Isolate* isolate, ScriptData* data, Vector<const byte> wire_bytes) { |
| 252 MaybeHandle<FixedArray> nothing; |
| 253 if (!wasm::IsWasmCodegenAllowed(isolate, isolate->native_context())) { |
| 254 return nothing; |
| 255 } |
| 252 SerializedCodeData::SanityCheckResult sanity_check_result = | 256 SerializedCodeData::SanityCheckResult sanity_check_result = |
| 253 SerializedCodeData::CHECK_SUCCESS; | 257 SerializedCodeData::CHECK_SUCCESS; |
| 254 MaybeHandle<FixedArray> nothing; | 258 |
| 255 const SerializedCodeData scd = SerializedCodeData::FromCachedData( | 259 const SerializedCodeData scd = SerializedCodeData::FromCachedData( |
| 256 isolate, data, 0, &sanity_check_result); | 260 isolate, data, 0, &sanity_check_result); |
| 257 | 261 |
| 258 if (sanity_check_result != SerializedCodeData::CHECK_SUCCESS) { | 262 if (sanity_check_result != SerializedCodeData::CHECK_SUCCESS) { |
| 259 return nothing; | 263 return nothing; |
| 260 } | 264 } |
| 261 | 265 |
| 262 Deserializer deserializer(&scd, true); | 266 Deserializer deserializer(&scd, true); |
| 263 deserializer.AddAttachedObject(isolate->native_context()); | 267 deserializer.AddAttachedObject(isolate->native_context()); |
| 264 | 268 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 *rejection_result = scd.SanityCheck(isolate, expected_source_hash); | 476 *rejection_result = scd.SanityCheck(isolate, expected_source_hash); |
| 473 if (*rejection_result != CHECK_SUCCESS) { | 477 if (*rejection_result != CHECK_SUCCESS) { |
| 474 cached_data->Reject(); | 478 cached_data->Reject(); |
| 475 return SerializedCodeData(nullptr, 0); | 479 return SerializedCodeData(nullptr, 0); |
| 476 } | 480 } |
| 477 return scd; | 481 return scd; |
| 478 } | 482 } |
| 479 | 483 |
| 480 } // namespace internal | 484 } // namespace internal |
| 481 } // namespace v8 | 485 } // namespace v8 |
| OLD | NEW |