diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2014-05-14 11:25:57 +0200 |
---|---|---|
committer | Trevor Norris <trev.norris@gmail.com> | 2014-09-09 16:52:45 -0700 |
commit | b8a8e5558d74333e141e3a72730eb72c3463c3ef (patch) | |
tree | f07b4fe2b26fd56a3bbd16840d4a093fb9c9bdc4 | |
parent | 6f07d2fa1bbc55d0159764dfe8b0d8c93b0e1990 (diff) | |
download | nodejs-b8a8e5558d74333e141e3a72730eb72c3463c3ef.tar.gz nodejs-b8a8e5558d74333e141e3a72730eb72c3463c3ef.tar.bz2 nodejs-b8a8e5558d74333e141e3a72730eb72c3463c3ef.zip |
deps: cherry-pick r21297 from v8 trunk
Changes the return value of PropertyCallbackInfo<T>::This() from
Local<Value> back to Local<Object>. See [1] and [2] for background.
[1] https://groups.google.com/forum/#!topic/v8-users/wP2UcQ4cBW4
[2] https://codereview.chromium.org/285643008/
Signed-off-by: Fedor Indutny <fedor@indutny.com>
-rw-r--r-- | deps/v8/include/v8.h | 6 | ||||
-rw-r--r-- | deps/v8/src/accessors.cc | 24 |
2 files changed, 20 insertions, 10 deletions
diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index d39dca96b..538b6581f 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -2493,7 +2493,7 @@ class PropertyCallbackInfo { public: V8_INLINE Isolate* GetIsolate() const; V8_INLINE Local<Value> Data() const; - V8_INLINE Local<Value> This() const; + V8_INLINE Local<Object> This() const; V8_INLINE Local<Object> Holder() const; V8_INLINE ReturnValue<T> GetReturnValue() const; // This shouldn't be public, but the arm compiler needs it. @@ -6488,8 +6488,8 @@ Local<Value> PropertyCallbackInfo<T>::Data() const { template<typename T> -Local<Value> PropertyCallbackInfo<T>::This() const { - return Local<Value>(reinterpret_cast<Value*>(&args_[kThisIndex])); +Local<Object> PropertyCallbackInfo<T>::This() const { + return Local<Object>(reinterpret_cast<Object*>(&args_[kThisIndex])); } diff --git a/deps/v8/src/accessors.cc b/deps/v8/src/accessors.cc index 8c8fcdd99..f219bed3b 100644 --- a/deps/v8/src/accessors.cc +++ b/deps/v8/src/accessors.cc @@ -20,6 +20,16 @@ namespace v8 { namespace internal { +// We have a slight impedance mismatch between the external API and the way we +// use callbacks internally: Externally, callbacks can only be used with +// v8::Object, but internally we even have callbacks on entities which are +// higher in the hierarchy, so we can only return i::Object here, not +// i::JSObject. +Handle<Object> GetThisFrom(const v8::PropertyCallbackInfo<v8::Value>& info) { + return Utils::OpenHandle(*v8::Local<v8::Value>(info.This())); +} + + Handle<AccessorInfo> Accessors::MakeAccessor( Isolate* isolate, Handle<String> name, @@ -146,7 +156,7 @@ void Accessors::ArrayLengthGetter( i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); DisallowHeapAllocation no_allocation; HandleScope scope(isolate); - Object* object = *Utils::OpenHandle(*info.This()); + Object* object = *GetThisFrom(info); // Traverse the prototype chain until we reach an array. JSArray* holder = FindInstanceOf<JSArray>(isolate, object); Object* result; @@ -229,7 +239,7 @@ void Accessors::StringLengthGetter( i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); DisallowHeapAllocation no_allocation; HandleScope scope(isolate); - Object* value = *Utils::OpenHandle(*info.This()); + Object* value = *GetThisFrom(info); Object* result; if (value->IsJSValue()) value = JSValue::cast(value)->value(); if (value->IsString()) { @@ -824,7 +834,7 @@ void Accessors::FunctionPrototypeGetter( const v8::PropertyCallbackInfo<v8::Value>& info) { i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); HandleScope scope(isolate); - Handle<Object> object = Utils::OpenHandle(*info.This()); + Handle<Object> object = GetThisFrom(info); Handle<Object> result = GetFunctionPrototype(isolate, object); info.GetReturnValue().Set(Utils::ToLocal(result)); } @@ -864,7 +874,7 @@ void Accessors::FunctionLengthGetter( const v8::PropertyCallbackInfo<v8::Value>& info) { i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); HandleScope scope(isolate); - Handle<Object> object = Utils::OpenHandle(*info.This()); + Handle<Object> object = GetThisFrom(info); MaybeHandle<JSFunction> maybe_function; { @@ -922,7 +932,7 @@ void Accessors::FunctionNameGetter( const v8::PropertyCallbackInfo<v8::Value>& info) { i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); HandleScope scope(isolate); - Handle<Object> object = Utils::OpenHandle(*info.This()); + Handle<Object> object = GetThisFrom(info); MaybeHandle<JSFunction> maybe_function; { @@ -1071,7 +1081,7 @@ void Accessors::FunctionArgumentsGetter( const v8::PropertyCallbackInfo<v8::Value>& info) { i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); HandleScope scope(isolate); - Handle<Object> object = Utils::OpenHandle(*info.This()); + Handle<Object> object = GetThisFrom(info); MaybeHandle<JSFunction> maybe_function; { @@ -1210,7 +1220,7 @@ void Accessors::FunctionCallerGetter( const v8::PropertyCallbackInfo<v8::Value>& info) { i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); HandleScope scope(isolate); - Handle<Object> object = Utils::OpenHandle(*info.This()); + Handle<Object> object = GetThisFrom(info); MaybeHandle<JSFunction> maybe_function; { DisallowHeapAllocation no_allocation; |