| 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 1732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1743 } | 1743 } |
| 1744 | 1744 |
| 1745 | 1745 |
| 1746 void JSObject::EnqueueChangeRecord(Handle<JSObject> object, | 1746 void JSObject::EnqueueChangeRecord(Handle<JSObject> object, |
| 1747 const char* type_str, | 1747 const char* type_str, |
| 1748 Handle<String> name, | 1748 Handle<String> name, |
| 1749 Handle<Object> old_value) { | 1749 Handle<Object> old_value) { |
| 1750 Isolate* isolate = object->GetIsolate(); | 1750 Isolate* isolate = object->GetIsolate(); |
| 1751 HandleScope scope; | 1751 HandleScope scope; |
| 1752 Handle<String> type = isolate->factory()->LookupUtf8Symbol(type_str); | 1752 Handle<String> type = isolate->factory()->LookupUtf8Symbol(type_str); |
| 1753 if (object->IsJSGlobalObject()) { | 1753 EnqueueChangeRecord(object, type, name, old_value); |
| 1754 } |
| 1755 |
| 1756 void JSObject::EnqueueChangeRecord(Handle<JSObject> object, |
| 1757 Handle<String> type, |
| 1758 Handle<String> name, |
| 1759 Handle<Object> old_value) { |
| 1760 Isolate* isolate = object->GetIsolate(); |
| 1761 HandleScope scope; |
| 1762 if (object->IsJSGlobalObject()) |
| 1754 object = handle(JSGlobalObject::cast(*object)->global_receiver(), isolate); | 1763 object = handle(JSGlobalObject::cast(*object)->global_receiver(), isolate); |
| 1764 Handle<JSObject> change_record = isolate->factory()->NewJSObjectFromMap( |
| 1765 old_value->IsTheHole() |
| 1766 ? isolate->change_record_map() |
| 1767 : isolate->change_record_oldvalue_map()); |
| 1768 |
| 1769 // Make sure both properties and elements are frozen. |
| 1770 ASSERT(!change_record->map()->is_extensible()); |
| 1771 Handle<SeededNumberDictionary> elements = NormalizeElements(change_record); |
| 1772 elements->set_requires_slow_elements(); |
| 1773 |
| 1774 change_record->InObjectPropertyAtPut(JSChangeRecord::kTypeIndex, *type); |
| 1775 change_record->InObjectPropertyAtPut(JSChangeRecord::kObjectIndex, *object); |
| 1776 change_record->InObjectPropertyAtPut(JSChangeRecord::kNameIndex, *name); |
| 1777 if (!old_value->IsTheHole()) { |
| 1778 change_record->InObjectPropertyAtPut( |
| 1779 JSChangeRecord::kOldValueIndex, *old_value); |
| 1755 } | 1780 } |
| 1756 Handle<Object> args[] = { type, object, name, old_value }; | 1781 |
| 1782 Handle<Object> args[] = { change_record }; |
| 1757 bool threw; | 1783 bool threw; |
| 1758 Execution::Call(Handle<JSFunction>(isolate->observers_notify_change()), | 1784 Execution::Call(isolate->observers_notify_change(), |
| 1759 Handle<Object>(isolate->heap()->undefined_value()), | 1785 isolate->factory()->undefined_value(), |
| 1760 old_value->IsTheHole() ? 3 : 4, args, | 1786 1, args, &threw); |
| 1761 &threw); | |
| 1762 ASSERT(!threw); | 1787 ASSERT(!threw); |
| 1763 } | 1788 } |
| 1764 | 1789 |
| 1765 | 1790 |
| 1766 void JSObject::DeliverChangeRecords(Isolate* isolate) { | 1791 void JSObject::DeliverChangeRecords(Isolate* isolate) { |
| 1767 ASSERT(isolate->observer_delivery_pending()); | 1792 ASSERT(isolate->observer_delivery_pending()); |
| 1768 bool threw = false; | 1793 bool threw = false; |
| 1769 Execution::Call( | 1794 Execution::Call( |
| 1770 isolate->observers_deliver_changes(), | 1795 isolate->observers_deliver_changes(), |
| 1771 isolate->factory()->undefined_value(), | 1796 isolate->factory()->undefined_value(), |
| (...skipping 7635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9407 } | 9432 } |
| 9408 | 9433 |
| 9409 MaybeObject* result = | 9434 MaybeObject* result = |
| 9410 self->GetElementsAccessor()->SetLength(*self, *new_length_handle); | 9435 self->GetElementsAccessor()->SetLength(*self, *new_length_handle); |
| 9411 Handle<Object> hresult; | 9436 Handle<Object> hresult; |
| 9412 if (!result->ToHandle(&hresult, isolate)) return result; | 9437 if (!result->ToHandle(&hresult, isolate)) return result; |
| 9413 | 9438 |
| 9414 CHECK(self->length()->ToArrayIndex(&new_length)); | 9439 CHECK(self->length()->ToArrayIndex(&new_length)); |
| 9415 if (old_length != new_length) { | 9440 if (old_length != new_length) { |
| 9416 for (int i = 0; i < indices.length(); ++i) { | 9441 for (int i = 0; i < indices.length(); ++i) { |
| 9417 JSObject::EnqueueChangeRecord( | 9442 EnqueueChangeRecord(self, "deleted", indices[i], old_values[i]); |
| 9418 self, "deleted", indices[i], old_values[i]); | |
| 9419 } | 9443 } |
| 9420 JSObject::EnqueueChangeRecord( | 9444 EnqueueChangeRecord(self, "updated", isolate->factory()->length_symbol(), |
| 9421 self, "updated", isolate->factory()->length_symbol(), | 9445 old_length_handle); |
| 9422 old_length_handle); | |
| 9423 } | 9446 } |
| 9424 return *hresult; | 9447 return *hresult; |
| 9425 } | 9448 } |
| 9426 | 9449 |
| 9427 | 9450 |
| 9428 Map* Map::GetPrototypeTransition(Object* prototype) { | 9451 Map* Map::GetPrototypeTransition(Object* prototype) { |
| 9429 FixedArray* cache = GetPrototypeTransitions(); | 9452 FixedArray* cache = GetPrototypeTransitions(); |
| 9430 int number_of_transitions = NumberOfProtoTransitions(); | 9453 int number_of_transitions = NumberOfProtoTransitions(); |
| 9431 const int proto_offset = | 9454 const int proto_offset = |
| 9432 kProtoTransitionHeaderSize + kProtoTransitionPrototypeOffset; | 9455 kProtoTransitionHeaderSize + kProtoTransitionPrototypeOffset; |
| (...skipping 4459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13892 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13915 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
| 13893 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13916 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
| 13894 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13917 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
| 13895 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13918 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
| 13896 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13919 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
| 13897 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13920 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
| 13898 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13921 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
| 13899 } | 13922 } |
| 13900 | 13923 |
| 13901 } } // namespace v8::internal | 13924 } } // namespace v8::internal |
| OLD | NEW |