| 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/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 11750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11761 const intptr_t len = NumberOfChecks(); | 11761 const intptr_t len = NumberOfChecks(); |
| 11762 for (intptr_t i = 1; i < len; i++) { | 11762 for (intptr_t i = 1; i < len; i++) { |
| 11763 if (GetTargetAt(i) != first_target.raw()) { | 11763 if (GetTargetAt(i) != first_target.raw()) { |
| 11764 return false; | 11764 return false; |
| 11765 } | 11765 } |
| 11766 } | 11766 } |
| 11767 return true; | 11767 return true; |
| 11768 } | 11768 } |
| 11769 | 11769 |
| 11770 | 11770 |
| 11771 RawICData* ICData::New(const Function& function, | 11771 RawICData* ICData::New(const Function& caller_function, |
| 11772 const String& target_name, | 11772 const String& target_name, |
| 11773 const Array& arguments_descriptor, | 11773 const Array& arguments_descriptor, |
| 11774 intptr_t deopt_id, | 11774 intptr_t deopt_id, |
| 11775 intptr_t num_args_tested) { | 11775 intptr_t num_args_tested) { |
| 11776 ASSERT(!function.IsNull()); | 11776 ASSERT(!caller_function.IsNull()); |
| 11777 ASSERT(!target_name.IsNull()); | 11777 ASSERT(!target_name.IsNull()); |
| 11778 ASSERT(!arguments_descriptor.IsNull()); | 11778 ASSERT(!arguments_descriptor.IsNull()); |
| 11779 ASSERT(Object::icdata_class() != Class::null()); | 11779 ASSERT(Object::icdata_class() != Class::null()); |
| 11780 ASSERT(num_args_tested >= 0); | 11780 ASSERT(num_args_tested >= 0); |
| 11781 ICData& result = ICData::Handle(); | 11781 ICData& result = ICData::Handle(); |
| 11782 { | 11782 { |
| 11783 // IC data objects are long living objects, allocate them in old generation. | 11783 // IC data objects are long living objects, allocate them in old generation. |
| 11784 RawObject* raw = Object::Allocate(ICData::kClassId, | 11784 RawObject* raw = Object::Allocate(ICData::kClassId, |
| 11785 ICData::InstanceSize(), | 11785 ICData::InstanceSize(), |
| 11786 Heap::kOld); | 11786 Heap::kOld); |
| 11787 NoGCScope no_gc; | 11787 NoGCScope no_gc; |
| 11788 result ^= raw; | 11788 result ^= raw; |
| 11789 } | 11789 } |
| 11790 result.set_function(function); | 11790 result.set_function(caller_function); |
| 11791 result.set_target_name(target_name); | 11791 result.set_target_name(target_name); |
| 11792 result.set_arguments_descriptor(arguments_descriptor); | 11792 result.set_arguments_descriptor(arguments_descriptor); |
| 11793 result.set_deopt_id(deopt_id); | 11793 result.set_deopt_id(deopt_id); |
| 11794 result.set_num_args_tested(num_args_tested); | 11794 result.set_num_args_tested(num_args_tested); |
| 11795 result.set_deopt_reason(kDeoptUnknown); | 11795 result.set_deopt_reason(kDeoptUnknown); |
| 11796 result.set_is_closure_call(false); | 11796 result.set_is_closure_call(false); |
| 11797 // Number of array elements in one test entry. | 11797 // Number of array elements in one test entry. |
| 11798 intptr_t len = result.TestEntryLength(); | 11798 intptr_t len = result.TestEntryLength(); |
| 11799 // IC data array must be null terminated (sentinel entry). | 11799 // IC data array must be null terminated (sentinel entry). |
| 11800 const Array& ic_data = Array::Handle(Array::New(len, Heap::kOld)); | 11800 const Array& ic_data = Array::Handle(Array::New(len, Heap::kOld)); |
| (...skipping 6250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18051 chars = isolate->current_zone()->Alloc<char>(len + 1); | 18051 chars = isolate->current_zone()->Alloc<char>(len + 1); |
| 18052 OS::SNPrint(chars, (len + 1), kFormatNoCol, | 18052 OS::SNPrint(chars, (len + 1), kFormatNoCol, |
| 18053 frame_index, function_name.ToCString(), | 18053 frame_index, function_name.ToCString(), |
| 18054 url.ToCString(), line); | 18054 url.ToCString(), line); |
| 18055 } | 18055 } |
| 18056 frame_strings->Add(chars); | 18056 frame_strings->Add(chars); |
| 18057 return len; | 18057 return len; |
| 18058 } | 18058 } |
| 18059 | 18059 |
| 18060 | 18060 |
| 18061 const char* Stacktrace::ToCStringInternal(intptr_t* frame_index) const { | 18061 const char* Stacktrace::ToCStringInternal(intptr_t* frame_index, |
| 18062 intptr_t max_frames) const { |
| 18062 Isolate* isolate = Isolate::Current(); | 18063 Isolate* isolate = Isolate::Current(); |
| 18063 Function& function = Function::Handle(); | 18064 Function& function = Function::Handle(); |
| 18064 Code& code = Code::Handle(); | 18065 Code& code = Code::Handle(); |
| 18065 // Iterate through the stack frames and create C string description | 18066 // Iterate through the stack frames and create C string description |
| 18066 // for each frame. | 18067 // for each frame. |
| 18067 intptr_t total_len = 0; | 18068 intptr_t total_len = 0; |
| 18068 GrowableArray<char*> frame_strings; | 18069 GrowableArray<char*> frame_strings; |
| 18069 for (intptr_t i = 0; i < Length(); i++) { | 18070 for (intptr_t i = 0; (i < Length()) && (*frame_index < max_frames); i++) { |
| 18070 function = FunctionAtFrame(i); | 18071 function = FunctionAtFrame(i); |
| 18071 if (function.IsNull()) { | 18072 if (function.IsNull()) { |
| 18072 // Check if null function object indicates a stack trace overflow. | 18073 // Check if null function object indicates a stack trace overflow. |
| 18073 if ((i < (Length() - 1)) && | 18074 if ((i < (Length() - 1)) && |
| 18074 (FunctionAtFrame(i + 1) != Function::null())) { | 18075 (FunctionAtFrame(i + 1) != Function::null())) { |
| 18075 const char* kTruncated = "...\n...\n"; | 18076 const char* kTruncated = "...\n...\n"; |
| 18076 intptr_t truncated_len = strlen(kTruncated) + 1; | 18077 intptr_t truncated_len = strlen(kTruncated) + 1; |
| 18077 char* chars = isolate->current_zone()->Alloc<char>(truncated_len); | 18078 char* chars = isolate->current_zone()->Alloc<char>(truncated_len); |
| 18078 OS::SNPrint(chars, truncated_len, "%s", kTruncated); | 18079 OS::SNPrint(chars, truncated_len, "%s", kTruncated); |
| 18079 frame_strings.Add(chars); | 18080 frame_strings.Add(chars); |
| 18080 } | 18081 } |
| 18081 } else if (function.is_visible() || FLAG_verbose_stacktrace) { | 18082 } else if (function.is_visible() || FLAG_verbose_stacktrace) { |
| 18082 code = CodeAtFrame(i); | 18083 code = CodeAtFrame(i); |
| 18083 ASSERT(function.raw() == code.function()); | 18084 ASSERT(function.raw() == code.function()); |
| 18084 uword pc = code.EntryPoint() + Smi::Value(PcOffsetAtFrame(i)); | 18085 uword pc = code.EntryPoint() + Smi::Value(PcOffsetAtFrame(i)); |
| 18085 if (code.is_optimized() && expand_inlined()) { | 18086 if (code.is_optimized() && expand_inlined()) { |
| 18086 // Traverse inlined frames. | 18087 // Traverse inlined frames. |
| 18087 for (InlinedFunctionsIterator it(code, pc); !it.Done(); it.Advance()) { | 18088 for (InlinedFunctionsIterator it(code, pc); |
| 18089 !it.Done() && (*frame_index < max_frames); it.Advance()) { |
| 18088 function = it.function(); | 18090 function = it.function(); |
| 18089 if (function.is_visible() || FLAG_verbose_stacktrace) { | 18091 if (function.is_visible() || FLAG_verbose_stacktrace) { |
| 18090 code = it.code(); | 18092 code = it.code(); |
| 18091 ASSERT(function.raw() == code.function()); | 18093 ASSERT(function.raw() == code.function()); |
| 18092 uword pc = it.pc(); | 18094 uword pc = it.pc(); |
| 18093 ASSERT(pc != 0); | 18095 ASSERT(pc != 0); |
| 18094 ASSERT(code.EntryPoint() <= pc); | 18096 ASSERT(code.EntryPoint() <= pc); |
| 18095 ASSERT(pc < (code.EntryPoint() + code.Size())); | 18097 ASSERT(pc < (code.EntryPoint() + code.Size())); |
| 18096 total_len += PrintOneStacktrace( | 18098 total_len += PrintOneStacktrace( |
| 18097 isolate, &frame_strings, pc, function, code, *frame_index); | 18099 isolate, &frame_strings, pc, function, code, *frame_index); |
| 18100 (*frame_index)++; // To account for inlined frames. |
| 18098 } | 18101 } |
| 18099 (*frame_index)++; // To account for inlined frames. | |
| 18100 } | 18102 } |
| 18101 } else { | 18103 } else { |
| 18102 total_len += PrintOneStacktrace( | 18104 total_len += PrintOneStacktrace( |
| 18103 isolate, &frame_strings, pc, function, code, *frame_index); | 18105 isolate, &frame_strings, pc, function, code, *frame_index); |
| 18104 (*frame_index)++; | 18106 (*frame_index)++; |
| 18105 } | 18107 } |
| 18106 } | 18108 } |
| 18107 } | 18109 } |
| 18108 | 18110 |
| 18109 // Now concatenate the frame descriptions into a single C string. | 18111 // Now concatenate the frame descriptions into a single C string. |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18424 return tag_label.ToCString(); | 18426 return tag_label.ToCString(); |
| 18425 } | 18427 } |
| 18426 | 18428 |
| 18427 | 18429 |
| 18428 void UserTag::PrintToJSONStream(JSONStream* stream, bool ref) const { | 18430 void UserTag::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 18429 Instance::PrintToJSONStream(stream, ref); | 18431 Instance::PrintToJSONStream(stream, ref); |
| 18430 } | 18432 } |
| 18431 | 18433 |
| 18432 | 18434 |
| 18433 } // namespace dart | 18435 } // namespace dart |
| OLD | NEW |