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 10827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10838 PropertyAttributes attributes = object->GetLocalElementAttribute(index); | 10838 PropertyAttributes attributes = object->GetLocalElementAttribute(index); |
10839 ASSERT(attributes != ABSENT); | 10839 ASSERT(attributes != ABSENT); |
10840 if (attributes == DONT_DELETE) return false; | 10840 if (attributes == DONT_DELETE) return false; |
10841 old_values->Add(object->GetLocalElementAccessorPair(index) == NULL | 10841 old_values->Add(object->GetLocalElementAccessorPair(index) == NULL |
10842 ? Object::GetElement(object, index) | 10842 ? Object::GetElement(object, index) |
10843 : Handle<Object>::cast(isolate->factory()->the_hole_value())); | 10843 : Handle<Object>::cast(isolate->factory()->the_hole_value())); |
10844 indices->Add(index); | 10844 indices->Add(index); |
10845 return true; | 10845 return true; |
10846 } | 10846 } |
10847 | 10847 |
10848 | |
10849 // TODO(rafaelw): Remove |delete_count| argument and rely on the length of | |
10850 // of |deleted|. | |
10851 static void EnqueueSpliceRecord(Handle<JSArray> object, | 10848 static void EnqueueSpliceRecord(Handle<JSArray> object, |
10852 uint32_t index, | 10849 uint32_t index, |
10853 Handle<JSArray> deleted, | 10850 Handle<JSArray> deleted, |
10854 uint32_t delete_count, | |
10855 uint32_t add_count) { | 10851 uint32_t add_count) { |
10856 Isolate* isolate = object->GetIsolate(); | 10852 Isolate* isolate = object->GetIsolate(); |
10857 HandleScope scope(isolate); | 10853 HandleScope scope(isolate); |
10858 Handle<Object> index_object = isolate->factory()->NewNumberFromUint(index); | 10854 Handle<Object> index_object = isolate->factory()->NewNumberFromUint(index); |
10859 Handle<Object> delete_count_object = | |
10860 isolate->factory()->NewNumberFromUint(delete_count); | |
10861 Handle<Object> add_count_object = | 10855 Handle<Object> add_count_object = |
10862 isolate->factory()->NewNumberFromUint(add_count); | 10856 isolate->factory()->NewNumberFromUint(add_count); |
10863 | 10857 |
10864 Handle<Object> args[] = | 10858 Handle<Object> args[] = |
10865 { object, index_object, deleted, delete_count_object, add_count_object }; | 10859 { object, index_object, deleted, add_count_object }; |
10866 | 10860 |
10867 bool threw; | 10861 bool threw; |
10868 Execution::Call(Handle<JSFunction>(isolate->observers_enqueue_splice()), | 10862 Execution::Call(Handle<JSFunction>(isolate->observers_enqueue_splice()), |
10869 isolate->factory()->undefined_value(), ARRAY_SIZE(args), args, | 10863 isolate->factory()->undefined_value(), ARRAY_SIZE(args), args, |
10870 &threw); | 10864 &threw); |
10871 ASSERT(!threw); | 10865 ASSERT(!threw); |
10872 } | 10866 } |
10873 | 10867 |
10874 | 10868 |
10875 static void BeginPerformSplice(Handle<JSArray> object) { | 10869 static void BeginPerformSplice(Handle<JSArray> object) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10959 JSObject::EnqueueChangeRecord( | 10953 JSObject::EnqueueChangeRecord( |
10960 self, "updated", isolate->factory()->length_string(), | 10954 self, "updated", isolate->factory()->length_string(), |
10961 old_length_handle); | 10955 old_length_handle); |
10962 | 10956 |
10963 EndPerformSplice(self); | 10957 EndPerformSplice(self); |
10964 | 10958 |
10965 uint32_t index = Min(old_length, new_length); | 10959 uint32_t index = Min(old_length, new_length); |
10966 uint32_t add_count = new_length > old_length ? new_length - old_length : 0; | 10960 uint32_t add_count = new_length > old_length ? new_length - old_length : 0; |
10967 uint32_t delete_count = new_length < old_length ? old_length - new_length : 0; | 10961 uint32_t delete_count = new_length < old_length ? old_length - new_length : 0; |
10968 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0); | 10962 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0); |
10969 if (delete_count) { | 10963 if (delete_count) { |
rossberg
2013/06/06 09:12:05
Nit: can we make this del_cnt > 0?
rafaelw
2013/06/06 18:44:41
Done.
| |
10970 for (int i = indices.length() - 1; i >= 0; i--) { | 10964 for (int i = indices.length() - 1; i >= 0; i--) { |
10971 JSObject::SetElement(deleted, indices[i] - index, old_values[i], NONE, | 10965 JSObject::SetElement(deleted, indices[i] - index, old_values[i], NONE, |
10972 kNonStrictMode); | 10966 kNonStrictMode); |
10973 } | 10967 } |
10974 } | 10968 } |
10975 | 10969 |
10976 EnqueueSpliceRecord(self, index, deleted, delete_count, add_count); | 10970 SetProperty(deleted, isolate->factory()->length_string(), |
adamk
2013/06/05 17:22:03
This can go inside the if (delete_count) block.
I
rafaelw
2013/06/06 18:44:41
Done.
| |
10971 isolate->factory()->NewNumberFromUint(delete_count), | |
10972 NONE, kNonStrictMode); | |
10973 EnqueueSpliceRecord(self, index, deleted, add_count); | |
10977 | 10974 |
10978 return *hresult; | 10975 return *hresult; |
10979 } | 10976 } |
10980 | 10977 |
10981 | 10978 |
10982 Map* Map::GetPrototypeTransition(Object* prototype) { | 10979 Map* Map::GetPrototypeTransition(Object* prototype) { |
10983 FixedArray* cache = GetPrototypeTransitions(); | 10980 FixedArray* cache = GetPrototypeTransitions(); |
10984 int number_of_transitions = NumberOfProtoTransitions(); | 10981 int number_of_transitions = NumberOfProtoTransitions(); |
10985 const int proto_offset = | 10982 const int proto_offset = |
10986 kProtoTransitionHeaderSize + kProtoTransitionPrototypeOffset; | 10983 kProtoTransitionHeaderSize + kProtoTransitionPrototypeOffset; |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12032 uint32_t new_length = 0; | 12029 uint32_t new_length = 0; |
12033 CHECK(old_length_handle->ToArrayIndex(&old_length)); | 12030 CHECK(old_length_handle->ToArrayIndex(&old_length)); |
12034 CHECK(new_length_handle->ToArrayIndex(&new_length)); | 12031 CHECK(new_length_handle->ToArrayIndex(&new_length)); |
12035 | 12032 |
12036 BeginPerformSplice(Handle<JSArray>::cast(self)); | 12033 BeginPerformSplice(Handle<JSArray>::cast(self)); |
12037 EnqueueChangeRecord(self, "new", name, old_value); | 12034 EnqueueChangeRecord(self, "new", name, old_value); |
12038 EnqueueChangeRecord(self, "updated", isolate->factory()->length_string(), | 12035 EnqueueChangeRecord(self, "updated", isolate->factory()->length_string(), |
12039 old_length_handle); | 12036 old_length_handle); |
12040 EndPerformSplice(Handle<JSArray>::cast(self)); | 12037 EndPerformSplice(Handle<JSArray>::cast(self)); |
12041 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0); | 12038 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0); |
12042 EnqueueSpliceRecord(Handle<JSArray>::cast(self), old_length, deleted, 0, | 12039 EnqueueSpliceRecord(Handle<JSArray>::cast(self), old_length, deleted, |
12043 new_length - old_length); | 12040 new_length - old_length); |
12044 } else { | 12041 } else { |
12045 EnqueueChangeRecord(self, "new", name, old_value); | 12042 EnqueueChangeRecord(self, "new", name, old_value); |
12046 } | 12043 } |
12047 } else if (old_value->IsTheHole()) { | 12044 } else if (old_value->IsTheHole()) { |
12048 EnqueueChangeRecord(self, "reconfigured", name, old_value); | 12045 EnqueueChangeRecord(self, "reconfigured", name, old_value); |
12049 } else { | 12046 } else { |
12050 Handle<Object> new_value = Object::GetElement(self, index); | 12047 Handle<Object> new_value = Object::GetElement(self, index); |
12051 bool value_changed = !old_value->SameValue(*new_value); | 12048 bool value_changed = !old_value->SameValue(*new_value); |
12052 if (old_attributes != new_attributes) { | 12049 if (old_attributes != new_attributes) { |
(...skipping 3605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15658 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 15655 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
15659 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 15656 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
15660 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 15657 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
15661 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 15658 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
15662 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 15659 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
15663 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 15660 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
15664 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 15661 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
15665 } | 15662 } |
15666 | 15663 |
15667 } } // namespace v8::internal | 15664 } } // namespace v8::internal |
OLD | NEW |