Skip to content

Commit 06d86eb

Browse files
committed
Move node_http_parser.cc global vars into node_vars.h
1 parent f8c335d commit 06d86eb

2 files changed

Lines changed: 110 additions & 72 deletions

File tree

src/node_http_parser.cc

Lines changed: 47 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -47,61 +47,57 @@
4747
// allocations.
4848

4949

50+
#include <node_vars.h>
51+
// We do the following to minimize the detal between v0.6 branch. We want to
52+
// use the variables as they were being used before.
53+
#define on_headers_sym NODE_VAR(on_headers_sym)
54+
#define on_headers_complete_sym NODE_VAR(on_headers_complete_sym)
55+
#define on_body_sym NODE_VAR(on_body_sym)
56+
#define on_message_complete_sym NODE_VAR(on_message_complete_sym)
57+
#define delete_sym NODE_VAR(delete_sym)
58+
#define get_sym NODE_VAR(get_sym)
59+
#define head_sym NODE_VAR(head_sym)
60+
#define post_sym NODE_VAR(post_sym)
61+
#define put_sym NODE_VAR(put_sym)
62+
#define connect_sym NODE_VAR(connect_sym)
63+
#define options_sym NODE_VAR(options_sym)
64+
#define trace_sym NODE_VAR(trace_sym)
65+
#define patch_sym NODE_VAR(patch_sym)
66+
#define copy_sym NODE_VAR(copy_sym)
67+
#define lock_sym NODE_VAR(lock_sym)
68+
#define mkcol_sym NODE_VAR(mkcol_sym)
69+
#define move_sym NODE_VAR(move_sym)
70+
#define propfind_sym NODE_VAR(propfind_sym)
71+
#define proppatch_sym NODE_VAR(proppatch_sym)
72+
#define unlock_sym NODE_VAR(unlock_sym)
73+
#define report_sym NODE_VAR(report_sym)
74+
#define mkactivity_sym NODE_VAR(mkactivity_sym)
75+
#define checkout_sym NODE_VAR(checkout_sym)
76+
#define merge_sym NODE_VAR(merge_sym)
77+
#define msearch_sym NODE_VAR(msearch_sym)
78+
#define notify_sym NODE_VAR(notify_sym)
79+
#define subscribe_sym NODE_VAR(subscribe_sym)
80+
#define unsubscribe_sym NODE_VAR(unsubscribe_sym)
81+
#define unknown_method_sym NODE_VAR(unknown_method_sym)
82+
#define method_sym NODE_VAR(method_sym)
83+
#define status_code_sym NODE_VAR(status_code_sym)
84+
#define http_version_sym NODE_VAR(http_version_sym)
85+
#define version_major_sym NODE_VAR(version_major_sym)
86+
#define version_minor_sym NODE_VAR(version_minor_sym)
87+
#define should_keep_alive_sym NODE_VAR(should_keep_alive_sym)
88+
#define upgrade_sym NODE_VAR(upgrade_sym)
89+
#define headers_sym NODE_VAR(headers_sym)
90+
#define url_sym NODE_VAR(url_sym)
91+
#define settings NODE_VAR(settings)
92+
#define current_buffer NODE_VAR(current_buffer)
93+
#define current_buffer_data NODE_VAR(current_buffer_data)
94+
#define current_buffer_len NODE_VAR(current_buffer_len)
95+
96+
5097
namespace node {
5198

5299
using namespace v8;
53100

54-
static Persistent<String> on_headers_sym;
55-
static Persistent<String> on_headers_complete_sym;
56-
static Persistent<String> on_body_sym;
57-
static Persistent<String> on_message_complete_sym;
58-
59-
static Persistent<String> delete_sym;
60-
static Persistent<String> get_sym;
61-
static Persistent<String> head_sym;
62-
static Persistent<String> post_sym;
63-
static Persistent<String> put_sym;
64-
static Persistent<String> connect_sym;
65-
static Persistent<String> options_sym;
66-
static Persistent<String> trace_sym;
67-
static Persistent<String> patch_sym;
68-
static Persistent<String> copy_sym;
69-
static Persistent<String> lock_sym;
70-
static Persistent<String> mkcol_sym;
71-
static Persistent<String> move_sym;
72-
static Persistent<String> propfind_sym;
73-
static Persistent<String> proppatch_sym;
74-
static Persistent<String> unlock_sym;
75-
static Persistent<String> report_sym;
76-
static Persistent<String> mkactivity_sym;
77-
static Persistent<String> checkout_sym;
78-
static Persistent<String> merge_sym;
79-
static Persistent<String> msearch_sym;
80-
static Persistent<String> notify_sym;
81-
static Persistent<String> subscribe_sym;
82-
static Persistent<String> unsubscribe_sym;
83-
static Persistent<String> unknown_method_sym;
84-
85-
static Persistent<String> method_sym;
86-
static Persistent<String> status_code_sym;
87-
static Persistent<String> http_version_sym;
88-
static Persistent<String> version_major_sym;
89-
static Persistent<String> version_minor_sym;
90-
static Persistent<String> should_keep_alive_sym;
91-
static Persistent<String> upgrade_sym;
92-
static Persistent<String> headers_sym;
93-
static Persistent<String> url_sym;
94-
95-
static struct http_parser_settings settings;
96-
97-
98-
// This is a hack to get the current_buffer to the callbacks with the least
99-
// amount of overhead. Nothing else will run while http_parser_execute()
100-
// runs, therefore this pointer can be set and used for the execution.
101-
static Local<Value>* current_buffer;
102-
static char* current_buffer_data;
103-
static size_t current_buffer_len;
104-
105101

106102
// gcc 3.x knows the always_inline attribute but fails at build time with a
107103
// "sorry, unimplemented: inlining failed" error when compiling at -O0

src/node_vars.h

Lines changed: 63 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <v8.h>
99
#include <uv.h>
10+
#include <http_parser.h>
1011

1112
#ifndef PATH_MAX
1213
# define PATH_MAX 4096
@@ -30,42 +31,23 @@ struct globals {
3031
v8::Persistent<v8::String> listeners_symbol;
3132
v8::Persistent<v8::String> uncaught_exception_symbol;
3233
v8::Persistent<v8::String> emit_symbol;
33-
34-
// stream_wrap.cc
35-
size_t slab_used;
36-
uv_stream_t* handle_that_last_alloced;
37-
v8::Persistent<v8::String> slab_sym;
38-
v8::Persistent<v8::String> buffer_sym;
39-
v8::Persistent<v8::String> write_queue_size_sym;
40-
bool stream_wrap_initialized;
41-
42-
// tcp_wrap.cc
43-
v8::Persistent<v8::Function> tcpConstructor;
44-
v8::Persistent<v8::String> family_symbol;
45-
v8::Persistent<v8::String> address_symbol;
46-
v8::Persistent<v8::String> port_symbol;
47-
4834
bool print_eval;
4935
char *eval_string;
5036
int option_end_index;
5137
bool use_debug_agent;
5238
bool debug_wait_connect;
5339
int debug_port;
5440
int max_stack_size;
55-
5641
uv_check_t check_tick_watcher;
5742
uv_prepare_t prepare_tick_watcher;
5843
uv_idle_t tick_spinner;
5944
bool need_tick_cb;
6045
v8::Persistent<v8::String> tick_callback_sym;
61-
6246
bool use_npn;
6347
bool use_sni;
64-
6548
// Buffer for getpwnam_r(), getgrpam_r() and other misc callers; keep this
6649
// scoped at file-level rather than method-level to avoid excess stack usage.
6750
char getbuf[PATH_MAX + 1];
68-
6951
// We need to notify V8 when we're idle so that it can run the garbage
7052
// collector. The interface to this is V8::IdleNotification(). It returns
7153
// true if the heap hasn't be fully compacted, and needs to be run again.
@@ -77,13 +59,73 @@ struct globals {
7759
uv_idle_t gc_idle;
7860
uv_timer_t gc_timer;
7961
bool need_gc;
80-
8162
# define FAST_TICK 700.
8263
# define GC_WAIT_TIME 5000.
8364
# define RPM_SAMPLES 100
84-
8565
int64_t tick_times[RPM_SAMPLES];
8666
int tick_time_head;
67+
68+
// stream_wrap.cc
69+
size_t slab_used;
70+
uv_stream_t* handle_that_last_alloced;
71+
v8::Persistent<v8::String> slab_sym;
72+
v8::Persistent<v8::String> buffer_sym;
73+
v8::Persistent<v8::String> write_queue_size_sym;
74+
bool stream_wrap_initialized;
75+
76+
// tcp_wrap.cc
77+
v8::Persistent<v8::Function> tcpConstructor;
78+
v8::Persistent<v8::String> family_symbol;
79+
v8::Persistent<v8::String> address_symbol;
80+
v8::Persistent<v8::String> port_symbol;
81+
82+
// node_http_parser.cc
83+
v8::Persistent<v8::String> on_headers_sym;
84+
v8::Persistent<v8::String> on_headers_complete_sym;
85+
v8::Persistent<v8::String> on_body_sym;
86+
v8::Persistent<v8::String> on_message_complete_sym;
87+
v8::Persistent<v8::String> delete_sym;
88+
v8::Persistent<v8::String> get_sym;
89+
v8::Persistent<v8::String> head_sym;
90+
v8::Persistent<v8::String> post_sym;
91+
v8::Persistent<v8::String> put_sym;
92+
v8::Persistent<v8::String> connect_sym;
93+
v8::Persistent<v8::String> options_sym;
94+
v8::Persistent<v8::String> trace_sym;
95+
v8::Persistent<v8::String> patch_sym;
96+
v8::Persistent<v8::String> copy_sym;
97+
v8::Persistent<v8::String> lock_sym;
98+
v8::Persistent<v8::String> mkcol_sym;
99+
v8::Persistent<v8::String> move_sym;
100+
v8::Persistent<v8::String> propfind_sym;
101+
v8::Persistent<v8::String> proppatch_sym;
102+
v8::Persistent<v8::String> unlock_sym;
103+
v8::Persistent<v8::String> report_sym;
104+
v8::Persistent<v8::String> mkactivity_sym;
105+
v8::Persistent<v8::String> checkout_sym;
106+
v8::Persistent<v8::String> merge_sym;
107+
v8::Persistent<v8::String> msearch_sym;
108+
v8::Persistent<v8::String> notify_sym;
109+
v8::Persistent<v8::String> subscribe_sym;
110+
v8::Persistent<v8::String> unsubscribe_sym;
111+
v8::Persistent<v8::String> unknown_method_sym;
112+
v8::Persistent<v8::String> method_sym;
113+
v8::Persistent<v8::String> status_code_sym;
114+
v8::Persistent<v8::String> http_version_sym;
115+
v8::Persistent<v8::String> version_major_sym;
116+
v8::Persistent<v8::String> version_minor_sym;
117+
v8::Persistent<v8::String> should_keep_alive_sym;
118+
v8::Persistent<v8::String> upgrade_sym;
119+
v8::Persistent<v8::String> headers_sym;
120+
v8::Persistent<v8::String> url_sym;
121+
struct http_parser_settings settings;
122+
// This is a hack to get the current_buffer to the callbacks with the least
123+
// amount of overhead. Nothing else will run while http_parser_execute()
124+
// runs, therefore this pointer can be set and used for the execution.
125+
v8::Local<v8::Value>* current_buffer;
126+
char* current_buffer_data;
127+
size_t current_buffer_len;
128+
87129
};
88130

89131
struct globals* globals_get();

0 commit comments

Comments
 (0)