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

Unified Diff: runtime/vm/precompiler.cc

Issue 1643023003: Precompilation: when removing top-level fields and functions, also remove them from the library dic… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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/object.cc ('K') | « runtime/vm/precompiler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/precompiler.cc
diff --git a/runtime/vm/precompiler.cc b/runtime/vm/precompiler.cc
index fd4cda8a385b7096cb29b9a5ac885f25c1b0e561..cb26652d54ba8c9917e2206384b5b41197f9e3f1 100644
--- a/runtime/vm/precompiler.cc
+++ b/runtime/vm/precompiler.cc
@@ -69,6 +69,7 @@ Precompiler::Precompiler(Thread* thread, bool reset_fields) :
GrowableObjectArray::Handle(GrowableObjectArray::New())),
sent_selectors_(),
enqueued_functions_(),
+ fields_to_retain_(),
error_(Error::Handle()) {
}
@@ -118,7 +119,7 @@ void Precompiler::DoCompileAll(
I->set_compilation_allowed(false);
- DropUncompiledFunctions();
+ DropFunctions();
DropFields();
// TODO(rmacnak): DropEmptyClasses();
@@ -897,7 +898,7 @@ void Precompiler::GetUniqueDynamicTarget(Isolate* isolate,
}
-void Precompiler::DropUncompiledFunctions() {
+void Precompiler::DropFunctions() {
Library& lib = Library::Handle(Z);
Class& cls = Class::Handle(Z);
Array& functions = Array::Handle(Z);
@@ -905,6 +906,7 @@ void Precompiler::DropUncompiledFunctions() {
Function& function2 = Function::Handle(Z);
GrowableObjectArray& retained_functions = GrowableObjectArray::Handle(Z);
GrowableObjectArray& closures = GrowableObjectArray::Handle(Z);
+ String& name = String::Handle(Z);
for (intptr_t i = 0; i < libraries_.Length(); i++) {
lib ^= libraries_.At(i);
@@ -915,6 +917,8 @@ void Precompiler::DropUncompiledFunctions() {
continue; // class 'dynamic' is in the read-only VM isolate.
}
+ bool top_level = cls.IsTopLevel();
Florian Schneider 2016/02/02 21:30:20 Move this right before its use?
rmacnak 2016/02/03 01:43:39 Done.
+
functions = cls.functions();
retained_functions = GrowableObjectArray::New();
for (intptr_t j = 0; j < functions.Length(); j++) {
@@ -932,6 +936,12 @@ void Precompiler::DropUncompiledFunctions() {
retained_functions.Add(function);
function.DropUncompiledImplicitClosureFunction();
} else {
+ if (top_level &&
+ (function.kind() != RawFunction::kImplicitStaticFinalGetter)) {
Florian Schneider 2016/02/02 21:30:20 Why not for implicit static final getters?
rmacnak 2016/02/03 01:43:40 They aren't in the library dictionary in the first
+ name = function.DictionaryName();
+ bool removed = lib.RemoveObject(function, name);
+ ASSERT(removed);
+ }
dropped_function_count_++;
if (FLAG_trace_precompiler) {
THR_Print("Precompilation dropping %s\n",
@@ -973,6 +983,7 @@ void Precompiler::DropFields() {
Array& fields = Array::Handle(Z);
Field& field = Field::Handle(Z);
GrowableObjectArray& retained_fields = GrowableObjectArray::Handle(Z);
+ String& name = String::Handle(Z);
for (intptr_t i = 0; i < libraries_.Length(); i++) {
lib ^= libraries_.At(i);
@@ -983,19 +994,26 @@ void Precompiler::DropFields() {
continue; // class 'dynamic' is in the read-only VM isolate.
}
+ bool top_level = cls.IsTopLevel();
Florian Schneider 2016/02/02 21:30:19 Move this right before its use?
rmacnak 2016/02/03 01:43:39 Done.
+
fields = cls.fields();
retained_fields = GrowableObjectArray::New();
for (intptr_t j = 0; j < fields.Length(); j++) {
field ^= fields.At(j);
- bool drop = fields_to_retain_.Lookup(&field) == NULL;
- if (drop) {
+ bool retain = fields_to_retain_.Lookup(&field) != NULL;
+ if (retain) {
+ retained_fields.Add(field);
+ } else {
+ if (top_level) {
+ name = field.DictionaryName();
+ bool removed = lib.RemoveObject(field, name);
+ ASSERT(removed);
+ }
dropped_field_count_++;
if (FLAG_trace_precompiler) {
THR_Print("Precompilation dropping %s\n",
field.ToCString());
}
- } else {
- retained_fields.Add(field);
}
}
@@ -1252,6 +1270,7 @@ void Precompiler::ResetPrecompilerState() {
class_count_ = 0;
selector_count_ = 0;
dropped_function_count_ = 0;
+ dropped_field_count_ = 0;
ASSERT(pending_functions_.Length() == 0);
sent_selectors_.Clear();
enqueued_functions_.Clear();
« runtime/vm/object.cc ('K') | « runtime/vm/precompiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698