Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Side by Side Diff: src/objects.cc

Issue 24195003: Handlify JSObject::AddFastPropertyUsingMap method. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1832 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 // If the constructor is not present, return "Object". 1843 // If the constructor is not present, return "Object".
1844 return GetHeap()->Object_string(); 1844 return GetHeap()->Object_string();
1845 } 1845 }
1846 1846
1847 1847
1848 String* JSReceiver::constructor_name() { 1848 String* JSReceiver::constructor_name() {
1849 return map()->constructor_name(); 1849 return map()->constructor_name();
1850 } 1850 }
1851 1851
1852 1852
1853 Handle<Object> JSObject::AddFastPropertyUsingMap( 1853 // TODO(mstarzinger): Temporary wrapper until handlified.
1854 Handle<JSObject> object, 1854 static Handle<Object> NewStorageFor(Isolate* isolate,
1855 Handle<Map> new_map, 1855 Handle<Object> object,
1856 Handle<Name> name, 1856 Representation representation) {
1857 Handle<Object> value, 1857 Heap* heap = isolate->heap();
1858 int field_index, 1858 CALL_HEAP_FUNCTION(isolate,
1859 Representation representation) { 1859 object->AllocateNewStorageFor(heap, representation),
1860 CALL_HEAP_FUNCTION(object->GetIsolate(),
1861 object->AddFastPropertyUsingMap(
1862 *new_map, *name, *value, field_index, representation),
1863 Object); 1860 Object);
1864 } 1861 }
1865 1862
1866 1863
1867 MaybeObject* JSObject::AddFastPropertyUsingMap(Map* new_map, 1864 void JSObject::AddFastPropertyUsingMap(Handle<JSObject> object,
1868 Name* name, 1865 Handle<Map> new_map,
1869 Object* value, 1866 Handle<Name> name,
1870 int field_index, 1867 Handle<Object> value,
1871 Representation representation) { 1868 int field_index,
1869 Representation representation) {
1870 Isolate* isolate = object->GetIsolate();
1871
1872 // This method is used to transition to a field. If we are transitioning to a 1872 // This method is used to transition to a field. If we are transitioning to a
1873 // double field, allocate new storage. 1873 // double field, allocate new storage.
1874 Object* storage; 1874 Handle<Object> storage = NewStorageFor(isolate, value, representation);
1875 MaybeObject* maybe_storage =
1876 value->AllocateNewStorageFor(GetHeap(), representation);
1877 if (!maybe_storage->To(&storage)) return maybe_storage;
1878 1875
1879 if (map()->unused_property_fields() == 0) { 1876 if (object->map()->unused_property_fields() == 0) {
1880 int new_unused = new_map->unused_property_fields(); 1877 int new_unused = new_map->unused_property_fields();
1881 FixedArray* values; 1878 Handle<FixedArray> properties(object->properties());
1882 MaybeObject* maybe_values = 1879 Handle<FixedArray> values = isolate->factory()->CopySizeFixedArray(
1883 properties()->CopySize(properties()->length() + new_unused + 1); 1880 properties, properties->length() + new_unused + 1);
1884 if (!maybe_values->To(&values)) return maybe_values; 1881 object->set_properties(*values);
1885
1886 set_properties(values);
1887 } 1882 }
1888 1883
1889 set_map(new_map); 1884 object->set_map(*new_map);
1890 1885 object->FastPropertyAtPut(field_index, *storage);
1891 FastPropertyAtPut(field_index, storage);
1892 return value;
1893 } 1886 }
1894 1887
1895 1888
1896 static MaybeObject* CopyAddFieldDescriptor(Map* map, 1889 static MaybeObject* CopyAddFieldDescriptor(Map* map,
1897 Name* name, 1890 Name* name,
1898 int index, 1891 int index,
1899 PropertyAttributes attributes, 1892 PropertyAttributes attributes,
1900 Representation representation, 1893 Representation representation,
1901 TransitionFlag flag) { 1894 TransitionFlag flag) {
1902 Map* new_map; 1895 Map* new_map;
(...skipping 1881 matching lines...) Expand 10 before | Expand all | Expand 10 after
3784 descriptor, value->OptimalRepresentation(), FORCE_FIELD); 3777 descriptor, value->OptimalRepresentation(), FORCE_FIELD);
3785 Object* back = transition_map->GetBackPointer(); 3778 Object* back = transition_map->GetBackPointer();
3786 if (back->IsMap()) { 3779 if (back->IsMap()) {
3787 MigrateToMap(object, handle(Map::cast(back))); 3780 MigrateToMap(object, handle(Map::cast(back)));
3788 } 3781 }
3789 descriptors = transition_map->instance_descriptors(); 3782 descriptors = transition_map->instance_descriptors();
3790 representation = descriptors->GetDetails(descriptor).representation(); 3783 representation = descriptors->GetDetails(descriptor).representation();
3791 } 3784 }
3792 3785
3793 int field_index = descriptors->GetFieldIndex(descriptor); 3786 int field_index = descriptors->GetFieldIndex(descriptor);
3794 return AddFastPropertyUsingMap( 3787 AddFastPropertyUsingMap(
3795 object, transition_map, name, value, field_index, representation); 3788 object, transition_map, name, value, field_index, representation);
3789 return value;
3796 } 3790 }
3797 3791
3798 3792
3799 static void SetPropertyToField(LookupResult* lookup, 3793 static void SetPropertyToField(LookupResult* lookup,
3800 Handle<Name> name, 3794 Handle<Name> name,
3801 Handle<Object> value) { 3795 Handle<Object> value) {
3802 Representation representation = lookup->representation(); 3796 Representation representation = lookup->representation();
3803 if (!value->FitsRepresentation(representation) || 3797 if (!value->FitsRepresentation(representation) ||
3804 lookup->type() == CONSTANT) { 3798 lookup->type() == CONSTANT) {
3805 JSObject::GeneralizeFieldRepresentation(handle(lookup->holder()), 3799 JSObject::GeneralizeFieldRepresentation(handle(lookup->holder()),
(...skipping 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after
5564 MaybeObject* maybe_copy = map()->Copy(); 5558 MaybeObject* maybe_copy = map()->Copy();
5565 if (!maybe_copy->To(&new_map)) return maybe_copy; 5559 if (!maybe_copy->To(&new_map)) return maybe_copy;
5566 new_map->set_is_observed(true); 5560 new_map->set_is_observed(true);
5567 } 5561 }
5568 set_map(new_map); 5562 set_map(new_map);
5569 5563
5570 return heap->undefined_value(); 5564 return heap->undefined_value();
5571 } 5565 }
5572 5566
5573 5567
5574 // TODO(mstarzinger): Temporary wrapper until handlified.
5575 static Handle<Object> NewStorageFor(Isolate* isolate,
5576 Handle<Object> object,
5577 Representation representation) {
5578 Heap* heap = isolate->heap();
5579 CALL_HEAP_FUNCTION(isolate,
5580 object->AllocateNewStorageFor(heap, representation),
5581 Object);
5582 }
5583
5584
5585 Handle<JSObject> JSObject::Copy(Handle<JSObject> object) { 5568 Handle<JSObject> JSObject::Copy(Handle<JSObject> object) {
5586 Isolate* isolate = object->GetIsolate(); 5569 Isolate* isolate = object->GetIsolate();
5587 CALL_HEAP_FUNCTION(isolate, 5570 CALL_HEAP_FUNCTION(isolate,
5588 isolate->heap()->CopyJSObject(*object), JSObject); 5571 isolate->heap()->CopyJSObject(*object), JSObject);
5589 } 5572 }
5590 5573
5591 5574
5592 Handle<JSObject> JSObject::DeepCopy(Handle<JSObject> object) { 5575 Handle<JSObject> JSObject::DeepCopy(Handle<JSObject> object) {
5593 Isolate* isolate = object->GetIsolate(); 5576 Isolate* isolate = object->GetIsolate();
5594 StackLimitCheck check(isolate); 5577 StackLimitCheck check(isolate);
(...skipping 10518 matching lines...) Expand 10 before | Expand all | Expand 10 after
16113 #define ERROR_MESSAGES_TEXTS(C, T) T, 16096 #define ERROR_MESSAGES_TEXTS(C, T) T,
16114 static const char* error_messages_[] = { 16097 static const char* error_messages_[] = {
16115 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16098 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16116 }; 16099 };
16117 #undef ERROR_MESSAGES_TEXTS 16100 #undef ERROR_MESSAGES_TEXTS
16118 return error_messages_[reason]; 16101 return error_messages_[reason];
16119 } 16102 }
16120 16103
16121 16104
16122 } } // namespace v8::internal 16105 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698