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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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/source_report.h" 5 #include "vm/source_report.h"
6 6
7 #include "vm/compiler.h" 7 #include "vm/compiler.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/object_store.h" 10 #include "vm/object_store.h"
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 return; 331 return;
332 } 332 }
333 333
334 const Script& script = Script::Handle(zone(), func.script()); 334 const Script& script = Script::Handle(zone(), func.script());
335 const TokenPosition begin_pos = func.token_pos(); 335 const TokenPosition begin_pos = func.token_pos();
336 const TokenPosition end_pos = func.end_token_pos(); 336 const TokenPosition end_pos = func.end_token_pos();
337 337
338 Code& code = Code::Handle(zone(), func.unoptimized_code()); 338 Code& code = Code::Handle(zone(), func.unoptimized_code());
339 if (code.IsNull()) { 339 if (code.IsNull()) {
340 if (func.HasCode() || (compile_mode_ == kForceCompile)) { 340 if (func.HasCode() || (compile_mode_ == kForceCompile)) {
341 if (Compiler::EnsureUnoptimizedCode(thread(), func) != Error::null()) { 341 const Error& err =
342 // Ignore the error and this function entirely. 342 Error::Handle(Compiler::EnsureUnoptimizedCode(thread(), func));
343 if (!err.IsNull()) {
344 // Emit an uncompiled range for this function with error information.
345 JSONObject range(jsarr);
346 range.AddProperty("scriptIndex", GetScriptIndex(script));
347 range.AddProperty("startPos", begin_pos);
348 range.AddProperty("endPos", end_pos);
349 range.AddProperty("compiled", false);
350 range.AddProperty("error", err);
343 return; 351 return;
344 } 352 }
345 code = func.unoptimized_code(); 353 code = func.unoptimized_code();
346 } else { 354 } else {
347 // This function has not been compiled yet. 355 // This function has not been compiled yet.
348 JSONObject range(jsarr); 356 JSONObject range(jsarr);
349 range.AddProperty("scriptIndex", GetScriptIndex(script)); 357 range.AddProperty("scriptIndex", GetScriptIndex(script));
350 range.AddProperty("startPos", begin_pos); 358 range.AddProperty("startPos", begin_pos);
351 range.AddProperty("endPos", end_pos); 359 range.AddProperty("endPos", end_pos);
352 range.AddProperty("compiled", false); 360 range.AddProperty("compiled", false);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 PrintProfileData(&range, profile_function); 394 PrintProfileData(&range, profile_function);
387 } 395 }
388 } 396 }
389 } 397 }
390 398
391 399
392 void SourceReport::VisitLibrary(JSONArray* jsarr, const Library& lib) { 400 void SourceReport::VisitLibrary(JSONArray* jsarr, const Library& lib) {
393 Class& cls = Class::Handle(zone()); 401 Class& cls = Class::Handle(zone());
394 Array& functions = Array::Handle(zone()); 402 Array& functions = Array::Handle(zone());
395 Function& func = Function::Handle(zone()); 403 Function& func = Function::Handle(zone());
404 Script& script = Script::Handle(zone());
396 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate); 405 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate);
397 while (it.HasNext()) { 406 while (it.HasNext()) {
398 cls = it.GetNextClass(); 407 cls = it.GetNextClass();
408 if (!cls.is_finalized()) {
409 if (compile_mode_ == kForceCompile) {
410 const Error& err = Error::Handle(cls.EnsureIsFinalized(thread()));
411 if (!err.IsNull()) {
412 // Emit an uncompiled range for this class with error information.
413 JSONObject range(jsarr);
414 script = cls.script();
415 range.AddProperty("scriptIndex", GetScriptIndex(script));
416 range.AddProperty("startPos", cls.token_pos());
417 range.AddProperty("endPos", cls.ComputeEndTokenPos());
418 range.AddProperty("compiled", false);
419 range.AddProperty("error", err);
420 continue;
421 }
422 } else {
423 // Emit one range for the whole uncompiled class.
424 JSONObject range(jsarr);
425 script = cls.script();
426 range.AddProperty("scriptIndex", GetScriptIndex(script));
427 range.AddProperty("startPos", cls.token_pos());
428 range.AddProperty("endPos", cls.ComputeEndTokenPos());
429 range.AddProperty("compiled", false);
430 continue;
431 }
432 }
433
399 functions = cls.functions(); 434 functions = cls.functions();
400 for (int i = 0; i < functions.Length(); i++) { 435 for (int i = 0; i < functions.Length(); i++) {
401 func ^= functions.At(i); 436 func ^= functions.At(i);
402 VisitFunction(jsarr, func); 437 VisitFunction(jsarr, func);
403 } 438 }
404 } 439 }
405 } 440 }
406 441
407 442
408 void SourceReport::VisitClosures(JSONArray* jsarr) { 443 void SourceReport::VisitClosures(JSONArray* jsarr) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 VisitClosures(&ranges); 481 VisitClosures(&ranges);
447 } 482 }
448 483
449 // Print the script table. 484 // Print the script table.
450 JSONArray scripts(&report, "scripts"); 485 JSONArray scripts(&report, "scripts");
451 PrintScriptTable(&scripts); 486 PrintScriptTable(&scripts);
452 } 487 }
453 488
454 489
455 } // namespace dart 490 } // namespace dart
OLDNEW
« 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