Chromium Code Reviews| 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/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| 11 #include "vm/bootstrap.h" | 11 #include "vm/bootstrap.h" |
| 12 #include "vm/datastream.h" | 12 #include "vm/class_finalizer.h" |
| 13 #include "vm/deopt_instructions.h" | |
| 14 #include "vm/code_generator.h" | 13 #include "vm/code_generator.h" |
| 15 #include "vm/code_patcher.h" | 14 #include "vm/code_patcher.h" |
| 16 #include "vm/compiler.h" | 15 #include "vm/compiler.h" |
| 17 #include "vm/compiler_stats.h" | 16 #include "vm/compiler_stats.h" |
| 18 #include "vm/class_finalizer.h" | |
| 19 #include "vm/dart.h" | 17 #include "vm/dart.h" |
| 20 #include "vm/dart_api_state.h" | 18 #include "vm/dart_api_state.h" |
| 21 #include "vm/dart_entry.h" | 19 #include "vm/dart_entry.h" |
| 20 #include "vm/datastream.h" | |
| 22 #include "vm/debuginfo.h" | 21 #include "vm/debuginfo.h" |
| 22 #include "vm/deopt_instructions.h" | |
| 23 #include "vm/double_conversion.h" | 23 #include "vm/double_conversion.h" |
| 24 #include "vm/exceptions.h" | 24 #include "vm/exceptions.h" |
| 25 #include "vm/growable_array.h" | 25 #include "vm/growable_array.h" |
| 26 #include "vm/heap.h" | 26 #include "vm/heap.h" |
| 27 #include "vm/object_store.h" | 27 #include "vm/object_store.h" |
| 28 #include "vm/parser.h" | 28 #include "vm/parser.h" |
| 29 #include "vm/runtime_entry.h" | 29 #include "vm/runtime_entry.h" |
| 30 #include "vm/scopes.h" | 30 #include "vm/scopes.h" |
| 31 #include "vm/stack_frame.h" | 31 #include "vm/stack_frame.h" |
| 32 #include "vm/symbols.h" | 32 #include "vm/symbols.h" |
| (...skipping 6518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6551 case PcDescriptors::kIcCall: return "ic-call "; | 6551 case PcDescriptors::kIcCall: return "ic-call "; |
| 6552 case PcDescriptors::kFuncCall: return "fn-call "; | 6552 case PcDescriptors::kFuncCall: return "fn-call "; |
| 6553 case PcDescriptors::kReturn: return "return "; | 6553 case PcDescriptors::kReturn: return "return "; |
| 6554 case PcDescriptors::kOther: return "other "; | 6554 case PcDescriptors::kOther: return "other "; |
| 6555 } | 6555 } |
| 6556 UNREACHABLE(); | 6556 UNREACHABLE(); |
| 6557 return ""; | 6557 return ""; |
| 6558 } | 6558 } |
| 6559 | 6559 |
| 6560 | 6560 |
| 6561 void PcDescriptors::PrintHeaderString() { | |
| 6562 // 4 bits per hex digit + 2 for "0x". | |
| 6563 const int addr_width = (kBitsPerWord / 4) + 2; | |
| 6564 OS::Print("%-*s\tkind \ttid\ttok-ix\ttry/deopt-ix\n", addr_width, "pc"); | |
| 6565 } | |
| 6566 | |
| 6567 | |
| 6561 const char* PcDescriptors::ToCString() const { | 6568 const char* PcDescriptors::ToCString() const { |
| 6562 if (Length() == 0) { | 6569 if (Length() == 0) { |
| 6563 return "No pc descriptors\n"; | 6570 return "No pc descriptors\n"; |
| 6564 } | 6571 } |
| 6572 // 4 bits per hex digit. | |
| 6573 const int addr_width = kBitsPerWord / 4; | |
| 6565 const char* kFormat = | 6574 const char* kFormat = |
| 6566 "0x%" PRIxPTR "\t%s\t%" PRIdPTR "\t%" PRIdPTR "\t%" PRIdPTR "\n"; | 6575 "0x%-*" PRIxPTR "\t%s\t%" PRIdPTR "\t%" PRIdPTR "\t%" PRIdPTR "\n"; |
|
Vyacheslav Egorov (Google)
2012/08/13 12:54:46
please add a comment about *
consider making a de
Kevin Millikin (Google)
2012/08/13 15:10:37
Blah. I'd rather use vanilla printf specifiers th
| |
| 6567 // First compute the buffer size required. | 6576 // First compute the buffer size required. |
| 6568 intptr_t len = 1; // Trailing '\0'. | 6577 intptr_t len = 1; // Trailing '\0'. |
| 6569 for (intptr_t i = 0; i < Length(); i++) { | 6578 for (intptr_t i = 0; i < Length(); i++) { |
| 6570 intptr_t token_pos_or_deopt_reason = DescriptorKind(i) == kDeoptIndex ? | 6579 intptr_t token_pos_or_deopt_reason = DescriptorKind(i) == kDeoptIndex ? |
| 6571 DeoptReason(i) : TokenPos(i); | 6580 DeoptReason(i) : TokenPos(i); |
| 6572 intptr_t multi_purpose_index = DescriptorKind(i) == kDeoptIndex ? | 6581 intptr_t multi_purpose_index = DescriptorKind(i) == kDeoptIndex ? |
| 6573 DeoptIndex(i) : TryIndex(i); | 6582 DeoptIndex(i) : TryIndex(i); |
| 6574 len += OS::SNPrint(NULL, 0, kFormat, | 6583 len += OS::SNPrint(NULL, 0, kFormat, addr_width, |
| 6575 PC(i), | 6584 PC(i), |
| 6576 KindAsStr(i), | 6585 KindAsStr(i), |
| 6577 DeoptId(i), | 6586 DeoptId(i), |
| 6578 token_pos_or_deopt_reason, | 6587 token_pos_or_deopt_reason, |
| 6579 multi_purpose_index); | 6588 multi_purpose_index); |
| 6580 } | 6589 } |
| 6581 // Allocate the buffer. | 6590 // Allocate the buffer. |
| 6582 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len); | 6591 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 6583 // Layout the fields in the buffer. | 6592 // Layout the fields in the buffer. |
| 6584 intptr_t index = 0; | 6593 intptr_t index = 0; |
| 6585 for (intptr_t i = 0; i < Length(); i++) { | 6594 for (intptr_t i = 0; i < Length(); i++) { |
| 6586 intptr_t token_pos_or_deopt_reason = DescriptorKind(i) == kDeoptIndex ? | 6595 intptr_t token_pos_or_deopt_reason = DescriptorKind(i) == kDeoptIndex ? |
| 6587 DeoptReason(i) : TokenPos(i); | 6596 DeoptReason(i) : TokenPos(i); |
| 6588 intptr_t multi_purpose_index = DescriptorKind(i) == kDeoptIndex ? | 6597 intptr_t multi_purpose_index = DescriptorKind(i) == kDeoptIndex ? |
| 6589 DeoptIndex(i) : TryIndex(i); | 6598 DeoptIndex(i) : TryIndex(i); |
| 6590 index += OS::SNPrint((buffer + index), (len - index), kFormat, | 6599 index += OS::SNPrint((buffer + index), (len - index), kFormat, addr_width, |
| 6591 PC(i), | 6600 PC(i), |
| 6592 KindAsStr(i), | 6601 KindAsStr(i), |
| 6593 DeoptId(i), | 6602 DeoptId(i), |
| 6594 token_pos_or_deopt_reason, | 6603 token_pos_or_deopt_reason, |
| 6595 multi_purpose_index); | 6604 multi_purpose_index); |
| 6596 } | 6605 } |
| 6597 return buffer; | 6606 return buffer; |
| 6598 } | 6607 } |
| 6599 | 6608 |
| 6600 | 6609 |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7030 } | 7039 } |
| 7031 ASSERT(Object::code_class() != Class::null()); | 7040 ASSERT(Object::code_class() != Class::null()); |
| 7032 Code& result = Code::Handle(); | 7041 Code& result = Code::Handle(); |
| 7033 { | 7042 { |
| 7034 uword size = Code::InstanceSize(pointer_offsets_length); | 7043 uword size = Code::InstanceSize(pointer_offsets_length); |
| 7035 RawObject* raw = Object::Allocate(Code::kClassId, size, Heap::kOld); | 7044 RawObject* raw = Object::Allocate(Code::kClassId, size, Heap::kOld); |
| 7036 NoGCScope no_gc; | 7045 NoGCScope no_gc; |
| 7037 result ^= raw; | 7046 result ^= raw; |
| 7038 result.set_pointer_offsets_length(pointer_offsets_length); | 7047 result.set_pointer_offsets_length(pointer_offsets_length); |
| 7039 result.set_is_optimized(false); | 7048 result.set_is_optimized(false); |
| 7049 result.set_spill_slot_count(0); | |
| 7040 result.set_comments(Comments::New(0)); | 7050 result.set_comments(Comments::New(0)); |
| 7041 } | 7051 } |
| 7042 return result.raw(); | 7052 return result.raw(); |
| 7043 } | 7053 } |
| 7044 | 7054 |
| 7045 | 7055 |
| 7046 RawCode* Code::FinalizeCode(const char* name, Assembler* assembler) { | 7056 RawCode* Code::FinalizeCode(const char* name, Assembler* assembler) { |
| 7047 ASSERT(assembler != NULL); | 7057 ASSERT(assembler != NULL); |
| 7048 | 7058 |
| 7049 // Allocate the Instructions object. | 7059 // Allocate the Instructions object. |
| (...skipping 3941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10991 const char* JSRegExp::ToCString() const { | 11001 const char* JSRegExp::ToCString() const { |
| 10992 const String& str = String::Handle(pattern()); | 11002 const String& str = String::Handle(pattern()); |
| 10993 const char* format = "JSRegExp: pattern=%s flags=%s"; | 11003 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 10994 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 11004 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 10995 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); | 11005 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); |
| 10996 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 11006 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 10997 return chars; | 11007 return chars; |
| 10998 } | 11008 } |
| 10999 | 11009 |
| 11000 } // namespace dart | 11010 } // namespace dart |
| OLD | NEW |