|
31 | 31 | #include "node_context_data.h" |
32 | 32 | #include "node_internals.h" |
33 | 33 | #include "node_perf_common.h" |
| 34 | +#include "node_realm-inl.h" |
34 | 35 | #include "util-inl.h" |
35 | 36 | #include "uv.h" |
36 | 37 | #include "v8.h" |
@@ -614,15 +615,7 @@ inline void Environment::set_can_call_into_js(bool can_call_into_js) { |
614 | 615 | } |
615 | 616 |
|
616 | 617 | inline bool Environment::has_run_bootstrapping_code() const { |
617 | | - return has_run_bootstrapping_code_; |
618 | | -} |
619 | | - |
620 | | -inline void Environment::DoneBootstrapping() { |
621 | | - has_run_bootstrapping_code_ = true; |
622 | | - // This adjusts the return value of base_object_created_after_bootstrap() so |
623 | | - // that tests that check the count do not have to account for internally |
624 | | - // created BaseObjects. |
625 | | - base_object_created_by_bootstrap_ = base_object_count_; |
| 618 | + return principal_realm_->has_run_bootstrapping_code(); |
626 | 619 | } |
627 | 620 |
|
628 | 621 | inline bool Environment::has_serialized_options() const { |
@@ -830,14 +823,18 @@ void Environment::modify_base_object_count(int64_t delta) { |
830 | 823 | base_object_count_ += delta; |
831 | 824 | } |
832 | 825 |
|
833 | | -int64_t Environment::base_object_created_after_bootstrap() const { |
834 | | - return base_object_count_ - base_object_created_by_bootstrap_; |
835 | | -} |
836 | | - |
837 | 826 | int64_t Environment::base_object_count() const { |
838 | 827 | return base_object_count_; |
839 | 828 | } |
840 | 829 |
|
| 830 | +inline void Environment::set_base_object_created_by_bootstrap(int64_t count) { |
| 831 | + base_object_created_by_bootstrap_ = base_object_count_; |
| 832 | +} |
| 833 | + |
| 834 | +int64_t Environment::base_object_created_after_bootstrap() const { |
| 835 | + return base_object_count_ - base_object_created_by_bootstrap_; |
| 836 | +} |
| 837 | + |
841 | 838 | void Environment::set_main_utf16(std::unique_ptr<v8::String::Value> str) { |
842 | 839 | CHECK(!main_utf16_); |
843 | 840 | main_utf16_ = std::move(str); |
@@ -902,16 +899,22 @@ void Environment::set_process_exit_handler( |
902 | 899 |
|
903 | 900 | #define V(PropertyName, TypeName) \ |
904 | 901 | inline v8::Local<TypeName> Environment::PropertyName() const { \ |
905 | | - return PersistentToLocal::Strong(PropertyName##_); \ |
| 902 | + DCHECK_NOT_NULL(principal_realm_); \ |
| 903 | + return principal_realm_->PropertyName(); \ |
906 | 904 | } \ |
907 | 905 | inline void Environment::set_##PropertyName(v8::Local<TypeName> value) { \ |
908 | | - PropertyName##_.Reset(isolate(), value); \ |
| 906 | + DCHECK_NOT_NULL(principal_realm_); \ |
| 907 | + principal_realm_->set_##PropertyName(value); \ |
909 | 908 | } |
910 | | - ENVIRONMENT_STRONG_PERSISTENT_VALUES(V) |
| 909 | + PER_REALM_STRONG_PERSISTENT_VALUES(V) |
911 | 910 | #undef V |
912 | 911 |
|
913 | 912 | v8::Local<v8::Context> Environment::context() const { |
914 | | - return PersistentToLocal::Strong(context_); |
| 913 | + return principal_realm()->context(); |
| 914 | +} |
| 915 | + |
| 916 | +Realm* Environment::principal_realm() const { |
| 917 | + return principal_realm_.get(); |
915 | 918 | } |
916 | 919 |
|
917 | 920 | } // namespace node |
|
0 commit comments