GCC Code Coverage Report
Directory: ../src/ Exec Total Coverage
File: /home/node-core-coverage/node-core-coverage/workdir/node/src/env.h Lines: 4 4 100.0 %
Date: 2016-07-23 Branches: 0 0 0.0 %

Line Exec Source
1
#ifndef SRC_ENV_H_
2
#define SRC_ENV_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#include "ares.h"
7
#include "debug-agent.h"
8
#if HAVE_INSPECTOR
9
#include "inspector_agent.h"
10
#endif
11
#include "handle_wrap.h"
12
#include "req-wrap.h"
13
#include "tree.h"
14
#include "util.h"
15
#include "uv.h"
16
#include "v8.h"
17
18
#include <stdint.h>
19
20
// Caveat emptor: we're going slightly crazy with macros here but the end
21
// hopefully justifies the means. We have a lot of per-context properties
22
// and adding and maintaining their getters and setters by hand would be
23
// a nightmare so let's make the preprocessor generate them for us.
24
//
25
// Make sure that any macros defined here are undefined again at the bottom
26
// of context-inl.h. The exceptions are NODE_CONTEXT_EMBEDDER_DATA_INDEX
27
// and NODE_ISOLATE_SLOT, they may have been defined externally.
28
namespace node {
29
30
// Pick an index that's hopefully out of the way when we're embedded inside
31
// another application. Performance-wise or memory-wise it doesn't matter:
32
// Context::SetAlignedPointerInEmbedderData() is backed by a FixedArray,
33
// worst case we pay a one-time penalty for resizing the array.
34
#ifndef NODE_CONTEXT_EMBEDDER_DATA_INDEX
35
#define NODE_CONTEXT_EMBEDDER_DATA_INDEX 32
36
#endif
37
38
// The slot 0 and 1 had already been taken by "gin" and "blink" in Chrome,
39
// and the size of isolate's slots is 4 by default, so using 3 should
40
// hopefully make node work independently when embedded into other
41
// application.
42
#ifndef NODE_ISOLATE_SLOT
43
#define NODE_ISOLATE_SLOT 3
44
#endif
45
46
// The number of items passed to push_values_to_array_function has diminishing
47
// returns around 8. This should be used at all call sites using said function.
48
#ifndef NODE_PUSH_VAL_TO_ARRAY_MAX
49
#define NODE_PUSH_VAL_TO_ARRAY_MAX 8
50
#endif
51
52
// Private symbols are per-isolate primitives but Environment proxies them
53
// for the sake of convenience.  Strings should be ASCII-only and have a
54
// "node:" prefix to avoid name clashes with third-party code.
55
#define PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(V)                              \
56
  V(alpn_buffer_private_symbol, "node:alpnBuffer")                            \
57
  V(arrow_message_private_symbol, "node:arrowMessage")                        \
58
  V(contextify_context_private_symbol, "node:contextify:context")             \
59
  V(contextify_global_private_symbol, "node:contextify:global")               \
60
  V(decorated_private_symbol, "node:decorated")                               \
61
  V(npn_buffer_private_symbol, "node:npnBuffer")                              \
62
  V(processed_private_symbol, "node:processed")                               \
63
  V(selected_npn_buffer_private_symbol, "node:selectedNpnBuffer")             \
64
65
// Strings are per-isolate primitives but Environment proxies them
66
// for the sake of convenience.  Strings should be ASCII-only.
67
#define PER_ISOLATE_STRING_PROPERTIES(V)                                      \
68
  V(address_string, "address")                                                \
69
  V(args_string, "args")                                                      \
70
  V(argv_string, "argv")                                                      \
71
  V(async, "async")                                                           \
72
  V(async_queue_string, "_asyncQueue")                                        \
73
  V(atime_string, "atime")                                                    \
74
  V(birthtime_string, "birthtime")                                            \
75
  V(blksize_string, "blksize")                                                \
76
  V(blocks_string, "blocks")                                                  \
77
  V(buffer_string, "buffer")                                                  \
78
  V(bytes_string, "bytes")                                                    \
79
  V(bytes_parsed_string, "bytesParsed")                                       \
80
  V(bytes_read_string, "bytesRead")                                           \
81
  V(cached_data_string, "cachedData")                                         \
82
  V(cached_data_produced_string, "cachedDataProduced")                        \
83
  V(cached_data_rejected_string, "cachedDataRejected")                        \
84
  V(callback_string, "callback")                                              \
85
  V(change_string, "change")                                                  \
86
  V(oncertcb_string, "oncertcb")                                              \
87
  V(onclose_string, "_onclose")                                               \
88
  V(code_string, "code")                                                      \
89
  V(compare_string, "compare")                                                \
90
  V(ctime_string, "ctime")                                                    \
91
  V(cwd_string, "cwd")                                                        \
92
  V(debug_port_string, "debugPort")                                           \
93
  V(debug_string, "debug")                                                    \
94
  V(dest_string, "dest")                                                      \
95
  V(detached_string, "detached")                                              \
96
  V(dev_string, "dev")                                                        \
97
  V(disposed_string, "_disposed")                                             \
98
  V(domain_string, "domain")                                                  \
99
  V(emitting_top_level_domain_error_string, "_emittingTopLevelDomainError")   \
100
  V(exchange_string, "exchange")                                              \
101
  V(idle_string, "idle")                                                      \
102
  V(irq_string, "irq")                                                        \
103
  V(encoding_string, "encoding")                                              \
104
  V(enter_string, "enter")                                                    \
105
  V(env_pairs_string, "envPairs")                                             \
106
  V(env_string, "env")                                                        \
107
  V(errno_string, "errno")                                                    \
108
  V(error_string, "error")                                                    \
109
  V(events_string, "_events")                                                 \
110
  V(exec_argv_string, "execArgv")                                             \
111
  V(exec_path_string, "execPath")                                             \
112
  V(exiting_string, "_exiting")                                               \
113
  V(exit_code_string, "exitCode")                                             \
114
  V(exit_string, "exit")                                                      \
115
  V(expire_string, "expire")                                                  \
116
  V(exponent_string, "exponent")                                              \
117
  V(exports_string, "exports")                                                \
118
  V(ext_key_usage_string, "ext_key_usage")                                    \
119
  V(external_stream_string, "_externalStream")                                \
120
  V(family_string, "family")                                                  \
121
  V(fatal_exception_string, "_fatalException")                                \
122
  V(fd_string, "fd")                                                          \
123
  V(file_string, "file")                                                      \
124
  V(fingerprint_string, "fingerprint")                                        \
125
  V(flags_string, "flags")                                                    \
126
  V(fsevent_string, "FSEvent")                                                \
127
  V(gid_string, "gid")                                                        \
128
  V(handle_string, "handle")                                                  \
129
  V(heap_total_string, "heapTotal")                                           \
130
  V(heap_used_string, "heapUsed")                                             \
131
  V(homedir_string, "homedir")                                                \
132
  V(hostmaster_string, "hostmaster")                                          \
133
  V(ignore_string, "ignore")                                                  \
134
  V(immediate_callback_string, "_immediateCallback")                          \
135
  V(infoaccess_string, "infoAccess")                                          \
136
  V(inherit_string, "inherit")                                                \
137
  V(ino_string, "ino")                                                        \
138
  V(input_string, "input")                                                    \
139
  V(internal_string, "internal")                                              \
140
  V(ipv4_string, "IPv4")                                                      \
141
  V(ipv6_lc_string, "ipv6")                                                   \
142
  V(ipv6_string, "IPv6")                                                      \
143
  V(isalive_string, "isAlive")                                                \
144
  V(isclosing_string, "isClosing")                                            \
145
  V(issuer_string, "issuer")                                                  \
146
  V(issuercert_string, "issuerCertificate")                                   \
147
  V(kill_signal_string, "killSignal")                                         \
148
  V(mac_string, "mac")                                                        \
149
  V(mark_sweep_compact_string, "mark-sweep-compact")                          \
150
  V(max_buffer_string, "maxBuffer")                                           \
151
  V(message_string, "message")                                                \
152
  V(minttl_string, "minttl")                                                  \
153
  V(mode_string, "mode")                                                      \
154
  V(model_string, "model")                                                    \
155
  V(modulus_string, "modulus")                                                \
156
  V(mtime_string, "mtime")                                                    \
157
  V(name_string, "name")                                                      \
158
  V(need_imm_cb_string, "_needImmediateCallback")                             \
159
  V(netmask_string, "netmask")                                                \
160
  V(nice_string, "nice")                                                      \
161
  V(nlink_string, "nlink")                                                    \
162
  V(nsname_string, "nsname")                                                  \
163
  V(ocsp_request_string, "OCSPRequest")                                       \
164
  V(offset_string, "offset")                                                  \
165
  V(onchange_string, "onchange")                                              \
166
  V(onclienthello_string, "onclienthello")                                    \
167
  V(oncomplete_string, "oncomplete")                                          \
168
  V(onconnection_string, "onconnection")                                      \
169
  V(ondone_string, "ondone")                                                  \
170
  V(onerror_string, "onerror")                                                \
171
  V(onexit_string, "onexit")                                                  \
172
  V(onhandshakedone_string, "onhandshakedone")                                \
173
  V(onhandshakestart_string, "onhandshakestart")                              \
174
  V(onmessage_string, "onmessage")                                            \
175
  V(onnewsession_string, "onnewsession")                                      \
176
  V(onnewsessiondone_string, "onnewsessiondone")                              \
177
  V(onocspresponse_string, "onocspresponse")                                  \
178
  V(onread_string, "onread")                                                  \
179
  V(onreadstart_string, "onreadstart")                                        \
180
  V(onreadstop_string, "onreadstop")                                          \
181
  V(onselect_string, "onselect")                                              \
182
  V(onshutdown_string, "onshutdown")                                          \
183
  V(onsignal_string, "onsignal")                                              \
184
  V(onstop_string, "onstop")                                                  \
185
  V(onwrite_string, "onwrite")                                                \
186
  V(output_string, "output")                                                  \
187
  V(order_string, "order")                                                    \
188
  V(owner_string, "owner")                                                    \
189
  V(parse_error_string, "Parse Error")                                        \
190
  V(path_string, "path")                                                      \
191
  V(pbkdf2_error_string, "PBKDF2 Error")                                      \
192
  V(pid_string, "pid")                                                        \
193
  V(pipe_string, "pipe")                                                      \
194
  V(port_string, "port")                                                      \
195
  V(preference_string, "preference")                                          \
196
  V(priority_string, "priority")                                              \
197
  V(produce_cached_data_string, "produceCachedData")                          \
198
  V(prototype_string, "prototype")                                            \
199
  V(raw_string, "raw")                                                        \
200
  V(rdev_string, "rdev")                                                      \
201
  V(readable_string, "readable")                                              \
202
  V(received_shutdown_string, "receivedShutdown")                             \
203
  V(refresh_string, "refresh")                                                \
204
  V(regexp_string, "regexp")                                                  \
205
  V(rename_string, "rename")                                                  \
206
  V(replacement_string, "replacement")                                        \
207
  V(retry_string, "retry")                                                    \
208
  V(rss_string, "rss")                                                        \
209
  V(serial_string, "serial")                                                  \
210
  V(scavenge_string, "scavenge")                                              \
211
  V(scopeid_string, "scopeid")                                                \
212
  V(sent_shutdown_string, "sentShutdown")                                     \
213
  V(serial_number_string, "serialNumber")                                     \
214
  V(service_string, "service")                                                \
215
  V(servername_string, "servername")                                          \
216
  V(session_id_string, "sessionId")                                           \
217
  V(shell_string, "shell")                                                    \
218
  V(signal_string, "signal")                                                  \
219
  V(size_string, "size")                                                      \
220
  V(sni_context_err_string, "Invalid SNI context")                            \
221
  V(sni_context_string, "sni_context")                                        \
222
  V(speed_string, "speed")                                                    \
223
  V(stack_string, "stack")                                                    \
224
  V(status_string, "status")                                                  \
225
  V(stdio_string, "stdio")                                                    \
226
  V(subject_string, "subject")                                                \
227
  V(subjectaltname_string, "subjectaltname")                                  \
228
  V(sys_string, "sys")                                                        \
229
  V(syscall_string, "syscall")                                                \
230
  V(tick_callback_string, "_tickCallback")                                    \
231
  V(tick_domain_cb_string, "_tickDomainCallback")                             \
232
  V(ticketkeycallback_string, "onticketkeycallback")                          \
233
  V(timeout_string, "timeout")                                                \
234
  V(times_string, "times")                                                    \
235
  V(timestamp_string, "timestamp")                                            \
236
  V(title_string, "title")                                                    \
237
  V(tls_npn_string, "tls_npn")                                                \
238
  V(tls_alpn_string, "tls_alpn")                                              \
239
  V(tls_ocsp_string, "tls_ocsp")                                              \
240
  V(tls_sni_string, "tls_sni")                                                \
241
  V(tls_string, "tls")                                                        \
242
  V(tls_ticket_string, "tlsTicket")                                           \
243
  V(type_string, "type")                                                      \
244
  V(uid_string, "uid")                                                        \
245
  V(unknown_string, "<unknown>")                                              \
246
  V(user_string, "user")                                                      \
247
  V(username_string, "username")                                              \
248
  V(uv_string, "uv")                                                          \
249
  V(valid_from_string, "valid_from")                                          \
250
  V(valid_to_string, "valid_to")                                              \
251
  V(verify_error_string, "verifyError")                                       \
252
  V(version_string, "version")                                                \
253
  V(weight_string, "weight")                                                  \
254
  V(windows_verbatim_arguments_string, "windowsVerbatimArguments")            \
255
  V(wrap_string, "wrap")                                                      \
256
  V(writable_string, "writable")                                              \
257
  V(write_queue_size_string, "writeQueueSize")                                \
258
  V(x_forwarded_string, "x-forwarded-for")                                    \
259
  V(zero_return_string, "ZERO_RETURN")                                        \
260
261
#define ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V)                           \
262
  V(as_external, v8::External)                                                \
263
  V(async_hooks_destroy_function, v8::Function)                               \
264
  V(async_hooks_init_function, v8::Function)                                  \
265
  V(async_hooks_post_function, v8::Function)                                  \
266
  V(async_hooks_pre_function, v8::Function)                                   \
267
  V(binding_cache_object, v8::Object)                                         \
268
  V(buffer_constructor_function, v8::Function)                                \
269
  V(buffer_prototype_object, v8::Object)                                      \
270
  V(context, v8::Context)                                                     \
271
  V(domain_array, v8::Array)                                                  \
272
  V(domains_stack_array, v8::Array)                                           \
273
  V(fs_stats_constructor_function, v8::Function)                              \
274
  V(generic_internal_field_template, v8::ObjectTemplate)                      \
275
  V(jsstream_constructor_template, v8::FunctionTemplate)                      \
276
  V(module_load_list_array, v8::Array)                                        \
277
  V(pipe_constructor_template, v8::FunctionTemplate)                          \
278
  V(process_object, v8::Object)                                               \
279
  V(promise_reject_function, v8::Function)                                    \
280
  V(push_values_to_array_function, v8::Function)                              \
281
  V(script_context_constructor_template, v8::FunctionTemplate)                \
282
  V(script_data_constructor_function, v8::Function)                           \
283
  V(secure_context_constructor_template, v8::FunctionTemplate)                \
284
  V(tcp_constructor_template, v8::FunctionTemplate)                           \
285
  V(tick_callback_function, v8::Function)                                     \
286
  V(tls_wrap_constructor_function, v8::Function)                              \
287
  V(tls_wrap_constructor_template, v8::FunctionTemplate)                      \
288
  V(tty_constructor_template, v8::FunctionTemplate)                           \
289
  V(udp_constructor_function, v8::Function)                                   \
290
  V(write_wrap_constructor_function, v8::Function)                            \
291
292
class Environment;
293
294
struct node_ares_task {
295
  Environment* env;
296
  ares_socket_t sock;
297
  uv_poll_t poll_watcher;
298
  RB_ENTRY(node_ares_task) node;
299
};
300
301
RB_HEAD(node_ares_task_list, node_ares_task);
302
303
class IsolateData {
304
 public:
305
  inline IsolateData(v8::Isolate* isolate, uv_loop_t* event_loop,
306
                     uint32_t* zero_fill_field = nullptr);
307
  inline uv_loop_t* event_loop() const;
308
  inline uint32_t* zero_fill_field() const;
309
310
#define VP(PropertyName, StringValue) V(v8::Private, PropertyName, StringValue)
311
#define VS(PropertyName, StringValue) V(v8::String, PropertyName, StringValue)
312
#define V(TypeName, PropertyName, StringValue)                                \
313
  inline v8::Local<TypeName> PropertyName(v8::Isolate* isolate) const;
314
  PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP)
315
  PER_ISOLATE_STRING_PROPERTIES(VS)
316
#undef V
317
#undef VS
318
#undef VP
319
320
 private:
321
#define VP(PropertyName, StringValue) V(v8::Private, PropertyName, StringValue)
322
#define VS(PropertyName, StringValue) V(v8::String, PropertyName, StringValue)
323
#define V(TypeName, PropertyName, StringValue)                                \
324
  v8::Eternal<TypeName> PropertyName ## _;
325
  PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP)
