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 <errno.h> | 5 #include <errno.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 #include <string.h> | 7 #include <string.h> |
8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 data_->realm_current_ = 0; | 718 data_->realm_current_ = 0; |
719 data_->realm_switch_ = 0; | 719 data_->realm_switch_ = 0; |
720 data_->realms_ = new Global<Context>[1]; | 720 data_->realms_ = new Global<Context>[1]; |
721 data_->realms_[0].Reset(data_->isolate_, | 721 data_->realms_[0].Reset(data_->isolate_, |
722 data_->isolate_->GetEnteredContext()); | 722 data_->isolate_->GetEnteredContext()); |
723 } | 723 } |
724 | 724 |
725 | 725 |
726 PerIsolateData::RealmScope::~RealmScope() { | 726 PerIsolateData::RealmScope::~RealmScope() { |
727 // Drop realms to avoid keeping them alive. | 727 // Drop realms to avoid keeping them alive. |
728 for (int i = 0; i < data_->realm_count_; ++i) | 728 for (int i = 0; i < data_->realm_count_; ++i) { |
729 data_->realms_[i].Reset(); | 729 Global<Context>& realm = data_->realms_[i]; |
| 730 if (realm.IsEmpty()) continue; |
| 731 DisposeModuleEmbedderData(realm.Get(data_->isolate_)); |
| 732 realm.Reset(); |
| 733 } |
730 delete[] data_->realms_; | 734 delete[] data_->realms_; |
731 if (!data_->realm_shared_.IsEmpty()) | 735 if (!data_->realm_shared_.IsEmpty()) |
732 data_->realm_shared_.Reset(); | 736 data_->realm_shared_.Reset(); |
733 } | 737 } |
734 | 738 |
735 | 739 |
736 int PerIsolateData::RealmFind(Local<Context> context) { | 740 int PerIsolateData::RealmFind(Local<Context> context) { |
737 for (int i = 0; i < realm_count_; ++i) { | 741 for (int i = 0; i < realm_count_; ++i) { |
738 if (realms_[i] == context) return i; | 742 if (realms_[i] == context) return i; |
739 } | 743 } |
(...skipping 2073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2813 } | 2817 } |
2814 | 2818 |
2815 } // namespace v8 | 2819 } // namespace v8 |
2816 | 2820 |
2817 | 2821 |
2818 #ifndef GOOGLE3 | 2822 #ifndef GOOGLE3 |
2819 int main(int argc, char* argv[]) { | 2823 int main(int argc, char* argv[]) { |
2820 return v8::Shell::Main(argc, argv); | 2824 return v8::Shell::Main(argc, argv); |
2821 } | 2825 } |
2822 #endif | 2826 #endif |
OLD | NEW |