| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/api.h" | 5 #include "src/api.h" |
| 6 | 6 |
| 7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
| 8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
| 9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
| 10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 data->contexts_.Clear(); | 462 data->contexts_.Clear(); |
| 463 | 463 |
| 464 i::SnapshotByteSink snapshot_sink; | 464 i::SnapshotByteSink snapshot_sink; |
| 465 i::StartupSerializer startup_serializer(isolate, &snapshot_sink, | 465 i::StartupSerializer startup_serializer(isolate, &snapshot_sink, |
| 466 function_code_handling); | 466 function_code_handling); |
| 467 startup_serializer.SerializeStrongReferences(); | 467 startup_serializer.SerializeStrongReferences(); |
| 468 | 468 |
| 469 i::SnapshotByteSink context_sink; | 469 i::SnapshotByteSink context_sink; |
| 470 i::PartialSerializer context_serializer(isolate, &startup_serializer, | 470 i::PartialSerializer context_serializer(isolate, &startup_serializer, |
| 471 &context_sink); | 471 &context_sink); |
| 472 // TODO(yangguo): support multiple contexts in the snapshot. | |
| 473 DCHECK_EQ(1, contexts.length()); | |
| 474 context_serializer.Serialize(&contexts[0]); | 472 context_serializer.Serialize(&contexts[0]); |
| 475 startup_serializer.SerializeWeakReferencesAndDeferred(); | 473 startup_serializer.SerializeWeakReferencesAndDeferred(); |
| 476 | 474 |
| 477 data->created_ = true; | 475 data->created_ = true; |
| 478 return i::Snapshot::CreateSnapshotBlob(startup_serializer, | 476 return i::Snapshot::CreateSnapshotBlob(&startup_serializer, |
| 479 context_serializer); | 477 &context_serializer); |
| 480 } | 478 } |
| 481 | 479 |
| 482 StartupData V8::CreateSnapshotDataBlob(const char* embedded_source) { | 480 StartupData V8::CreateSnapshotDataBlob(const char* embedded_source) { |
| 483 // Create a new isolate and a new context from scratch, optionally run | 481 // Create a new isolate and a new context from scratch, optionally run |
| 484 // a script to embed, and serialize to create a snapshot blob. | 482 // a script to embed, and serialize to create a snapshot blob. |
| 485 StartupData result = {nullptr, 0}; | 483 StartupData result = {nullptr, 0}; |
| 486 base::ElapsedTimer timer; | 484 base::ElapsedTimer timer; |
| 487 timer.Start(); | 485 timer.Start(); |
| 488 { | 486 { |
| 489 SnapshotCreator snapshot_creator; | 487 SnapshotCreator snapshot_creator; |
| (...skipping 8313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8803 Address callback_address = | 8801 Address callback_address = |
| 8804 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8802 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8805 VMState<EXTERNAL> state(isolate); | 8803 VMState<EXTERNAL> state(isolate); |
| 8806 ExternalCallbackScope call_scope(isolate, callback_address); | 8804 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8807 callback(info); | 8805 callback(info); |
| 8808 } | 8806 } |
| 8809 | 8807 |
| 8810 | 8808 |
| 8811 } // namespace internal | 8809 } // namespace internal |
| 8812 } // namespace v8 | 8810 } // namespace v8 |
| OLD | NEW |