@@ -77,6 +77,76 @@ IsolateData::~IsolateData() {
77
77
platform_->UnregisterIsolate (this );
78
78
}
79
79
80
+ Environment::Environment (IsolateData* isolate_data,
81
+ Local<Context> context)
82
+ : isolate_(context->GetIsolate ()),
83
+ isolate_data_(isolate_data),
84
+ timer_base_(uv_now(isolate_data->event_loop ())),
85
+ using_domains_(false ),
86
+ printed_error_(false ),
87
+ trace_sync_io_(false ),
88
+ abort_on_uncaught_exception_(false ),
89
+ makecallback_cntr_(0 ),
90
+ scheduled_immediate_count_(isolate_, 1 ),
91
+ #if HAVE_INSPECTOR
92
+ inspector_agent_ (new inspector::Agent(this )),
93
+ #endif
94
+ handle_cleanup_waiting_ (0 ),
95
+ http_parser_buffer_(nullptr ),
96
+ fs_stats_field_array_(nullptr ),
97
+ context_(context->GetIsolate (), context) {
98
+ // We'll be creating new objects so make sure we've entered the context.
99
+ v8::HandleScope handle_scope (isolate ());
100
+ v8::Context::Scope context_scope (context);
101
+ set_as_external (v8::External::New (isolate (), this ));
102
+
103
+ v8::Local<v8::Primitive> null = v8::Null (isolate ());
104
+ v8::Local<v8::Object> binding_cache_object = v8::Object::New (isolate ());
105
+ CHECK (binding_cache_object->SetPrototype (context, null).FromJust ());
106
+ set_binding_cache_object (binding_cache_object);
107
+
108
+ v8::Local<v8::Object> internal_binding_cache_object =
109
+ v8::Object::New (isolate ());
110
+ CHECK (internal_binding_cache_object->SetPrototype (context, null).FromJust ());
111
+ set_internal_binding_cache_object (internal_binding_cache_object);
112
+
113
+ set_module_load_list_array (v8::Array::New (isolate ()));
114
+
115
+ AssignToContext (context);
116
+
117
+ destroy_async_id_list_.reserve (512 );
118
+ performance_state_.reset (new performance::performance_state (isolate ()));
119
+ performance_state_->milestones [
120
+ performance::NODE_PERFORMANCE_MILESTONE_ENVIRONMENT] =
121
+ PERFORMANCE_NOW ();
122
+ performance_state_->milestones [
123
+ performance::NODE_PERFORMANCE_MILESTONE_NODE_START] =
124
+ performance::performance_node_start;
125
+ performance_state_->milestones [
126
+ performance::NODE_PERFORMANCE_MILESTONE_V8_START] =
127
+ performance::performance_v8_start;
128
+ }
129
+
130
+ Environment::~Environment () {
131
+ v8::HandleScope handle_scope (isolate ());
132
+
133
+ #if HAVE_INSPECTOR
134
+ // Destroy inspector agent before erasing the context. The inspector
135
+ // destructor depends on the context still being accessible.
136
+ inspector_agent_.reset ();
137
+ #endif
138
+
139
+ context ()->SetAlignedPointerInEmbedderData (kContextEmbedderDataIndex ,
140
+ nullptr );
141
+ #define V (PropertyName, TypeName ) PropertyName ## _.Reset();
142
+ ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES (V)
143
+ #undef V
144
+
145
+ delete[] heap_statistics_buffer_;
146
+ delete[] heap_space_statistics_buffer_;
147
+ delete[] http_parser_buffer_;
148
+ }
149
+
80
150
void Environment::Start (int argc,
81
151
const char * const * argv,
82
152
int exec_argc,
0 commit comments