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 10857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10868 PropertyAttributes attributes = object->GetLocalElementAttribute(index); | 10868 PropertyAttributes attributes = object->GetLocalElementAttribute(index); |
10869 ASSERT(attributes != ABSENT); | 10869 ASSERT(attributes != ABSENT); |
10870 if (attributes == DONT_DELETE) return false; | 10870 if (attributes == DONT_DELETE) return false; |
10871 old_values->Add(object->GetLocalElementAccessorPair(index) == NULL | 10871 old_values->Add(object->GetLocalElementAccessorPair(index) == NULL |
10872 ? Object::GetElement(object, index) | 10872 ? Object::GetElement(object, index) |
10873 : Handle<Object>::cast(isolate->factory()->the_hole_value())); | 10873 : Handle<Object>::cast(isolate->factory()->the_hole_value())); |
10874 indices->Add(index); | 10874 indices->Add(index); |
10875 return true; | 10875 return true; |
10876 } | 10876 } |
10877 | 10877 |
10878 | |
10879 // TODO(rafaelw): Remove |delete_count| argument and rely on the length of | |
10880 // of |deleted|. | |
10881 static void EnqueueSpliceRecord(Handle<JSArray> object, | 10878 static void EnqueueSpliceRecord(Handle<JSArray> object, |
10882 uint32_t index, | 10879 uint32_t index, |
10883 Handle<JSArray> deleted, | 10880 Handle<JSArray> deleted, |
10884 uint32_t delete_count, | |
10885 uint32_t add_count) { | 10881 uint32_t add_count) { |
10886 Isolate* isolate = object->GetIsolate(); | 10882 Isolate* isolate = object->GetIsolate(); |
10887 HandleScope scope(isolate); | 10883 HandleScope scope(isolate); |
10888 Handle<Object> index_object = isolate->factory()->NewNumberFromUint(index); | 10884 Handle<Object> index_object = isolate->factory()->NewNumberFromUint(index); |
10889 Handle<Object> delete_count_object = | |
10890 isolate->factory()->NewNumberFromUint(delete_count); | |
10891 Handle<Object> add_count_object = | 10885 Handle<Object> add_count_object = |
10892 isolate->factory()->NewNumberFromUint(add_count); | 10886 isolate->factory()->NewNumberFromUint(add_count); |
10893 | 10887 |
10894 Handle<Object> args[] = | 10888 Handle<Object> args[] = |
10895 { object, index_object, deleted, delete_count_object, add_count_object }; | 10889 { object, index_object, deleted, add_count_object }; |
10896 | 10890 |
10897 bool threw; | 10891 bool threw; |
10898 Execution::Call(Handle<JSFunction>(isolate->observers_enqueue_splice()), | 10892 Execution::Call(Handle<JSFunction>(isolate->observers_enqueue_splice()), |
10899 isolate->factory()->undefined_value(), ARRAY_SIZE(args), args, | 10893 isolate->factory()->undefined_value(), ARRAY_SIZE(args), args, |
10900 &threw); | 10894 &threw); |
10901 ASSERT(!threw); | 10895 ASSERT(!threw); |
10902 } | 10896 } |
10903 | 10897 |
10904 | 10898 |
10905 static void BeginPerformSplice(Handle<JSArray> object) { | 10899 static void BeginPerformSplice(Handle<JSArray> object) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10989 JSObject::EnqueueChangeRecord( | 10983 JSObject::EnqueueChangeRecord( |
10990 self, "updated", isolate->factory()->length_string(), | 10984 self, "updated", isolate->factory()->length_string(), |
10991 old_length_handle); | 10985 old_length_handle); |
10992 | 10986 |
10993 EndPerformSplice(self); | 10987 EndPerformSplice(self); |
10994 | 10988 |
10995 uint32_t index = Min(old_length, new_length); | 10989 uint32_t index = Min(old_length, new_length); |
10996 uint32_t add_count = new_length > old_length ? new_length - old_length : 0; | 10990 uint32_t add_count = new_length > old_length ? new_length - old_length : 0; |
10997 uint32_t delete_count = new_length < old_length ? old_length - new_length : 0; | 10991 uint32_t delete_count = new_length < old_length ? old_length - new_length : 0; |
10998 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0); | 10992 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0); |
10999 if (delete_count) { | 10993 if (delete_count > 0) { |
11000 for (int i = indices.length() - 1; i >= 0; i--) { | 10994 for (int i = indices.length() - 1; i >= 0; i--) { |
11001 JSObject::SetElement(deleted, indices[i] - index, old_values[i], NONE, | 10995 JSObject::SetElement(deleted, indices[i] - index, old_values[i], NONE, |
11002 kNonStrictMode); | 10996 kNonStrictMode); |
11003 } | 10997 } |
| 10998 |
| 10999 SetProperty(deleted, isolate->factory()->length_string(), |
| 11000 isolate->factory()->NewNumberFromUint(delete_count), |
| 11001 NONE, kNonStrictMode); |
11004 } | 11002 } |
11005 | 11003 |
11006 EnqueueSpliceRecord(self, index, deleted, delete_count, add_count); | 11004 EnqueueSpliceRecord(self, index, deleted, add_count); |
11007 | 11005 |
11008 return *hresult; | 11006 return *hresult; |
11009 } | 11007 } |
11010 | 11008 |
11011 | 11009 |
11012 Map* Map::GetPrototypeTransition(Object* prototype) { | 11010 Map* Map::GetPrototypeTransition(Object* prototype) { |
11013 FixedArray* cache = GetPrototypeTransitions(); | 11011 FixedArray* cache = GetPrototypeTransitions(); |
11014 int number_of_transitions = NumberOfProtoTransitions(); | 11012 int number_of_transitions = NumberOfProtoTransitions(); |
11015 const int proto_offset = | 11013 const int proto_offset = |
11016 kProtoTransitionHeaderSize + kProtoTransitionPrototypeOffset; | 11014 kProtoTransitionHeaderSize + kProtoTransitionPrototypeOffset; |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12062 uint32_t new_length = 0; | 12060 uint32_t new_length = 0; |
12063 CHECK(old_length_handle->ToArrayIndex(&old_length)); | 12061 CHECK(old_length_handle->ToArrayIndex(&old_length)); |
12064 CHECK(new_length_handle->ToArrayIndex(&new_length)); | 12062 CHECK(new_length_handle->ToArrayIndex(&new_length)); |
12065 | 12063 |
12066 BeginPerformSplice(Handle<JSArray>::cast(self)); | 12064 BeginPerformSplice(Handle<JSArray>::cast(self)); |
12067 EnqueueChangeRecord(self, "new", name, old_value); | 12065 EnqueueChangeRecord(self, "new", name, old_value); |
12068 EnqueueChangeRecord(self, "updated", isolate->factory()->length_string(), | 12066 EnqueueChangeRecord(self, "updated", isolate->factory()->length_string(), |
12069 old_length_handle); | 12067 old_length_handle); |
12070 EndPerformSplice(Handle<JSArray>::cast(self)); | 12068 EndPerformSplice(Handle<JSArray>::cast(self)); |
12071 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0); | 12069 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0); |
12072 EnqueueSpliceRecord(Handle<JSArray>::cast(self), old_length, deleted, 0, | 12070 EnqueueSpliceRecord(Handle<JSArray>::cast(self), old_length, deleted, |
12073 new_length - old_length); | 12071 new_length - old_length); |
12074 } else { | 12072 } else { |
12075 EnqueueChangeRecord(self, "new", name, old_value); | 12073 EnqueueChangeRecord(self, "new", name, old_value); |
12076 } | 12074 } |
12077 } else if (old_value->IsTheHole()) { | 12075 } else if (old_value->IsTheHole()) { |
12078 EnqueueChangeRecord(self, "reconfigured", name, old_value); | 12076 EnqueueChangeRecord(self, "reconfigured", name, old_value); |
12079 } else { | 12077 } else { |
12080 Handle<Object> new_value = Object::GetElement(self, index); | 12078 Handle<Object> new_value = Object::GetElement(self, index); |
12081 bool value_changed = !old_value->SameValue(*new_value); | 12079 bool value_changed = !old_value->SameValue(*new_value); |
12082 if (old_attributes != new_attributes) { | 12080 if (old_attributes != new_attributes) { |
(...skipping 3605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15688 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 15686 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
15689 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 15687 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
15690 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 15688 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
15691 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 15689 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
15692 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 15690 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
15693 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 15691 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
15694 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 15692 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
15695 } | 15693 } |
15696 | 15694 |
15697 } } // namespace v8::internal | 15695 } } // namespace v8::internal |
OLD | NEW |