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