| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/exceptions.h" | 5 #include "vm/exceptions.h" |
| 6 | 6 |
| 7 #include "platform/address_sanitizer.h" | 7 #include "platform/address_sanitizer.h" |
| 8 | 8 |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 const GrowableObjectArray& pc_offset_list_; | 57 const GrowableObjectArray& pc_offset_list_; |
| 58 | 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(RegularStacktraceBuilder); | 59 DISALLOW_COPY_AND_ASSIGN(RegularStacktraceBuilder); |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 | 62 |
| 63 class PreallocatedStacktraceBuilder : public StacktraceBuilder { | 63 class PreallocatedStacktraceBuilder : public StacktraceBuilder { |
| 64 public: | 64 public: |
| 65 explicit PreallocatedStacktraceBuilder(const Instance& stacktrace) | 65 explicit PreallocatedStacktraceBuilder(const Instance& stacktrace) |
| 66 : stacktrace_(Stacktrace::Cast(stacktrace)), | 66 : stacktrace_(Stacktrace::Cast(stacktrace)), |
| 67 cur_index_(0) { | 67 cur_index_(0), |
| 68 dropped_frames_(0) { |
| 68 ASSERT(stacktrace_.raw() == | 69 ASSERT(stacktrace_.raw() == |
| 69 Isolate::Current()->object_store()->preallocated_stack_trace()); | 70 Isolate::Current()->object_store()->preallocated_stack_trace()); |
| 70 } | 71 } |
| 71 ~PreallocatedStacktraceBuilder() { } | 72 ~PreallocatedStacktraceBuilder() { } |
| 72 | 73 |
| 73 virtual void AddFrame(const Code& code, const Smi& offset); | 74 virtual void AddFrame(const Code& code, const Smi& offset); |
| 74 | 75 |
| 75 private: | 76 private: |
| 76 static const int kNumTopframes = Stacktrace::kPreallocatedStackdepth / 2; | 77 static const int kNumTopframes = Stacktrace::kPreallocatedStackdepth / 2; |
| 77 | 78 |
| 78 const Stacktrace& stacktrace_; | 79 const Stacktrace& stacktrace_; |
| 79 intptr_t cur_index_; | 80 intptr_t cur_index_; |
| 81 intptr_t dropped_frames_; |
| 80 | 82 |
| 81 DISALLOW_COPY_AND_ASSIGN(PreallocatedStacktraceBuilder); | 83 DISALLOW_COPY_AND_ASSIGN(PreallocatedStacktraceBuilder); |
| 82 }; | 84 }; |
| 83 | 85 |
| 84 | 86 |
| 85 void PreallocatedStacktraceBuilder::AddFrame(const Code& code, | 87 void PreallocatedStacktraceBuilder::AddFrame(const Code& code, |
| 86 const Smi& offset) { | 88 const Smi& offset) { |
| 87 if (cur_index_ >= Stacktrace::kPreallocatedStackdepth) { | 89 if (cur_index_ >= Stacktrace::kPreallocatedStackdepth) { |
| 88 // The number of frames is overflowing the preallocated stack trace object. | 90 // The number of frames is overflowing the preallocated stack trace object. |
| 89 Code& frame_code = Code::Handle(); | 91 Code& frame_code = Code::Handle(); |
| 90 Smi& frame_offset = Smi::Handle(); | 92 Smi& frame_offset = Smi::Handle(); |
| 91 intptr_t start = Stacktrace::kPreallocatedStackdepth - (kNumTopframes - 1); | 93 intptr_t start = Stacktrace::kPreallocatedStackdepth - (kNumTopframes - 1); |
| 92 intptr_t null_slot = start - 2; | 94 intptr_t null_slot = start - 2; |
| 95 // We are going to drop one frame. |
| 96 dropped_frames_++; |
| 93 // Add an empty slot to indicate the overflow so that the toString | 97 // Add an empty slot to indicate the overflow so that the toString |
| 94 // method can account for the overflow. | 98 // method can account for the overflow. |
| 95 if (stacktrace_.FunctionAtFrame(null_slot) != Function::null()) { | 99 if (stacktrace_.FunctionAtFrame(null_slot) != Function::null()) { |
| 96 stacktrace_.SetCodeAtFrame(null_slot, frame_code); | 100 stacktrace_.SetCodeAtFrame(null_slot, frame_code); |
| 101 // We drop an extra frame here too. |
| 102 dropped_frames_++; |
| 97 } | 103 } |
| 104 // Encode the number of dropped frames into the pc offset. |
| 105 frame_offset ^= Smi::New(dropped_frames_); |
| 106 stacktrace_.SetPcOffsetAtFrame(null_slot, frame_offset); |
| 98 // Move frames one slot down so that we can accomodate the new frame. | 107 // Move frames one slot down so that we can accomodate the new frame. |
| 99 for (intptr_t i = start; i < Stacktrace::kPreallocatedStackdepth; i++) { | 108 for (intptr_t i = start; i < Stacktrace::kPreallocatedStackdepth; i++) { |
| 100 intptr_t prev = (i - 1); | 109 intptr_t prev = (i - 1); |
| 101 frame_code = stacktrace_.CodeAtFrame(i); | 110 frame_code = stacktrace_.CodeAtFrame(i); |
| 102 frame_offset = stacktrace_.PcOffsetAtFrame(i); | 111 frame_offset = stacktrace_.PcOffsetAtFrame(i); |
| 103 stacktrace_.SetCodeAtFrame(prev, frame_code); | 112 stacktrace_.SetCodeAtFrame(prev, frame_code); |
| 104 stacktrace_.SetPcOffsetAtFrame(prev, frame_offset); | 113 stacktrace_.SetPcOffsetAtFrame(prev, frame_offset); |
| 105 } | 114 } |
| 106 cur_index_ = (Stacktrace::kPreallocatedStackdepth - 1); | 115 cur_index_ = (Stacktrace::kPreallocatedStackdepth - 1); |
| 107 } | 116 } |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 } | 667 } |
| 659 | 668 |
| 660 return DartLibraryCalls::InstanceCreate(library, | 669 return DartLibraryCalls::InstanceCreate(library, |
| 661 *class_name, | 670 *class_name, |
| 662 *constructor_name, | 671 *constructor_name, |
| 663 arguments); | 672 arguments); |
| 664 } | 673 } |
| 665 | 674 |
| 666 | 675 |
| 667 } // namespace dart | 676 } // namespace dart |
| OLD | NEW |