Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Side by Side Diff: runtime/vm/object.cc

Issue 2632183002: Debugging in kernel shaping up. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/become.h" 10 #include "vm/become.h"
(...skipping 8808 matching lines...) Expand 10 before | Expand all | Expand 10 after
8819 } 8819 }
8820 return token_stream.GenerateSource(); 8820 return token_stream.GenerateSource();
8821 } 8821 }
8822 8822
8823 8823
8824 void Script::set_compile_time_constants(const Array& value) const { 8824 void Script::set_compile_time_constants(const Array& value) const {
8825 StorePointer(&raw_ptr()->compile_time_constants_, value.raw()); 8825 StorePointer(&raw_ptr()->compile_time_constants_, value.raw());
8826 } 8826 }
8827 8827
8828 8828
8829 RawGrowableObjectArray* Script::GenerateLineNumberArray() const { 8829 RawGrowableObjectArray* Script::GenerateLineNumberArray() const {
Kevin Millikin (Google) 2017/01/24 13:44:13 This function really needs a comment somewhere doc
jensj 2017/01/25 12:52:22 In runtime/include/dart_tools_api.h Dart_ScriptGet
8830 Zone* zone = Thread::Current()->zone(); 8830 Zone* zone = Thread::Current()->zone();
8831 const GrowableObjectArray& info = 8831 const GrowableObjectArray& info =
8832 GrowableObjectArray::Handle(zone, GrowableObjectArray::New()); 8832 GrowableObjectArray::Handle(zone, GrowableObjectArray::New());
8833 const String& source = String::Handle(zone, Source()); 8833 const String& source = String::Handle(zone, Source());
8834 const String& key = Symbols::Empty(); 8834 const String& key = Symbols::Empty();
8835 const Object& line_separator = Object::Handle(zone); 8835 const Object& line_separator = Object::Handle(zone);
8836 Smi& value = Smi::Handle(zone); 8836 Smi& value = Smi::Handle(zone);
8837 8837
8838 if (kind() == RawScript::kKernelTag) { 8838 if (kind() == RawScript::kKernelTag) {
8839 const Array& line_starts_array = Array::Handle(line_starts()); 8839 const Array& line_starts_array = Array::Handle(line_starts());
8840 if (line_starts_array.IsNull()) { 8840 if (line_starts_array.IsNull()) {
8841 // Scripts in the AOT snapshot do not have a line starts array. 8841 // Scripts in the AOT snapshot do not have a line starts array.
8842 // A well-formed line number array has a leading null. 8842 // A well-formed line number array has a leading null.
8843 info.Add(line_separator); // New line. 8843 info.Add(line_separator); // New line.
8844 return info.raw(); 8844 return info.raw();
8845 } 8845 }
8846 intptr_t line_count = line_starts_array.Length(); 8846 intptr_t line_count = line_starts_array.Length();
8847 ASSERT(line_count > 0); 8847 ASSERT(line_count > 0);
8848 const Array& tokens_seen_array = Array::Handle(tokens_seen());
8849 intptr_t token_count = tokens_seen_array.Length();
8850 int token_idx = 0;
Kevin Millikin (Google) 2017/01/24 13:44:13 You can also spell out index.
jensj 2017/01/25 12:52:22 Done.
8851 int last_line = -1;
8848 8852
8849 for (int i = 0; i < line_count; i++) { 8853 for (int i = 0; i < line_count; i++) {
Kevin Millikin (Google) 2017/01/24 13:44:13 Instead of i, it's clearer to use the name 'line_i
jensj 2017/01/25 12:52:22 Done.
8850 info.Add(line_separator); // New line.
8851 value = Smi::New(i + 1);
8852 info.Add(value); // Line number.
8853 value ^= line_starts_array.At(i); 8854 value ^= line_starts_array.At(i);
8854 info.Add(value); // Token position. 8855 intptr_t start = value.Value();
8855 value = Smi::New(1); 8856 // Output the rest of the tokens if we have no next line.
8856 info.Add(value); // Column. 8857 intptr_t end = LONG_MAX;
Kevin Millikin (Google) 2017/01/24 13:44:13 INTPTR_MAX
jensj 2017/01/25 12:52:22 Done.
8858 if (i + 1 < line_count) {
8859 value ^= line_starts_array.At(i + 1);
8860 end = value.Value();
8861 }
8862 while (token_idx < token_count) {
8863 value ^= tokens_seen_array.At(token_idx);
8864 intptr_t seen = value.Value();
Kevin Millikin (Google) 2017/01/24 13:44:13 seen ==> debug_position ?
jensj 2017/01/25 12:52:22 Done.
8865 if (seen == -1) {
Kevin Millikin (Google) 2017/01/24 13:44:13 Can we just eliminate the -1 entries, or do we nee
jensj 2017/01/25 12:52:22 I'll move the check to the recording of the entrie
8866 ++token_idx;
8867 continue;
8868 }
8869 if (seen >= end) break;
8870
8871 if (i != last_line) {
Kevin Millikin (Google) 2017/01/24 13:44:13 last_line is just used to detect the first debug p
jensj 2017/01/25 12:52:22 It was done to look like the non-kernel version. I
8872 info.Add(line_separator); // New line.
8873 value = Smi::New(i + 1); // Line number.
8874 info.Add(value);
8875 last_line = i;
8876 }
8877
8878 value ^= tokens_seen_array.At(token_idx);
8879 info.Add(value); // Token position.
8880 value = Smi::New(seen - start + 1); // Column.
8881 info.Add(value);
8882 ++token_idx;
8883 }
8857 } 8884 }
8858 return info.raw(); 8885 return info.raw();
8859 } 8886 }
8860 8887
8861 const TokenStream& tkns = TokenStream::Handle(zone, tokens()); 8888 const TokenStream& tkns = TokenStream::Handle(zone, tokens());
8862 String& tokenValue = String::Handle(zone); 8889 String& tokenValue = String::Handle(zone);
8863 ASSERT(!tkns.IsNull()); 8890 ASSERT(!tkns.IsNull());
8864 TokenStream::Iterator tkit(zone, tkns, TokenPosition::kMinSource, 8891 TokenStream::Iterator tkit(zone, tkns, TokenPosition::kMinSource,
8865 TokenStream::Iterator::kAllTokens); 8892 TokenStream::Iterator::kAllTokens);
8866 int current_line = -1; 8893 int current_line = -1;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
8967 8994
8968 void Script::set_source(const String& value) const { 8995 void Script::set_source(const String& value) const {
8969 StorePointer(&raw_ptr()->source_, value.raw()); 8996 StorePointer(&raw_ptr()->source_, value.raw());
8970 } 8997 }
8971 8998
8972 void Script::set_line_starts(const Array& value) const { 8999 void Script::set_line_starts(const Array& value) const {
8973 StorePointer(&raw_ptr()->line_starts_, value.raw()); 9000 StorePointer(&raw_ptr()->line_starts_, value.raw());
8974 } 9001 }
8975 9002
8976 9003
9004 void Script::set_tokens_seen(const Array& value) const {
9005 StorePointer(&raw_ptr()->tokens_seen_, value.raw());
9006 }
9007
9008
9009 void Script::set_yields_seen(const Array& value) const {
9010 StorePointer(&raw_ptr()->yields_seen_, value.raw());
9011 }
9012
9013
8977 void Script::set_kind(RawScript::Kind value) const { 9014 void Script::set_kind(RawScript::Kind value) const {
8978 StoreNonPointer(&raw_ptr()->kind_, value); 9015 StoreNonPointer(&raw_ptr()->kind_, value);
8979 } 9016 }
8980 9017
8981 9018
8982 void Script::set_load_timestamp(int64_t value) const { 9019 void Script::set_load_timestamp(int64_t value) const {
8983 StoreNonPointer(&raw_ptr()->load_timestamp_, value); 9020 StoreNonPointer(&raw_ptr()->load_timestamp_, value);
8984 } 9021 }
8985 9022
8986 9023
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
9057 } else { 9094 } else {
9058 min = midpoint; 9095 min = midpoint;
9059 } 9096 }
9060 } 9097 }
9061 *line = min + 1; 9098 *line = min + 1;
9062 smi ^= line_starts_array.At(min); 9099 smi ^= line_starts_array.At(min);
9063 if (column != NULL) { 9100 if (column != NULL) {
9064 *column = offset - smi.Value() + 1; 9101 *column = offset - smi.Value() + 1;
9065 } 9102 }
9066 if (token_len != NULL) { 9103 if (token_len != NULL) {
9104 // We don't explicitly save this data.
9105 // TODO(jensj): Load the source and attempt to find it from there.
9067 *token_len = 1; 9106 *token_len = 1;
9068 } 9107 }
9069 return; 9108 return;
9070 } 9109 }
9071 9110
9072 const TokenStream& tkns = TokenStream::Handle(zone, tokens()); 9111 const TokenStream& tkns = TokenStream::Handle(zone, tokens());
9073 if (tkns.IsNull()) { 9112 if (tkns.IsNull()) {
9074 ASSERT((Dart::snapshot_kind() == Snapshot::kAppAOT)); 9113 ASSERT((Dart::snapshot_kind() == Snapshot::kAppAOT));
9075 *line = -1; 9114 *line = -1;
9076 if (column != NULL) { 9115 if (column != NULL) {
(...skipping 13922 matching lines...) Expand 10 before | Expand all | Expand 10 after
22999 return UserTag::null(); 23038 return UserTag::null();
23000 } 23039 }
23001 23040
23002 23041
23003 const char* UserTag::ToCString() const { 23042 const char* UserTag::ToCString() const {
23004 const String& tag_label = String::Handle(label()); 23043 const String& tag_label = String::Handle(label());
23005 return tag_label.ToCString(); 23044 return tag_label.ToCString();
23006 } 23045 }
23007 23046
23008 } // namespace dart 23047 } // namespace dart
OLDNEW
« runtime/vm/object.h ('K') | « runtime/vm/object.h ('k') | runtime/vm/object_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698