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/snapshot.h" | 5 #include "vm/snapshot.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/bootstrap.h" | 8 #include "vm/bootstrap.h" |
9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
11 #include "vm/dart_entry.h" | 11 #include "vm/dart_entry.h" |
12 #include "vm/exceptions.h" | 12 #include "vm/exceptions.h" |
13 #include "vm/heap.h" | 13 #include "vm/heap.h" |
14 #include "vm/lockers.h" | 14 #include "vm/lockers.h" |
15 #include "vm/longjump.h" | 15 #include "vm/longjump.h" |
16 #include "vm/object.h" | 16 #include "vm/object.h" |
17 #include "vm/object_store.h" | 17 #include "vm/object_store.h" |
18 #include "vm/snapshot_ids.h" | 18 #include "vm/snapshot_ids.h" |
19 #include "vm/stub_code.h" | 19 #include "vm/stub_code.h" |
20 #include "vm/symbols.h" | 20 #include "vm/symbols.h" |
21 #include "vm/timeline.h" | 21 #include "vm/timeline.h" |
22 #include "vm/version.h" | 22 #include "vm/version.h" |
| 23 #include "vm/code_statistics.h" |
23 | 24 |
24 // We currently only expect the Dart mutator to read snapshots. | 25 // We currently only expect the Dart mutator to read snapshots. |
25 #define ASSERT_NO_SAFEPOINT_SCOPE() \ | 26 #define ASSERT_NO_SAFEPOINT_SCOPE() \ |
26 isolate()->AssertCurrentThreadIsMutator(); \ | 27 isolate()->AssertCurrentThreadIsMutator(); \ |
27 ASSERT(thread()->no_safepoint_scope_depth() != 0) | 28 ASSERT(thread()->no_safepoint_scope_depth() != 0) |
28 | 29 |
29 namespace dart { | 30 namespace dart { |
30 | 31 |
31 static const int kNumInitialReferences = 64; | 32 static const int kNumInitialReferences = 64; |
32 | 33 |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 | 702 |
702 int32_t InstructionsWriter::GetObjectOffsetFor(RawObject* raw_object) { | 703 int32_t InstructionsWriter::GetObjectOffsetFor(RawObject* raw_object) { |
703 intptr_t heap_size = raw_object->Size(); | 704 intptr_t heap_size = raw_object->Size(); |
704 intptr_t offset = next_object_offset_; | 705 intptr_t offset = next_object_offset_; |
705 next_object_offset_ += heap_size; | 706 next_object_offset_ += heap_size; |
706 objects_.Add(ObjectData(raw_object)); | 707 objects_.Add(ObjectData(raw_object)); |
707 return offset; | 708 return offset; |
708 } | 709 } |
709 | 710 |
710 | 711 |
| 712 void InstructionsWriter::DumpCombinedCodeStatistics() const { |
| 713 CombinedCodeStatistics instruction_stats; |
| 714 intptr_t count = instructions_.length(); |
| 715 intptr_t missing_count = 0; |
| 716 for (intptr_t i = 0; i < count; i++) { |
| 717 const Code &code = *instructions_[i].code_; |
| 718 CodeStatistics* stats = code.stats(); |
| 719 if (stats != NULL) { |
| 720 stats->AppendTo(&instruction_stats); |
| 721 } else { |
| 722 missing_count++; |
| 723 } |
| 724 } |
| 725 instruction_stats.DumpStatistics(); |
| 726 if (missing_count > 0) { |
| 727 fprintf(stderr, "--------------------\n"); |
| 728 fprintf( |
| 729 stderr, |
| 730 "Missed statistics for %" Pd " out of %" Pd " functions\n", |
| 731 missing_count, count); |
| 732 fprintf(stderr, "--------------------\n"); |
| 733 } |
| 734 |
| 735 fprintf(stderr, "--------------------\n"); |
| 736 fprintf(stderr, "Emitted %" Pd " functions\n", count); |
| 737 fprintf(stderr, "--------------------\n"); |
| 738 } |
| 739 |
| 740 |
711 static void EnsureIdentifier(char* label) { | 741 static void EnsureIdentifier(char* label) { |
712 for (char c = *label; c != '\0'; c = *++label) { | 742 for (char c = *label; c != '\0'; c = *++label) { |
713 if (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) || | 743 if (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) || |
714 ((c >= '0') && (c <= '9'))) { | 744 ((c >= '0') && (c <= '9'))) { |
715 continue; | 745 continue; |
716 } | 746 } |
717 *label = '_'; | 747 *label = '_'; |
718 } | 748 } |
719 } | 749 } |
720 | 750 |
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1956 if (setjmp(*jump.Set()) == 0) { | 1986 if (setjmp(*jump.Set()) == 0) { |
1957 NoSafepointScope no_safepoint; | 1987 NoSafepointScope no_safepoint; |
1958 WriteObject(obj.raw()); | 1988 WriteObject(obj.raw()); |
1959 } else { | 1989 } else { |
1960 ThrowException(exception_type(), exception_msg()); | 1990 ThrowException(exception_type(), exception_msg()); |
1961 } | 1991 } |
1962 } | 1992 } |
1963 | 1993 |
1964 | 1994 |
1965 } // namespace dart | 1995 } // namespace dart |
OLD | NEW |