Skip to content

Commit

Permalink
Remove _isolate variable (unsure about this)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmfcmf committed Mar 13, 2018
1 parent 81e9d6a commit c70d931
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4465,7 +4465,6 @@ Local<Context> context;
bool request_stop = false;
CmdArgs* cmd_args = nullptr;
bool _event_loop_running = false;
v8::Isolate* _isolate = nullptr;
Environment* _environment = nullptr;

bool eventLoopIsRunning() {
Expand All @@ -4474,7 +4473,7 @@ bool eventLoopIsRunning() {

namespace internal {
v8::Isolate* isolate() {
return _isolate;
return node_isolate;
}

Environment* environment() {
Expand Down Expand Up @@ -4538,18 +4537,17 @@ void _DeleteIsolate() {
delete _handle_scope_wrapper;
_handle_scope_wrapper = nullptr;

_isolate->Exit();
node_isolate->Exit();

delete locker;
locker = nullptr;

{
Mutex::ScopedLock scoped_lock(node_isolate_mutex);
CHECK_EQ(node_isolate, _isolate);
node_isolate->Dispose();
node_isolate = nullptr;
}

_isolate->Dispose();

delete allocator;
allocator = nullptr;
Expand Down Expand Up @@ -4597,45 +4595,45 @@ int _CreateIsolate() {
params.code_event_handler = vTune::GetVtuneCodeEventHandler();
#endif

_isolate = Isolate::New(params);
if (_isolate == nullptr) {
Isolate* const isolate = Isolate::New(params);
if (isolate == nullptr) {
return 12; // Signal internal error.
}

_isolate->AddMessageListener(OnMessage);
_isolate->SetAbortOnUncaughtExceptionCallback(ShouldAbortOnUncaughtException);
_isolate->SetMicrotasksPolicy(v8::MicrotasksPolicy::kExplicit);
_isolate->SetFatalErrorHandler(OnFatalError);
isolate->AddMessageListener(OnMessage);
isolate->SetAbortOnUncaughtExceptionCallback(ShouldAbortOnUncaughtException);
isolate->SetMicrotasksPolicy(v8::MicrotasksPolicy::kExplicit);
isolate->SetFatalErrorHandler(OnFatalError);

{
Mutex::ScopedLock scoped_lock(node_isolate_mutex);
CHECK_EQ(node_isolate, nullptr);
node_isolate = _isolate;
node_isolate = isolate;
}

return 0;
}

void _CreateInitialEnvironment() {
locker = new Locker(_isolate);
_isolate->Enter();
_handle_scope_wrapper = new HandleScopeHeapWrapper(_isolate);
locker = new Locker(node_isolate);
node_isolate->Enter();
_handle_scope_wrapper = new HandleScopeHeapWrapper(node_isolate);

isolate_data = new IsolateData(
_isolate,
node_isolate,
uv_default_loop(),
v8_platform.Platform(),
allocator->zero_fill_field());

if (track_heap_objects) {
_isolate->GetHeapProfiler()->StartTrackingHeapObjects(true);
node_isolate->GetHeapProfiler()->StartTrackingHeapObjects(true);
}

// TODO(justus-hildebrand): in the initial Start functions,
// two handle scopes were created
// (one in Start() 2 and one in Start() 3). Currently, we have no idea why.
// HandleScope handle_scope(isolate);
context = NewContext(_isolate);
context = NewContext(node_isolate);
context->Enter();
_environment = new Environment(isolate_data, context);
}
Expand Down Expand Up @@ -4774,7 +4772,7 @@ v8::MaybeLocal<v8::Value> Evaluate(const std::string& js_code) {
// ScriptOrigin origin(filename);
MaybeLocal<v8::Script> script = v8::Script::Compile(
_environment->context(),
v8::String::NewFromUtf8(_isolate, js_code.c_str())
v8::String::NewFromUtf8(node_isolate, js_code.c_str())
/*removed param: origin*/);

if (script.IsEmpty()) {
Expand Down Expand Up @@ -4832,7 +4830,7 @@ v8::MaybeLocal<v8::Value> Call(v8::Local<v8::Object> object,
const std::string& function_name,
const std::vector<v8::Local<v8::Value>>& args) {
MaybeLocal<v8::String> maybe_function_name =
v8::String::NewFromUtf8(_isolate, function_name.c_str());
v8::String::NewFromUtf8(node_isolate, function_name.c_str());

Local<v8::String> v8_function_name;

Expand Down Expand Up @@ -4863,7 +4861,7 @@ v8::MaybeLocal<v8::Value> Call(v8::Local<v8::Object> object,

v8::MaybeLocal<v8::Object> IncludeModule(const std::string& name) {
MaybeLocal<v8::String> maybe_arg =
v8::String::NewFromUtf8(_isolate, name.c_str());
v8::String::NewFromUtf8(node_isolate, name.c_str());

Local<v8::String> arg;

Expand Down Expand Up @@ -4895,7 +4893,7 @@ v8::MaybeLocal<v8::Object> IncludeModule(const std::string& name) {
v8::MaybeLocal<v8::Value> GetValue(v8::Local<v8::Object> object,
const std::string& value_name) {
MaybeLocal<v8::String> maybe_key =
v8::String::NewFromUtf8(_isolate, value_name.c_str());
v8::String::NewFromUtf8(node_isolate, value_name.c_str());

Local<v8::String> key;

Expand Down

0 comments on commit c70d931

Please sign in to comment.