326
  PER_ISOLATE_STRING_PROPERTIES(VS)
327
#undef V
328
#undef VS
329
#undef VP
330
331
  uv_loop_t* const event_loop_;
332
  uint32_t* const zero_fill_field_;
333
334
  DISALLOW_COPY_AND_ASSIGN(IsolateData);
335
};
336
337
class Environment {
338
 public:
339
  class AsyncHooks {
340
   public:
341
    inline uint32_t* fields();
342
    inline int fields_count() const;
343
    inline bool callbacks_enabled();
344
    inline void set_enable_callbacks(uint32_t flag);
345
346
   private:
347
    friend class Environment;  // So we can call the constructor.
348
    inline AsyncHooks();
349
350
    enum Fields {
351
      // Set this to not zero if the init hook should be called.
352
      kEnableCallbacks,
353
      kFieldsCount
354
    };
355
356
    uint32_t fields_[kFieldsCount];
357
358
    DISALLOW_COPY_AND_ASSIGN(AsyncHooks);
359
  };
360
361
  class AsyncCallbackScope {
362
   public:
363
    explicit AsyncCallbackScope(Environment* env);
364
    ~AsyncCallbackScope();
365
366
    inline bool in_makecallback();
367
368
   private:
369
    Environment* env_;
370
371
    DISALLOW_COPY_AND_ASSIGN(AsyncCallbackScope);
372
  };
373
374
  class DomainFlag {
375
   public:
376
    inline uint32_t* fields();
377
    inline int fields_count() const;
378
    inline uint32_t count() const;
379
380
   private:
381
    friend class Environment;  // So we can call the constructor.
382
    inline DomainFlag();
383
384
    enum Fields {
385
      kCount,
386
      kFieldsCount
387
    };
388
389
    uint32_t fields_[kFieldsCount];
390
391
    DISALLOW_COPY_AND_ASSIGN(DomainFlag);
392
  };
393
394
  class TickInfo {
395
   public:
396
    inline uint32_t* fields();
397
    inline int fields_count() const;
398
    inline uint32_t index() const;
399
    inline uint32_t length() const;
400
    inline void set_index(uint32_t value);
401
402
   private:
403
    friend class Environment;  // So we can call the constructor.
404
    inline TickInfo();
405
406
    enum Fields {
407
      kIndex,
408
      kLength,
409
      kFieldsCount
410
    };
411
412
    uint32_t fields_[kFieldsCount];
413
414
    DISALLOW_COPY_AND_ASSIGN(TickInfo);
415
  };
416
417
  typedef void (*HandleCleanupCb)(Environment* env,
418
                                  uv_handle_t* handle,
419
                                  void* arg);
420
421
13650
  class HandleCleanup {
422
   private:
423
    friend class Environment;
424
425
    HandleCleanup(uv_handle_t* handle, HandleCleanupCb cb, void* arg)
426
        : handle_(handle),
427
          cb_(cb),
428
15528
          arg_(arg) {
429
    }
430
431
    uv_handle_t* handle_;
432
    HandleCleanupCb cb_;
433
    void* arg_;
434
    ListNode<HandleCleanup> handle_cleanup_queue_;
435
  };
436
437
  static inline Environment* GetCurrent(v8::Isolate* isolate);
438
  static inline Environment* GetCurrent(v8::Local<v8::Context> context);
439
  static inline Environment* GetCurrent(
440
      const v8::FunctionCallbackInfo<v8::Value>& info);
441
442
  template <typename T>
443
  static inline Environment* GetCurrent(
444
      const v8::PropertyCallbackInfo<T>& info);
445
446
  inline Environment(IsolateData* isolate_data, v8::Local<v8::Context> context);
447
  inline ~Environment();
448
449
  void Start(int argc,
450
             const char* const* argv,
451
             int exec_argc,
452
             const char* const* exec_argv,
453
             bool start_profiler_idle_notifier);
454
  void AssignToContext(v8::Local<v8::Context> context);
455
456
  void StartProfilerIdleNotifier();
457
  void StopProfilerIdleNotifier();
458
459
  inline v8::Isolate* isolate() const;
460
  inline uv_loop_t* event_loop() const;
461
  inline bool async_wrap_callbacks_enabled() const;
462
  inline bool in_domain() const;
463
  inline uint32_t watched_providers() const;
464
465
  static inline Environment* from_immediate_check_handle(uv_check_t* handle);
466
  inline uv_check_t* immediate_check_handle();
467
  inline uv_idle_t* immediate_idle_handle();
468
469
  // Register clean-up cb to be called on environment destruction.
470
  inline void RegisterHandleCleanup(uv_handle_t* handle,
471
                                    HandleCleanupCb cb,
472
                                    void *arg);
473
  inline void FinishHandleCleanup(uv_handle_t* handle);
474
475
  inline AsyncHooks* async_hooks();
476
  inline DomainFlag* domain_flag();
477
  inline TickInfo* tick_info();
478
  inline uint64_t timer_base() const;
479
480
  static inline Environment* from_cares_timer_handle(uv_timer_t* handle);
481
  inline uv_timer_t* cares_timer_handle();
482
  inline ares_channel cares_channel();
483
  inline ares_channel* cares_channel_ptr();
484
  inline node_ares_task_list* cares_task_list();
485
  inline IsolateData* isolate_data() const;
486
487
  inline bool using_domains() const;
488
  inline void set_using_domains(bool value);
489
490
  inline bool printed_error() const;
491
  inline void set_printed_error(bool value);
492
493
  void PrintSyncTrace() const;
494
  inline void set_trace_sync_io(bool value);
495
496
  inline int64_t get_async_wrap_uid();
497
498
  inline uint32_t* heap_statistics_buffer() const;
499
  inline void set_heap_statistics_buffer(uint32_t* pointer);
500
501
  inline uint32_t* heap_space_statistics_buffer() const;
502
  inline void set_heap_space_statistics_buffer(uint32_t* pointer);
503
504
  inline char* http_parser_buffer() const;
505
  inline void set_http_parser_buffer(char* buffer);
506
507
  inline void ThrowError(const char* errmsg);
508
  inline void ThrowTypeError(const char* errmsg);
509
  inline void ThrowRangeError(const char* errmsg);
510
  inline void ThrowErrnoException(int errorno,
511
                                  const char* syscall = nullptr,
512
                                  const char* message = nullptr,
513
                                  const char* path = nullptr);
514
  inline void ThrowUVException(int errorno,
515
                               const char* syscall = nullptr,
516
                               const char* message = nullptr,
517
                               const char* path = nullptr,
518
                               const char* dest = nullptr);
519
520
  // Convenience methods for contextify
521
  inline static void ThrowError(v8::Isolate* isolate, const char* errmsg);
522
  inline static void ThrowTypeError(v8::Isolate* isolate, const char* errmsg);
523
  inline static void ThrowRangeError(v8::Isolate* isolate, const char* errmsg);
524
525
  inline v8::Local<v8::FunctionTemplate>
526
      NewFunctionTemplate(v8::FunctionCallback callback,
527
                          v8::Local<v8::Signature> signature =
528
                              v8::Local<v8::Signature>());
529
530
  // Convenience methods for NewFunctionTemplate().
531
  inline void SetMethod(v8::Local<v8::Object> that,
532
                        const char* name,
533
                        v8::FunctionCallback callback);
534
  inline void SetProtoMethod(v8::Local<v8::FunctionTemplate> that,
535
                             const char* name,
536
                             v8::FunctionCallback callback);
537
  inline void SetTemplateMethod(v8::Local<v8::FunctionTemplate> that,
538
                                const char* name,
539
                                v8::FunctionCallback callback);
540
541
  inline v8::Local<v8::Object> NewInternalFieldObject();
542
543
  // Strings and private symbols are shared across shared contexts
544
  // The getters simply proxy to the per-isolate primitive.
545
#define VP(PropertyName, StringValue) V(v8::Private, PropertyName, StringValue)
546
#define VS(PropertyName, StringValue) V(v8::String, PropertyName, StringValue)
547
#define V(TypeName, PropertyName, StringValue)                                \
548
  inline v8::Local<TypeName> PropertyName() const;
549
  PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP)
