Commit 0fbfdf16 authored by dcarney@chromium.org's avatar dcarney@chromium.org

ReturnValue::Set needs to check for empty handles

R=jkummerow@chromium.org
BUG=

Review URL: https://codereview.chromium.org/16073010

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14898 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d0d7619d
......@@ -5665,14 +5665,22 @@ template<typename T>
template<typename S>
void ReturnValue<T>::Set(const Persistent<S>& handle) {
TYPE_CHECK(T, S);
*value_ = *reinterpret_cast<internal::Object**>(*handle);
if (V8_UNLIKELY(handle.IsEmpty())) {
SetUndefined();
} else {
*value_ = *reinterpret_cast<internal::Object**>(*handle);
}
}
template<typename T>
template<typename S>
void ReturnValue<T>::Set(const Handle<S> handle) {
TYPE_CHECK(T, S);
*value_ = *reinterpret_cast<internal::Object**>(*handle);
if (V8_UNLIKELY(handle.IsEmpty())) {
SetUndefined();
} else {
*value_ = *reinterpret_cast<internal::Object**>(*handle);
}
}
template<typename T>
......
......@@ -1029,6 +1029,7 @@ static const double kFastReturnValueDouble = 2.7;
// variable return values
static bool fast_return_value_bool = false;
static bool fast_return_value_void_is_null = false;
static bool fast_return_value_object_is_empty = false;
template<>
void FastReturnValueCallback<int32_t>(
......@@ -1072,7 +1073,9 @@ void FastReturnValueCallback<void>(
template<>
void FastReturnValueCallback<Object>(
const v8::FunctionCallbackInfo<v8::Value>& info) {
info.GetReturnValue().Set(Object::New());
v8::Handle<v8::Object> object;
if (!fast_return_value_object_is_empty) object = Object::New();
info.GetReturnValue().Set(object);
}
template<typename T>
......@@ -1119,8 +1122,13 @@ THREADED_TEST(FastReturnValues) {
CHECK(value->IsUndefined());
}
}
// check handles
fast_return_value_object_is_empty = false;
value = TestFastReturnValues<Object>();
CHECK(value->IsObject());
fast_return_value_object_is_empty = true;
value = TestFastReturnValues<Object>();
CHECK(value->IsUndefined());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment