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

Unified Diff: runtime/vm/precompiler.cc

Issue 2556193003: VM: Make precompiler process constants/fields only once, avoid using pool.InfoAt() (Closed)
Patch Set: Created 4 years 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.h ('K') | « runtime/vm/object.cc ('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 ce07486c707488878bde0cd3312493e488848a53..9f8cbca6f794e9939def5c4e67c1a55388c9f351 100644
--- a/runtime/vm/precompiler.cc
+++ b/runtime/vm/precompiler.cc
@@ -830,6 +830,7 @@ void Precompiler::AddCalleesOf(const Function& function) {
#endif
const ObjectPool& pool = ObjectPool::Handle(Z, code.GetObjectPool());
+ ObjectPoolInfo pool_info(pool);
ICData& call_site = ICData::Handle(Z);
MegamorphicCache& cache = MegamorphicCache::Handle(Z);
String& selector = String::Handle(Z);
@@ -838,7 +839,7 @@ void Precompiler::AddCalleesOf(const Function& function) {
Instance& instance = Instance::Handle(Z);
Code& target_code = Code::Handle(Z);
for (intptr_t i = 0; i < pool.Length(); i++) {
- if (pool.InfoAt(i) == ObjectPool::kTaggedObject) {
+ if (pool_info.InfoAt(i) == ObjectPool::kTaggedObject) {
kustermann 2016/12/08 13:52:44 This moves the handle allocation out of the loop.
entry = pool.ObjectAt(i);
if (entry.IsICData()) {
// A dynamic call.
@@ -1032,6 +1033,9 @@ void Precompiler::AddConstObject(const Instance& instance) {
// argument descriptors.
if (!instance.IsCanonical()) return;
+ // Constants are canonicalized and we avoid repeated processing of them.
+ if (consts_to_retain_.Lookup(&instance) != NULL) return;
+
consts_to_retain_.Insert(&Instance::ZoneHandle(Z, instance.raw()));
kustermann 2016/12/08 13:52:44 Please note that consts_to_retain_.Insert() ca
Vyacheslav Egorov (Google) 2016/12/08 18:18:19 What about adding an ASSERT there?
kustermann 2016/12/08 19:14:38 If it's fine with you, I'll do it in a different C
if (cls.NumTypeArguments() > 0) {
@@ -1077,6 +1081,8 @@ void Precompiler::AddClosureCall(const Array& arguments_descriptor) {
void Precompiler::AddField(const Field& field) {
+ if (fields_to_retain_.Lookup(&field) != NULL) return;
+
fields_to_retain_.Insert(&Field::ZoneHandle(Z, field.raw()));
if (field.is_static()) {
@@ -2095,6 +2101,7 @@ void Precompiler::SwitchICCalls() {
code_(Code::Handle(zone)),
pool_(ObjectPool::Handle(zone)),
entry_(Object::Handle(zone)),
+ info_array_(TypedData::Handle(zone)),
ic_(ICData::Handle(zone)),
target_name_(String::Handle(zone)),
args_descriptor_(Array::Handle(zone)),
@@ -2109,8 +2116,10 @@ void Precompiler::SwitchICCalls() {
code_ = function.CurrentCode();
pool_ = code_.object_pool();
+ info_array_ = pool_.info_array();
+ ObjectPoolInfo pool_info(info_array_);
Florian Schneider 2016/12/08 18:30:45 Why not just: ObjectPoolInfo pool_info(pool_);
kustermann 2016/12/08 19:14:38 So we allocate one handle per [SwitchICCallsVisito
for (intptr_t i = 0; i < pool_.Length(); i++) {
- if (pool_.InfoAt(i) != ObjectPool::kTaggedObject) continue;
+ if (pool_info.InfoAt(i) != ObjectPool::kTaggedObject) continue;
kustermann 2016/12/08 13:52:44 Same thing: Move handle allocation out of loop.
entry_ = pool_.ObjectAt(i);
if (entry_.IsICData()) {
// The only IC calls generated by precompilation are for switchable
@@ -2150,6 +2159,7 @@ void Precompiler::SwitchICCalls() {
Code& code_;
ObjectPool& pool_;
Object& entry_;
+ TypedData& info_array_;
ICData& ic_;
String& target_name_;
Array& args_descriptor_;
« runtime/vm/object.h ('K') | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698