Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 93037822cf3553ca0b60b62b736430b96770520d..d84f2718b41f94e2388054ec6adf0a500daa8c5b 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -2377,6 +2377,9 @@ bool v8::Object::SetPrototype(Handle<Value> value) { |
ENTER_V8; |
i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
+ // We do not allow exceptions thrown while setting the prototype |
+ // propagate outside. |
+ TryCatch try_catch; |
EXCEPTION_PREAMBLE(); |
i::Handle<i::Object> result = i::SetPrototype(self, value_obj); |
has_pending_exception = result.is_null(); |
@@ -2563,6 +2566,30 @@ bool v8::Object::HasIndexedLookupInterceptor() { |
} |
+static Local<Value> GetPropertyByLookup(i::Handle<i::JSObject> receiver, |
+ i::Handle<i::String> name, |
+ i::LookupResult* lookup) { |
+ if (!lookup->IsProperty()) { |
+ // No real property was found. |
+ return Local<Value>(); |
+ } |
+ |
+ EXCEPTION_PREAMBLE(); |
+ |
+ PropertyAttributes attributes; |
+ i::MaybeObject* value = |
+ receiver->GetProperty(*receiver, lookup, *name, &attributes); |
Vitaly Repeshko
2011/02/01 19:07:17
Wrap this in CALL_HEAP_FUNCTION?
antonm
2011/02/01 20:14:39
Done.
|
+ |
+ // If the property being looked up is a callback, it can throw |
+ // an exception. |
+ has_pending_exception = value->IsFailure(); |
+ EXCEPTION_BAILOUT_CHECK(Local<Value>()); |
+ |
+ i::Handle<i::Object> result(value->ToObjectUnchecked()); |
+ return Utils::ToLocal(result); |
+} |
+ |
+ |
Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( |
Handle<String> key) { |
ON_BAILOUT("v8::Object::GetRealNamedPropertyInPrototypeChain()", |
@@ -2572,17 +2599,7 @@ Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( |
i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
i::LookupResult lookup; |
self_obj->LookupRealNamedPropertyInPrototypes(*key_obj, &lookup); |
- if (lookup.IsProperty()) { |
- PropertyAttributes attributes; |
- i::Object* property = |
- self_obj->GetProperty(*self_obj, |
- &lookup, |
- *key_obj, |
- &attributes)->ToObjectUnchecked(); |
- i::Handle<i::Object> result(property); |
- return Utils::ToLocal(result); |
- } |
- return Local<Value>(); // No real property was found in prototype chain. |
+ return GetPropertyByLookup(self_obj, key_obj, &lookup); |
} |
@@ -2593,17 +2610,7 @@ Local<Value> v8::Object::GetRealNamedProperty(Handle<String> key) { |
i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
i::LookupResult lookup; |
self_obj->LookupRealNamedProperty(*key_obj, &lookup); |
- if (lookup.IsProperty()) { |
- PropertyAttributes attributes; |
- i::Object* property = |
- self_obj->GetProperty(*self_obj, |
- &lookup, |
- *key_obj, |
- &attributes)->ToObjectUnchecked(); |
- i::Handle<i::Object> result(property); |
- return Utils::ToLocal(result); |
- } |
- return Local<Value>(); // No real property was found in prototype chain. |
+ return GetPropertyByLookup(self_obj, key_obj, &lookup); |
} |