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

Side by Side Diff: src/objects.cc

Issue 6588130: Handled return-value of SetElement in some cases, or avoided it in other. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge/build-ia32
Patch Set: Addressed review comments. Fixed some GetElements. Created 9 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/parser.cc » ('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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 6504 matching lines...) Expand 10 before | Expand all | Expand 10 after
6515 Handle<FixedArray> old_backing(FixedArray::cast(elements())); 6515 Handle<FixedArray> old_backing(FixedArray::cast(elements()));
6516 int old_size = old_backing->length(); 6516 int old_size = old_backing->length();
6517 int new_size = required_size > old_size ? required_size : old_size; 6517 int new_size = required_size > old_size ? required_size : old_size;
6518 Handle<FixedArray> new_backing = Factory::NewFixedArray(new_size); 6518 Handle<FixedArray> new_backing = Factory::NewFixedArray(new_size);
6519 // Can't use this any more now because we may have had a GC! 6519 // Can't use this any more now because we may have had a GC!
6520 for (int i = 0; i < old_size; i++) new_backing->set(i, old_backing->get(i)); 6520 for (int i = 0; i < old_size; i++) new_backing->set(i, old_backing->get(i));
6521 self->SetContent(*new_backing); 6521 self->SetContent(*new_backing);
6522 } 6522 }
6523 6523
6524 6524
6525 // Computes the new capacity when expanding the elements of a JSObject.
6526 static int NewElementsCapacity(int old_capacity) {
6527 // (old_capacity + 50%) + 16
6528 return old_capacity + (old_capacity >> 1) + 16;
6529 }
6530
6531
6532 static Failure* ArrayLengthRangeError() { 6525 static Failure* ArrayLengthRangeError() {
6533 HandleScope scope; 6526 HandleScope scope;
6534 return Top::Throw(*Factory::NewRangeError("invalid_array_length", 6527 return Top::Throw(*Factory::NewRangeError("invalid_array_length",
6535 HandleVector<Object>(NULL, 0))); 6528 HandleVector<Object>(NULL, 0)));
6536 } 6529 }
6537 6530
6538 6531
6539 MaybeObject* JSObject::SetElementsLength(Object* len) { 6532 MaybeObject* JSObject::SetElementsLength(Object* len) {
6540 // We should never end in here with a pixel or external array. 6533 // We should never end in here with a pixel or external array.
6541 ASSERT(AllowsSetElementsLength()); 6534 ASSERT(AllowsSetElementsLength());
(...skipping 3493 matching lines...) Expand 10 before | Expand all | Expand 10 after
10035 if (break_point_objects()->IsUndefined()) return 0; 10028 if (break_point_objects()->IsUndefined()) return 0;
10036 // Single beak point. 10029 // Single beak point.
10037 if (!break_point_objects()->IsFixedArray()) return 1; 10030 if (!break_point_objects()->IsFixedArray()) return 1;
10038 // Multiple break points. 10031 // Multiple break points.
10039 return FixedArray::cast(break_point_objects())->length(); 10032 return FixedArray::cast(break_point_objects())->length();
10040 } 10033 }
10041 #endif 10034 #endif
10042 10035
10043 10036
10044 } } // namespace v8::internal 10037 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698