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

Side by Side Diff: src/objects.cc

Issue 40110: Merge bleeding_edge revision 1419 to trunk. Fixes a GC unsafety that... (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/api.cc ('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 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 4862 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) { 4882 void JSArray::EnsureSize(int required_size) {
4883 Handle<JSArray> self(this);
4883 ASSERT(HasFastElements()); 4884 ASSERT(HasFastElements());
4884 if (elements()->length() >= required_size) return; 4885 if (elements()->length() >= required_size) return;
4885 Handle<FixedArray> old_backing(elements()); 4886 Handle<FixedArray> old_backing(elements());
4886 int old_size = old_backing->length(); 4887 int old_size = old_backing->length();
4887 // Doubling in size would be overkill, but leave some slack to avoid 4888 // Doubling in size would be overkill, but leave some slack to avoid
4888 // constantly growing. 4889 // constantly growing.
4889 int new_size = required_size + (required_size >> 3); 4890 int new_size = required_size + (required_size >> 3);
4890 Handle<FixedArray> new_backing = Factory::NewFixedArray(new_size); 4891 Handle<FixedArray> new_backing = Factory::NewFixedArray(new_size);
4892 // Can't use this any more now because we may have had a GC!
4891 for (int i = 0; i < old_size; i++) new_backing->set(i, old_backing->get(i)); 4893 for (int i = 0; i < old_size; i++) new_backing->set(i, old_backing->get(i));
4892 SetContent(*new_backing); 4894 self->SetContent(*new_backing);
4893 } 4895 }
4894 4896
4895 4897
4896 // Computes the new capacity when expanding the elements of a JSObject. 4898 // Computes the new capacity when expanding the elements of a JSObject.
4897 static int NewElementsCapacity(int old_capacity) { 4899 static int NewElementsCapacity(int old_capacity) {
4898 // (old_capacity + 50%) + 16 4900 // (old_capacity + 50%) + 16
4899 return old_capacity + (old_capacity >> 1) + 16; 4901 return old_capacity + (old_capacity >> 1) + 16;
4900 } 4902 }
4901 4903
4902 4904
(...skipping 2369 matching lines...) Expand 10 before | Expand all | Expand 10 after
7272 // No break point. 7274 // No break point.
7273 if (break_point_objects()->IsUndefined()) return 0; 7275 if (break_point_objects()->IsUndefined()) return 0;
7274 // Single beak point. 7276 // Single beak point.
7275 if (!break_point_objects()->IsFixedArray()) return 1; 7277 if (!break_point_objects()->IsFixedArray()) return 1;
7276 // Multiple break points. 7278 // Multiple break points.
7277 return FixedArray::cast(break_point_objects())->length(); 7279 return FixedArray::cast(break_point_objects())->length();
7278 } 7280 }
7279 7281
7280 7282
7281 } } // namespace v8::internal 7283 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698