OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 2139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2150 AddSlowProperty(object, name, value, attributes); | 2150 AddSlowProperty(object, name, value, attributes); |
2151 } | 2151 } |
2152 } else { | 2152 } else { |
2153 AddSlowProperty(object, name, value, attributes); | 2153 AddSlowProperty(object, name, value, attributes); |
2154 } | 2154 } |
2155 | 2155 |
2156 if (FLAG_harmony_observation && | 2156 if (FLAG_harmony_observation && |
2157 object->map()->is_observed() && | 2157 object->map()->is_observed() && |
2158 *name != isolate->heap()->hidden_string()) { | 2158 *name != isolate->heap()->hidden_string()) { |
2159 Handle<Object> old_value = isolate->factory()->the_hole_value(); | 2159 Handle<Object> old_value = isolate->factory()->the_hole_value(); |
2160 EnqueueChangeRecord(object, "new", name, old_value); | 2160 EnqueueChangeRecord(object, "add", name, old_value); |
2161 } | 2161 } |
2162 | 2162 |
2163 return value; | 2163 return value; |
2164 } | 2164 } |
2165 | 2165 |
2166 | 2166 |
2167 void JSObject::EnqueueChangeRecord(Handle<JSObject> object, | 2167 void JSObject::EnqueueChangeRecord(Handle<JSObject> object, |
2168 const char* type_str, | 2168 const char* type_str, |
2169 Handle<Name> name, | 2169 Handle<Name> name, |
2170 Handle<Object> old_value) { | 2170 Handle<Object> old_value) { |
(...skipping 1927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4098 break; | 4098 break; |
4099 case HANDLER: | 4099 case HANDLER: |
4100 case NONEXISTENT: | 4100 case NONEXISTENT: |
4101 UNREACHABLE(); | 4101 UNREACHABLE(); |
4102 } | 4102 } |
4103 | 4103 |
4104 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, result, Handle<Object>()); | 4104 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, result, Handle<Object>()); |
4105 | 4105 |
4106 if (is_observed) { | 4106 if (is_observed) { |
4107 if (lookup->IsTransition()) { | 4107 if (lookup->IsTransition()) { |
4108 EnqueueChangeRecord(object, "new", name, old_value); | 4108 EnqueueChangeRecord(object, "add", name, old_value); |
4109 } else { | 4109 } else { |
4110 LookupResult new_lookup(isolate); | 4110 LookupResult new_lookup(isolate); |
4111 object->LocalLookup(*name, &new_lookup, true); | 4111 object->LocalLookup(*name, &new_lookup, true); |
4112 if (new_lookup.IsDataProperty()) { | 4112 if (new_lookup.IsDataProperty()) { |
4113 Handle<Object> new_value = Object::GetProperty(object, name); | 4113 Handle<Object> new_value = Object::GetProperty(object, name); |
4114 if (!new_value->SameValue(*old_value)) { | 4114 if (!new_value->SameValue(*old_value)) { |
4115 EnqueueChangeRecord(object, "updated", name, old_value); | 4115 EnqueueChangeRecord(object, "update", name, old_value); |
4116 } | 4116 } |
4117 } | 4117 } |
4118 } | 4118 } |
4119 } | 4119 } |
4120 | 4120 |
4121 return result; | 4121 return result; |
4122 } | 4122 } |
4123 | 4123 |
4124 | 4124 |
4125 // Set a real local property, even if it is READ_ONLY. If the property is not | 4125 // Set a real local property, even if it is READ_ONLY. If the property is not |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4215 break; | 4215 break; |
4216 } | 4216 } |
4217 case NONEXISTENT: | 4217 case NONEXISTENT: |
4218 case HANDLER: | 4218 case HANDLER: |
4219 case INTERCEPTOR: | 4219 case INTERCEPTOR: |
4220 UNREACHABLE(); | 4220 UNREACHABLE(); |
4221 } | 4221 } |
4222 | 4222 |
4223 if (is_observed) { | 4223 if (is_observed) { |
4224 if (lookup.IsTransition()) { | 4224 if (lookup.IsTransition()) { |
4225 EnqueueChangeRecord(object, "new", name, old_value); | 4225 EnqueueChangeRecord(object, "add", name, old_value); |
4226 } else if (old_value->IsTheHole()) { | 4226 } else if (old_value->IsTheHole()) { |
4227 EnqueueChangeRecord(object, "reconfigured", name, old_value); | 4227 EnqueueChangeRecord(object, "reconfigure", name, old_value); |
4228 } else { | 4228 } else { |
4229 LookupResult new_lookup(isolate); | 4229 LookupResult new_lookup(isolate); |
4230 object->LocalLookup(*name, &new_lookup, true); | 4230 object->LocalLookup(*name, &new_lookup, true); |
4231 bool value_changed = false; | 4231 bool value_changed = false; |
4232 if (new_lookup.IsDataProperty()) { | 4232 if (new_lookup.IsDataProperty()) { |
4233 Handle<Object> new_value = Object::GetProperty(object, name); | 4233 Handle<Object> new_value = Object::GetProperty(object, name); |
4234 value_changed = !old_value->SameValue(*new_value); | 4234 value_changed = !old_value->SameValue(*new_value); |
4235 } | 4235 } |
4236 if (new_lookup.GetAttributes() != old_attributes) { | 4236 if (new_lookup.GetAttributes() != old_attributes) { |
4237 if (!value_changed) old_value = isolate->factory()->the_hole_value(); | 4237 if (!value_changed) old_value = isolate->factory()->the_hole_value(); |
4238 EnqueueChangeRecord(object, "reconfigured", name, old_value); | 4238 EnqueueChangeRecord(object, "reconfigure", name, old_value); |
4239 } else if (value_changed) { | 4239 } else if (value_changed) { |
4240 EnqueueChangeRecord(object, "updated", name, old_value); | 4240 EnqueueChangeRecord(object, "update", name, old_value); |
4241 } | 4241 } |
4242 } | 4242 } |
4243 } | 4243 } |
4244 | 4244 |
4245 return value; | 4245 return value; |
4246 } | 4246 } |
4247 | 4247 |
4248 | 4248 |
4249 PropertyAttributes JSObject::GetPropertyAttributePostInterceptor( | 4249 PropertyAttributes JSObject::GetPropertyAttributePostInterceptor( |
4250 JSObject* receiver, | 4250 JSObject* receiver, |
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5176 // Skip interceptor if forcing deletion. | 5176 // Skip interceptor if forcing deletion. |
5177 Handle<Object> result; | 5177 Handle<Object> result; |
5178 if (object->HasIndexedInterceptor() && mode != FORCE_DELETION) { | 5178 if (object->HasIndexedInterceptor() && mode != FORCE_DELETION) { |
5179 result = DeleteElementWithInterceptor(object, index); | 5179 result = DeleteElementWithInterceptor(object, index); |
5180 } else { | 5180 } else { |
5181 result = AccessorDelete(object, index, mode); | 5181 result = AccessorDelete(object, index, mode); |
5182 } | 5182 } |
5183 | 5183 |
5184 if (should_enqueue_change_record && !HasLocalElement(object, index)) { | 5184 if (should_enqueue_change_record && !HasLocalElement(object, index)) { |
5185 Handle<String> name = factory->Uint32ToString(index); | 5185 Handle<String> name = factory->Uint32ToString(index); |
5186 EnqueueChangeRecord(object, "deleted", name, old_value); | 5186 EnqueueChangeRecord(object, "delete", name, old_value); |
5187 } | 5187 } |
5188 | 5188 |
5189 return result; | 5189 return result; |
5190 } | 5190 } |
5191 | 5191 |
5192 | 5192 |
5193 Handle<Object> JSObject::DeleteProperty(Handle<JSObject> object, | 5193 Handle<Object> JSObject::DeleteProperty(Handle<JSObject> object, |
5194 Handle<Name> name, | 5194 Handle<Name> name, |
5195 DeleteMode mode) { | 5195 DeleteMode mode) { |
5196 Isolate* isolate = object->GetIsolate(); | 5196 Isolate* isolate = object->GetIsolate(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5252 result = DeletePropertyWithInterceptor(object, name); | 5252 result = DeletePropertyWithInterceptor(object, name); |
5253 } | 5253 } |
5254 } else { | 5254 } else { |
5255 // Normalize object if needed. | 5255 // Normalize object if needed. |
5256 NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0); | 5256 NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0); |
5257 // Make sure the properties are normalized before removing the entry. | 5257 // Make sure the properties are normalized before removing the entry. |
5258 result = DeleteNormalizedProperty(object, name, mode); | 5258 result = DeleteNormalizedProperty(object, name, mode); |
5259 } | 5259 } |
5260 | 5260 |
5261 if (is_observed && !HasLocalProperty(object, name)) { | 5261 if (is_observed && !HasLocalProperty(object, name)) { |
5262 EnqueueChangeRecord(object, "deleted", name, old_value); | 5262 EnqueueChangeRecord(object, "delete", name, old_value); |
5263 } | 5263 } |
5264 | 5264 |
5265 return result; | 5265 return result; |
5266 } | 5266 } |
5267 | 5267 |
5268 | 5268 |
5269 Handle<Object> JSReceiver::DeleteElement(Handle<JSReceiver> object, | 5269 Handle<Object> JSReceiver::DeleteElement(Handle<JSReceiver> object, |
5270 uint32_t index, | 5270 uint32_t index, |
5271 DeleteMode mode) { | 5271 DeleteMode mode) { |
5272 if (object->IsJSProxy()) { | 5272 if (object->IsJSProxy()) { |
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6342 | 6342 |
6343 if (is_element) { | 6343 if (is_element) { |
6344 DefineElementAccessor( | 6344 DefineElementAccessor( |
6345 object, index, getter, setter, attributes, access_control); | 6345 object, index, getter, setter, attributes, access_control); |
6346 } else { | 6346 } else { |
6347 DefinePropertyAccessor( | 6347 DefinePropertyAccessor( |
6348 object, name, getter, setter, attributes, access_control); | 6348 object, name, getter, setter, attributes, access_control); |
6349 } | 6349 } |
6350 | 6350 |
6351 if (is_observed) { | 6351 if (is_observed) { |
6352 const char* type = preexists ? "reconfigured" : "new"; | 6352 const char* type = preexists ? "reconfigure" : "add"; |
6353 EnqueueChangeRecord(object, type, name, old_value); | 6353 EnqueueChangeRecord(object, type, name, old_value); |
6354 } | 6354 } |
6355 } | 6355 } |
6356 | 6356 |
6357 | 6357 |
6358 static bool TryAccessorTransition(JSObject* self, | 6358 static bool TryAccessorTransition(JSObject* self, |
6359 Map* transitioned_map, | 6359 Map* transitioned_map, |
6360 int target_descriptor, | 6360 int target_descriptor, |
6361 AccessorComponent component, | 6361 AccessorComponent component, |
6362 Object* accessor, | 6362 Object* accessor, |
(...skipping 5083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11446 Handle<Object> hresult; | 11446 Handle<Object> hresult; |
11447 if (!result->ToHandle(&hresult, isolate)) return result; | 11447 if (!result->ToHandle(&hresult, isolate)) return result; |
11448 | 11448 |
11449 CHECK(self->length()->ToArrayIndex(&new_length)); | 11449 CHECK(self->length()->ToArrayIndex(&new_length)); |
11450 if (old_length == new_length) return *hresult; | 11450 if (old_length == new_length) return *hresult; |
11451 | 11451 |
11452 BeginPerformSplice(self); | 11452 BeginPerformSplice(self); |
11453 | 11453 |
11454 for (int i = 0; i < indices.length(); ++i) { | 11454 for (int i = 0; i < indices.length(); ++i) { |
11455 JSObject::EnqueueChangeRecord( | 11455 JSObject::EnqueueChangeRecord( |
11456 self, "deleted", isolate->factory()->Uint32ToString(indices[i]), | 11456 self, "delete", isolate->factory()->Uint32ToString(indices[i]), |
11457 old_values[i]); | 11457 old_values[i]); |
11458 } | 11458 } |
11459 JSObject::EnqueueChangeRecord( | 11459 JSObject::EnqueueChangeRecord( |
11460 self, "updated", isolate->factory()->length_string(), | 11460 self, "update", isolate->factory()->length_string(), |
11461 old_length_handle); | 11461 old_length_handle); |
11462 | 11462 |
11463 EndPerformSplice(self); | 11463 EndPerformSplice(self); |
11464 | 11464 |
11465 uint32_t index = Min(old_length, new_length); | 11465 uint32_t index = Min(old_length, new_length); |
11466 uint32_t add_count = new_length > old_length ? new_length - old_length : 0; | 11466 uint32_t add_count = new_length > old_length ? new_length - old_length : 0; |
11467 uint32_t delete_count = new_length < old_length ? old_length - new_length : 0; | 11467 uint32_t delete_count = new_length < old_length ? old_length - new_length : 0; |
11468 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0); | 11468 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0); |
11469 if (delete_count > 0) { | 11469 if (delete_count > 0) { |
11470 for (int i = indices.length() - 1; i >= 0; i--) { | 11470 for (int i = indices.length() - 1; i >= 0; i--) { |
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12596 if (self->IsJSArray() && | 12596 if (self->IsJSArray() && |
12597 !old_length_handle->SameValue(Handle<JSArray>::cast(self)->length())) { | 12597 !old_length_handle->SameValue(Handle<JSArray>::cast(self)->length())) { |
12598 new_length_handle = handle(Handle<JSArray>::cast(self)->length(), | 12598 new_length_handle = handle(Handle<JSArray>::cast(self)->length(), |
12599 isolate); | 12599 isolate); |
12600 uint32_t old_length = 0; | 12600 uint32_t old_length = 0; |
12601 uint32_t new_length = 0; | 12601 uint32_t new_length = 0; |
12602 CHECK(old_length_handle->ToArrayIndex(&old_length)); | 12602 CHECK(old_length_handle->ToArrayIndex(&old_length)); |
12603 CHECK(new_length_handle->ToArrayIndex(&new_length)); | 12603 CHECK(new_length_handle->ToArrayIndex(&new_length)); |
12604 | 12604 |
12605 BeginPerformSplice(Handle<JSArray>::cast(self)); | 12605 BeginPerformSplice(Handle<JSArray>::cast(self)); |
12606 EnqueueChangeRecord(self, "new", name, old_value); | 12606 EnqueueChangeRecord(self, "add", name, old_value); |
12607 EnqueueChangeRecord(self, "updated", isolate->factory()->length_string(), | 12607 EnqueueChangeRecord(self, "update", isolate->factory()->length_string(), |
12608 old_length_handle); | 12608 old_length_handle); |
12609 EndPerformSplice(Handle<JSArray>::cast(self)); | 12609 EndPerformSplice(Handle<JSArray>::cast(self)); |
12610 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0); | 12610 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0); |
12611 EnqueueSpliceRecord(Handle<JSArray>::cast(self), old_length, deleted, | 12611 EnqueueSpliceRecord(Handle<JSArray>::cast(self), old_length, deleted, |
12612 new_length - old_length); | 12612 new_length - old_length); |
12613 } else { | 12613 } else { |
12614 EnqueueChangeRecord(self, "new", name, old_value); | 12614 EnqueueChangeRecord(self, "add", name, old_value); |
12615 } | 12615 } |
12616 } else if (old_value->IsTheHole()) { | 12616 } else if (old_value->IsTheHole()) { |
12617 EnqueueChangeRecord(self, "reconfigured", name, old_value); | 12617 EnqueueChangeRecord(self, "reconfigure", name, old_value); |
12618 } else { | 12618 } else { |
12619 Handle<Object> new_value = Object::GetElement(isolate, self, index); | 12619 Handle<Object> new_value = Object::GetElement(isolate, self, index); |
12620 bool value_changed = !old_value->SameValue(*new_value); | 12620 bool value_changed = !old_value->SameValue(*new_value); |
12621 if (old_attributes != new_attributes) { | 12621 if (old_attributes != new_attributes) { |
12622 if (!value_changed) old_value = isolate->factory()->the_hole_value(); | 12622 if (!value_changed) old_value = isolate->factory()->the_hole_value(); |
12623 EnqueueChangeRecord(self, "reconfigured", name, old_value); | 12623 EnqueueChangeRecord(self, "reconfigure", name, old_value); |
12624 } else if (value_changed) { | 12624 } else if (value_changed) { |
12625 EnqueueChangeRecord(self, "updated", name, old_value); | 12625 EnqueueChangeRecord(self, "update", name, old_value); |
12626 } | 12626 } |
12627 } | 12627 } |
12628 | 12628 |
12629 return *hresult; | 12629 return *hresult; |
12630 } | 12630 } |
12631 | 12631 |
12632 | 12632 |
12633 MaybeObject* JSObject::SetElementWithoutInterceptor(uint32_t index, | 12633 MaybeObject* JSObject::SetElementWithoutInterceptor(uint32_t index, |
12634 Object* value, | 12634 Object* value, |
12635 PropertyAttributes attr, | 12635 PropertyAttributes attr, |
(...skipping 3842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16478 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16478 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16479 static const char* error_messages_[] = { | 16479 static const char* error_messages_[] = { |
16480 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16480 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16481 }; | 16481 }; |
16482 #undef ERROR_MESSAGES_TEXTS | 16482 #undef ERROR_MESSAGES_TEXTS |
16483 return error_messages_[reason]; | 16483 return error_messages_[reason]; |
16484 } | 16484 } |
16485 | 16485 |
16486 | 16486 |
16487 } } // namespace v8::internal | 16487 } } // namespace v8::internal |
OLD | NEW |