550
  PER_ISOLATE_STRING_PROPERTIES(VS)
551
#undef V
552
#undef VS
553
#undef VP
554
555
#define V(PropertyName, TypeName)                                             \
556
  inline v8::Local<TypeName> PropertyName() const;                            \
557
  inline void set_ ## PropertyName(v8::Local<TypeName> value);
558
  ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V)
559
#undef V
560
561
  inline debugger::Agent* debugger_agent() {
562
16
    return &debugger_agent_;
563
  }
564
565
#if HAVE_INSPECTOR
566
  inline inspector::Agent* inspector_agent() {
567
1505
    return &inspector_agent_;
568
  }
569
#endif
570
571
  typedef ListHead<HandleWrap, &HandleWrap::handle_wrap_queue_> HandleWrapQueue;
572
  typedef ListHead<ReqWrap<uv_req_t>, &ReqWrap<uv_req_t>::req_wrap_queue_>
573
          ReqWrapQueue;
574
575
  inline HandleWrapQueue* handle_wrap_queue() { return &handle_wrap_queue_; }
576
  inline ReqWrapQueue* req_wrap_queue() { return &req_wrap_queue_; }
577
578
  static const int kContextEmbedderDataIndex = NODE_CONTEXT_EMBEDDER_DATA_INDEX;
