diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2014-10-13 15:19:55 +0200 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2014-10-13 23:46:46 +0400 |
commit | d3c317e08ac6a624fde8b242905992eafdd954ac (patch) | |
tree | 1dd2756855ab5b4513503acc660705fa898c5c64 /src/process_wrap.cc | |
parent | b45d33617b569bf5fa84c9343da9f7d129756968 (diff) | |
download | android-node-v8-d3c317e08ac6a624fde8b242905992eafdd954ac.tar.gz android-node-v8-d3c317e08ac6a624fde8b242905992eafdd954ac.tar.bz2 android-node-v8-d3c317e08ac6a624fde8b242905992eafdd954ac.zip |
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/process_wrap.cc')
-rw-r--r-- | src/process_wrap.cc | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/process_wrap.cc b/src/process_wrap.cc index 47baf90994..69c696acd0 100644 --- a/src/process_wrap.cc +++ b/src/process_wrap.cc @@ -51,18 +51,17 @@ class ProcessWrap : public HandleWrap { Handle<Value> unused, Handle<Context> context) { Environment* env = Environment::GetCurrent(context); - Local<FunctionTemplate> constructor = FunctionTemplate::New(env->isolate(), - New); + Local<FunctionTemplate> constructor = env->NewFunctionTemplate(New); constructor->InstanceTemplate()->SetInternalFieldCount(1); constructor->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "Process")); - NODE_SET_PROTOTYPE_METHOD(constructor, "close", HandleWrap::Close); + env->SetProtoMethod(constructor, "close", HandleWrap::Close); - NODE_SET_PROTOTYPE_METHOD(constructor, "spawn", Spawn); - NODE_SET_PROTOTYPE_METHOD(constructor, "kill", Kill); + env->SetProtoMethod(constructor, "spawn", Spawn); + env->SetProtoMethod(constructor, "kill", Kill); - NODE_SET_PROTOTYPE_METHOD(constructor, "ref", HandleWrap::Ref); - NODE_SET_PROTOTYPE_METHOD(constructor, "unref", HandleWrap::Unref); + env->SetProtoMethod(constructor, "ref", HandleWrap::Ref); + env->SetProtoMethod(constructor, "unref", HandleWrap::Unref); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Process"), constructor->GetFunction()); @@ -74,7 +73,7 @@ class ProcessWrap : public HandleWrap { // Therefore we assert that we are not trying to call this as a // normal function. CHECK(args.IsConstructCall()); - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); new ProcessWrap(env, args.This()); } @@ -130,7 +129,7 @@ class ProcessWrap : public HandleWrap { } static void Spawn(const FunctionCallbackInfo<Value>& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); ProcessWrap* wrap = Unwrap<ProcessWrap>(args.Holder()); |