V4 IR: Change data type used in RemoveSharedExpressions pass.
authorRobin Burchell <robin.burchell@viroteck.net>
Sun, 21 Dec 2014 18:44:41 +0000 (19:44 +0100)
committerRobin Burchell <robin.burchell@viroteck.net>
Wed, 7 Jan 2015 20:35:54 +0000 (21:35 +0100)
commitba690fb73864915b4a35bbec5b7dc134ff1dafd0
treeda3577cf3e0cfe1a14ed48491ef449c266b9795b
parent05fd01c14a7a4b26f366704fb0b0a4eddaceccf4
V4 IR: Change data type used in RemoveSharedExpressions pass.

Profiling the loading of a pretty morbidly large QML file consistently showed
that this was quite slow, around 1300ms in removeSharedExpressions, of which a
good >600-700ms (I didn't count exactly, but it was a very large amount) was
down to allocating and freeing QHash nodes.

As we don't require removals, leaving insertion and lookup as the only two
remaining options, a sorted vector becomes a viable alternative (credit to João
Abecasis for the idea).

An additional benefit of this change is that the two hash lookups are now
compressed into a single 'hash' lookup (via the lower_bound call) instead of
separately using contains() / insert().

Measuring the exact saving is difficult, but it looks like this saves between
700-1000ms off the runtime RemoveSharedExpressions. After this patch, malloc and
free are dominating the optimizer run, instead of any particular method.

Change-Id: I6c0bb8495eac4dd3613ba0274e8802d7bd609460
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/compiler/qv4jsir.cpp