579
580
 private:
581
  v8::Isolate* const isolate_;
582
  IsolateData* const isolate_data_;
583
  uv_check_t immediate_check_handle_;
584
  uv_idle_t immediate_idle_handle_;
585
  uv_prepare_t idle_prepare_handle_;
586
  uv_check_t idle_check_handle_;
587
  AsyncHooks async_hooks_;
588
  DomainFlag domain_flag_;
589
  TickInfo tick_info_;
590
  const uint64_t timer_base_;
591
  uv_timer_t cares_timer_handle_;
592
  ares_channel cares_channel_;
593
  node_ares_task_list cares_task_list_;
594
  bool using_domains_;
595
  bool printed_error_;
596
  bool trace_sync_io_;
597
  size_t makecallback_cntr_;
598
  int64_t async_wrap_uid_;
599
  debugger::Agent debugger_agent_;
600
#if HAVE_INSPECTOR
601
  inspector::Agent inspector_agent_;
602
#endif
603
604
  HandleWrapQueue handle_wrap_queue_;
605
  ReqWrapQueue req_wrap_queue_;
606
  ListHead<HandleCleanup,
607
           &HandleCleanup::handle_cleanup_queue_> handle_cleanup_queue_;
608
  int handle_cleanup_waiting_;
609
610
  uint32_t* heap_statistics_buffer_ = nullptr;
611
  uint32_t* heap_space_statistics_buffer_ = nullptr;
612
613
  char* http_parser_buffer_;
614
615
#define V(PropertyName, TypeName)                                             \
616
  v8::Persistent<TypeName> PropertyName ## _;
617
  ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V)
618
#undef V
619
620
  DISALLOW_COPY_AND_ASSIGN(Environment);
621
};
622
623
}  // namespace node
624
625
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
626
627
#endif  // SRC_ENV_H_