| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f8c9a58 commit 70f8e71
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -281,11 +281,12 @@ Environment* CreateEnvironment(IsolateData* isolate_data, | |||
| 281 | 281 | Environment* env = new Environment( | |
| 282 | 282 | isolate_data, | |
| 283 | 283 | context, | |
| 284 | + args, | ||
| 285 | + exec_args, | ||
| 284 | 286 | static_cast<Environment::Flags>(Environment::kIsMainThread | | |
| 285 | 287 | Environment::kOwnsProcessState | | |
| 286 | 288 | Environment::kOwnsInspector)); | |
| 287 | 289 | env->InitializeLibuv(per_process::v8_is_profiling); | |
| 288 | - env->ProcessCliArgs(args, exec_args); | ||
| 289 | 290 | if (RunBootstrapping(env).IsEmpty()) { | |
| 290 | 291 | return nullptr; | |
| 291 | 292 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -237,13 +237,17 @@ uint64_t Environment::AllocateThreadId() { | |||
| 237 | 237 | ||
| 238 | 238 | Environment::Environment(IsolateData* isolate_data, | |
| 239 | 239 | Local<Context> context, | |
| 240 | + const std::vector<std::string>& args, | ||
| 241 | + const std::vector<std::string>& exec_args, | ||
| 240 | 242 | Flags flags, | |
| 241 | 243 | uint64_t thread_id) | |
| 242 | 244 | : isolate_(context->GetIsolate()), | |
| 243 | 245 | isolate_data_(isolate_data), | |
| 244 | 246 | immediate_info_(context->GetIsolate()), | |
| 245 | 247 | tick_info_(context->GetIsolate()), | |
| 246 | 248 | timer_base_(uv_now(isolate_data->event_loop())), | |
| 249 | + exec_argv_(exec_args), | ||
| 250 | + argv_(args), | ||
| 247 | 251 | should_abort_on_uncaught_toggle_(isolate_, 1), | |
| 248 | 252 | stream_base_state_(isolate_, StreamBase::kNumStreamBaseStateFields), | |
| 249 | 253 | flags_(flags), | |
@@ -306,6 +310,22 @@ Environment::Environment(IsolateData* isolate_data, | |||
| 306 | 310 | performance::NODE_PERFORMANCE_MILESTONE_V8_START, | |
| 307 | 311 | performance::performance_v8_start); | |
| 308 | 312 | ||
| 313 | + if (*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( | ||
| 314 | + TRACING_CATEGORY_NODE1(environment)) != 0) { | ||
| 315 | + auto traced_value = tracing::TracedValue::Create(); | ||
| 316 | + traced_value->BeginArray("args"); | ||
| 317 | + for (const std::string& arg : args) traced_value->AppendString(arg); | ||
| 318 | + traced_value->EndArray(); | ||
| 319 | + traced_value->BeginArray("exec_args"); | ||
| 320 | + for (const std::string& arg : exec_args) traced_value->AppendString(arg); | ||
| 321 | + traced_value->EndArray(); | ||
| 322 | + TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(TRACING_CATEGORY_NODE1(environment), | ||
| 323 | + "Environment", | ||
| 324 | + this, | ||
| 325 | + "args", | ||
| 326 | + std::move(traced_value)); | ||
| 327 | + } | ||
| 328 | + | ||
| 309 | 329 | // By default, always abort when --abort-on-uncaught-exception was passed. | |
| 310 | 330 | should_abort_on_uncaught_toggle_[0] = 1; | |
| 311 | 331 | ||
@@ -318,6 +338,8 @@ Environment::Environment(IsolateData* isolate_data, | |||
| 318 | 338 | if (options_->no_force_async_hooks_checks) { | |
| 319 | 339 | async_hooks_.no_force_checks(); | |
| 320 | 340 | } | |
| 341 | + | ||
| 342 | + set_process_object(node::CreateProcessObject(this).ToLocalChecked()); | ||
| 321 | 343 | } | |
| 322 | 344 | ||
| 323 | 345 | CompileFnEntry::CompileFnEntry(Environment* env, uint32_t id) | |
@@ -434,35 +456,6 @@ void Environment::ExitEnv() { | |||
| 434 | 456 | isolate_->TerminateExecution(); | |
| 435 | 457 | } | |
| 436 | 458 | ||
| 437 | - MaybeLocal<Object> Environment::ProcessCliArgs( | ||
| 438 | - const std::vector<std::string>& args, | ||
| 439 | - const std::vector<std::string>& exec_args) { | ||
| 440 | - argv_ = args; | ||
| 441 | - exec_argv_ = exec_args; | ||
| 442 | - | ||
| 443 | - if (*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( | ||
| 444 | - TRACING_CATEGORY_NODE1(environment)) != 0) { | ||
| 445 | - auto traced_value = tracing::TracedValue::Create(); | ||
| 446 | - traced_value->BeginArray("args"); | ||
| 447 | - for (const std::string& arg : args) traced_value->AppendString(arg); | ||
| 448 | - traced_value->EndArray(); | ||
| 449 | - traced_value->BeginArray("exec_args"); | ||
| 450 | - for (const std::string& arg : exec_args) traced_value->AppendString(arg); | ||
| 451 | - traced_value->EndArray(); | ||
| 452 | - TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(TRACING_CATEGORY_NODE1(environment), | ||
| 453 | - "Environment", | ||
| 454 | - this, | ||
| 455 | - "args", | ||
| 456 | - std::move(traced_value)); | ||
| 457 | - } | ||
| 458 | - | ||
| 459 | - Local<Object> process_object = | ||
| 460 | - node::CreateProcessObject(this, args, exec_args) | ||
| 461 | - .FromMaybe(Local<Object>()); | ||
| 462 | - set_process_object(process_object); | ||
| 463 | - return process_object; | ||
| 464 | - } | ||
| 465 | - | ||
| 466 | 459 | void Environment::RegisterHandleCleanups() { | |
| 467 | 460 | HandleCleanupCb close_and_finish = [](Environment* env, uv_handle_t* handle, | |
| 468 | 461 | void* arg) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -823,14 +823,13 @@ class Environment : public MemoryRetainer { | |||
| 823 | 823 | ||
| 824 | 824 | Environment(IsolateData* isolate_data, | |
| 825 | 825 | v8::Local<v8::Context> context, | |
| 826 | + const std::vector<std::string>& args, | ||
| 827 | + const std::vector<std::string>& exec_args, | ||
| 826 | 828 | Flags flags = Flags(), | |
| 827 | 829 | uint64_t thread_id = kNoThreadId); | |
| 828 | 830 | ~Environment(); | |
| 829 | 831 | ||
| 830 | 832 | void InitializeLibuv(bool start_profiler_idle_notifier); | |
| 831 | - v8::MaybeLocal<v8::Object> ProcessCliArgs( | ||
| 832 | - const std::vector<std::string>& args, | ||
| 833 | - const std::vector<std::string>& exec_args); | ||
| 834 | 833 | inline const std::vector<std::string>& exec_argv(); | |
| 835 | 834 | inline const std::vector<std::string>& argv(); | |
| 836 | 835 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -188,11 +188,12 @@ std::unique_ptr<Environment> NodeMainInstance::CreateMainEnvironment( | |||
| 188 | 188 | std::unique_ptr<Environment> env = std::make_unique<Environment>( | |
| 189 | 189 | isolate_data_.get(), | |
| 190 | 190 | context, | |
| 191 | + args_, | ||
| 192 | + exec_args_, | ||
| 191 | 193 | static_cast<Environment::Flags>(Environment::kIsMainThread | | |
| 192 | 194 | Environment::kOwnsProcessState | | |
| 193 | 195 | Environment::kOwnsInspector)); | |
| 194 | 196 | env->InitializeLibuv(per_process::v8_is_profiling); | |
| 195 | - env->ProcessCliArgs(args_, exec_args_); | ||
| 196 | 197 | ||
| 197 | 198 | #if HAVE_INSPECTOR && NODE_USE_V8_PLATFORM | |
| 198 | 199 | CHECK(!env->inspector_agent()->IsListening()); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,10 +31,7 @@ v8::Maybe<bool> ProcessEmitDeprecationWarning(Environment* env, | |||
| 31 | 31 | const char* warning, | |
| 32 | 32 | const char* deprecation_code); | |
| 33 | 33 | ||
| 34 | - v8::MaybeLocal<v8::Object> CreateProcessObject( | ||
| 35 | - Environment* env, | ||
| 36 | - const std::vector<std::string>& args, | ||
| 37 | - const std::vector<std::string>& exec_args); | ||
| 34 | + v8::MaybeLocal<v8::Object> CreateProcessObject(Environment* env); | ||
| 38 | 35 | void PatchProcessObject(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 39 | 36 | ||
| 40 | 37 | namespace task_queue { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -68,10 +68,7 @@ static void GetParentProcessId(Local<Name> property, | |||
| 68 | 68 | info.GetReturnValue().Set(uv_os_getppid()); | |
| 69 | 69 | } | |
| 70 | 70 | ||
| 71 | - MaybeLocal<Object> CreateProcessObject( | ||
| 72 | - Environment* env, | ||
| 73 | - const std::vector<std::string>& args, | ||
| 74 | - const std::vector<std::string>& exec_args) { | ||
| 71 | + MaybeLocal<Object> CreateProcessObject(Environment* env) { | ||
| 75 | 72 | Isolate* isolate = env->isolate(); | |
| 76 | 73 | EscapableHandleScope scope(isolate); | |
| 77 | 74 | Local<Context> context = env->context(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -256,6 +256,8 @@ void Worker::Run() { | |||
| 256 | 256 | // public API. | |
| 257 | 257 | env_.reset(new Environment(data.isolate_data_.get(), | |
| 258 | 258 | context, | |
| 259 | + std::move(argv_), | ||
| 260 | + std::move(exec_argv_), | ||
| 259 | 261 | Environment::kNoFlags, | |
| 260 | 262 | thread_id_)); | |
| 261 | 263 | CHECK_NOT_NULL(env_); | |
@@ -264,7 +266,6 @@ void Worker::Run() { | |||
| 264 | 266 | env_->set_worker_context(this); | |
| 265 | 267 | ||
| 266 | 268 | env_->InitializeLibuv(profiler_idle_notifier_started_); | |
| 267 | - env_->ProcessCliArgs(std::move(argv_), std::move(exec_argv_)); | ||
| 268 | 269 | } | |
| 269 | 270 | { | |
| 270 | 271 | Mutex::ScopedLock lock(mutex_); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments