Index: src/objects.cc |
=================================================================== |
--- src/objects.cc (revision 3900) |
+++ src/objects.cc (working copy) |
@@ -219,7 +219,7 @@ |
LookupResult* result, |
String* name, |
PropertyAttributes* attributes) { |
- if (result->IsValid()) { |
+ if (result->IsProperty()) { |
switch (result->type()) { |
case CALLBACKS: { |
// Only allow API accessors. |
@@ -242,7 +242,7 @@ |
// Search ALL_CAN_READ accessors in prototype chain. |
LookupResult r; |
result->holder()->LookupRealNamedPropertyInPrototypes(name, &r); |
- if (r.IsValid()) { |
+ if (r.IsProperty()) { |
return GetPropertyWithFailedAccessCheck(receiver, |
&r, |
name, |
@@ -255,16 +255,15 @@ |
// No access check in GetPropertyAttributeWithInterceptor. |
LookupResult r; |
result->holder()->LookupRealNamedProperty(name, &r); |
- if (r.IsValid()) { |
+ if (r.IsProperty()) { |
return GetPropertyWithFailedAccessCheck(receiver, |
&r, |
name, |
attributes); |
} |
} |
- default: { |
- break; |
- } |
+ default: |
+ UNREACHABLE(); |
} |
} |
@@ -280,7 +279,7 @@ |
LookupResult* result, |
String* name, |
bool continue_search) { |
- if (result->IsValid()) { |
+ if (result->IsProperty()) { |
switch (result->type()) { |
case CALLBACKS: { |
// Only allow API accessors. |
@@ -301,7 +300,7 @@ |
// Search ALL_CAN_READ accessors in prototype chain. |
LookupResult r; |
result->holder()->LookupRealNamedPropertyInPrototypes(name, &r); |
- if (r.IsValid()) { |
+ if (r.IsProperty()) { |
return GetPropertyAttributeWithFailedAccessCheck(receiver, |
&r, |
name, |
@@ -319,7 +318,7 @@ |
} else { |
result->holder()->LocalLookupRealNamedProperty(name, &r); |
} |
- if (r.IsValid()) { |
+ if (r.IsProperty()) { |
return GetPropertyAttributeWithFailedAccessCheck(receiver, |
&r, |
name, |
@@ -328,9 +327,8 @@ |
break; |
} |
- default: { |
- break; |
- } |
+ default: |
+ UNREACHABLE(); |
} |
} |
@@ -505,7 +503,7 @@ |
// holder will always be the interceptor holder and the search may |
// only continue with a current object just after the interceptor |
// holder in the prototype chain. |
- Object* last = result->IsValid() ? result->holder() : Heap::null_value(); |
+ Object* last = result->IsProperty() ? result->holder() : Heap::null_value(); |
for (Object* current = this; true; current = current->GetPrototype()) { |
if (current->IsAccessCheckNeeded()) { |
// Check if we're allowed to read from the current object. Note |
@@ -1463,8 +1461,12 @@ |
// Check local property, ignore interceptor. |
LookupResult result; |
LocalLookupRealNamedProperty(name, &result); |
- if (result.IsValid()) return SetProperty(&result, name, value, attributes); |
- // Add real property. |
+ if (result.IsFound()) { |
+ // An existing property, a map transition or a null descriptor was |
+ // found. Use set property to handle all these cases. |
+ return SetProperty(&result, name, value, attributes); |
+ } |
+ // Add a new real property. |
return AddProperty(name, value, attributes); |
} |
@@ -1696,8 +1698,8 @@ |
pt != Heap::null_value(); |
pt = pt->GetPrototype()) { |
JSObject::cast(pt)->LocalLookupRealNamedProperty(name, result); |
- if (result->IsValid()) { |
- if (!result->IsTransitionType() && result->IsReadOnly()) { |
+ if (result->IsProperty()) { |
+ if (result->IsReadOnly()) { |
result->NotFound(); |
return; |
} |
@@ -1758,7 +1760,11 @@ |
if (HasFastProperties()) { |
LookupInDescriptor(name, result); |
- if (result->IsValid()) { |
+ if (result->IsFound()) { |
+ // A property, a map transition or a null descriptor was found. |
+ // We return all of these result types because |
+ // LocalLookupRealNamedProperty is used when setting properties |
+ // where map transitions and null descriptors are handled. |
ASSERT(result->holder() == this && result->type() != NORMAL); |
// Disallow caching for uninitialized constants. These can only |
// occur as fields. |
@@ -1808,16 +1814,7 @@ |
pt != Heap::null_value(); |
pt = JSObject::cast(pt)->GetPrototype()) { |
JSObject::cast(pt)->LocalLookupRealNamedProperty(name, result); |
- if (result->IsValid()) { |
- switch (result->type()) { |
- case NORMAL: |
- case FIELD: |
- case CONSTANT_FUNCTION: |
- case CALLBACKS: |
- return; |
- default: break; |
- } |
- } |
+ if (result->IsProperty() && (result->type() != INTERCEPTOR)) return; |
} |
result->NotFound(); |
} |
@@ -1903,14 +1900,15 @@ |
// accessor that wants to handle the property. |
LookupResult accessor_result; |
LookupCallbackSetterInPrototypes(name, &accessor_result); |
- if (accessor_result.IsValid()) { |
+ if (accessor_result.IsProperty()) { |
return SetPropertyWithCallback(accessor_result.GetCallbackObject(), |
name, |
value, |
accessor_result.holder()); |
} |
} |
- if (result->IsNotFound()) { |
+ if (!result->IsFound()) { |
+ // Neither properties nor transitions found. |
return AddProperty(name, value, attributes); |
} |
if (!result->IsLoaded()) { |
@@ -1972,15 +1970,12 @@ |
// Make sure that the top context does not change when doing callbacks or |
// interceptor calls. |
AssertNoContextChange ncc; |
- // ADDED TO CLONE |
- LookupResult result_struct; |
- LocalLookup(name, &result_struct); |
- LookupResult* result = &result_struct; |
- // END ADDED TO CLONE |
+ LookupResult result; |
+ LocalLookup(name, &result); |
// Check access rights if needed. |
if (IsAccessCheckNeeded() |
- && !Top::MayNamedAccess(this, name, v8::ACCESS_SET)) { |
- return SetPropertyWithFailedAccessCheck(result, name, value); |
+ && !Top::MayNamedAccess(this, name, v8::ACCESS_SET)) { |
+ return SetPropertyWithFailedAccessCheck(&result, name, value); |
} |
if (IsJSGlobalProxy()) { |
@@ -1994,33 +1989,34 @@ |
} |
// Check for accessor in prototype chain removed here in clone. |
- if (result->IsNotFound()) { |
+ if (!result.IsFound()) { |
+ // Neither properties nor transitions found. |
return AddProperty(name, value, attributes); |
} |
- if (!result->IsLoaded()) { |
- return SetLazyProperty(result, name, value, attributes); |
+ if (!result.IsLoaded()) { |
+ return SetLazyProperty(&result, name, value, attributes); |
} |
PropertyDetails details = PropertyDetails(attributes, NORMAL); |
// Check of IsReadOnly removed from here in clone. |
- switch (result->type()) { |
+ switch (result.type()) { |
case NORMAL: |
return SetNormalizedProperty(name, value, details); |
case FIELD: |
- return FastPropertyAtPut(result->GetFieldIndex(), value); |
+ return FastPropertyAtPut(result.GetFieldIndex(), value); |
case MAP_TRANSITION: |
- if (attributes == result->GetAttributes()) { |
+ if (attributes == result.GetAttributes()) { |
// Only use map transition if the attributes match. |
- return AddFastPropertyUsingMap(result->GetTransitionMap(), |
+ return AddFastPropertyUsingMap(result.GetTransitionMap(), |
name, |
value); |
} |
return ConvertDescriptorToField(name, value, attributes); |
case CONSTANT_FUNCTION: |
// Only replace the function if necessary. |
- if (value == result->GetConstantFunction()) return value; |
+ if (value == result.GetConstantFunction()) return value; |
// Preserve the attributes of this existing property. |
- attributes = result->GetAttributes(); |
+ attributes = result.GetAttributes(); |
return ConvertDescriptorToField(name, value, attributes); |
case CALLBACKS: |
case INTERCEPTOR: |
@@ -2136,7 +2132,7 @@ |
name, |
continue_search); |
} |
- if (result->IsValid()) { |
+ if (result->IsProperty()) { |
switch (result->type()) { |
case NORMAL: // fall through |
case FIELD: |
@@ -2146,13 +2142,8 @@ |
case INTERCEPTOR: |
return result->holder()-> |
GetPropertyAttributeWithInterceptor(receiver, name, continue_search); |
- case MAP_TRANSITION: |
- case CONSTANT_TRANSITION: |
- case NULL_DESCRIPTOR: |
- return ABSENT; |
default: |
UNREACHABLE(); |
- break; |
} |
} |
return ABSENT; |
@@ -2325,7 +2316,7 @@ |
// Check local property, ignore interceptor. |
LookupResult result; |
LocalLookupRealNamedProperty(name, &result); |
- if (!result.IsValid()) return Heap::true_value(); |
+ if (!result.IsProperty()) return Heap::true_value(); |
// Normalize object if needed. |
Object* obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); |
@@ -2509,7 +2500,7 @@ |
} else { |
LookupResult result; |
LocalLookup(name, &result); |
- if (!result.IsValid()) return Heap::true_value(); |
+ if (!result.IsProperty()) return Heap::true_value(); |
// Ignore attributes if forcing a deletion. |
if (result.IsDontDelete() && mode != FORCE_DELETION) { |
return Heap::false_value(); |
@@ -2744,7 +2735,7 @@ |
current != Heap::null_value(); |
current = JSObject::cast(current)->GetPrototype()) { |
JSObject::cast(current)->LocalLookup(name, result); |
- if (result->IsValid() && !result->IsTransitionType()) return; |
+ if (result->IsProperty()) return; |
} |
result->NotFound(); |
} |
@@ -2756,7 +2747,7 @@ |
current != Heap::null_value(); |
current = JSObject::cast(current)->GetPrototype()) { |
JSObject::cast(current)->LocalLookupRealNamedProperty(name, result); |
- if (result->IsValid() && result->type() == CALLBACKS) return; |
+ if (result->IsProperty() && result->type() == CALLBACKS) return; |
} |
result->NotFound(); |
} |
@@ -2786,7 +2777,7 @@ |
// cause security problems. |
LookupResult callback_result; |
LookupCallback(name, &callback_result); |
- if (callback_result.IsValid()) { |
+ if (callback_result.IsFound()) { |
Object* obj = callback_result.GetCallbackObject(); |
if (obj->IsAccessorInfo() && |
AccessorInfo::cast(obj)->prohibits_overwriting()) { |
@@ -2837,7 +2828,7 @@ |
// Lookup the name. |
LookupResult result; |
LocalLookup(name, &result); |
- if (result.IsValid()) { |
+ if (result.IsProperty()) { |
if (result.IsReadOnly()) return Heap::undefined_value(); |
if (result.type() == CALLBACKS) { |
Object* obj = result.GetCallbackObject(); |
@@ -2959,7 +2950,7 @@ |
obj = JSObject::cast(obj)->GetPrototype()) { |
LookupResult result; |
JSObject::cast(obj)->LocalLookup(name, &result); |
- if (result.IsValid()) { |
+ if (result.IsProperty()) { |
if (result.IsReadOnly()) return Heap::undefined_value(); |
if (result.type() == CALLBACKS) { |
Object* obj = result.GetCallbackObject(); |
@@ -4851,7 +4842,7 @@ |
LookupResult result; |
String* name = GetThisPropertyAssignmentName(i); |
js_object->LocalLookupRealNamedProperty(name, &result); |
- if (result.IsValid() && result.type() == CALLBACKS) { |
+ if (result.IsProperty() && result.type() == CALLBACKS) { |
return false; |
} |
} |
@@ -6252,7 +6243,9 @@ |
// Check local property in holder, ignore interceptor. |
LookupResult result; |
LocalLookupRealNamedProperty(name, &result); |
- if (result.IsValid()) return GetProperty(receiver, &result, name, attributes); |
+ if (result.IsProperty()) { |
+ return GetProperty(receiver, &result, name, attributes); |
+ } |
// Continue searching via the prototype chain. |
Object* pt = GetPrototype(); |
*attributes = ABSENT; |
@@ -6268,8 +6261,10 @@ |
// Check local property in holder, ignore interceptor. |
LookupResult result; |
LocalLookupRealNamedProperty(name, &result); |
- if (!result.IsValid()) return Heap::undefined_value(); |
- return GetProperty(receiver, &result, name, attributes); |
+ if (result.IsProperty()) { |
+ return GetProperty(receiver, &result, name, attributes); |
+ } |
+ return Heap::undefined_value(); |
} |
@@ -6321,24 +6316,7 @@ |
LookupResult result; |
LocalLookupRealNamedProperty(key, &result); |
- if (result.IsValid()) { |
- switch (result.type()) { |
- case NORMAL: // fall through. |
- case FIELD: // fall through. |
- case CALLBACKS: // fall through. |
- case CONSTANT_FUNCTION: |
- return true; |
- case INTERCEPTOR: |
- case MAP_TRANSITION: |
- case CONSTANT_TRANSITION: |
- case NULL_DESCRIPTOR: |
- return false; |
- default: |
- UNREACHABLE(); |
- } |
- } |
- |
- return false; |
+ return result.IsProperty() && (result.type() != INTERCEPTOR); |
} |
@@ -6400,7 +6378,7 @@ |
LookupResult result; |
LocalLookupRealNamedProperty(key, &result); |
- return result.IsValid() && (result.type() == CALLBACKS); |
+ return result.IsProperty() && (result.type() == CALLBACKS); |
} |