| OLD | NEW |
| 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/snapshot_ids.h" | 7 #include "vm/snapshot_ids.h" |
| 8 #include "vm/symbols.h" | 8 #include "vm/symbols.h" |
| 9 #include "vm/unicode.h" | 9 #include "vm/unicode.h" |
| 10 | 10 |
| (...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 if (object->type == Dart_CObject_kArray) { | 799 if (object->type == Dart_CObject_kArray) { |
| 800 for (int i = 0; i < object->value.as_array.length; i++) { | 800 for (int i = 0; i < object->value.as_array.length; i++) { |
| 801 Dart_CObject* element = object->value.as_array.values[i]; | 801 Dart_CObject* element = object->value.as_array.values[i]; |
| 802 UnmarkAllCObjects(element); | 802 UnmarkAllCObjects(element); |
| 803 } | 803 } |
| 804 } | 804 } |
| 805 } | 805 } |
| 806 | 806 |
| 807 | 807 |
| 808 void ApiMessageWriter::AddToForwardList(Dart_CObject* object) { | 808 void ApiMessageWriter::AddToForwardList(Dart_CObject* object) { |
| 809 if (forward_id_ >= forward_list_length_) { | 809 ASSERT(forward_id_ <= forward_list_length_); |
| 810 void* new_list = NULL; | 810 if (forward_id_ == forward_list_length_) { |
| 811 intptr_t new_size; |
| 812 intptr_t old_size; |
| 811 if (forward_list_length_ == 0) { | 813 if (forward_list_length_ == 0) { |
| 814 old_size = 0; |
| 812 forward_list_length_ = 4; | 815 forward_list_length_ = 4; |
| 813 intptr_t new_size = forward_list_length_ * sizeof(object); | 816 new_size = forward_list_length_ * sizeof(object); |
| 814 new_list = ::malloc(new_size); | |
| 815 } else { | 817 } else { |
| 818 old_size = forward_list_length_ * sizeof(object); |
| 819 new_size = old_size + old_size; |
| 816 forward_list_length_ *= 2; | 820 forward_list_length_ *= 2; |
| 817 intptr_t new_size = (forward_list_length_ * sizeof(object)); | |
| 818 new_list = ::realloc(forward_list_, new_size); | |
| 819 } | 821 } |
| 822 Dart_CObject** new_list = Utils::Realloc(forward_list_, old_size, new_size); |
| 820 ASSERT(new_list != NULL); | 823 ASSERT(new_list != NULL); |
| 821 forward_list_ = reinterpret_cast<Dart_CObject**>(new_list); | 824 forward_list_ = new_list; |
| 822 } | 825 } |
| 823 forward_list_[forward_id_] = object; | 826 forward_list_[forward_id_] = object; |
| 824 forward_id_ += 1; | 827 forward_id_ += 1; |
| 825 } | 828 } |
| 826 | 829 |
| 827 | 830 |
| 828 void ApiMessageWriter::WriteSmi(int64_t value) { | 831 void ApiMessageWriter::WriteSmi(int64_t value) { |
| 829 ASSERT(Smi::IsValid64(value)); | 832 ASSERT(Smi::IsValid64(value)); |
| 830 Write<RawObject*>(Smi::New(value)); | 833 Write<RawObject*>(Smi::New(value)); |
| 831 } | 834 } |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 if (!success) { | 1117 if (!success) { |
| 1115 UnmarkAllCObjects(object); | 1118 UnmarkAllCObjects(object); |
| 1116 return false; | 1119 return false; |
| 1117 } | 1120 } |
| 1118 } | 1121 } |
| 1119 UnmarkAllCObjects(object); | 1122 UnmarkAllCObjects(object); |
| 1120 return true; | 1123 return true; |
| 1121 } | 1124 } |
| 1122 | 1125 |
| 1123 } // namespace dart | 1126 } // namespace dart |
| OLD | NEW |