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/heap_profiler.h" | 5 #include "vm/heap_profiler.h" |
6 | 6 |
7 #include "vm/dart_api_state.h" | 7 #include "vm/dart_api_state.h" |
8 #include "vm/object.h" | 8 #include "vm/object.h" |
9 #include "vm/raw_object.h" | 9 #include "vm/raw_object.h" |
10 #include "vm/stack_frame.h" | 10 #include "vm/stack_frame.h" |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 case kFloat64ArrayCid: { | 271 case kFloat64ArrayCid: { |
272 const RawFloat64Array* raw_float64_array = | 272 const RawFloat64Array* raw_float64_array = |
273 reinterpret_cast<const RawFloat64Array*>(raw_obj); | 273 reinterpret_cast<const RawFloat64Array*>(raw_obj); |
274 WritePrimitiveArrayDump(raw_float64_array, | 274 WritePrimitiveArrayDump(raw_float64_array, |
275 kDouble, | 275 kDouble, |
276 &raw_float64_array->data_[0]); | 276 &raw_float64_array->data_[0]); |
277 break; | 277 break; |
278 } | 278 } |
279 case kOneByteStringCid: | 279 case kOneByteStringCid: |
280 case kTwoByteStringCid: | 280 case kTwoByteStringCid: |
281 case kFourByteStringCid: | |
282 case kExternalOneByteStringCid: | 281 case kExternalOneByteStringCid: |
283 case kExternalTwoByteStringCid: | 282 case kExternalTwoByteStringCid: { |
284 case kExternalFourByteStringCid: { | |
285 WriteInstanceDump(StringId(reinterpret_cast<const RawString*>(raw_obj))); | 283 WriteInstanceDump(StringId(reinterpret_cast<const RawString*>(raw_obj))); |
286 break; | 284 break; |
287 } | 285 } |
288 default: | 286 default: |
289 WriteInstanceDump(raw_obj); | 287 WriteInstanceDump(raw_obj); |
290 } | 288 } |
291 } | 289 } |
292 | 290 |
293 | 291 |
294 void HeapProfiler::Write(const void* data, intptr_t size) { | 292 void HeapProfiler::Write(const void* data, intptr_t size) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 const RawOneByteString* onestr = | 346 const RawOneByteString* onestr = |
349 reinterpret_cast<const RawOneByteString*>(raw_string); | 347 reinterpret_cast<const RawOneByteString*>(raw_string); |
350 for (intptr_t i = 0; i < Smi::Value(onestr->ptr()->length_); ++i) { | 348 for (intptr_t i = 0; i < Smi::Value(onestr->ptr()->length_); ++i) { |
351 length += Utf8::Length(onestr->ptr()->data_[i]); | 349 length += Utf8::Length(onestr->ptr()->data_[i]); |
352 } | 350 } |
353 characters = new char[length]; | 351 characters = new char[length]; |
354 for (intptr_t i = 0, j = 0; i < Smi::Value(onestr->ptr()->length_); ++i) { | 352 for (intptr_t i = 0, j = 0; i < Smi::Value(onestr->ptr()->length_); ++i) { |
355 int32_t ch = onestr->ptr()->data_[i]; | 353 int32_t ch = onestr->ptr()->data_[i]; |
356 j += Utf8::Encode(ch, &characters[j]); | 354 j += Utf8::Encode(ch, &characters[j]); |
357 } | 355 } |
358 } else if (class_id == kTwoByteStringCid) { | 356 } else { |
| 357 ASSERT(class_id == kTwoByteStringCid); |
359 const RawTwoByteString* twostr = | 358 const RawTwoByteString* twostr = |
360 reinterpret_cast<const RawTwoByteString*>(raw_string); | 359 reinterpret_cast<const RawTwoByteString*>(raw_string); |
361 for (intptr_t i = 0; i < Smi::Value(twostr->ptr()->length_); ++i) { | 360 for (intptr_t i = 0; i < Smi::Value(twostr->ptr()->length_); ++i) { |
362 length += Utf8::Length(twostr->ptr()->data_[i]); | 361 length += Utf8::Length(twostr->ptr()->data_[i]); |
363 } | 362 } |
364 characters = new char[length]; | 363 characters = new char[length]; |
365 for (intptr_t i = 0, j = 0; i < Smi::Value(twostr->ptr()->length_); ++i) { | 364 for (intptr_t i = 0, j = 0; i < Smi::Value(twostr->ptr()->length_); ++i) { |
366 int32_t ch = twostr->ptr()->data_[i]; | 365 int32_t ch = twostr->ptr()->data_[i]; |
367 j += Utf8::Encode(ch, &characters[j]); | 366 j += Utf8::Encode(ch, &characters[j]); |
368 } | 367 } |
369 } else { | |
370 ASSERT(class_id == kFourByteStringCid); | |
371 const RawFourByteString* fourstr = | |
372 reinterpret_cast<const RawFourByteString*>(raw_string); | |
373 for (intptr_t i = 0; i < Smi::Value(fourstr->ptr()->length_); ++i) { | |
374 length += Utf8::Length(fourstr->ptr()->data_[i]); | |
375 } | |
376 characters = new char[length]; | |
377 for (intptr_t i = 0, j = 0; i < Smi::Value(fourstr->ptr()->length_); ++i) { | |
378 int32_t ch = fourstr->ptr()->data_[i]; | |
379 j += Utf8::Encode(ch, &characters[j]); | |
380 } | |
381 } | 368 } |
382 Record record(kStringInUtf8, this); | 369 Record record(kStringInUtf8, this); |
383 record.WritePointer(ObjectId(raw_string)); | 370 record.WritePointer(ObjectId(raw_string)); |
384 for (intptr_t i = 0; i < length; ++i) { | 371 for (intptr_t i = 0; i < length; ++i) { |
385 record.Write8(characters[i]); | 372 record.Write8(characters[i]); |
386 } | 373 } |
387 delete[] characters; | 374 delete[] characters; |
388 } | 375 } |
389 | 376 |
390 | 377 |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 RawObject* raw_obj = handle->raw(); | 702 RawObject* raw_obj = handle->raw(); |
716 visitor_->VisitPointer(&raw_obj); | 703 visitor_->VisitPointer(&raw_obj); |
717 } | 704 } |
718 | 705 |
719 | 706 |
720 void HeapProfilerObjectVisitor::VisitObject(RawObject* raw_obj) { | 707 void HeapProfilerObjectVisitor::VisitObject(RawObject* raw_obj) { |
721 profiler_->WriteObject(raw_obj); | 708 profiler_->WriteObject(raw_obj); |
722 } | 709 } |
723 | 710 |
724 } // namespace dart | 711 } // namespace dart |
OLD | NEW |