Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 667aa60b7ef0051d1ebb77913693e84e9233bd7e..62d34ac6f813654f6a2863dc5b2f17e94cdc9c87 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -2578,6 +2578,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 |
+ // to propagate outside. |
+ TryCatch try_catch; |
EXCEPTION_PREAMBLE(); |
i::Handle<i::Object> result = i::SetPrototype(self, value_obj); |
has_pending_exception = result.is_null(); |
@@ -2778,9 +2781,30 @@ bool v8::Object::HasIndexedLookupInterceptor() { |
} |
+static Local<Value> GetPropertyByLookup(i::Isolate* isolate, |
Mads Ager (chromium)
2011/03/22 07:32:14
The isolate parameter is not used. Remove?
antonm
2011/03/22 10:57:06
It's implicitly used in EXCEPTION_BAILOUT_CHECK.
|
+ i::Handle<i::JSObject> receiver, |
+ i::Handle<i::String> name, |
+ i::LookupResult* lookup) { |
+ if (!lookup->IsProperty()) { |
+ // No real property was found. |
+ return Local<Value>(); |
+ } |
+ |
+ // If the property being looked up is a callback, it can throw |
+ // an exception. |
+ EXCEPTION_PREAMBLE(); |
+ i::Handle<i::Object> result = i::GetProperty(receiver, name, lookup); |
+ has_pending_exception = result.is_null(); |
+ EXCEPTION_BAILOUT_CHECK(Local<Value>()); |
+ |
+ return Utils::ToLocal(result); |
+} |
+ |
+ |
Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( |
Handle<String> key) { |
- ON_BAILOUT(i::Isolate::Current(), |
+ i::Isolate* isolate = i::Isolate::Current(); |
+ ON_BAILOUT(isolate, |
"v8::Object::GetRealNamedPropertyInPrototypeChain()", |
return Local<Value>()); |
ENTER_V8; |
@@ -2788,39 +2812,20 @@ 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(isolate, self_obj, key_obj, &lookup); |
} |
Local<Value> v8::Object::GetRealNamedProperty(Handle<String> key) { |
- ON_BAILOUT(i::Isolate::Current(), "v8::Object::GetRealNamedProperty()", |
+ i::Isolate* isolate = i::Isolate::Current(); |
+ ON_BAILOUT(isolate, "v8::Object::GetRealNamedProperty()", |
return Local<Value>()); |
ENTER_V8; |
i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); |
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(isolate, self_obj, key_obj, &lookup); |
} |