Index: src/runtime.cc |
=================================================================== |
--- src/runtime.cc (revision 1900) |
+++ src/runtime.cc (working copy) |
@@ -2832,19 +2832,37 @@ |
} |
-static Object* HasLocalPropertyImplementation(Object* obj, String* key) { |
+static Object* HasLocalPropertyImplementation(Handle<JSObject> object, |
+ Handle<String> key) { |
+ if (object->HasLocalProperty(*key)) return Heap::true_value(); |
+ // Handle hidden prototypes. If there's a hidden prototype above this thing |
+ // then we have to check it for properties, because they are supposed to |
+ // look like they are on this object. |
+ Handle<Object> proto(object->GetPrototype()); |
+ if (proto->IsJSObject() && |
+ JSObject::cast(*proto)->map()->is_hidden_prototype()) { |
+ return HasLocalPropertyImplementation(Handle<JSObject>::cast(proto), key); |
+ } |
+ return Heap::false_value(); |
+} |
+ |
+ |
+static Object* Runtime_HasLocalProperty(Arguments args) { |
+ NoHandleAllocation ha; |
+ ASSERT(args.length() == 2); |
+ CONVERT_CHECKED(String, key, args[1]); |
+ |
+ Object* obj = args[0]; |
// Only JS objects can have properties. |
if (obj->IsJSObject()) { |
JSObject* object = JSObject::cast(obj); |
- if (object->HasLocalProperty(key)) return Heap::true_value(); |
- // Handle hidden prototypes. If there's a hidden prototype above this thing |
- // then we have to check it for properties, because they are supposed to |
- // look like they are on this object. |
- Object* proto = object->GetPrototype(); |
- if (proto->IsJSObject() && |
- JSObject::cast(proto)->map()->is_hidden_prototype()) { |
- return HasLocalPropertyImplementation(object->GetPrototype(), key); |
- } |
+ // Fast case - no interceptors. |
+ if (object->HasRealNamedProperty(key)) return Heap::true_value(); |
+ // Slow case. Either it's not there or we have an interceptor. We should |
+ // have handles for this kind of deal. |
+ HandleScope scope; |
+ return HasLocalPropertyImplementation(Handle<JSObject>(object), |
+ Handle<String>(key)); |
} else if (obj->IsString()) { |
// Well, there is one exception: Handle [] on strings. |
uint32_t index; |
@@ -2858,15 +2876,6 @@ |
} |
-static Object* Runtime_HasLocalProperty(Arguments args) { |
- NoHandleAllocation ha; |
- ASSERT(args.length() == 2); |
- CONVERT_CHECKED(String, key, args[1]); |
- |
- return HasLocalPropertyImplementation(args[0], key); |
-} |
- |
- |
static Object* Runtime_HasProperty(Arguments args) { |
NoHandleAllocation na; |
ASSERT(args.length() == 2); |