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

Side by Side Diff: runtime/vm/dart_api_message.cc

Issue 10557043: - Avoid doubling 0 when trying to determine a new size for the (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | « runtime/vm/dart_api_message.h ('k') | runtime/vm/vm_sources.gypi » ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/dart_api_message.h" 5 #include "vm/dart_api_message.h"
6 #include "vm/object.h" 6 #include "vm/object.h"
7 #include "vm/object_store.h" 7 #include "vm/object_store.h"
8 8
9 namespace dart { 9 namespace dart {
10 10
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 for (int i = 0; i < object->value.as_array.length; i++) { 506 for (int i = 0; i < object->value.as_array.length; i++) {
507 Dart_CObject* element = object->value.as_array.values[i]; 507 Dart_CObject* element = object->value.as_array.values[i];
508 UnmarkAllCObjects(element); 508 UnmarkAllCObjects(element);
509 } 509 }
510 } 510 }
511 } 511 }
512 512
513 513
514 void ApiMessageWriter::AddToForwardList(Dart_CObject* object) { 514 void ApiMessageWriter::AddToForwardList(Dart_CObject* object) {
515 if (forward_id_ >= forward_list_length_) { 515 if (forward_id_ >= forward_list_length_) {
516 intptr_t new_size = (forward_list_length_ * sizeof(object)) * 2; 516 void* new_list = NULL;
517 void* new_list = ::realloc(forward_list_, new_size); 517 if (forward_list_length_ == 0) {
518 intptr_t new_size = (4 * sizeof(object)) * 2;
519 new_list = ::malloc(new_size);
520 } else {
521 intptr_t new_size = (forward_list_length_ * sizeof(object)) * 2;
522 new_list = ::realloc(forward_list_, new_size);
523 }
518 ASSERT(new_list != NULL); 524 ASSERT(new_list != NULL);
519 forward_list_ = reinterpret_cast<Dart_CObject**>(new_list); 525 forward_list_ = reinterpret_cast<Dart_CObject**>(new_list);
520 } 526 }
521 forward_list_[forward_id_] = object; 527 forward_list_[forward_id_] = object;
522 forward_id_ += 1; 528 forward_id_ += 1;
523 } 529 }
524 530
525 531
526 void ApiMessageWriter::WriteSmi(int64_t value) { 532 void ApiMessageWriter::WriteSmi(int64_t value) {
527 ASSERT(Smi::IsValid64(value)); 533 ASSERT(Smi::IsValid64(value));
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 // not been serialized yet. These would typically be fields of arrays. 727 // not been serialized yet. These would typically be fields of arrays.
722 // NOTE: The forward list might grow as we process the list. 728 // NOTE: The forward list might grow as we process the list.
723 for (intptr_t i = 0; i < forward_id_; i++) { 729 for (intptr_t i = 0; i < forward_id_; i++) {
724 WriteForwardedCObject(forward_list_[i]); 730 WriteForwardedCObject(forward_list_[i]);
725 } 731 }
726 UnmarkAllCObjects(object); 732 UnmarkAllCObjects(object);
727 FinalizeBuffer(); 733 FinalizeBuffer();
728 } 734 }
729 735
730 } // namespace dart 736 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_message.h ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698