| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 11 matching lines...) Expand all Loading... |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #include "heap-snapshot-generator-inl.h" | 30 #include "heap-snapshot-generator-inl.h" |
| 31 | 31 |
| 32 #include "allocation-tracker.h" |
| 32 #include "code-stubs.h" | 33 #include "code-stubs.h" |
| 33 #include "heap-profiler.h" | 34 #include "heap-profiler.h" |
| 34 #include "debug.h" | 35 #include "debug.h" |
| 35 #include "types.h" | 36 #include "types.h" |
| 36 | 37 |
| 37 namespace v8 { | 38 namespace v8 { |
| 38 namespace internal { | 39 namespace internal { |
| 39 | 40 |
| 40 | 41 |
| 41 HeapGraphEdge::HeapGraphEdge(Type type, const char* name, int from, int to) | 42 HeapGraphEdge::HeapGraphEdge(Type type, const char* name, int from, int to) |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 sizeof(*this) + | 742 sizeof(*this) + |
| 742 sizeof(HashMap::Entry) * entries_map_.capacity() + | 743 sizeof(HashMap::Entry) * entries_map_.capacity() + |
| 743 GetMemoryUsedByList(entries_) + | 744 GetMemoryUsedByList(entries_) + |
| 744 GetMemoryUsedByList(time_intervals_); | 745 GetMemoryUsedByList(time_intervals_); |
| 745 } | 746 } |
| 746 | 747 |
| 747 | 748 |
| 748 HeapSnapshotsCollection::HeapSnapshotsCollection(Heap* heap) | 749 HeapSnapshotsCollection::HeapSnapshotsCollection(Heap* heap) |
| 749 : is_tracking_objects_(false), | 750 : is_tracking_objects_(false), |
| 750 names_(heap), | 751 names_(heap), |
| 751 ids_(heap) { | 752 ids_(heap), |
| 753 allocation_tracker_(NULL) { |
| 752 } | 754 } |
| 753 | 755 |
| 754 | 756 |
| 755 static void DeleteHeapSnapshot(HeapSnapshot** snapshot_ptr) { | 757 static void DeleteHeapSnapshot(HeapSnapshot** snapshot_ptr) { |
| 756 delete *snapshot_ptr; | 758 delete *snapshot_ptr; |
| 757 } | 759 } |
| 758 | 760 |
| 759 | 761 |
| 760 HeapSnapshotsCollection::~HeapSnapshotsCollection() { | 762 HeapSnapshotsCollection::~HeapSnapshotsCollection() { |
| 763 delete allocation_tracker_; |
| 761 snapshots_.Iterate(DeleteHeapSnapshot); | 764 snapshots_.Iterate(DeleteHeapSnapshot); |
| 762 } | 765 } |
| 763 | 766 |
| 764 | 767 |
| 768 void HeapSnapshotsCollection::StartHeapObjectsTracking() { |
| 769 ids_.UpdateHeapObjectsMap(); |
| 770 if (allocation_tracker_ == NULL) { |
| 771 allocation_tracker_ = new AllocationTracker(&ids_, names()); |
| 772 } |
| 773 is_tracking_objects_ = true; |
| 774 } |
| 775 |
| 776 |
| 777 void HeapSnapshotsCollection::StopHeapObjectsTracking() { |
| 778 ids_.StopHeapObjectsTracking(); |
| 779 if (allocation_tracker_ != NULL) { |
| 780 delete allocation_tracker_; |
| 781 allocation_tracker_ = NULL; |
| 782 } |
| 783 } |
| 784 |
| 785 |
| 765 HeapSnapshot* HeapSnapshotsCollection::NewSnapshot(const char* name, | 786 HeapSnapshot* HeapSnapshotsCollection::NewSnapshot(const char* name, |
| 766 unsigned uid) { | 787 unsigned uid) { |
| 767 is_tracking_objects_ = true; // Start watching for heap objects moves. | 788 is_tracking_objects_ = true; // Start watching for heap objects moves. |
| 768 return new HeapSnapshot(this, name, uid); | 789 return new HeapSnapshot(this, name, uid); |
| 769 } | 790 } |
| 770 | 791 |
| 771 | 792 |
| 772 void HeapSnapshotsCollection::SnapshotGenerationFinished( | 793 void HeapSnapshotsCollection::SnapshotGenerationFinished( |
| 773 HeapSnapshot* snapshot) { | 794 HeapSnapshot* snapshot) { |
| 774 ids_.SnapshotGenerationFinished(); | 795 ids_.SnapshotGenerationFinished(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 798 if (ids_.FindEntry(obj->address()) == id) { | 819 if (ids_.FindEntry(obj->address()) == id) { |
| 799 ASSERT(object == NULL); | 820 ASSERT(object == NULL); |
| 800 object = obj; | 821 object = obj; |
| 801 // Can't break -- kFilterUnreachable requires full heap traversal. | 822 // Can't break -- kFilterUnreachable requires full heap traversal. |
| 802 } | 823 } |
| 803 } | 824 } |
| 804 return object != NULL ? Handle<HeapObject>(object) : Handle<HeapObject>(); | 825 return object != NULL ? Handle<HeapObject>(object) : Handle<HeapObject>(); |
| 805 } | 826 } |
| 806 | 827 |
| 807 | 828 |
| 829 void HeapSnapshotsCollection::NewObjectEvent(Address addr, int size) { |
| 830 DisallowHeapAllocation no_allocation; |
| 831 ids_.NewObject(addr, size); |
| 832 if (allocation_tracker_ != NULL) { |
| 833 allocation_tracker_->NewObjectEvent(addr, size); |
| 834 } |
| 835 } |
| 836 |
| 837 |
| 808 size_t HeapSnapshotsCollection::GetUsedMemorySize() const { | 838 size_t HeapSnapshotsCollection::GetUsedMemorySize() const { |
| 809 size_t size = sizeof(*this); | 839 size_t size = sizeof(*this); |
| 810 size += names_.GetUsedMemorySize(); | 840 size += names_.GetUsedMemorySize(); |
| 811 size += ids_.GetUsedMemorySize(); | 841 size += ids_.GetUsedMemorySize(); |
| 812 size += GetMemoryUsedByList(snapshots_); | 842 size += GetMemoryUsedByList(snapshots_); |
| 813 for (int i = 0; i < snapshots_.length(); ++i) { | 843 for (int i = 0; i < snapshots_.length(); ++i) { |
| 814 size += snapshots_[i]->RawSnapshotSize(); | 844 size += snapshots_[i]->RawSnapshotSize(); |
| 815 } | 845 } |
| 816 return size; | 846 return size; |
| 817 } | 847 } |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1489 PropertyCell::kDependentCodeOffset); | 1519 PropertyCell::kDependentCodeOffset); |
| 1490 } | 1520 } |
| 1491 | 1521 |
| 1492 | 1522 |
| 1493 void V8HeapExplorer::ExtractAllocationSiteReferences(int entry, | 1523 void V8HeapExplorer::ExtractAllocationSiteReferences(int entry, |
| 1494 AllocationSite* site) { | 1524 AllocationSite* site) { |
| 1495 SetInternalReference(site, entry, "transition_info", site->transition_info(), | 1525 SetInternalReference(site, entry, "transition_info", site->transition_info(), |
| 1496 AllocationSite::kTransitionInfoOffset); | 1526 AllocationSite::kTransitionInfoOffset); |
| 1497 SetInternalReference(site, entry, "nested_site", site->nested_site(), | 1527 SetInternalReference(site, entry, "nested_site", site->nested_site(), |
| 1498 AllocationSite::kNestedSiteOffset); | 1528 AllocationSite::kNestedSiteOffset); |
| 1529 SetInternalReference(site, entry, "memento_found_count", |
| 1530 site->memento_found_count(), |
| 1531 AllocationSite::kMementoFoundCountOffset); |
| 1532 SetInternalReference(site, entry, "memento_create_count", |
| 1533 site->memento_create_count(), |
| 1534 AllocationSite::kMementoCreateCountOffset); |
| 1535 SetInternalReference(site, entry, "pretenure_decision", |
| 1536 site->pretenure_decision(), |
| 1537 AllocationSite::kPretenureDecisionOffset); |
| 1499 SetInternalReference(site, entry, "dependent_code", site->dependent_code(), | 1538 SetInternalReference(site, entry, "dependent_code", site->dependent_code(), |
| 1500 AllocationSite::kDependentCodeOffset); | 1539 AllocationSite::kDependentCodeOffset); |
| 1501 } | 1540 } |
| 1502 | 1541 |
| 1503 | 1542 |
| 1504 void V8HeapExplorer::ExtractClosureReferences(JSObject* js_obj, int entry) { | 1543 void V8HeapExplorer::ExtractClosureReferences(JSObject* js_obj, int entry) { |
| 1505 if (!js_obj->IsJSFunction()) return; | 1544 if (!js_obj->IsJSFunction()) return; |
| 1506 | 1545 |
| 1507 JSFunction* func = JSFunction::cast(js_obj); | 1546 JSFunction* func = JSFunction::cast(js_obj); |
| 1508 if (func->shared()->bound()) { | 1547 if (func->shared()->bound()) { |
| (...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2638 bool aborted_; | 2677 bool aborted_; |
| 2639 }; | 2678 }; |
| 2640 | 2679 |
| 2641 | 2680 |
| 2642 // type, name|index, to_node. | 2681 // type, name|index, to_node. |
| 2643 const int HeapSnapshotJSONSerializer::kEdgeFieldsCount = 3; | 2682 const int HeapSnapshotJSONSerializer::kEdgeFieldsCount = 3; |
| 2644 // type, name, id, self_size, children_index. | 2683 // type, name, id, self_size, children_index. |
| 2645 const int HeapSnapshotJSONSerializer::kNodeFieldsCount = 5; | 2684 const int HeapSnapshotJSONSerializer::kNodeFieldsCount = 5; |
| 2646 | 2685 |
| 2647 void HeapSnapshotJSONSerializer::Serialize(v8::OutputStream* stream) { | 2686 void HeapSnapshotJSONSerializer::Serialize(v8::OutputStream* stream) { |
| 2687 if (AllocationTracker* allocation_tracker = |
| 2688 snapshot_->collection()->allocation_tracker()) { |
| 2689 allocation_tracker->PrepareForSerialization(); |
| 2690 } |
| 2648 ASSERT(writer_ == NULL); | 2691 ASSERT(writer_ == NULL); |
| 2649 writer_ = new OutputStreamWriter(stream); | 2692 writer_ = new OutputStreamWriter(stream); |
| 2650 SerializeImpl(); | 2693 SerializeImpl(); |
| 2651 delete writer_; | 2694 delete writer_; |
| 2652 writer_ = NULL; | 2695 writer_ = NULL; |
| 2653 } | 2696 } |
| 2654 | 2697 |
| 2655 | 2698 |
| 2656 void HeapSnapshotJSONSerializer::SerializeImpl() { | 2699 void HeapSnapshotJSONSerializer::SerializeImpl() { |
| 2657 ASSERT(0 == snapshot_->root()->index()); | 2700 ASSERT(0 == snapshot_->root()->index()); |
| 2658 writer_->AddCharacter('{'); | 2701 writer_->AddCharacter('{'); |
| 2659 writer_->AddString("\"snapshot\":{"); | 2702 writer_->AddString("\"snapshot\":{"); |
| 2660 SerializeSnapshot(); | 2703 SerializeSnapshot(); |
| 2661 if (writer_->aborted()) return; | 2704 if (writer_->aborted()) return; |
| 2662 writer_->AddString("},\n"); | 2705 writer_->AddString("},\n"); |
| 2663 writer_->AddString("\"nodes\":["); | 2706 writer_->AddString("\"nodes\":["); |
| 2664 SerializeNodes(); | 2707 SerializeNodes(); |
| 2665 if (writer_->aborted()) return; | 2708 if (writer_->aborted()) return; |
| 2666 writer_->AddString("],\n"); | 2709 writer_->AddString("],\n"); |
| 2667 writer_->AddString("\"edges\":["); | 2710 writer_->AddString("\"edges\":["); |
| 2668 SerializeEdges(); | 2711 SerializeEdges(); |
| 2669 if (writer_->aborted()) return; | 2712 if (writer_->aborted()) return; |
| 2670 writer_->AddString("],\n"); | 2713 writer_->AddString("],\n"); |
| 2714 |
| 2715 writer_->AddString("\"trace_function_infos\":["); |
| 2716 SerializeTraceNodeInfos(); |
| 2717 if (writer_->aborted()) return; |
| 2718 writer_->AddString("],\n"); |
| 2719 writer_->AddString("\"trace_tree\":["); |
| 2720 SerializeTraceTree(); |
| 2721 if (writer_->aborted()) return; |
| 2722 writer_->AddString("],\n"); |
| 2723 |
| 2671 writer_->AddString("\"strings\":["); | 2724 writer_->AddString("\"strings\":["); |
| 2672 SerializeStrings(); | 2725 SerializeStrings(); |
| 2673 if (writer_->aborted()) return; | 2726 if (writer_->aborted()) return; |
| 2674 writer_->AddCharacter(']'); | 2727 writer_->AddCharacter(']'); |
| 2675 writer_->AddCharacter('}'); | 2728 writer_->AddCharacter('}'); |
| 2676 writer_->Finalize(); | 2729 writer_->Finalize(); |
| 2677 } | 2730 } |
| 2678 | 2731 |
| 2679 | 2732 |
| 2680 int HeapSnapshotJSONSerializer::GetStringId(const char* s) { | 2733 int HeapSnapshotJSONSerializer::GetStringId(const char* s) { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2821 JSON_S("edge_types") ":" JSON_A( | 2874 JSON_S("edge_types") ":" JSON_A( |
| 2822 JSON_A( | 2875 JSON_A( |
| 2823 JSON_S("context") "," | 2876 JSON_S("context") "," |
| 2824 JSON_S("element") "," | 2877 JSON_S("element") "," |
| 2825 JSON_S("property") "," | 2878 JSON_S("property") "," |
| 2826 JSON_S("internal") "," | 2879 JSON_S("internal") "," |
| 2827 JSON_S("hidden") "," | 2880 JSON_S("hidden") "," |
| 2828 JSON_S("shortcut") "," | 2881 JSON_S("shortcut") "," |
| 2829 JSON_S("weak")) "," | 2882 JSON_S("weak")) "," |
| 2830 JSON_S("string_or_number") "," | 2883 JSON_S("string_or_number") "," |
| 2831 JSON_S("node")))); | 2884 JSON_S("node")) "," |
| 2885 JSON_S("trace_function_info_fields") ":" JSON_A( |
| 2886 JSON_S("function_id") "," |
| 2887 JSON_S("name") "," |
| 2888 JSON_S("script_name") "," |
| 2889 JSON_S("script_id") "," |
| 2890 JSON_S("line") "," |
| 2891 JSON_S("column")) "," |
| 2892 JSON_S("trace_node_fields") ":" JSON_A( |
| 2893 JSON_S("id") "," |
| 2894 JSON_S("function_id") "," |
| 2895 JSON_S("count") "," |
| 2896 JSON_S("size") "," |
| 2897 JSON_S("children")))); |
| 2832 #undef JSON_S | 2898 #undef JSON_S |
| 2833 #undef JSON_O | 2899 #undef JSON_O |
| 2834 #undef JSON_A | 2900 #undef JSON_A |
| 2835 writer_->AddString(",\"node_count\":"); | 2901 writer_->AddString(",\"node_count\":"); |
| 2836 writer_->AddNumber(snapshot_->entries().length()); | 2902 writer_->AddNumber(snapshot_->entries().length()); |
| 2837 writer_->AddString(",\"edge_count\":"); | 2903 writer_->AddString(",\"edge_count\":"); |
| 2838 writer_->AddNumber(snapshot_->edges().length()); | 2904 writer_->AddNumber(snapshot_->edges().length()); |
| 2905 writer_->AddString(",\"trace_function_count\":"); |
| 2906 uint32_t count = 0; |
| 2907 AllocationTracker* tracker = snapshot_->collection()->allocation_tracker(); |
| 2908 if (tracker) { |
| 2909 count = tracker->id_to_function_info()->occupancy(); |
| 2910 } |
| 2911 writer_->AddNumber(count); |
| 2839 } | 2912 } |
| 2840 | 2913 |
| 2841 | 2914 |
| 2842 static void WriteUChar(OutputStreamWriter* w, unibrow::uchar u) { | 2915 static void WriteUChar(OutputStreamWriter* w, unibrow::uchar u) { |
| 2843 static const char hex_chars[] = "0123456789ABCDEF"; | 2916 static const char hex_chars[] = "0123456789ABCDEF"; |
| 2844 w->AddString("\\u"); | 2917 w->AddString("\\u"); |
| 2845 w->AddCharacter(hex_chars[(u >> 12) & 0xf]); | 2918 w->AddCharacter(hex_chars[(u >> 12) & 0xf]); |
| 2846 w->AddCharacter(hex_chars[(u >> 8) & 0xf]); | 2919 w->AddCharacter(hex_chars[(u >> 8) & 0xf]); |
| 2847 w->AddCharacter(hex_chars[(u >> 4) & 0xf]); | 2920 w->AddCharacter(hex_chars[(u >> 4) & 0xf]); |
| 2848 w->AddCharacter(hex_chars[u & 0xf]); | 2921 w->AddCharacter(hex_chars[u & 0xf]); |
| 2849 } | 2922 } |
| 2850 | 2923 |
| 2851 | 2924 |
| 2925 void HeapSnapshotJSONSerializer::SerializeTraceTree() { |
| 2926 AllocationTracker* tracker = snapshot_->collection()->allocation_tracker(); |
| 2927 if (!tracker) return; |
| 2928 AllocationTraceTree* traces = tracker->trace_tree(); |
| 2929 SerializeTraceNode(traces->root()); |
| 2930 } |
| 2931 |
| 2932 |
| 2933 void HeapSnapshotJSONSerializer::SerializeTraceNode(AllocationTraceNode* node) { |
| 2934 // The buffer needs space for 4 unsigned ints, 4 commas, [ and \0 |
| 2935 const int kBufferSize = |
| 2936 4 * MaxDecimalDigitsIn<sizeof(unsigned)>::kUnsigned // NOLINT |
| 2937 + 4 + 1 + 1; |
| 2938 EmbeddedVector<char, kBufferSize> buffer; |
| 2939 int buffer_pos = 0; |
| 2940 buffer_pos = utoa(node->id(), buffer, buffer_pos); |
| 2941 buffer[buffer_pos++] = ','; |
| 2942 buffer_pos = utoa(node->function_id(), buffer, buffer_pos); |
| 2943 buffer[buffer_pos++] = ','; |
| 2944 buffer_pos = utoa(node->allocation_count(), buffer, buffer_pos); |
| 2945 buffer[buffer_pos++] = ','; |
| 2946 buffer_pos = utoa(node->allocation_size(), buffer, buffer_pos); |
| 2947 buffer[buffer_pos++] = ','; |
| 2948 buffer[buffer_pos++] = '['; |
| 2949 buffer[buffer_pos++] = '\0'; |
| 2950 writer_->AddString(buffer.start()); |
| 2951 |
| 2952 Vector<AllocationTraceNode*> children = node->children(); |
| 2953 for (int i = 0; i < children.length(); i++) { |
| 2954 if (i > 0) { |
| 2955 writer_->AddCharacter(','); |
| 2956 } |
| 2957 SerializeTraceNode(children[i]); |
| 2958 } |
| 2959 writer_->AddCharacter(']'); |
| 2960 } |
| 2961 |
| 2962 |
| 2963 // 0-based position is converted to 1-based during the serialization. |
| 2964 static int SerializePosition(int position, const Vector<char>& buffer, |
| 2965 int buffer_pos) { |
| 2966 if (position == -1) { |
| 2967 buffer[buffer_pos++] = '0'; |
| 2968 } else { |
| 2969 ASSERT(position >= 0); |
| 2970 buffer_pos = utoa(static_cast<unsigned>(position + 1), buffer, buffer_pos); |
| 2971 } |
| 2972 return buffer_pos; |
| 2973 } |
| 2974 |
| 2975 |
| 2976 void HeapSnapshotJSONSerializer::SerializeTraceNodeInfos() { |
| 2977 AllocationTracker* tracker = snapshot_->collection()->allocation_tracker(); |
| 2978 if (!tracker) return; |
| 2979 // The buffer needs space for 6 unsigned ints, 6 commas, \n and \0 |
| 2980 const int kBufferSize = |
| 2981 6 * MaxDecimalDigitsIn<sizeof(unsigned)>::kUnsigned // NOLINT |
| 2982 + 6 + 1 + 1; |
| 2983 EmbeddedVector<char, kBufferSize> buffer; |
| 2984 HashMap* id_to_function_info = tracker->id_to_function_info(); |
| 2985 bool first_entry = true; |
| 2986 for (HashMap::Entry* p = id_to_function_info->Start(); |
| 2987 p != NULL; |
| 2988 p = id_to_function_info->Next(p)) { |
| 2989 SnapshotObjectId id = |
| 2990 static_cast<SnapshotObjectId>(reinterpret_cast<intptr_t>(p->key)); |
| 2991 AllocationTracker::FunctionInfo* info = |
| 2992 reinterpret_cast<AllocationTracker::FunctionInfo* >(p->value); |
| 2993 int buffer_pos = 0; |
| 2994 if (first_entry) { |
| 2995 first_entry = false; |
| 2996 } else { |
| 2997 buffer[buffer_pos++] = ','; |
| 2998 } |
| 2999 buffer_pos = utoa(id, buffer, buffer_pos); |
| 3000 buffer[buffer_pos++] = ','; |
| 3001 buffer_pos = utoa(GetStringId(info->name), buffer, buffer_pos); |
| 3002 buffer[buffer_pos++] = ','; |
| 3003 buffer_pos = utoa(GetStringId(info->script_name), buffer, buffer_pos); |
| 3004 buffer[buffer_pos++] = ','; |
| 3005 // The cast is safe because script id is a non-negative Smi. |
| 3006 buffer_pos = utoa(static_cast<unsigned>(info->script_id), buffer, |
| 3007 buffer_pos); |
| 3008 buffer[buffer_pos++] = ','; |
| 3009 buffer_pos = SerializePosition(info->line, buffer, buffer_pos); |
| 3010 buffer[buffer_pos++] = ','; |
| 3011 buffer_pos = SerializePosition(info->column, buffer, buffer_pos); |
| 3012 buffer[buffer_pos++] = '\n'; |
| 3013 buffer[buffer_pos++] = '\0'; |
| 3014 writer_->AddString(buffer.start()); |
| 3015 } |
| 3016 } |
| 3017 |
| 3018 |
| 2852 void HeapSnapshotJSONSerializer::SerializeString(const unsigned char* s) { | 3019 void HeapSnapshotJSONSerializer::SerializeString(const unsigned char* s) { |
| 2853 writer_->AddCharacter('\n'); | 3020 writer_->AddCharacter('\n'); |
| 2854 writer_->AddCharacter('\"'); | 3021 writer_->AddCharacter('\"'); |
| 2855 for ( ; *s != '\0'; ++s) { | 3022 for ( ; *s != '\0'; ++s) { |
| 2856 switch (*s) { | 3023 switch (*s) { |
| 2857 case '\b': | 3024 case '\b': |
| 2858 writer_->AddString("\\b"); | 3025 writer_->AddString("\\b"); |
| 2859 continue; | 3026 continue; |
| 2860 case '\f': | 3027 case '\f': |
| 2861 writer_->AddString("\\f"); | 3028 writer_->AddString("\\f"); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2911 writer_->AddString("\"<dummy>\""); | 3078 writer_->AddString("\"<dummy>\""); |
| 2912 for (int i = 1; i < sorted_strings.length(); ++i) { | 3079 for (int i = 1; i < sorted_strings.length(); ++i) { |
| 2913 writer_->AddCharacter(','); | 3080 writer_->AddCharacter(','); |
| 2914 SerializeString(sorted_strings[i]); | 3081 SerializeString(sorted_strings[i]); |
| 2915 if (writer_->aborted()) return; | 3082 if (writer_->aborted()) return; |
| 2916 } | 3083 } |
| 2917 } | 3084 } |
| 2918 | 3085 |
| 2919 | 3086 |
| 2920 } } // namespace v8::internal | 3087 } } // namespace v8::internal |
| OLD | NEW |