Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index 46539311de9625d9c7ffccc54bd476ab5510a47b..33da88e4db094350b099c1e67032987bcef46dc8 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -180,8 +180,8 @@ MaybeObject* JSObject::GetPropertyWithCallback(Object* receiver, |
| } |
| // api style callbacks. |
| - if (structure->IsAccessorInfo()) { |
| - AccessorInfo* data = AccessorInfo::cast(structure); |
| + if (structure->IsExecutableAccessorInfo()) { |
| + ExecutableAccessorInfo* data = ExecutableAccessorInfo::cast(structure); |
| if (!data->IsCompatibleReceiver(receiver)) { |
| Handle<Object> name_handle(name); |
| Handle<Object> receiver_handle(receiver); |
| @@ -227,6 +227,11 @@ MaybeObject* JSObject::GetPropertyWithCallback(Object* receiver, |
| return isolate->heap()->undefined_value(); |
| } |
| + // TODO(dcarney): Handle correctly. |
| + if (structure->IsDeclaredAccessorInfo()) { |
| + return isolate->heap()->undefined_value(); |
| + } |
| + |
| UNREACHABLE(); |
| return NULL; |
| } |
| @@ -331,15 +336,14 @@ MaybeObject* JSObject::GetPropertyWithFailedAccessCheck( |
| case CALLBACKS: { |
| // Only allow API accessors. |
| Object* obj = result->GetCallbackObject(); |
| - if (obj->IsAccessorInfo()) { |
| - AccessorInfo* info = AccessorInfo::cast(obj); |
| - if (info->all_can_read()) { |
| - *attributes = result->GetAttributes(); |
| - return result->holder()->GetPropertyWithCallback( |
| - receiver, result->GetCallbackObject(), name); |
| - } |
| - } |
| - break; |
| + if (obj->IsExecutableAccessorInfo()) { |
|
Sven Panne
2013/02/07 10:01:03
I think the old code should stay as it is and inst
|
| + if (!ExecutableAccessorInfo::cast(obj)->all_can_read()) break; |
| + } else if (obj->IsDeclaredAccessorInfo()) { |
| + if (!DeclaredAccessorInfo::cast(obj)->all_can_read()) break; |
| + } else { break; } |
| + *attributes = result->GetAttributes(); |
| + return result->holder()->GetPropertyWithCallback( |
| + receiver, result->GetCallbackObject(), name); |
| } |
| case NORMAL: |
| case FIELD: |
| @@ -391,13 +395,12 @@ PropertyAttributes JSObject::GetPropertyAttributeWithFailedAccessCheck( |
| case CALLBACKS: { |
| // Only allow API accessors. |
| Object* obj = result->GetCallbackObject(); |
| - if (obj->IsAccessorInfo()) { |
| - AccessorInfo* info = AccessorInfo::cast(obj); |
| - if (info->all_can_read()) { |
| - return result->GetAttributes(); |
| - } |
| - } |
| - break; |
| + if (obj->IsExecutableAccessorInfo()) { |
|
Sven Panne
2013/02/07 10:01:03
See comment above.
|
| + if (!ExecutableAccessorInfo::cast(obj)->all_can_read()) break; |
| + } else if (obj->IsDeclaredAccessorInfo()) { |
| + if (!DeclaredAccessorInfo::cast(obj)->all_can_read()) break; |
| + } else { break; } |
| + return result->GetAttributes(); |
| } |
| case NORMAL: |
| @@ -2003,9 +2006,9 @@ MaybeObject* JSObject::SetPropertyWithCallback(Object* structure, |
| return *value_handle; |
| } |
| - if (structure->IsAccessorInfo()) { |
| + if (structure->IsExecutableAccessorInfo()) { |
| // api style callbacks |
| - AccessorInfo* data = AccessorInfo::cast(structure); |
| + ExecutableAccessorInfo* data = ExecutableAccessorInfo::cast(structure); |
| if (!data->IsCompatibleReceiver(this)) { |
| Handle<Object> name_handle(name); |
| Handle<Object> receiver_handle(this); |
| @@ -2052,6 +2055,11 @@ MaybeObject* JSObject::SetPropertyWithCallback(Object* structure, |
| } |
| } |
| + // TODO(dcarney): Handle correctly. |
| + if (structure->IsDeclaredAccessorInfo()) { |
| + return value; |
| + } |
| + |
| UNREACHABLE(); |
| return NULL; |
| } |
| @@ -2259,7 +2267,14 @@ void Map::AppendCallbackDescriptors(Handle<Map> map, |
| // descriptor. Since it may cause a GC, it has to be done before we |
| // temporarily put the heap in an invalid state while appending descriptors. |
| for (int i = 0; i < nof_callbacks; ++i) { |
| - Handle<AccessorInfo> entry(AccessorInfo::cast(callbacks.get(i))); |
| + Object* callback = callbacks.get(i); |
|
Sven Panne
2013/02/07 10:01:03
See comment above.
|
| + AccessorInfo* ptr; |
| + if (callback->IsExecutableAccessorInfo()) { |
| + ptr = ExecutableAccessorInfo::cast(callback); |
| + } else { |
| + ptr = DeclaredAccessorInfo::cast(callback); |
| + } |
| + Handle<AccessorInfo> entry(ptr); |
| Handle<String> key = |
| isolate->factory()->SymbolFromString( |
| Handle<String>(String::cast(entry->name()))); |
| @@ -2272,7 +2287,13 @@ void Map::AppendCallbackDescriptors(Handle<Map> map, |
| // back to front so that the last callback with a given name takes |
| // precedence over previously added callbacks with that name. |
| for (int i = nof_callbacks - 1; i >= 0; i--) { |
| - AccessorInfo* entry = AccessorInfo::cast(callbacks.get(i)); |
| + Object* callback = callbacks.get(i); |
| + AccessorInfo* entry; |
|
Sven Panne
2013/02/07 10:01:03
See comment above.
|
| + if (callback->IsExecutableAccessorInfo()) { |
| + entry = ExecutableAccessorInfo::cast(callback); |
| + } else { |
| + entry = DeclaredAccessorInfo::cast(callback); |
| + } |
| String* key = String::cast(entry->name()); |
| // Check if a descriptor with this name already exists before writing. |
| if (array->Search(key, nof) == DescriptorArray::kNotFound) { |
| @@ -2522,17 +2543,16 @@ MaybeObject* JSObject::SetPropertyWithFailedAccessCheck( |
| switch (result->type()) { |
| case CALLBACKS: { |
| Object* obj = result->GetCallbackObject(); |
| - if (obj->IsAccessorInfo()) { |
| - AccessorInfo* info = AccessorInfo::cast(obj); |
| - if (info->all_can_write()) { |
| - return SetPropertyWithCallback(result->GetCallbackObject(), |
| - name, |
| - value, |
| - result->holder(), |
| - strict_mode); |
| - } |
| - } |
| - break; |
| + if (obj->IsExecutableAccessorInfo()) { |
|
Sven Panne
2013/02/07 10:01:03
See comment above.
|
| + if (!ExecutableAccessorInfo::cast(obj)->all_can_write()) break; |
| + } else if (obj->IsDeclaredAccessorInfo()) { |
| + if (!DeclaredAccessorInfo::cast(obj)->all_can_write()) break; |
| + } else { break; } |
| + return SetPropertyWithCallback(result->GetCallbackObject(), |
| + name, |
| + value, |
| + result->holder(), |
| + strict_mode); |
| } |
| case INTERCEPTOR: { |
| // Try lookup real named properties. Note that only property can be |
| @@ -4801,9 +4821,11 @@ bool JSObject::CanSetCallback(String* name) { |
| LookupCallbackProperty(name, &callback_result); |
| if (callback_result.IsFound()) { |
| Object* obj = callback_result.GetCallbackObject(); |
| - if (obj->IsAccessorInfo() && |
| - AccessorInfo::cast(obj)->prohibits_overwriting()) { |
| - return false; |
| + if (obj->IsExecutableAccessorInfo()) { |
|
Sven Panne
2013/02/07 10:01:03
See comment above.
|
| + return !ExecutableAccessorInfo::cast(obj)->prohibits_overwriting(); |
| + } |
| + if (obj->IsDeclaredAccessorInfo()) { |
| + return !DeclaredAccessorInfo::cast(obj)->prohibits_overwriting(); |
| } |
| } |
| @@ -9733,8 +9755,9 @@ MaybeObject* JSObject::GetElementWithCallback(Object* receiver, |
| ASSERT(!structure->IsForeign()); |
| // api style callbacks. |
| - if (structure->IsAccessorInfo()) { |
| - Handle<AccessorInfo> data(AccessorInfo::cast(structure)); |
| + if (structure->IsExecutableAccessorInfo()) { |
| + Handle<ExecutableAccessorInfo> data( |
| + ExecutableAccessorInfo::cast(structure)); |
| Object* fun_obj = data->getter(); |
| v8::AccessorGetter call_fun = v8::ToCData<v8::AccessorGetter>(fun_obj); |
| if (call_fun == NULL) return isolate->heap()->undefined_value(); |
| @@ -9770,6 +9793,11 @@ MaybeObject* JSObject::GetElementWithCallback(Object* receiver, |
| return isolate->heap()->undefined_value(); |
| } |
| + if (structure->IsDeclaredAccessorInfo()) { |
| + // TODO(dcarney): Handle correctly. |
| + return isolate->heap()->undefined_value(); |
| + } |
| + |
| UNREACHABLE(); |
| return NULL; |
| } |
| @@ -9793,11 +9821,12 @@ MaybeObject* JSObject::SetElementWithCallback(Object* structure, |
| // callbacks should be phased out. |
| ASSERT(!structure->IsForeign()); |
| - if (structure->IsAccessorInfo()) { |
| + if (structure->IsExecutableAccessorInfo()) { |
| // api style callbacks |
| Handle<JSObject> self(this); |
| Handle<JSObject> holder_handle(JSObject::cast(holder)); |
| - Handle<AccessorInfo> data(AccessorInfo::cast(structure)); |
| + Handle<ExecutableAccessorInfo> data( |
| + ExecutableAccessorInfo::cast(structure)); |
| Object* call_obj = data->setter(); |
| v8::AccessorSetter call_fun = v8::ToCData<v8::AccessorSetter>(call_obj); |
| if (call_fun == NULL) return value; |
| @@ -9835,6 +9864,9 @@ MaybeObject* JSObject::SetElementWithCallback(Object* structure, |
| } |
| } |
| + // TODO(dcarney): Handle correctly. |
| + if (structure->IsDeclaredAccessorInfo()) return value; |
| + |
| UNREACHABLE(); |
| return NULL; |
| } |