| 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);
|
|
|