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

Unified Diff: runtime/vm/source_report.cc

Issue 1916243002: Fix getSourceReport's forceCompile option for unused classes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix tests Created 4 years, 7 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
« no previous file with comments | « runtime/vm/service/service.md ('k') | runtime/vm/source_report_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/source_report.cc
diff --git a/runtime/vm/source_report.cc b/runtime/vm/source_report.cc
index 1d3e818521487593de3d2a3e67e7f0fac3a30126..cfc79be852d3c32ab485d907387a48f3fb9cb142 100644
--- a/runtime/vm/source_report.cc
+++ b/runtime/vm/source_report.cc
@@ -338,8 +338,16 @@ void SourceReport::VisitFunction(JSONArray* jsarr, const Function& func) {
Code& code = Code::Handle(zone(), func.unoptimized_code());
if (code.IsNull()) {
if (func.HasCode() || (compile_mode_ == kForceCompile)) {
- if (Compiler::EnsureUnoptimizedCode(thread(), func) != Error::null()) {
- // Ignore the error and this function entirely.
+ const Error& err =
+ Error::Handle(Compiler::EnsureUnoptimizedCode(thread(), func));
+ if (!err.IsNull()) {
+ // Emit an uncompiled range for this function with error information.
+ JSONObject range(jsarr);
+ range.AddProperty("scriptIndex", GetScriptIndex(script));
+ range.AddProperty("startPos", begin_pos);
+ range.AddProperty("endPos", end_pos);
+ range.AddProperty("compiled", false);
+ range.AddProperty("error", err);
return;
}
code = func.unoptimized_code();
@@ -393,9 +401,36 @@ void SourceReport::VisitLibrary(JSONArray* jsarr, const Library& lib) {
Class& cls = Class::Handle(zone());
Array& functions = Array::Handle(zone());
Function& func = Function::Handle(zone());
+ Script& script = Script::Handle(zone());
ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate);
while (it.HasNext()) {
cls = it.GetNextClass();
+ if (!cls.is_finalized()) {
+ if (compile_mode_ == kForceCompile) {
+ const Error& err = Error::Handle(cls.EnsureIsFinalized(thread()));
+ if (!err.IsNull()) {
+ // Emit an uncompiled range for this class with error information.
+ JSONObject range(jsarr);
+ script = cls.script();
+ range.AddProperty("scriptIndex", GetScriptIndex(script));
+ range.AddProperty("startPos", cls.token_pos());
+ range.AddProperty("endPos", cls.ComputeEndTokenPos());
+ range.AddProperty("compiled", false);
+ range.AddProperty("error", err);
+ continue;
+ }
+ } else {
+ // Emit one range for the whole uncompiled class.
+ JSONObject range(jsarr);
+ script = cls.script();
+ range.AddProperty("scriptIndex", GetScriptIndex(script));
+ range.AddProperty("startPos", cls.token_pos());
+ range.AddProperty("endPos", cls.ComputeEndTokenPos());
+ range.AddProperty("compiled", false);
+ continue;
+ }
+ }
+
functions = cls.functions();
for (int i = 0; i < functions.Length(); i++) {
func ^= functions.At(i);
« no previous file with comments | « runtime/vm/service/service.md ('k') | runtime/vm/source_report_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698