OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 4053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4064 for (Object* current = this; | 4064 for (Object* current = this; |
4065 current != heap->null_value() && current->IsJSObject(); | 4065 current != heap->null_value() && current->IsJSObject(); |
4066 current = JSObject::cast(current)->GetPrototype()) { | 4066 current = JSObject::cast(current)->GetPrototype()) { |
4067 JSObject::cast(current)->LocalLookupRealNamedProperty(name, result); | 4067 JSObject::cast(current)->LocalLookupRealNamedProperty(name, result); |
4068 if (result->IsProperty() && result->type() == CALLBACKS) return; | 4068 if (result->IsProperty() && result->type() == CALLBACKS) return; |
4069 } | 4069 } |
4070 result->NotFound(); | 4070 result->NotFound(); |
4071 } | 4071 } |
4072 | 4072 |
4073 | 4073 |
4074 // Search for a getter or setter in an elements dictionary. Returns either | 4074 // Search for a getter or setter in an elements dictionary and update its |
4075 // undefined if the element is read-only, or the getter/setter pair (fixed | 4075 // attributes. Returns either undefined if the element is read-only, or the |
4076 // array) if there is an existing one, or the hole value if the element does | 4076 // getter/setter pair (fixed array) if there is an existing one, or the hole |
4077 // not exist or is a normal non-getter/setter data element. | 4077 // value if the element does not exist or is a normal non-getter/setter data |
4078 static Object* FindGetterSetterInDictionary(NumberDictionary* dictionary, | 4078 // element. |
4079 uint32_t index, | 4079 static Object* UpdateGetterSetterInDictionary(NumberDictionary* dictionary, |
4080 Heap* heap) { | 4080 uint32_t index, |
| 4081 PropertyAttributes attributes, |
| 4082 Heap* heap) { |
4081 int entry = dictionary->FindEntry(index); | 4083 int entry = dictionary->FindEntry(index); |
4082 if (entry != NumberDictionary::kNotFound) { | 4084 if (entry != NumberDictionary::kNotFound) { |
4083 Object* result = dictionary->ValueAt(entry); | 4085 Object* result = dictionary->ValueAt(entry); |
4084 PropertyDetails details = dictionary->DetailsAt(entry); | 4086 PropertyDetails details = dictionary->DetailsAt(entry); |
4085 if (details.IsReadOnly()) return heap->undefined_value(); | 4087 if (details.IsReadOnly()) return heap->undefined_value(); |
4086 if (details.type() == CALLBACKS && result->IsFixedArray()) return result; | 4088 if (details.type() == CALLBACKS && result->IsFixedArray()) { |
| 4089 if (details.attributes() != attributes) { |
| 4090 dictionary->DetailsAtPut(entry, |
| 4091 PropertyDetails(attributes, CALLBACKS, index)); |
| 4092 } |
| 4093 return result; |
| 4094 } |
4087 } | 4095 } |
4088 return heap->the_hole_value(); | 4096 return heap->the_hole_value(); |
4089 } | 4097 } |
4090 | 4098 |
4091 | 4099 |
4092 MaybeObject* JSObject::DefineGetterSetter(String* name, | 4100 MaybeObject* JSObject::DefineGetterSetter(String* name, |
4093 PropertyAttributes attributes) { | 4101 PropertyAttributes attributes) { |
4094 Heap* heap = GetHeap(); | 4102 Heap* heap = GetHeap(); |
4095 // Make sure that the top context does not change when doing callbacks or | 4103 // Make sure that the top context does not change when doing callbacks or |
4096 // interceptor calls. | 4104 // interceptor calls. |
(...skipping 21 matching lines...) Expand all Loading... |
4118 case EXTERNAL_SHORT_ELEMENTS: | 4126 case EXTERNAL_SHORT_ELEMENTS: |
4119 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 4127 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
4120 case EXTERNAL_INT_ELEMENTS: | 4128 case EXTERNAL_INT_ELEMENTS: |
4121 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 4129 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
4122 case EXTERNAL_FLOAT_ELEMENTS: | 4130 case EXTERNAL_FLOAT_ELEMENTS: |
4123 case EXTERNAL_DOUBLE_ELEMENTS: | 4131 case EXTERNAL_DOUBLE_ELEMENTS: |
4124 // Ignore getters and setters on pixel and external array | 4132 // Ignore getters and setters on pixel and external array |
4125 // elements. | 4133 // elements. |
4126 return heap->undefined_value(); | 4134 return heap->undefined_value(); |
4127 case DICTIONARY_ELEMENTS: { | 4135 case DICTIONARY_ELEMENTS: { |
4128 Object* probe = | 4136 Object* probe = UpdateGetterSetterInDictionary(element_dictionary(), |
4129 FindGetterSetterInDictionary(element_dictionary(), index, heap); | 4137 index, |
| 4138 attributes, |
| 4139 heap); |
4130 if (!probe->IsTheHole()) return probe; | 4140 if (!probe->IsTheHole()) return probe; |
4131 // Otherwise allow to override it. | 4141 // Otherwise allow to override it. |
4132 break; | 4142 break; |
4133 } | 4143 } |
4134 case NON_STRICT_ARGUMENTS_ELEMENTS: { | 4144 case NON_STRICT_ARGUMENTS_ELEMENTS: { |
4135 // Ascertain whether we have read-only properties or an existing | 4145 // Ascertain whether we have read-only properties or an existing |
4136 // getter/setter pair in an arguments elements dictionary backing | 4146 // getter/setter pair in an arguments elements dictionary backing |
4137 // store. | 4147 // store. |
4138 FixedArray* parameter_map = FixedArray::cast(elements()); | 4148 FixedArray* parameter_map = FixedArray::cast(elements()); |
4139 uint32_t length = parameter_map->length(); | 4149 uint32_t length = parameter_map->length(); |
4140 Object* probe = | 4150 Object* probe = |
4141 index < (length - 2) ? parameter_map->get(index + 2) : NULL; | 4151 index < (length - 2) ? parameter_map->get(index + 2) : NULL; |
4142 if (probe == NULL || probe->IsTheHole()) { | 4152 if (probe == NULL || probe->IsTheHole()) { |
4143 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | 4153 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
4144 if (arguments->IsDictionary()) { | 4154 if (arguments->IsDictionary()) { |
4145 NumberDictionary* dictionary = NumberDictionary::cast(arguments); | 4155 NumberDictionary* dictionary = NumberDictionary::cast(arguments); |
4146 probe = FindGetterSetterInDictionary(dictionary, index, heap); | 4156 probe = UpdateGetterSetterInDictionary(dictionary, |
| 4157 index, |
| 4158 attributes, |
| 4159 heap); |
4147 if (!probe->IsTheHole()) return probe; | 4160 if (!probe->IsTheHole()) return probe; |
4148 } | 4161 } |
4149 } | 4162 } |
4150 break; | 4163 break; |
4151 } | 4164 } |
4152 } | 4165 } |
4153 } else { | 4166 } else { |
4154 // Lookup the name. | 4167 // Lookup the name. |
4155 LookupResult result; | 4168 LookupResult result; |
4156 LocalLookup(name, &result); | 4169 LocalLookup(name, &result); |
(...skipping 8146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12303 if (break_point_objects()->IsUndefined()) return 0; | 12316 if (break_point_objects()->IsUndefined()) return 0; |
12304 // Single break point. | 12317 // Single break point. |
12305 if (!break_point_objects()->IsFixedArray()) return 1; | 12318 if (!break_point_objects()->IsFixedArray()) return 1; |
12306 // Multiple break points. | 12319 // Multiple break points. |
12307 return FixedArray::cast(break_point_objects())->length(); | 12320 return FixedArray::cast(break_point_objects())->length(); |
12308 } | 12321 } |
12309 #endif // ENABLE_DEBUGGER_SUPPORT | 12322 #endif // ENABLE_DEBUGGER_SUPPORT |
12310 | 12323 |
12311 | 12324 |
12312 } } // namespace v8::internal | 12325 } } // namespace v8::internal |
OLD | NEW |