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

Side by Side Diff: src/objects.cc

Issue 126265: Inline fast case of the method that ensures that an array has a (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 6 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') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 4959 matching lines...) Expand 10 before | Expand all | Expand 10 after
4970 } else { 4970 } else {
4971 Object* obj = Heap::AllocateFixedArrayWithHoles(capacity); 4971 Object* obj = Heap::AllocateFixedArrayWithHoles(capacity);
4972 if (obj->IsFailure()) return obj; 4972 if (obj->IsFailure()) return obj;
4973 new_elements = FixedArray::cast(obj); 4973 new_elements = FixedArray::cast(obj);
4974 } 4974 }
4975 set_elements(new_elements); 4975 set_elements(new_elements);
4976 return this; 4976 return this;
4977 } 4977 }
4978 4978
4979 4979
4980 void JSArray::EnsureSize(int required_size) { 4980 void JSArray::Expand(int required_size) {
4981 Handle<JSArray> self(this); 4981 Handle<JSArray> self(this);
4982 ASSERT(HasFastElements());
4983 if (elements()->length() >= required_size) return;
4984 Handle<FixedArray> old_backing(elements()); 4982 Handle<FixedArray> old_backing(elements());
4985 int old_size = old_backing->length(); 4983 int old_size = old_backing->length();
4986 // Doubling in size would be overkill, but leave some slack to avoid 4984 // Doubling in size would be overkill, but leave some slack to avoid
4987 // constantly growing. 4985 // constantly growing.
4988 int new_size = required_size + (required_size >> 3); 4986 int new_size = required_size + (required_size >> 3);
4989 Handle<FixedArray> new_backing = Factory::NewFixedArray(new_size); 4987 Handle<FixedArray> new_backing = Factory::NewFixedArray(new_size);
4990 // Can't use this any more now because we may have had a GC! 4988 // Can't use this any more now because we may have had a GC!
4991 for (int i = 0; i < old_size; i++) new_backing->set(i, old_backing->get(i)); 4989 for (int i = 0; i < old_size; i++) new_backing->set(i, old_backing->get(i));
4992 self->SetContent(*new_backing); 4990 self->SetContent(*new_backing);
4993 } 4991 }
(...skipping 2485 matching lines...) Expand 10 before | Expand all | Expand 10 after
7479 // No break point. 7477 // No break point.
7480 if (break_point_objects()->IsUndefined()) return 0; 7478 if (break_point_objects()->IsUndefined()) return 0;
7481 // Single beak point. 7479 // Single beak point.
7482 if (!break_point_objects()->IsFixedArray()) return 1; 7480 if (!break_point_objects()->IsFixedArray()) return 1;
7483 // Multiple break points. 7481 // Multiple break points.
7484 return FixedArray::cast(break_point_objects())->length(); 7482 return FixedArray::cast(break_point_objects())->length();
7485 } 7483 }
7486 #endif 7484 #endif
7487 7485
7488 } } // namespace v8::internal 7486 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698