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 10966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10977 deopt_ids->Add(iter.DeoptId()); | 10977 deopt_ids->Add(iter.DeoptId()); |
10978 } else { | 10978 } else { |
10979 ASSERT(!iccall_ids->Contains(iter.DeoptId())); | 10979 ASSERT(!iccall_ids->Contains(iter.DeoptId())); |
10980 iccall_ids->Add(iter.DeoptId()); | 10980 iccall_ids->Add(iter.DeoptId()); |
10981 } | 10981 } |
10982 } | 10982 } |
10983 #endif // DEBUG | 10983 #endif // DEBUG |
10984 } | 10984 } |
10985 | 10985 |
10986 | 10986 |
| 10987 TokenPosition CodeSourceMap::TokenPositionForPCOffset( |
| 10988 uword pc_offset) const { |
| 10989 Iterator iterator(*this); |
| 10990 |
| 10991 TokenPosition result = TokenPosition::kNoSource; |
| 10992 |
| 10993 while (iterator.MoveNext()) { |
| 10994 if (iterator.PcOffset() > pc_offset) { |
| 10995 break; |
| 10996 } |
| 10997 result = iterator.TokenPos(); |
| 10998 } |
| 10999 |
| 11000 return result; |
| 11001 } |
| 11002 |
| 11003 |
| 11004 RawFunction* CodeSourceMap::FunctionForPCOffset(const Code& code, |
| 11005 const Function& function, |
| 11006 uword pc_offset) const { |
| 11007 GrowableArray<Function*> inlined_functions; |
| 11008 code.GetInlinedFunctionsAt(pc_offset, &inlined_functions); |
| 11009 if (inlined_functions.length() > 0) { |
| 11010 Function* inlined_function = inlined_functions[0]; |
| 11011 return inlined_function->raw(); |
| 11012 } else { |
| 11013 return function.raw(); |
| 11014 } |
| 11015 } |
| 11016 |
| 11017 |
| 11018 RawScript* CodeSourceMap::ScriptForPCOffset(const Code& code, |
| 11019 const Function& function, |
| 11020 uword pc_offset) const { |
| 11021 const Function& func = |
| 11022 Function::Handle(FunctionForPCOffset(code, function, pc_offset)); |
| 11023 return func.script(); |
| 11024 } |
| 11025 |
| 11026 |
| 11027 void CodeSourceMap::Dump(const CodeSourceMap& code_source_map, |
| 11028 const Code& code, |
| 11029 const Function& function) { |
| 11030 const String& code_name = String::Handle(code.QualifiedName()); |
| 11031 THR_Print("Dumping Code Source Map for %s\n", code_name.ToCString()); |
| 11032 if (code_source_map.Length() == 0) { |
| 11033 THR_Print("<empty>\n"); |
| 11034 return; |
| 11035 } |
| 11036 |
| 11037 const int addr_width = kBitsPerWord / 4; |
| 11038 |
| 11039 Iterator iterator(code_source_map); |
| 11040 Function& current_function = Function::Handle(); |
| 11041 Script& current_script = Script::Handle(); |
| 11042 TokenPosition tp; |
| 11043 while (iterator.MoveNext()) { |
| 11044 const uword pc_offset = iterator.PcOffset(); |
| 11045 tp = code_source_map.TokenPositionForPCOffset(pc_offset); |
| 11046 current_function ^= |
| 11047 code_source_map.FunctionForPCOffset(code, function, pc_offset); |
| 11048 current_script ^= |
| 11049 code_source_map.ScriptForPCOffset(code, function, pc_offset); |
| 11050 if (current_function.IsNull() || current_script.IsNull()) { |
| 11051 THR_Print("%#-*" Px "\t%s\t%s\n", addr_width, |
| 11052 pc_offset, |
| 11053 tp.ToCString(), |
| 11054 code_name.ToCString()); |
| 11055 continue; |
| 11056 } |
| 11057 const String& uri = String::Handle(current_script.url()); |
| 11058 ASSERT(!uri.IsNull()); |
| 11059 THR_Print("%#-*" Px "\t%s\t%s\t%s\n", addr_width, |
| 11060 pc_offset, |
| 11061 tp.ToCString(), |
| 11062 current_function.ToQualifiedCString(), |
| 11063 uri.ToCString()); |
| 11064 } |
| 11065 } |
| 11066 |
| 11067 |
10987 intptr_t CodeSourceMap::Length() const { | 11068 intptr_t CodeSourceMap::Length() const { |
10988 return raw_ptr()->length_; | 11069 return raw_ptr()->length_; |
10989 } | 11070 } |
10990 | 11071 |
10991 | 11072 |
10992 void CodeSourceMap::SetLength(intptr_t value) const { | 11073 void CodeSourceMap::SetLength(intptr_t value) const { |
10993 StoreNonPointer(&raw_ptr()->length_, value); | 11074 StoreNonPointer(&raw_ptr()->length_, value); |
10994 } | 11075 } |
10995 | 11076 |
10996 | 11077 |
(...skipping 10455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21452 return UserTag::null(); | 21533 return UserTag::null(); |
21453 } | 21534 } |
21454 | 21535 |
21455 | 21536 |
21456 const char* UserTag::ToCString() const { | 21537 const char* UserTag::ToCString() const { |
21457 const String& tag_label = String::Handle(label()); | 21538 const String& tag_label = String::Handle(label()); |
21458 return tag_label.ToCString(); | 21539 return tag_label.ToCString(); |
21459 } | 21540 } |
21460 | 21541 |
21461 } // namespace dart | 21542 } // namespace dart |
OLD | NEW |