#ifndef NODE_VARS_H #define NODE_VARS_H // This file contains all Isolate-local variables. We allow people to // compile Node either with Isolates or without. In the case that they // compile without isolates, these will be static variables. #include #include #include #if defined(_MSC_VER) # define PATH_MAX MAX_PATH #endif #ifndef PATH_MAX # define PATH_MAX 4096 #endif namespace node { #define NODE_VAR(x) (globals_get()->x) struct globals { // node.cc v8::Persistent process; v8::Persistent errno_symbol; v8::Persistent syscall_symbol; v8::Persistent errpath_symbol; v8::Persistent code_symbol; v8::Persistent rss_symbol; v8::Persistent heap_total_symbol; v8::Persistent heap_used_symbol; v8::Persistent listeners_symbol; v8::Persistent uncaught_exception_symbol; v8::Persistent emit_symbol; uv_check_t check_tick_watcher; uv_prepare_t prepare_tick_watcher; uv_idle_t tick_spinner; bool need_tick_cb; v8::Persistent tick_callback_sym; bool use_npn; bool use_sni; // Buffer for getpwnam_r(), getgrpam_r() and other misc callers; keep this // scoped at file-level rather than method-level to avoid excess stack usage. char getbuf[PATH_MAX + 1]; // We need to notify V8 when we're idle so that it can run the garbage // collector. The interface to this is V8::IdleNotification(). It returns // true if the heap hasn't be fully compacted, and needs to be run again. // Returning false means that it doesn't have anymore work to do. // // A rather convoluted algorithm has been devised to determine when Node is // idle. You'll have to figure it out for yourself. uv_check_t gc_check; uv_idle_t gc_idle; uv_timer_t gc_timer; bool need_gc; # define FAST_TICK 700. # define GC_WAIT_TIME 5000. # define RPM_SAMPLES 100 int64_t tick_times[RPM_SAMPLES]; int tick_time_head; int uncaught_exception_counter; v8::Persistent binding_cache; v8::Persistent module_load_list; v8::Isolate* node_isolate; volatile bool debugger_running; double prog_start_time; // stream_wrap.cc size_t slab_used; uv_stream_t* handle_that_last_alloced; v8::Persistent slab_sym; v8::Persistent buffer_sym; v8::Persistent write_queue_size_sym; bool stream_wrap_initialized; // tcp_wrap.cc v8::Persistent tcpConstructor; v8::Persistent family_symbol; v8::Persistent address_symbol; v8::Persistent port_symbol; // node_http_parser.cc v8::Persistent on_headers_sym; v8::Persistent on_headers_complete_sym; v8::Persistent on_body_sym; v8::Persistent on_message_complete_sym; v8::Persistent delete_sym; v8::Persistent get_sym; v8::Persistent head_sym; v8::Persistent post_sym; v8::Persistent put_sym; v8::Persistent connect_sym; v8::Persistent options_sym; v8::Persistent trace_sym; v8::Persistent patch_sym; v8::Persistent copy_sym; v8::Persistent lock_sym; v8::Persistent mkcol_sym; v8::Persistent move_sym; v8::Persistent propfind_sym; v8::Persistent proppatch_sym; v8::Persistent unlock_sym; v8::Persistent report_sym; v8::Persistent mkactivity_sym; v8::Persistent checkout_sym; v8::Persistent merge_sym; v8::Persistent msearch_sym; v8::Persistent notify_sym; v8::Persistent subscribe_sym; v8::Persistent unsubscribe_sym; v8::Persistent unknown_method_sym; v8::Persistent method_sym; v8::Persistent status_code_sym; v8::Persistent http_version_sym; v8::Persistent version_major_sym; v8::Persistent version_minor_sym; v8::Persistent should_keep_alive_sym; v8::Persistent upgrade_sym; v8::Persistent headers_sym; v8::Persistent url_sym; struct http_parser_settings settings; // This is a hack to get the current_buffer to the callbacks with the least // amount of overhead. Nothing else will run while http_parser_execute() // runs, therefore this pointer can be set and used for the execution. v8::Local* current_buffer; char* current_buffer_data; size_t current_buffer_len; // node_file.cc v8::Persistent encoding_symbol; v8::Persistent buf_symbol; v8::Persistent oncomplete_sym; v8::Persistent stats_constructor_template; v8::Persistent dev_symbol; v8::Persistent ino_symbol; v8::Persistent mode_symbol; v8::Persistent nlink_symbol; v8::Persistent uid_symbol; v8::Persistent gid_symbol; v8::Persistent rdev_symbol; v8::Persistent size_symbol; v8::Persistent blksize_symbol; v8::Persistent blocks_symbol; v8::Persistent atime_symbol; v8::Persistent mtime_symbol; v8::Persistent ctime_symbol; // node_zlib.cc v8::Persistent callback_sym; // node_crypto.cc v8::Persistent subject_symbol; v8::Persistent subjectaltname_symbol; v8::Persistent modulus_symbol; v8::Persistent exponent_symbol; v8::Persistent issuer_symbol; v8::Persistent valid_from_symbol; v8::Persistent valid_to_symbol; v8::Persistent fingerprint_symbol; v8::Persistent name_symbol; v8::Persistent version_symbol; v8::Persistent ext_key_usage_symbol; v8::Persistent secure_context_constructor; // node_buffer.cc v8::Persistent length_symbol; v8::Persistent chars_written_sym; v8::Persistent write_sym; v8::Persistent buffer_constructor_template; // node_script.cc v8::Persistent wrapped_context_constructor; v8::Persistent wrapped_script_constructor; // node_isolate.cc v8::Persistent isolate_debugger_constructor; // node_signal_watcher.cc v8::Persistent callback_symbol; v8::Persistent signal_watcher_constructor_template; // cares_wrap.cc ::ares_channel ares_channel; }; // Initialize globals struct. void globals_init(struct globals*); // Get the globals struct for the current Isolate. The returned pointer is // already initialized. struct globals* globals_get(); } // namespace node #endif // NODE_VARS_H