| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5af6a89 commit 8fd55ff
24 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -342,14 +342,14 @@ | |||
| 342 | 342 | 'src/node_config.cc', | |
| 343 | 343 | 'src/node_constants.cc', | |
| 344 | 344 | 'src/node_contextify.cc', | |
| 345 | - 'src/node_debug_options.cc', | ||
| 346 | 345 | 'src/node_domain.cc', | |
| 347 | 346 | 'src/node_encoding.cc', | |
| 348 | 347 | 'src/node_errors.h', | |
| 349 | 348 | 'src/node_file.cc', | |
| 350 | 349 | 'src/node_http2.cc', | |
| 351 | 350 | 'src/node_http_parser.cc', | |
| 352 | 351 | 'src/node_messaging.cc', | |
| 352 | + 'src/node_options.cc', | ||
| 353 | 353 | 'src/node_os.cc', | |
| 354 | 354 | 'src/node_platform.cc', | |
| 355 | 355 | 'src/node_perf.cc', | |
@@ -406,14 +406,15 @@ | |||
| 406 | 406 | 'src/node_code_cache.h', | |
| 407 | 407 | 'src/node_constants.h', | |
| 408 | 408 | 'src/node_contextify.h', | |
| 409 | - 'src/node_debug_options.h', | ||
| 410 | 409 | 'src/node_file.h', | |
| 411 | 410 | 'src/node_http2.h', | |
| 412 | 411 | 'src/node_http2_state.h', | |
| 413 | 412 | 'src/node_internals.h', | |
| 414 | 413 | 'src/node_javascript.h', | |
| 415 | 414 | 'src/node_messaging.h', | |
| 416 | 415 | 'src/node_mutex.h', | |
| 416 | + 'src/node_options.h', | ||
| 417 | + 'src/node_options-inl.h', | ||
| 417 | 418 | 'src/node_perf.h', | |
| 418 | 419 | 'src/node_perf_common.h', | |
| 419 | 420 | 'src/node_persistent.h', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -559,6 +559,14 @@ Environment::file_handle_read_wrap_freelist() { | |||
| 559 | 559 | return file_handle_read_wrap_freelist_; | |
| 560 | 560 | } | |
| 561 | 561 | ||
| 562 | + inline std::shared_ptr<EnvironmentOptions> Environment::options() { | ||
| 563 | + return options_; | ||
| 564 | + } | ||
| 565 | + | ||
| 566 | + inline std::shared_ptr<PerIsolateOptions> IsolateData::options() { | ||
| 567 | + return options_; | ||
| 568 | + } | ||
| 569 | + | ||
| 562 | 570 | void Environment::CreateImmediate(native_immediate_callback cb, | |
| 563 | 571 | void* data, | |
| 564 | 572 | v8::Local<v8::Object> obj, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,6 +44,8 @@ IsolateData::IsolateData(Isolate* isolate, | |||
| 44 | 44 | if (platform_ != nullptr) | |
| 45 | 45 | platform_->RegisterIsolate(this, event_loop); | |
| 46 | 46 | ||
| 47 | + options_.reset(new PerIsolateOptions(*per_process_opts->per_isolate)); | ||
| 48 | + | ||
| 47 | 49 | // Create string and private symbol properties as internalized one byte | |
| 48 | 50 | // strings after the platform is properly initialized. | |
| 49 | 51 | // | |
@@ -116,9 +118,6 @@ Environment::Environment(IsolateData* isolate_data, | |||
| 116 | 118 | emit_env_nonstring_warning_(true), | |
| 117 | 119 | makecallback_cntr_(0), | |
| 118 | 120 | should_abort_on_uncaught_toggle_(isolate_, 1), | |
| 119 | - #if HAVE_INSPECTOR | ||
| 120 | - inspector_agent_(new inspector::Agent(this)), | ||
| 121 | - #endif | ||
| 122 | 121 | http_parser_buffer_(nullptr), | |
| 123 | 122 | fs_stats_field_array_(isolate_, kFsStatsFieldsLength * 2), | |
| 124 | 123 | fs_stats_field_bigint_array_(isolate_, kFsStatsFieldsLength * 2), | |
@@ -128,6 +127,19 @@ Environment::Environment(IsolateData* isolate_data, | |||
| 128 | 127 | v8::Context::Scope context_scope(context); | |
| 129 | 128 | set_as_external(v8::External::New(isolate(), this)); | |
| 130 | 129 | ||
| 130 | + // We create new copies of the per-Environment option sets, so that it is | ||
| 131 | + // easier to modify them after Environment creation. The defaults are | ||
| 132 | + // part of the per-Isolate option set, for which in turn the defaults are | ||
| 133 | + // part of the per-process option set. | ||
| 134 | + options_.reset(new EnvironmentOptions(*isolate_data->options()->per_env)); | ||
| 135 | + options_->debug_options.reset(new DebugOptions(*options_->debug_options)); | ||
| 136 | + | ||
| 137 | + #if HAVE_INSPECTOR | ||
| 138 | + // We can only create the inspector agent after having cloned the options. | ||
| 139 | + inspector_agent_ = | ||
| 140 | + std::unique_ptr<inspector::Agent>(new inspector::Agent(this)); | ||
| 141 | + #endif | ||
| 142 | + | ||
| 131 | 143 | AssignToContext(context, ContextInfo("")); | |
| 132 | 144 | ||
| 133 | 145 | destroy_async_id_list_.reserve(512); | |
@@ -176,10 +188,8 @@ Environment::~Environment() { | |||
| 176 | 188 | delete[] http_parser_buffer_; | |
| 177 | 189 | } | |
| 178 | 190 | ||
| 179 | - void Environment::Start(int argc, | ||
| 180 | - const char* const* argv, | ||
| 181 | - int exec_argc, | ||
| 182 | - const char* const* exec_argv, | ||
| 191 | + void Environment::Start(const std::vector<std::string>& args, | ||
| 192 | + const std::vector<std::string>& exec_args, | ||
| 183 | 193 | bool start_profiler_idle_notifier) { | |
| 184 | 194 | HandleScope handle_scope(isolate()); | |
| 185 | 195 | Context::Scope context_scope(context()); | |
@@ -222,7 +232,7 @@ void Environment::Start(int argc, | |||
| 222 | 232 | process_template->GetFunction()->NewInstance(context()).ToLocalChecked(); | |
| 223 | 233 | set_process_object(process_object); | |
| 224 | 234 | ||
| 225 | - SetupProcessObject(this, argc, argv, exec_argc, exec_argv); | ||
| 235 | + SetupProcessObject(this, args, exec_args); | ||
| 226 | 236 | ||
| 227 | 237 | static uv_once_t init_once = UV_ONCE_INIT; | |
| 228 | 238 | uv_once(&init_once, InitThreadLocalOnce); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,6 +34,7 @@ | |||
| 34 | 34 | #include "uv.h" | |
| 35 | 35 | #include "v8.h" | |
| 36 | 36 | #include "node.h" | |
| 37 | + #include "node_options.h" | ||
| 37 | 38 | #include "node_http2_state.h" | |
| 38 | 39 | ||
| 39 | 40 | #include <list> | |
@@ -364,6 +365,7 @@ class IsolateData { | |||
| 364 | 365 | inline uv_loop_t* event_loop() const; | |
| 365 | 366 | inline uint32_t* zero_fill_field() const; | |
| 366 | 367 | inline MultiIsolatePlatform* platform() const; | |
| 368 | + inline std::shared_ptr<PerIsolateOptions> options(); | ||
| 367 | 369 | ||
| 368 | 370 | #define VP(PropertyName, StringValue) V(v8::Private, PropertyName) | |
| 369 | 371 | #define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName) | |
@@ -397,6 +399,7 @@ class IsolateData { | |||
| 397 | 399 | uv_loop_t* const event_loop_; | |
| 398 | 400 | uint32_t* const zero_fill_field_; | |
| 399 | 401 | MultiIsolatePlatform* platform_; | |
| 402 | + std::shared_ptr<PerIsolateOptions> options_; | ||
| 400 | 403 | ||
| 401 | 404 | DISALLOW_COPY_AND_ASSIGN(IsolateData); | |
| 402 | 405 | }; | |
@@ -584,10 +587,8 @@ class Environment { | |||
| 584 | 587 | tracing::AgentWriterHandle* tracing_agent_writer); | |
| 585 | 588 | ~Environment(); | |
| 586 | 589 | ||
| 587 | - void Start(int argc, | ||
| 588 | - const char* const* argv, | ||
| 589 | - int exec_argc, | ||
| 590 | - const char* const* exec_argv, | ||
| 590 | + void Start(const std::vector<std::string>& args, | ||
| 591 | + const std::vector<std::string>& exec_args, | ||
| 591 | 592 | bool start_profiler_idle_notifier); | |
| 592 | 593 | ||
| 593 | 594 | typedef void (*HandleCleanupCb)(Environment* env, | |
@@ -858,6 +859,8 @@ class Environment { | |||
| 858 | 859 | v8::EmbedderGraph* graph, | |
| 859 | 860 | void* data); | |
| 860 | 861 | ||
| 862 | + inline std::shared_ptr<EnvironmentOptions> options(); | ||
| 863 | + | ||
| 861 | 864 | private: | |
| 862 | 865 | inline void CreateImmediate(native_immediate_callback cb, | |
| 863 | 866 | void* data, | |
@@ -887,6 +890,8 @@ class Environment { | |||
| 887 | 890 | size_t makecallback_cntr_; | |
| 888 | 891 | std::vector<double> destroy_async_id_list_; | |
| 889 | 892 | ||
| 893 | + std::shared_ptr<EnvironmentOptions> options_; | ||
| 894 | + | ||
| 890 | 895 | AliasedBuffer<uint32_t, v8::Uint32Array> should_abort_on_uncaught_toggle_; | |
| 891 | 896 | int should_not_abort_scope_counter_ = 0; | |
| 892 | 897 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -608,11 +608,14 @@ class NodeInspectorClient : public V8InspectorClient { | |||
| 608 | 608 | std::unique_ptr<MainThreadInterface> interface_; | |
| 609 | 609 | }; | |
| 610 | 610 | ||
| 611 | - Agent::Agent(Environment* env) : parent_env_(env) {} | ||
| 611 | + Agent::Agent(Environment* env) | ||
| 612 | + : parent_env_(env), | ||
| 613 | + debug_options_(env->options()->debug_options) {} | ||
| 612 | 614 | ||
| 613 | 615 | Agent::~Agent() = default; | |
| 614 | 616 | ||
| 615 | - bool Agent::Start(const std::string& path, const DebugOptions& options) { | ||
| 617 | + bool Agent::Start(const std::string& path, | ||
| 618 | + std::shared_ptr<DebugOptions> options) { | ||
| 616 | 619 | path_ = path; | |
| 617 | 620 | debug_options_ = options; | |
| 618 | 621 | client_ = std::make_shared<NodeInspectorClient>(parent_env_); | |
@@ -626,8 +629,8 @@ bool Agent::Start(const std::string& path, const DebugOptions& options) { | |||
| 626 | 629 | StartDebugSignalHandler(); | |
| 627 | 630 | } | |
| 628 | 631 | ||
| 629 | - bool wait_for_connect = options.wait_for_connect(); | ||
| 630 | - if (!options.inspector_enabled() || !StartIoThread()) { | ||
| 632 | + bool wait_for_connect = options->wait_for_connect(); | ||
| 633 | + if (!options->inspector_enabled || !StartIoThread()) { | ||
| 631 | 634 | return false; | |
| 632 | 635 | } | |
| 633 | 636 | if (wait_for_connect) { | |
@@ -789,7 +792,7 @@ void Agent::ContextCreated(Local<Context> context, const ContextInfo& info) { | |||
| 789 | 792 | } | |
| 790 | 793 | ||
| 791 | 794 | bool Agent::WillWaitForConnect() { | |
| 792 | - return debug_options_.wait_for_connect(); | ||
| 795 | + return debug_options_->wait_for_connect(); | ||
| 793 | 796 | } | |
| 794 | 797 | ||
| 795 | 798 | bool Agent::IsActive() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,7 @@ | |||
| 9 | 9 | #error("This header can only be used when inspector is enabled") | |
| 10 | 10 | #endif | |
| 11 | 11 | ||
| 12 | - #include "node_debug_options.h" | ||
| 12 | + #include "node_options.h" | ||
| 13 | 13 | #include "node_persistent.h" | |
| 14 | 14 | #include "v8.h" | |
| 15 | 15 | ||
@@ -45,7 +45,7 @@ class Agent { | |||
| 45 | 45 | ~Agent(); | |
| 46 | 46 | ||
| 47 | 47 | // Create client_, may create io_ if option enabled | |
| 48 | - bool Start(const std::string& path, const DebugOptions& options); | ||
| 48 | + bool Start(const std::string& path, std::shared_ptr<DebugOptions> options); | ||
| 49 | 49 | // Stop and destroy io_ | |
| 50 | 50 | void Stop(); | |
| 51 | 51 | ||
@@ -96,7 +96,7 @@ class Agent { | |||
| 96 | 96 | // Calls StartIoThread() from off the main thread. | |
| 97 | 97 | void RequestIoThreadStart(); | |
| 98 | 98 | ||
| 99 | - DebugOptions& options() { return debug_options_; } | ||
| 99 | + std::shared_ptr<DebugOptions> options() { return debug_options_; } | ||
| 100 | 100 | void ContextCreated(v8::Local<v8::Context> context, const ContextInfo& info); | |
| 101 | 101 | ||
| 102 | 102 | private: | |
@@ -109,7 +109,7 @@ class Agent { | |||
| 109 | 109 | // Interface for transports, e.g. WebSocket server | |
| 110 | 110 | std::unique_ptr<InspectorIo> io_; | |
| 111 | 111 | std::string path_; | |
| 112 | - DebugOptions debug_options_; | ||
| 112 | + std::shared_ptr<DebugOptions> debug_options_; | ||
| 113 | 113 | ||
| 114 | 114 | bool pending_enable_async_hook_ = false; | |
| 115 | 115 | bool pending_disable_async_hook_ = false; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -242,7 +242,7 @@ class InspectorIoDelegate: public node::inspector::SocketServerDelegate { | |||
| 242 | 242 | std::unique_ptr<InspectorIo> InspectorIo::Start( | |
| 243 | 243 | std::shared_ptr<MainThreadHandle> main_thread, | |
| 244 | 244 | const std::string& path, | |
| 245 | - const DebugOptions& options) { | ||
| 245 | + std::shared_ptr<DebugOptions> options) { | ||
| 246 | 246 | auto io = std::unique_ptr<InspectorIo>( | |
| 247 | 247 | new InspectorIo(main_thread, path, options)); | |
| 248 | 248 | if (io->request_queue_->Expired()) { // Thread is not running | |
@@ -253,7 +253,7 @@ std::unique_ptr<InspectorIo> InspectorIo::Start( | |||
| 253 | 253 | ||
| 254 | 254 | InspectorIo::InspectorIo(std::shared_ptr<MainThreadHandle> main_thread, | |
| 255 | 255 | const std::string& path, | |
| 256 | - const DebugOptions& options) | ||
| 256 | + std::shared_ptr<DebugOptions> options) | ||
| 257 | 257 | : main_thread_(main_thread), options_(options), | |
| 258 | 258 | thread_(), script_name_(path), id_(GenerateID()) { | |
| 259 | 259 | Mutex::ScopedLock scoped_lock(thread_start_lock_); | |
@@ -288,7 +288,8 @@ void InspectorIo::ThreadMain() { | |||
| 288 | 288 | new InspectorIoDelegate(queue, main_thread_, id_, | |
| 289 | 289 | script_path, script_name_)); | |
| 290 | 290 | InspectorSocketServer server(std::move(delegate), &loop, | |
| 291 | - options_.host_name(), options_.port()); | ||
| 291 | + options_->host().c_str(), | ||
| 292 | + options_->port()); | ||
| 292 | 293 | request_queue_ = queue->handle(); | |
| 293 | 294 | // Its lifetime is now that of the server delegate | |
| 294 | 295 | queue.reset(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,6 @@ | |||
| 2 | 2 | #define SRC_INSPECTOR_IO_H_ | |
| 3 | 3 | ||
| 4 | 4 | #include "inspector_socket_server.h" | |
| 5 | - #include "node_debug_options.h" | ||
| 6 | 5 | #include "node_mutex.h" | |
| 7 | 6 | #include "uv.h" | |
| 8 | 7 | ||
@@ -46,19 +45,20 @@ class InspectorIo { | |||
| 46 | 45 | // Returns empty pointer if thread was not started | |
| 47 | 46 | static std::unique_ptr<InspectorIo> Start( | |
| 48 | 47 | std::shared_ptr<MainThreadHandle> main_thread, const std::string& path, | |
| 49 | - const DebugOptions& options); | ||
| 48 | + std::shared_ptr<DebugOptions> options); | ||
| 50 | 49 | ||
| 51 | 50 | // Will block till the transport thread shuts down | |
| 52 | 51 | ~InspectorIo(); | |
| 53 | 52 | ||
| 54 | 53 | void StopAcceptingNewConnections(); | |
| 55 | - std::string host() const { return options_.host_name(); } | ||
| 54 | + const std::string& host() const { return options_->host(); } | ||
| 56 | 55 | int port() const { return port_; } | |
| 57 | 56 | std::vector<std::string> GetTargetIds() const; | |
| 58 | 57 | ||
| 59 | 58 | private: | |
| 60 | 59 | InspectorIo(std::shared_ptr<MainThreadHandle> handle, | |
| 61 | - const std::string& path, const DebugOptions& options); | ||
| 60 | + const std::string& path, | ||
| 61 | + std::shared_ptr<DebugOptions> options); | ||
| 62 | 62 | ||
| 63 | 63 | // Wrapper for agent->ThreadMain() | |
| 64 | 64 | static void ThreadMain(void* agent); | |
@@ -72,7 +72,7 @@ class InspectorIo { | |||
| 72 | 72 | // Used to post on a frontend interface thread, lives while the server is | |
| 73 | 73 | // running | |
| 74 | 74 | std::shared_ptr<RequestQueue> request_queue_; | |
| 75 | - const DebugOptions options_; | ||
| 75 | + std::shared_ptr<DebugOptions> options_; | ||
| 76 | 76 | ||
| 77 | 77 | // The IO thread runs its own uv_loop to implement the TCP server off | |
| 78 | 78 | // the main thread. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -242,12 +242,12 @@ void Open(const FunctionCallbackInfo<Value>& args) { | |||
| 242 | 242 | ||
| 243 | 243 | if (args.Length() > 0 && args[0]->IsUint32()) { | |
| 244 | 244 | uint32_t port = args[0]->Uint32Value(); | |
| 245 | - agent->options().set_port(static_cast<int>(port)); | ||
| 245 | + agent->options()->host_port.port = port; | ||
| 246 | 246 | } | |
| 247 | 247 | ||
| 248 | 248 | if (args.Length() > 1 && args[1]->IsString()) { | |
| 249 | 249 | Utf8Value host(env->isolate(), args[1].As<String>()); | |
| 250 | - agent->options().set_host_name(*host); | ||
| 250 | + agent->options()->host_port.host_name = *host; | ||
| 251 | 251 | } | |
| 252 | 252 | ||
| 253 | 253 | if (args.Length() > 2 && args[2]->IsBoolean()) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments