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

Unified Diff: runtime/vm/profiler_service.cc

Issue 2944433003: [kernel] Add TokenPosition to AllocateObject, fix some cc tests (Closed)
Patch Set: Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« runtime/vm/kernel_binary_flowgraph.cc ('K') | « runtime/vm/kernel_to_il.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/profiler_service.cc
diff --git a/runtime/vm/profiler_service.cc b/runtime/vm/profiler_service.cc
index 9a4fe3b6916104fcf09acde7a1eaa54342033f1b..7275da2e24ba639c7f0dc3c7e21e870fa791338b 100644
--- a/runtime/vm/profiler_service.cc
+++ b/runtime/vm/profiler_service.cc
@@ -2678,11 +2678,6 @@ const char* ProfileTrieWalker::CurrentToken() {
// No script.
return NULL;
}
- const TokenStream& token_stream = TokenStream::Handle(zone, script.tokens());
- if (token_stream.IsNull()) {
- // No token position.
- return NULL;
- }
ProfileFunctionSourcePosition pfsp(TokenPosition::kNoSource);
if (!func->GetSinglePosition(&pfsp)) {
// Not exactly one source position.
@@ -2696,12 +2691,30 @@ const char* ProfileTrieWalker::CurrentToken() {
if (token_pos.IsSynthetic()) {
token_pos = token_pos.FromSynthetic();
}
- TokenStream::Iterator iterator(zone, token_stream, token_pos);
- const String& str = String::Handle(zone, iterator.CurrentLiteral());
- if (str.IsNull()) {
- return NULL;
+
+ if (script.kind() == RawScript::kKernelTag) {
Vyacheslav Egorov (Google) 2017/06/16 11:09:18 Please update CL description to include descriptio
jensj 2017/06/16 11:39:07 "fix some cc tests" isn't descriptive enough?
Kevin Millikin (Google) 2017/06/21 06:50:43 I would probably factor out the common code from t
+ intptr_t line = 0, column = 0, token_len = 0;
+ script.GetTokenLocation(token_pos, &line, &column, &token_len);
+ const String& str = String::Handle(
+ zone, script.GetSnippet(line, column, line, column + token_len));
+ if (str.IsNull()) {
+ return NULL;
+ }
+ return str.ToCString();
+ } else {
+ const TokenStream& token_stream =
+ TokenStream::Handle(zone, script.tokens());
+ if (token_stream.IsNull()) {
+ // No token position.
+ return NULL;
+ }
+ TokenStream::Iterator iterator(zone, token_stream, token_pos);
+ const String& str = String::Handle(zone, iterator.CurrentLiteral());
+ if (str.IsNull()) {
+ return NULL;
+ }
+ return str.ToCString();
}
- return str.ToCString();
}
bool ProfileTrieWalker::Down() {
« runtime/vm/kernel_binary_flowgraph.cc ('K') | « runtime/vm/kernel_to_il.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698