| 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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 int num_contexts = static_cast<int>(data->contexts_.Size()); | 552 int num_contexts = static_cast<int>(data->contexts_.Size()); |
| 553 i::List<i::Object*> contexts(num_contexts); | 553 i::List<i::Object*> contexts(num_contexts); |
| 554 for (int i = 0; i < num_contexts; i++) { | 554 for (int i = 0; i < num_contexts; i++) { |
| 555 i::HandleScope scope(isolate); | 555 i::HandleScope scope(isolate); |
| 556 i::Handle<i::Context> context = | 556 i::Handle<i::Context> context = |
| 557 v8::Utils::OpenHandle(*data->contexts_.Get(i)); | 557 v8::Utils::OpenHandle(*data->contexts_.Get(i)); |
| 558 contexts.Add(*context); | 558 contexts.Add(*context); |
| 559 } | 559 } |
| 560 data->contexts_.Clear(); | 560 data->contexts_.Clear(); |
| 561 | 561 |
| 562 #ifdef DEBUG |
| 563 i::ExternalReferenceTable::instance(isolate)->ResetCount(); |
| 564 #endif // DEBUG |
| 565 |
| 562 i::StartupSerializer startup_serializer(isolate, function_code_handling); | 566 i::StartupSerializer startup_serializer(isolate, function_code_handling); |
| 563 startup_serializer.SerializeStrongReferences(); | 567 startup_serializer.SerializeStrongReferences(); |
| 564 | 568 |
| 565 // Serialize each context with a new partial serializer. | 569 // Serialize each context with a new partial serializer. |
| 566 i::List<i::SnapshotData*> context_snapshots(num_contexts); | 570 i::List<i::SnapshotData*> context_snapshots(num_contexts); |
| 567 for (int i = 0; i < num_contexts; i++) { | 571 for (int i = 0; i < num_contexts; i++) { |
| 568 i::PartialSerializer partial_serializer(isolate, &startup_serializer, | 572 i::PartialSerializer partial_serializer(isolate, &startup_serializer, |
| 569 callback); | 573 callback); |
| 570 partial_serializer.Serialize(&contexts[i]); | 574 partial_serializer.Serialize(&contexts[i]); |
| 571 context_snapshots.Add(new i::SnapshotData(&partial_serializer)); | 575 context_snapshots.Add(new i::SnapshotData(&partial_serializer)); |
| 572 } | 576 } |
| 573 | 577 |
| 574 startup_serializer.SerializeWeakReferencesAndDeferred(); | 578 startup_serializer.SerializeWeakReferencesAndDeferred(); |
| 579 |
| 580 #ifdef DEBUG |
| 581 if (i::FLAG_external_reference_stats) { |
| 582 i::ExternalReferenceTable::instance(isolate)->PrintCount(); |
| 583 } |
| 584 #endif // DEBUG |
| 585 |
| 575 i::SnapshotData startup_snapshot(&startup_serializer); | 586 i::SnapshotData startup_snapshot(&startup_serializer); |
| 576 StartupData result = | 587 StartupData result = |
| 577 i::Snapshot::CreateSnapshotBlob(&startup_snapshot, &context_snapshots); | 588 i::Snapshot::CreateSnapshotBlob(&startup_snapshot, &context_snapshots); |
| 578 | 589 |
| 579 // Delete heap-allocated context snapshot instances. | 590 // Delete heap-allocated context snapshot instances. |
| 580 for (const auto& context_snapshot : context_snapshots) { | 591 for (const auto& context_snapshot : context_snapshots) { |
| 581 delete context_snapshot; | 592 delete context_snapshot; |
| 582 } | 593 } |
| 583 data->created_ = true; | 594 data->created_ = true; |
| 584 return result; | 595 return result; |
| (...skipping 9188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9773 Address callback_address = | 9784 Address callback_address = |
| 9774 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 9785 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 9775 VMState<EXTERNAL> state(isolate); | 9786 VMState<EXTERNAL> state(isolate); |
| 9776 ExternalCallbackScope call_scope(isolate, callback_address); | 9787 ExternalCallbackScope call_scope(isolate, callback_address); |
| 9777 callback(info); | 9788 callback(info); |
| 9778 } | 9789 } |
| 9779 | 9790 |
| 9780 | 9791 |
| 9781 } // namespace internal | 9792 } // namespace internal |
| 9782 } // namespace v8 | 9793 } // namespace v8 |
| OLD | NEW |