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

Side by Side Diff: src/objects.cc

Issue 7863: - Optimized CopyFixedArray and CopyJSObject. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 2 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
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 return Heap::Object_symbol(); 903 return Heap::Object_symbol();
904 } 904 }
905 905
906 906
907 void JSObject::JSObjectIterateBody(int object_size, ObjectVisitor* v) { 907 void JSObject::JSObjectIterateBody(int object_size, ObjectVisitor* v) {
908 // Iterate over all fields in the body. Assumes all are Object*. 908 // Iterate over all fields in the body. Assumes all are Object*.
909 IteratePointers(v, kPropertiesOffset, object_size); 909 IteratePointers(v, kPropertiesOffset, object_size);
910 } 910 }
911 911
912 912
913 Object* JSObject::Copy(PretenureFlag pretenure) {
914 // Never used to copy functions. If functions need to be copied we
915 // have to be careful to clear the literals array.
916 ASSERT(!IsJSFunction());
917
918 // Copy the elements and properties.
919 Object* elem = FixedArray::cast(elements())->Copy();
920 if (elem->IsFailure()) return elem;
921 Object* prop = properties()->Copy();
922 if (prop->IsFailure()) return prop;
923
924 // Make the clone.
925 Object* clone = (pretenure == NOT_TENURED) ?
926 Heap::Allocate(map(), NEW_SPACE) :
927 Heap::Allocate(map(), OLD_POINTER_SPACE);
928 if (clone->IsFailure()) return clone;
929 JSObject::cast(clone)->CopyBody(this);
930
931 // Set the new elements and properties.
932 JSObject::cast(clone)->set_elements(FixedArray::cast(elem));
933 JSObject::cast(clone)->set_properties(FixedArray::cast(prop));
934
935 // Return the new clone.
936 return clone;
937 }
938
939
940 Object* JSObject::AddFastPropertyUsingMap(Map* new_map, 913 Object* JSObject::AddFastPropertyUsingMap(Map* new_map,
941 String* name, 914 String* name,
942 Object* value) { 915 Object* value) {
943 int index = new_map->PropertyIndexFor(name); 916 int index = new_map->PropertyIndexFor(name);
944 if (map()->unused_property_fields() == 0) { 917 if (map()->unused_property_fields() == 0) {
945 ASSERT(map()->unused_property_fields() == 0); 918 ASSERT(map()->unused_property_fields() == 0);
946 int new_unused = new_map->unused_property_fields(); 919 int new_unused = new_map->unused_property_fields();
947 Object* values = 920 Object* values =
948 properties()->CopySize(properties()->length() + new_unused + 1); 921 properties()->CopySize(properties()->length() + new_unused + 1);
949 if (values->IsFailure()) return values; 922 if (values->IsFailure()) return values;
(...skipping 5594 matching lines...) Expand 10 before | Expand all | Expand 10 after
6544 // No break point. 6517 // No break point.
6545 if (break_point_objects()->IsUndefined()) return 0; 6518 if (break_point_objects()->IsUndefined()) return 0;
6546 // Single beak point. 6519 // Single beak point.
6547 if (!break_point_objects()->IsFixedArray()) return 1; 6520 if (!break_point_objects()->IsFixedArray()) return 1;
6548 // Multiple break points. 6521 // Multiple break points.
6549 return FixedArray::cast(break_point_objects())->length(); 6522 return FixedArray::cast(break_point_objects())->length();
6550 } 6523 }
6551 6524
6552 6525
6553 } } // namespace v8::internal 6526 } } // namespace v8::internal
OLDNEW
« src/objects.h ('K') | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698