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

Side by Side Diff: runtime/vm/precompiler.cc

Issue 1400193003: Don't assume at least one closure function is encountered before tree-shaking. Allow… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
« runtime/vm/flow_graph_builder.cc ('K') | « runtime/vm/object.cc ('k') | no next file » | 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/precompiler.h" 5 #include "vm/precompiler.h"
6 6
7 #include "vm/code_patcher.h" 7 #include "vm/code_patcher.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/log.h" 10 #include "vm/log.h"
(...skipping 29 matching lines...) Expand all
40 } else { 40 } else {
41 Isolate* isolate = Isolate::Current(); 41 Isolate* isolate = Isolate::Current();
42 const Error& error = Error::Handle(isolate->object_store()->sticky_error()); 42 const Error& error = Error::Handle(isolate->object_store()->sticky_error());
43 isolate->object_store()->clear_sticky_error(); 43 isolate->object_store()->clear_sticky_error();
44 return error.raw(); 44 return error.raw();
45 } 45 }
46 } 46 }
47 47
48 48
49 Precompiler::Precompiler(Thread* thread, bool reset_fields) : 49 Precompiler::Precompiler(Thread* thread, bool reset_fields) :
50 thread_(thread), 50 thread_(thread),
51 zone_(thread->zone()), 51 zone_(thread->zone()),
52 isolate_(thread->isolate()), 52 isolate_(thread->isolate()),
53 reset_fields_(reset_fields), 53 reset_fields_(reset_fields),
54 changed_(false), 54 changed_(false),
55 function_count_(0), 55 function_count_(0),
56 class_count_(0), 56 class_count_(0),
57 selector_count_(0), 57 selector_count_(0),
58 dropped_function_count_(0), 58 dropped_function_count_(0),
59 libraries_(GrowableObjectArray::Handle(Z, I->object_store()->libraries())), 59 libraries_(GrowableObjectArray::Handle(Z, I->object_store()->libraries())),
60 pending_functions_(GrowableObjectArray::Handle(Z, 60 pending_functions_(
61 GrowableObjectArray::New())), 61 GrowableObjectArray::Handle(Z, GrowableObjectArray::New())),
62 collected_closures_(GrowableObjectArray::Handle(Z, I->collected_closures())), 62 collected_closures_(
63 sent_selectors_(), 63 GrowableObjectArray::Handle(Z, GrowableObjectArray::New())),
64 error_(Error::Handle(Z)) { 64 sent_selectors_(),
65 error_(Error::Handle(Z)) {
66 I->set_collected_closures(collected_closures_);
65 } 67 }
66 68
67 69
68 void Precompiler::DoCompileAll( 70 void Precompiler::DoCompileAll(
69 Dart_QualifiedFunctionName embedder_entry_points[]) { 71 Dart_QualifiedFunctionName embedder_entry_points[]) {
70 // Drop all existing code so we can use the presence of code as an indicator 72 // Drop all existing code so we can use the presence of code as an indicator
71 // that we have already looked for the function's callees. 73 // that we have already looked for the function's callees.
72 ClearAllCode(); 74 ClearAllCode();
73 75
74 // Start with the allocations and invocations that happen from C++. 76 // Start with the allocations and invocations that happen from C++.
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 660
659 functions = Array::New(retained_functions.Length(), Heap::kOld); 661 functions = Array::New(retained_functions.Length(), Heap::kOld);
660 for (intptr_t j = 0; j < retained_functions.Length(); j++) { 662 for (intptr_t j = 0; j < retained_functions.Length(); j++) {
661 function ^= retained_functions.At(j); 663 function ^= retained_functions.At(j);
662 functions.SetAt(j, function); 664 functions.SetAt(j, function);
663 } 665 }
664 cls.SetFunctions(functions); 666 cls.SetFunctions(functions);
665 667
666 closures = cls.closures(); 668 closures = cls.closures();
667 if (!closures.IsNull()) { 669 if (!closures.IsNull()) {
670 retained_functions = GrowableObjectArray::New();
668 for (intptr_t j = 0; j < closures.Length(); j++) { 671 for (intptr_t j = 0; j < closures.Length(); j++) {
669 function ^= closures.At(j); 672 function ^= closures.At(j);
670 ASSERT(function.HasCode()); 673 if (function.HasCode()) {
674 retained_functions.Add(function);
675 } else {
676 dropped_function_count_++;
677 if (FLAG_trace_precompiler) {
678 THR_Print("Precompilation dropping %s\n",
679 function.ToLibNamePrefixedQualifiedCString());
680 }
681 }
671 } 682 }
683 cls.set_closures(retained_functions);
672 } 684 }
673 } 685 }
674 } 686 }
675 } 687 }
676 688
677 689
678 void Precompiler::BindStaticCalls() { 690 void Precompiler::BindStaticCalls() {
679 class BindStaticCallsVisitor : public FunctionVisitor { 691 class BindStaticCallsVisitor : public FunctionVisitor {
680 public: 692 public:
681 explicit BindStaticCallsVisitor(Zone* zone) : 693 explicit BindStaticCallsVisitor(Zone* zone) :
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 for (intptr_t j = 0; j < closures.Length(); j++) { 818 for (intptr_t j = 0; j < closures.Length(); j++) {
807 function ^= closures.At(j); 819 function ^= closures.At(j);
808 visitor->VisitFunction(function); 820 visitor->VisitFunction(function);
809 } 821 }
810 } 822 }
811 } 823 }
812 } 824 }
813 } 825 }
814 826
815 } // namespace dart 827 } // namespace dart
OLDNEW
« runtime/vm/flow_graph_builder.cc ('K') | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698