| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b11616b commit a7f3bc0
21 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -525,6 +525,7 @@ | |||
| 525 | 525 | 'src/node_process_events.cc', | |
| 526 | 526 | 'src/node_process_methods.cc', | |
| 527 | 527 | 'src/node_process_object.cc', | |
| 528 | + 'src/node_realm.cc', | ||
| 528 | 529 | 'src/node_report.cc', | |
| 529 | 530 | 'src/node_report_module.cc', | |
| 530 | 531 | 'src/node_report_utils.cc', | |
@@ -585,6 +586,7 @@ | |||
| 585 | 586 | 'src/connection_wrap.h', | |
| 586 | 587 | 'src/debug_utils.h', | |
| 587 | 588 | 'src/debug_utils-inl.h', | |
| 589 | + 'src/env_properties.h', | ||
| 588 | 590 | 'src/env.h', | |
| 589 | 591 | 'src/env-inl.h', | |
| 590 | 592 | 'src/handle_wrap.h', | |
@@ -632,6 +634,8 @@ | |||
| 632 | 634 | 'src/node_platform.h', | |
| 633 | 635 | 'src/node_process.h', | |
| 634 | 636 | 'src/node_process-inl.h', | |
| 637 | + 'src/node_realm.h', | ||
| 638 | + 'src/node_realm-inl.h', | ||
| 635 | 639 | 'src/node_report.h', | |
| 636 | 640 | 'src/node_revert.h', | |
| 637 | 641 | 'src/node_root_certs.h', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ | |||
| 5 | 5 | #include "node_internals.h" | |
| 6 | 6 | #include "node_options-inl.h" | |
| 7 | 7 | #include "node_platform.h" | |
| 8 | + #include "node_realm-inl.h" | ||
| 8 | 9 | #include "node_shadow_realm.h" | |
| 9 | 10 | #include "node_v8_platform-inl.h" | |
| 10 | 11 | #include "node_wasm_web_api.h" | |
@@ -378,7 +379,7 @@ Environment* CreateEnvironment( | |||
| 378 | 379 | } | |
| 379 | 380 | #endif | |
| 380 | 381 | ||
| 381 | - if (env->RunBootstrapping().IsEmpty()) { | ||
| 382 | + if (env->principal_realm()->RunBootstrapping().IsEmpty()) { | ||
| 382 | 383 | FreeEnvironment(env); | |
| 383 | 384 | return nullptr; | |
| 384 | 385 | } | |
@@ -453,11 +454,13 @@ MaybeLocal<Value> LoadEnvironment( | |||
| 453 | 454 | builtins::BuiltinLoader::Add( | |
| 454 | 455 | name.c_str(), UnionBytes(**main_utf16, main_utf16->length())); | |
| 455 | 456 | env->set_main_utf16(std::move(main_utf16)); | |
| 457 | + Realm* realm = env->principal_realm(); | ||
| 458 | + | ||
| 456 | 459 | // Arguments must match the parameters specified in | |
| 457 | 460 | // BuiltinLoader::LookupAndCompile(). | |
| 458 | - std::vector<Local<Value>> args = {env->process_object(), | ||
| 459 | - env->builtin_module_require()}; | ||
| 460 | - return ExecuteBootstrapper(env, name.c_str(), &args); | ||
| 461 | + std::vector<Local<Value>> args = {realm->process_object(), | ||
| 462 | + realm->builtin_module_require()}; | ||
| 463 | + return realm->ExecuteBootstrapper(name.c_str(), &args); | ||
| 461 | 464 | }); | |
| 462 | 465 | } | |
| 463 | 466 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,6 +32,12 @@ | |||
| 32 | 32 | ||
| 33 | 33 | namespace node { | |
| 34 | 34 | ||
| 35 | + // static | ||
| 36 | + v8::Local<v8::FunctionTemplate> BaseObject::GetConstructorTemplate( | ||
| 37 | + Environment* env) { | ||
| 38 | + return BaseObject::GetConstructorTemplate(env->isolate_data()); | ||
| 39 | + } | ||
| 40 | + | ||
| 35 | 41 | void BaseObject::Detach() { | |
| 36 | 42 | CHECK_GT(pointer_data()->strong_ptr_count, 0); | |
| 37 | 43 | pointer_data()->is_detached = true; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,6 +31,7 @@ | |||
| 31 | 31 | namespace node { | |
| 32 | 32 | ||
| 33 | 33 | class Environment; | |
| 34 | + class IsolateData; | ||
| 34 | 35 | template <typename T, bool kIsWeak> | |
| 35 | 36 | class BaseObjectPtrImpl; | |
| 36 | 37 | ||
@@ -113,8 +114,10 @@ class BaseObject : public MemoryRetainer { | |||
| 113 | 114 | // a BaseObjectPtr to this object. | |
| 114 | 115 | inline void Detach(); | |
| 115 | 116 | ||
| 116 | - static v8::Local<v8::FunctionTemplate> GetConstructorTemplate( | ||
| 117 | + static inline v8::Local<v8::FunctionTemplate> GetConstructorTemplate( | ||
| 117 | 118 | Environment* env); | |
| 119 | + static v8::Local<v8::FunctionTemplate> GetConstructorTemplate( | ||
| 120 | + IsolateData* isolate_data); | ||
| 118 | 121 | ||
| 119 | 122 | // Interface for transferring BaseObject instances using the .postMessage() | |
| 120 | 123 | // method of MessagePorts (and, by extension, Workers). | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,6 +31,7 @@ | |||
| 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 { | |
@@ -805,14 +798,18 @@ void Environment::modify_base_object_count(int64_t delta) { | |||
| 805 | 798 | base_object_count_ += delta; | |
| 806 | 799 | } | |
| 807 | 800 | ||
| 808 | - int64_t Environment::base_object_created_after_bootstrap() const { | ||
| 809 | - return base_object_count_ - base_object_created_by_bootstrap_; | ||
| 810 | - } | ||
| 811 | - | ||
| 812 | 801 | int64_t Environment::base_object_count() const { | |
| 813 | 802 | return base_object_count_; | |
| 814 | 803 | } | |
| 815 | 804 | ||
| 805 | + inline void Environment::set_base_object_created_by_bootstrap(int64_t count) { | ||
| 806 | + base_object_created_by_bootstrap_ = base_object_count_; | ||
| 807 | + } | ||
| 808 | + | ||
| 809 | + int64_t Environment::base_object_created_after_bootstrap() const { | ||
| 810 | + return base_object_count_ - base_object_created_by_bootstrap_; | ||
| 811 | + } | ||
| 812 | + | ||
| 816 | 813 | void Environment::set_main_utf16(std::unique_ptr<v8::String::Value> str) { | |
| 817 | 814 | CHECK(!main_utf16_); | |
| 818 | 815 | main_utf16_ = std::move(str); | |
@@ -877,16 +874,22 @@ void Environment::set_process_exit_handler( | |||
| 877 | 874 | ||
| 878 | 875 | #define V(PropertyName, TypeName) \ | |
| 879 | 876 | inline v8::Local<TypeName> Environment::PropertyName() const { \ | |
| 880 | - return PersistentToLocal::Strong(PropertyName##_); \ | ||
| 877 | + DCHECK_NOT_NULL(principal_realm_); \ | ||
| 878 | + return principal_realm_->PropertyName(); \ | ||
| 881 | 879 | } \ | |
| 882 | 880 | inline void Environment::set_##PropertyName(v8::Local<TypeName> value) { \ | |
| 883 | - PropertyName##_.Reset(isolate(), value); \ | ||
| 881 | + DCHECK_NOT_NULL(principal_realm_); \ | ||
| 882 | + principal_realm_->set_##PropertyName(value); \ | ||
| 884 | 883 | } | |
| 885 | - ENVIRONMENT_STRONG_PERSISTENT_VALUES(V) | ||
| 884 | + PER_REALM_STRONG_PERSISTENT_VALUES(V) | ||
| 886 | 885 | #undef V | |
| 887 | 886 | ||
| 888 | 887 | v8::Local<v8::Context> Environment::context() const { | |
| 889 | - return PersistentToLocal::Strong(context_); | ||
| 888 | + return principal_realm()->context(); | ||
| 889 | + } | ||
| 890 | + | ||
| 891 | + Realm* Environment::principal_realm() const { | ||
| 892 | + return principal_realm_.get(); | ||
| 890 | 893 | } | |
| 891 | 894 | ||
| 892 | 895 | inline void Environment::set_heap_snapshot_near_heap_limit(uint32_t limit) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments