summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2011-12-07 13:31:55 -0800
committerRyan Dahl <ry@tinyclouds.org>2011-12-07 13:31:55 -0800
commit06d86ebe84281ec53b83145b77e4a8a1a41a6fde (patch)
treeb60b3f9bb52b5152df86e8240eaa7d416cd18048
parentf8c335d0caf47f16d31413f89aa28eda3878e3aa (diff)
downloadnode-new-06d86ebe84281ec53b83145b77e4a8a1a41a6fde.tar.gz
Move node_http_parser.cc global vars into node_vars.h
-rw-r--r--src/node_http_parser.cc98
-rw-r--r--src/node_vars.h84
2 files changed, 110 insertions, 72 deletions
diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc
index 38251a1e7c..4cbde2253c 100644
--- a/src/node_http_parser.cc
+++ b/src/node_http_parser.cc
@@ -47,61 +47,57 @@
// allocations.
+#include <node_vars.h>
+// We do the following to minimize the detal between v0.6 branch. We want to
+// use the variables as they were being used before.
+#define on_headers_sym NODE_VAR(on_headers_sym)
+#define on_headers_complete_sym NODE_VAR(on_headers_complete_sym)
+#define on_body_sym NODE_VAR(on_body_sym)
+#define on_message_complete_sym NODE_VAR(on_message_complete_sym)
+#define delete_sym NODE_VAR(delete_sym)
+#define get_sym NODE_VAR(get_sym)
+#define head_sym NODE_VAR(head_sym)
+#define post_sym NODE_VAR(post_sym)
+#define put_sym NODE_VAR(put_sym)
+#define connect_sym NODE_VAR(connect_sym)
+#define options_sym NODE_VAR(options_sym)
+#define trace_sym NODE_VAR(trace_sym)
+#define patch_sym NODE_VAR(patch_sym)
+#define copy_sym NODE_VAR(copy_sym)
+#define lock_sym NODE_VAR(lock_sym)
+#define mkcol_sym NODE_VAR(mkcol_sym)
+#define move_sym NODE_VAR(move_sym)
+#define propfind_sym NODE_VAR(propfind_sym)
+#define proppatch_sym NODE_VAR(proppatch_sym)
+#define unlock_sym NODE_VAR(unlock_sym)
+#define report_sym NODE_VAR(report_sym)
+#define mkactivity_sym NODE_VAR(mkactivity_sym)
+#define checkout_sym NODE_VAR(checkout_sym)
+#define merge_sym NODE_VAR(merge_sym)
+#define msearch_sym NODE_VAR(msearch_sym)
+#define notify_sym NODE_VAR(notify_sym)
+#define subscribe_sym NODE_VAR(subscribe_sym)
+#define unsubscribe_sym NODE_VAR(unsubscribe_sym)
+#define unknown_method_sym NODE_VAR(unknown_method_sym)
+#define method_sym NODE_VAR(method_sym)
+#define status_code_sym NODE_VAR(status_code_sym)
+#define http_version_sym NODE_VAR(http_version_sym)
+#define version_major_sym NODE_VAR(version_major_sym)
+#define version_minor_sym NODE_VAR(version_minor_sym)
+#define should_keep_alive_sym NODE_VAR(should_keep_alive_sym)
+#define upgrade_sym NODE_VAR(upgrade_sym)
+#define headers_sym NODE_VAR(headers_sym)
+#define url_sym NODE_VAR(url_sym)
+#define settings NODE_VAR(settings)
+#define current_buffer NODE_VAR(current_buffer)
+#define current_buffer_data NODE_VAR(current_buffer_data)
+#define current_buffer_len NODE_VAR(current_buffer_len)
+
+
namespace node {
using namespace v8;
-static Persistent<String> on_headers_sym;
-static Persistent<String> on_headers_complete_sym;
-static Persistent<String> on_body_sym;
-static Persistent<String> on_message_complete_sym;
-
-static Persistent<String> delete_sym;
-static Persistent<String> get_sym;
-static Persistent<String> head_sym;
-static Persistent<String> post_sym;
-static Persistent<String> put_sym;
-static Persistent<String> connect_sym;
-static Persistent<String> options_sym;
-static Persistent<String> trace_sym;
-static Persistent<String> patch_sym;
-static Persistent<String> copy_sym;
-static Persistent<String> lock_sym;
-static Persistent<String> mkcol_sym;
-static Persistent<String> move_sym;
-static Persistent<String> propfind_sym;
-static Persistent<String> proppatch_sym;
-static Persistent<String> unlock_sym;
-static Persistent<String> report_sym;
-static Persistent<String> mkactivity_sym;
-static Persistent<String> checkout_sym;
-static Persistent<String> merge_sym;
-static Persistent<String> msearch_sym;
-static Persistent<String> notify_sym;
-static Persistent<String> subscribe_sym;
-static Persistent<String> unsubscribe_sym;
-static Persistent<String> unknown_method_sym;
-
-static Persistent<String> method_sym;
-static Persistent<String> status_code_sym;
-static Persistent<String> http_version_sym;
-static Persistent<String> version_major_sym;
-static Persistent<String> version_minor_sym;
-static Persistent<String> should_keep_alive_sym;
-static Persistent<String> upgrade_sym;
-static Persistent<String> headers_sym;
-static Persistent<String> url_sym;
-
-static 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.
-static Local<Value>* current_buffer;
-static char* current_buffer_data;
-static size_t current_buffer_len;
-
// gcc 3.x knows the always_inline attribute but fails at build time with a
// "sorry, unimplemented: inlining failed" error when compiling at -O0
diff --git a/src/node_vars.h b/src/node_vars.h
index 049be057ee..ce49dbaf3f 100644
--- a/src/node_vars.h
+++ b/src/node_vars.h
@@ -7,6 +7,7 @@
#include <v8.h>
#include <uv.h>
+#include <http_parser.h>
#ifndef PATH_MAX
# define PATH_MAX 4096
@@ -30,21 +31,6 @@ struct globals {
v8::Persistent<v8::String> listeners_symbol;
v8::Persistent<v8::String> uncaught_exception_symbol;
v8::Persistent<v8::String> emit_symbol;
-
- // stream_wrap.cc
- size_t slab_used;
- uv_stream_t* handle_that_last_alloced;
- v8::Persistent<v8::String> slab_sym;
- v8::Persistent<v8::String> buffer_sym;
- v8::Persistent<v8::String> write_queue_size_sym;
- bool stream_wrap_initialized;
-
- // tcp_wrap.cc
- v8::Persistent<v8::Function> tcpConstructor;
- v8::Persistent<v8::String> family_symbol;
- v8::Persistent<v8::String> address_symbol;
- v8::Persistent<v8::String> port_symbol;
-
bool print_eval;
char *eval_string;
int option_end_index;
@@ -52,20 +38,16 @@ struct globals {
bool debug_wait_connect;
int debug_port;
int max_stack_size;
-
uv_check_t check_tick_watcher;
uv_prepare_t prepare_tick_watcher;
uv_idle_t tick_spinner;
bool need_tick_cb;
v8::Persistent<v8::String> 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.
@@ -77,13 +59,73 @@ struct globals {
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;
+
+ // stream_wrap.cc
+ size_t slab_used;
+ uv_stream_t* handle_that_last_alloced;
+ v8::Persistent<v8::String> slab_sym;
+ v8::Persistent<v8::String> buffer_sym;
+ v8::Persistent<v8::String> write_queue_size_sym;
+ bool stream_wrap_initialized;
+
+ // tcp_wrap.cc
+ v8::Persistent<v8::Function> tcpConstructor;
+ v8::Persistent<v8::String> family_symbol;
+ v8::Persistent<v8::String> address_symbol;
+ v8::Persistent<v8::String> port_symbol;
+
+ // node_http_parser.cc
+ v8::Persistent<v8::String> on_headers_sym;
+ v8::Persistent<v8::String> on_headers_complete_sym;
+ v8::Persistent<v8::String> on_body_sym;
+ v8::Persistent<v8::String> on_message_complete_sym;
+ v8::Persistent<v8::String> delete_sym;
+ v8::Persistent<v8::String> get_sym;
+ v8::Persistent<v8::String> head_sym;
+ v8::Persistent<v8::String> post_sym;
+ v8::Persistent<v8::String> put_sym;
+ v8::Persistent<v8::String> connect_sym;
+ v8::Persistent<v8::String> options_sym;
+ v8::Persistent<v8::String> trace_sym;
+ v8::Persistent<v8::String> patch_sym;
+ v8::Persistent<v8::String> copy_sym;
+ v8::Persistent<v8::String> lock_sym;
+ v8::Persistent<v8::String> mkcol_sym;
+ v8::Persistent<v8::String> move_sym;
+ v8::Persistent<v8::String> propfind_sym;
+ v8::Persistent<v8::String> proppatch_sym;
+ v8::Persistent<v8::String> unlock_sym;
+ v8::Persistent<v8::String> report_sym;
+ v8::Persistent<v8::String> mkactivity_sym;
+ v8::Persistent<v8::String> checkout_sym;
+ v8::Persistent<v8::String> merge_sym;
+ v8::Persistent<v8::String> msearch_sym;
+ v8::Persistent<v8::String> notify_sym;
+ v8::Persistent<v8::String> subscribe_sym;
+ v8::Persistent<v8::String> unsubscribe_sym;
+ v8::Persistent<v8::String> unknown_method_sym;
+ v8::Persistent<v8::String> method_sym;
+ v8::Persistent<v8::String> status_code_sym;
+ v8::Persistent<v8::String> http_version_sym;
+ v8::Persistent<v8::String> version_major_sym;
+ v8::Persistent<v8::String> version_minor_sym;
+ v8::Persistent<v8::String> should_keep_alive_sym;
+ v8::Persistent<v8::String> upgrade_sym;
+ v8::Persistent<v8::String> headers_sym;
+ v8::Persistent<v8::String> 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<v8::Value>* current_buffer;
+ char* current_buffer_data;
+ size_t current_buffer_len;
+
};
struct globals* globals_get();