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

Unified Diff: runtime/vm/object.cc

Issue 2512653002: Merge of source position information from kernel-sdk. (Closed)
Patch Set: Changed how GetTokenLocation was called back to original to fix failing failing tests. Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index ccd7f25336eb8ac0355e8d39ec991b23466daed9..0cfa413eda298e48f3058400b91f3111308433f1 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -8782,6 +8782,8 @@ const char* Script::GetKindAsCString() const {
return "patch";
case RawScript::kEvaluateTag:
return "evaluate";
+ case RawScript::kKernelTag:
+ return "kernel";
default:
UNIMPLEMENTED();
}
@@ -8804,6 +8806,10 @@ void Script::set_source(const String& value) const {
StorePointer(&raw_ptr()->source_, value.raw());
}
+void Script::set_line_starts(const Array& value) const {
+ StorePointer(&raw_ptr()->line_starts_, value.raw());
+}
+
void Script::set_kind(RawScript::Kind value) const {
StoreNonPointer(&raw_ptr()->kind_, value);
@@ -8854,10 +8860,49 @@ void Script::GetTokenLocation(TokenPosition token_pos,
intptr_t* token_len) const {
ASSERT(line != NULL);
Zone* zone = Thread::Current()->zone();
+
+ if (kind() == RawScript::kKernelTag) {
+ const Array& line_starts_array = Array::Handle(line_starts());
+ if (line_starts_array.IsNull()) {
+ // Scripts in the AOT snapshot do not have a line starts array.
+ *line = -1;
+ if (column != NULL) {
+ *column = -1;
+ }
+ if (token_len != NULL) {
+ *token_len = 1;
+ }
+ return;
+ }
+ ASSERT(line_starts_array.Length() > 0);
+ intptr_t offset = token_pos.value();
+ int min = 0;
+ int max = line_starts_array.Length() - 1;
+
+ // Binary search to find the line containing this offset.
+ Smi& smi = Smi::Handle();
+ while (min < max) {
+ int midpoint = (max - min + 1) / 2 + min;
+
+ smi ^= line_starts_array.At(midpoint);
+ if (smi.Value() > offset) {
+ max = midpoint - 1;
+ } else {
+ min = midpoint;
+ }
+ }
+ *line = min + 1;
+ smi ^= line_starts_array.At(min);
+ *column = offset - smi.Value() + 1;
+ if (token_len != NULL) {
+ *token_len = 1;
+ }
+ return;
+ }
+
const TokenStream& tkns = TokenStream::Handle(zone, tokens());
if (tkns.IsNull()) {
- ASSERT((Dart::snapshot_kind() == Snapshot::kAppNoJIT) ||
- (url() == Symbols::KernelScriptUri().raw()));
+ ASSERT((Dart::snapshot_kind() == Snapshot::kAppNoJIT));
*line = -1;
if (column != NULL) {
*column = -1;
@@ -22312,7 +22357,7 @@ static intptr_t PrintOneStacktrace(Zone* zone,
intptr_t line = -1;
intptr_t column = -1;
if (!script.IsNull() && token_pos.IsReal()) {
- if (script.HasSource()) {
+ if (script.HasSource() || script.kind() == RawScript::kKernelTag) {
script.GetTokenLocation(token_pos, &line, &column);
} else {
script.GetTokenLocation(token_pos, &line, NULL);
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698