OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 4139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4150 Object* proto = GetPrototype(); | 4150 Object* proto = GetPrototype(); |
4151 if (proto->IsNull()) return isolate->heap()->false_value(); | 4151 if (proto->IsNull()) return isolate->heap()->false_value(); |
4152 ASSERT(proto->IsJSGlobalObject()); | 4152 ASSERT(proto->IsJSGlobalObject()); |
4153 return JSGlobalObject::cast(proto)->DeleteElement(index, mode); | 4153 return JSGlobalObject::cast(proto)->DeleteElement(index, mode); |
4154 } | 4154 } |
4155 | 4155 |
4156 // From this point on everything needs to be handlified. | 4156 // From this point on everything needs to be handlified. |
4157 HandleScope scope(isolate); | 4157 HandleScope scope(isolate); |
4158 Handle<JSObject> self(this); | 4158 Handle<JSObject> self(this); |
4159 | 4159 |
4160 Handle<String> name; | |
4161 Handle<Object> old_value; | 4160 Handle<Object> old_value; |
4162 bool preexists = false; | 4161 bool should_enqueue_change_record = false; |
4163 if (FLAG_harmony_observation && map()->is_observed()) { | 4162 if (FLAG_harmony_observation && self->map()->is_observed()) { |
4164 name = isolate->factory()->Uint32ToString(index); | 4163 should_enqueue_change_record = self->HasLocalElement(index); |
4165 preexists = self->HasLocalElement(index); | 4164 if (should_enqueue_change_record) { |
4166 if (preexists) { | 4165 old_value = self->GetLocalElementAccessorPair(index) != NULL |
4167 old_value = GetLocalElementAccessorPair(index) != NULL | |
4168 ? Handle<Object>::cast(isolate->factory()->the_hole_value()) | 4166 ? Handle<Object>::cast(isolate->factory()->the_hole_value()) |
4169 : Object::GetElement(self, index); | 4167 : Object::GetElement(self, index); |
4170 } | 4168 } |
4171 } | 4169 } |
4172 | 4170 |
4173 MaybeObject* result; | 4171 MaybeObject* result; |
4174 // Skip interceptor if forcing deletion. | 4172 // Skip interceptor if forcing deletion. |
4175 if (self->HasIndexedInterceptor() && mode != FORCE_DELETION) { | 4173 if (self->HasIndexedInterceptor() && mode != FORCE_DELETION) { |
4176 result = self->DeleteElementWithInterceptor(index); | 4174 result = self->DeleteElementWithInterceptor(index); |
4177 } else { | 4175 } else { |
4178 result = self->GetElementsAccessor()->Delete(*self, index, mode); | 4176 result = self->GetElementsAccessor()->Delete(*self, index, mode); |
4179 } | 4177 } |
4180 | 4178 |
4181 Handle<Object> hresult; | 4179 Handle<Object> hresult; |
4182 if (!result->ToHandle(&hresult, isolate)) return result; | 4180 if (!result->ToHandle(&hresult, isolate)) return result; |
4183 | 4181 |
4184 if (FLAG_harmony_observation && map()->is_observed()) { | 4182 if (should_enqueue_change_record && !self->HasLocalElement(index)) { |
4185 if (preexists && !self->HasLocalElement(index)) | 4183 Handle<String> name = isolate->factory()->Uint32ToString(index); |
4186 EnqueueChangeRecord(self, "deleted", name, old_value); | 4184 EnqueueChangeRecord(self, "deleted", name, old_value); |
4187 } | 4185 } |
4188 | 4186 |
4189 return *hresult; | 4187 return *hresult; |
4190 } | 4188 } |
4191 | 4189 |
4192 | 4190 |
4193 Handle<Object> JSObject::DeleteProperty(Handle<JSObject> obj, | 4191 Handle<Object> JSObject::DeleteProperty(Handle<JSObject> obj, |
4194 Handle<String> prop) { | 4192 Handle<String> prop) { |
4195 CALL_HEAP_FUNCTION(obj->GetIsolate(), | 4193 CALL_HEAP_FUNCTION(obj->GetIsolate(), |
4196 obj->DeleteProperty(*prop, JSObject::NORMAL_DELETION), | 4194 obj->DeleteProperty(*prop, JSObject::NORMAL_DELETION), |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4236 } | 4234 } |
4237 return isolate->heap()->false_value(); | 4235 return isolate->heap()->false_value(); |
4238 } | 4236 } |
4239 | 4237 |
4240 // From this point on everything needs to be handlified. | 4238 // From this point on everything needs to be handlified. |
4241 HandleScope scope(isolate); | 4239 HandleScope scope(isolate); |
4242 Handle<JSObject> self(this); | 4240 Handle<JSObject> self(this); |
4243 Handle<String> hname(name); | 4241 Handle<String> hname(name); |
4244 | 4242 |
4245 Handle<Object> old_value(isolate->heap()->the_hole_value()); | 4243 Handle<Object> old_value(isolate->heap()->the_hole_value()); |
4246 if (FLAG_harmony_observation && map()->is_observed()) { | 4244 bool is_observed = FLAG_harmony_observation && self->map()->is_observed(); |
| 4245 if (is_observed) { |
4247 old_value = handle(lookup.GetLazyValue(), isolate); | 4246 old_value = handle(lookup.GetLazyValue(), isolate); |
4248 } | 4247 } |
4249 MaybeObject* result; | 4248 MaybeObject* result; |
4250 | 4249 |
4251 // Check for interceptor. | 4250 // Check for interceptor. |
4252 if (lookup.IsInterceptor()) { | 4251 if (lookup.IsInterceptor()) { |
4253 // Skip interceptor if forcing a deletion. | 4252 // Skip interceptor if forcing a deletion. |
4254 if (mode == FORCE_DELETION) { | 4253 if (mode == FORCE_DELETION) { |
4255 result = self->DeletePropertyPostInterceptor(*hname, mode); | 4254 result = self->DeletePropertyPostInterceptor(*hname, mode); |
4256 } else { | 4255 } else { |
4257 result = self->DeletePropertyWithInterceptor(*hname); | 4256 result = self->DeletePropertyWithInterceptor(*hname); |
4258 } | 4257 } |
4259 } else { | 4258 } else { |
4260 // Normalize object if needed. | 4259 // Normalize object if needed. |
4261 Object* obj; | 4260 Object* obj; |
4262 result = self->NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); | 4261 result = self->NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); |
4263 if (!result->To(&obj)) return result; | 4262 if (!result->To(&obj)) return result; |
4264 // Make sure the properties are normalized before removing the entry. | 4263 // Make sure the properties are normalized before removing the entry. |
4265 result = self->DeleteNormalizedProperty(*hname, mode); | 4264 result = self->DeleteNormalizedProperty(*hname, mode); |
4266 } | 4265 } |
4267 | 4266 |
4268 Handle<Object> hresult; | 4267 Handle<Object> hresult; |
4269 if (!result->ToHandle(&hresult, isolate)) return result; | 4268 if (!result->ToHandle(&hresult, isolate)) return result; |
4270 | 4269 |
4271 if (FLAG_harmony_observation && map()->is_observed()) { | 4270 if (is_observed && !self->HasLocalProperty(*hname)) { |
4272 if (!self->HasLocalProperty(*hname)) | 4271 EnqueueChangeRecord(self, "deleted", hname, old_value); |
4273 EnqueueChangeRecord(self, "deleted", hname, old_value); | |
4274 } | 4272 } |
4275 | 4273 |
4276 return *hresult; | 4274 return *hresult; |
4277 } | 4275 } |
4278 | 4276 |
4279 | 4277 |
4280 MaybeObject* JSReceiver::DeleteElement(uint32_t index, DeleteMode mode) { | 4278 MaybeObject* JSReceiver::DeleteElement(uint32_t index, DeleteMode mode) { |
4281 if (IsJSProxy()) { | 4279 if (IsJSProxy()) { |
4282 return JSProxy::cast(this)->DeleteElementWithHandler(index, mode); | 4280 return JSProxy::cast(this)->DeleteElementWithHandler(index, mode); |
4283 } | 4281 } |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4917 HandleScope scope(isolate); | 4915 HandleScope scope(isolate); |
4918 Handle<JSObject> self(this); | 4916 Handle<JSObject> self(this); |
4919 Handle<String> name(name_raw); | 4917 Handle<String> name(name_raw); |
4920 Handle<Object> getter(getter_raw); | 4918 Handle<Object> getter(getter_raw); |
4921 Handle<Object> setter(setter_raw); | 4919 Handle<Object> setter(setter_raw); |
4922 | 4920 |
4923 uint32_t index = 0; | 4921 uint32_t index = 0; |
4924 bool is_element = name->AsArrayIndex(&index); | 4922 bool is_element = name->AsArrayIndex(&index); |
4925 | 4923 |
4926 Handle<Object> old_value = isolate->factory()->the_hole_value(); | 4924 Handle<Object> old_value = isolate->factory()->the_hole_value(); |
| 4925 bool is_observed = FLAG_harmony_observation && self->map()->is_observed(); |
4927 bool preexists = false; | 4926 bool preexists = false; |
4928 if (FLAG_harmony_observation && map()->is_observed()) { | 4927 if (is_observed) { |
4929 if (is_element) { | 4928 if (is_element) { |
4930 preexists = HasLocalElement(index); | 4929 preexists = HasLocalElement(index); |
4931 if (preexists && GetLocalElementAccessorPair(index) == NULL) { | 4930 if (preexists && self->GetLocalElementAccessorPair(index) == NULL) { |
4932 old_value = Object::GetElement(self, index); | 4931 old_value = Object::GetElement(self, index); |
4933 } | 4932 } |
4934 } else { | 4933 } else { |
4935 LookupResult lookup(isolate); | 4934 LookupResult lookup(isolate); |
4936 LocalLookup(*name, &lookup, true); | 4935 LocalLookup(*name, &lookup, true); |
4937 preexists = lookup.IsProperty(); | 4936 preexists = lookup.IsProperty(); |
4938 if (preexists) old_value = handle(lookup.GetLazyValue(), isolate); | 4937 if (preexists) old_value = handle(lookup.GetLazyValue(), isolate); |
4939 } | 4938 } |
4940 } | 4939 } |
4941 | 4940 |
4942 MaybeObject* result = is_element ? | 4941 MaybeObject* result = is_element ? |
4943 self->DefineElementAccessor(index, *getter, *setter, attributes) : | 4942 self->DefineElementAccessor(index, *getter, *setter, attributes) : |
4944 self->DefinePropertyAccessor(*name, *getter, *setter, attributes); | 4943 self->DefinePropertyAccessor(*name, *getter, *setter, attributes); |
4945 | 4944 |
4946 Handle<Object> hresult; | 4945 Handle<Object> hresult; |
4947 if (!result->ToHandle(&hresult, isolate)) return result; | 4946 if (!result->ToHandle(&hresult, isolate)) return result; |
4948 | 4947 |
4949 if (FLAG_harmony_observation && map()->is_observed()) { | 4948 if (is_observed) { |
4950 const char* type = preexists ? "reconfigured" : "new"; | 4949 const char* type = preexists ? "reconfigured" : "new"; |
4951 EnqueueChangeRecord(self, type, name, old_value); | 4950 EnqueueChangeRecord(self, type, name, old_value); |
4952 } | 4951 } |
4953 | 4952 |
4954 return *hresult; | 4953 return *hresult; |
4955 } | 4954 } |
4956 | 4955 |
4957 | 4956 |
4958 static MaybeObject* TryAccessorTransition(JSObject* self, | 4957 static MaybeObject* TryAccessorTransition(JSObject* self, |
4959 Map* transitioned_map, | 4958 Map* transitioned_map, |
(...skipping 5377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10337 } | 10336 } |
10338 | 10337 |
10339 // From here on, everything has to be handlified. | 10338 // From here on, everything has to be handlified. |
10340 Handle<JSObject> self(this); | 10339 Handle<JSObject> self(this); |
10341 Handle<Object> value(value_raw); | 10340 Handle<Object> value(value_raw); |
10342 PropertyAttributes old_attributes = self->GetLocalElementAttribute(index); | 10341 PropertyAttributes old_attributes = self->GetLocalElementAttribute(index); |
10343 Handle<Object> old_value = isolate->factory()->the_hole_value(); | 10342 Handle<Object> old_value = isolate->factory()->the_hole_value(); |
10344 Handle<Object> old_length; | 10343 Handle<Object> old_length; |
10345 | 10344 |
10346 if (old_attributes != ABSENT) { | 10345 if (old_attributes != ABSENT) { |
10347 if (GetLocalElementAccessorPair(index) == NULL) | 10346 if (self->GetLocalElementAccessorPair(index) == NULL) |
10348 old_value = Object::GetElement(self, index); | 10347 old_value = Object::GetElement(self, index); |
10349 } else if (self->IsJSArray()) { | 10348 } else if (self->IsJSArray()) { |
10350 // Store old array length in case adding an element grows the array. | 10349 // Store old array length in case adding an element grows the array. |
10351 old_length = handle(Handle<JSArray>::cast(self)->length(), isolate); | 10350 old_length = handle(Handle<JSArray>::cast(self)->length(), isolate); |
10352 } | 10351 } |
10353 | 10352 |
10354 // Check for lookup interceptor | 10353 // Check for lookup interceptor |
10355 MaybeObject* result = self->HasIndexedInterceptor() | 10354 MaybeObject* result = self->HasIndexedInterceptor() |
10356 ? self->SetElementWithInterceptor( | 10355 ? self->SetElementWithInterceptor( |
10357 index, *value, attributes, strict_mode, check_prototype, set_mode) | 10356 index, *value, attributes, strict_mode, check_prototype, set_mode) |
(...skipping 3526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13884 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13883 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13885 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13884 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13886 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13885 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13887 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13886 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13888 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13887 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13889 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13888 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13890 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13889 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13891 } | 13890 } |
13892 | 13891 |
13893 } } // namespace v8::internal | 13892 } } // namespace v8::internal |
OLD | NEW |