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

Side by Side Diff: src/objects.cc

Issue 39134: Pull out bleeding_edge revision 1383, 1391 and 1491 from trunk since it is... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 11 years, 9 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/regexp-delay.js » ('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-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 4861 matching lines...) Expand 10 before | Expand all | Expand 10 after
4872 } else { 4872 } else {
4873 Object* obj = Heap::AllocateFixedArrayWithHoles(capacity); 4873 Object* obj = Heap::AllocateFixedArrayWithHoles(capacity);
4874 if (obj->IsFailure()) return obj; 4874 if (obj->IsFailure()) return obj;
4875 new_elements = FixedArray::cast(obj); 4875 new_elements = FixedArray::cast(obj);
4876 } 4876 }
4877 set_elements(new_elements); 4877 set_elements(new_elements);
4878 return this; 4878 return this;
4879 } 4879 }
4880 4880
4881 4881
4882 void JSArray::EnsureSize(int required_size) {
4883 Handle<JSArray> self(this);
4884 ASSERT(HasFastElements());
4885 if (elements()->length() >= required_size) return;
4886 Handle<FixedArray> old_backing(elements());
4887 int old_size = old_backing->length();
4888 // Doubling in size would be overkill, but leave some slack to avoid
4889 // constantly growing.
4890 int new_size = required_size + (required_size >> 3);
4891 Handle<FixedArray> new_backing = Factory::NewFixedArray(new_size);
4892 // Can't use this any more now because we may have had a GC!
4893 for (int i = 0; i < old_size; i++) new_backing->set(i, old_backing->get(i));
4894 self->SetContent(*new_backing);
4895 }
4896
4897
4898 // Computes the new capacity when expanding the elements of a JSObject. 4882 // Computes the new capacity when expanding the elements of a JSObject.
4899 static int NewElementsCapacity(int old_capacity) { 4883 static int NewElementsCapacity(int old_capacity) {
4900 // (old_capacity + 50%) + 16 4884 // (old_capacity + 50%) + 16
4901 return old_capacity + (old_capacity >> 1) + 16; 4885 return old_capacity + (old_capacity >> 1) + 16;
4902 } 4886 }
4903 4887
4904 4888
4905 static Object* ArrayLengthRangeError() { 4889 static Object* ArrayLengthRangeError() {
4906 HandleScope scope; 4890 HandleScope scope;
4907 return Top::Throw(*Factory::NewRangeError("invalid_array_length", 4891 return Top::Throw(*Factory::NewRangeError("invalid_array_length",
(...skipping 2366 matching lines...) Expand 10 before | Expand all | Expand 10 after
7274 // No break point. 7258 // No break point.
7275 if (break_point_objects()->IsUndefined()) return 0; 7259 if (break_point_objects()->IsUndefined()) return 0;
7276 // Single beak point. 7260 // Single beak point.
7277 if (!break_point_objects()->IsFixedArray()) return 1; 7261 if (!break_point_objects()->IsFixedArray()) return 1;
7278 // Multiple break points. 7262 // Multiple break points.
7279 return FixedArray::cast(break_point_objects())->length(); 7263 return FixedArray::cast(break_point_objects())->length();
7280 } 7264 }
7281 7265
7282 7266
7283 } } // namespace v8::internal 7267 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/regexp-delay.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698