diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2014-10-13 17:19:55 +0400 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2014-10-13 23:46:46 +0400 |
commit | d3c317e08ac6a624fde8b242905992eafdd954ac (patch) | |
tree | 1dd2756855ab5b4513503acc660705fa898c5c64 /src/node_v8.cc | |
parent | b45d33617b569bf5fa84c9343da9f7d129756968 (diff) |
src: attach env directly to api functions
Attach the per-context execution environment directly to API functions.
Rationale:
* Gets node one step closer to multi-isolate readiness.
* Avoids multi-context confusion, e.g. when the caller and callee live
in different contexts.
* Avoids expensive calls to pthread_getspecific() on platforms where
V8 does not know how to use the thread-local storage directly.
(Linux, the BSDs.)
PR-URL: https://github.com/node-forward/node/pull/18
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Diffstat (limited to 'src/node_v8.cc')
-rw-r--r-- | src/node_v8.cc | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/node_v8.cc b/src/node_v8.cc index 0c7d5f3ebd8..d59e661fbdb 100644 --- a/src/node_v8.cc +++ b/src/node_v8.cc @@ -173,14 +173,14 @@ void Environment::StopGarbageCollectionTracking() { void StartGarbageCollectionTracking(const FunctionCallbackInfo<Value>& args) { CHECK(args[0]->IsFunction() == true); - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); env->StartGarbageCollectionTracking(args[0].As<Function>()); } void GetHeapStatistics(const FunctionCallbackInfo<Value>& args) { + Environment* env = Environment::GetCurrent(args); Isolate* isolate = args.GetIsolate(); - Environment* env = Environment::GetCurrent(isolate); HeapStatistics s; isolate->GetHeapStatistics(&s); Local<Object> info = Object::New(isolate); @@ -200,20 +200,21 @@ void GetHeapStatistics(const FunctionCallbackInfo<Value>& args) { void StopGarbageCollectionTracking(const FunctionCallbackInfo<Value>& args) { - Environment::GetCurrent(args.GetIsolate())->StopGarbageCollectionTracking(); + Environment::GetCurrent(args)->StopGarbageCollectionTracking(); } void InitializeV8Bindings(Handle<Object> target, Handle<Value> unused, Handle<Context> context) { - NODE_SET_METHOD(target, - "startGarbageCollectionTracking", - StartGarbageCollectionTracking); - NODE_SET_METHOD(target, - "stopGarbageCollectionTracking", - StopGarbageCollectionTracking); - NODE_SET_METHOD(target, "getHeapStatistics", GetHeapStatistics); + Environment* env = Environment::GetCurrent(context); + env->SetMethod(target, + "startGarbageCollectionTracking", + StartGarbageCollectionTracking); + env->SetMethod(target, + "stopGarbageCollectionTracking", + StopGarbageCollectionTracking); + env->SetMethod(target, "getHeapStatistics", GetHeapStatistics); } } // namespace node |