OSDN Git Service

Use iterators "before" the use node in HUserRecord<>.
authorVladimir Marko <vmarko@google.com>
Tue, 29 Mar 2016 11:21:58 +0000 (12:21 +0100)
committerVladimir Marko <vmarko@google.com>
Wed, 20 Apr 2016 16:16:09 +0000 (17:16 +0100)
commitd59f3b1b7f5c1ab9f0731ff9dc60611e8d9a6ede
tree154c545ded1feb3042b4705cebc3cf29fb2703bd
parentc88af3f53e3fced0559f770a9da645701fec9609
Use iterators "before" the use node in HUserRecord<>.

Create a new template class IntrusiveForwardList<> that
mimicks std::forward_list<> except that all allocations
are handled externally. This is essentially the same as
boost::intrusive::slist<> but since we're not using Boost
we have to reinvent the wheel.

Use the new container to replace the HUseList and use the
iterators to "before" use nodes in HUserRecord<> to avoid
the extra pointer to the previous node which was used
exclusively for removing nodes from the list. This reduces
the size of the HUseListNode by 25%, 32B to 24B in 64-bit
compiler, 16B to 12B in 32-bit compiler. This translates
directly to overall memory savings for the 64-bit compiler
but due to rounding up of the arena allocations to 8B, we
do not get any improvement in the 32-bit compiler.

Compiling the Nexus 5 boot image with the 64-bit dex2oat
on host this CL reduces the memory used for compiling the
most hungry method, BatteryStats.dumpLocked(), by ~3.3MiB:

Before:
  MEM: used: 47829200, allocated: 48769120, lost: 939920
  Number of arenas allocated: 345,
  Number of allocations: 815492, avg size: 58
  ...
  UseListNode    13744640
  ...
After:
  MEM: used: 44393040, allocated: 45361248, lost: 968208
  Number of arenas allocated: 319,
  Number of allocations: 815492, avg size: 54
  ...
  UseListNode    10308480
  ...

Note that while we do not ship the 64-bit dex2oat to the
device, the JIT compilation for 64-bit processes is using
the 64-bit libart-compiler.

Bug: 28173563
Bug: 27856014

(cherry picked from commit 46817b876ab00d6b78905b80ed12b4344c522b6c)

Change-Id: Ifb2d7b357064b003244e92c0d601d81a05e56a7b
23 files changed:
build/Android.gtest.mk
compiler/optimizing/bounds_check_elimination.cc
compiler/optimizing/common_arm64.h
compiler/optimizing/graph_checker.cc
compiler/optimizing/graph_visualizer.cc
compiler/optimizing/instruction_simplifier.cc
compiler/optimizing/instruction_simplifier_arm64.cc
compiler/optimizing/instruction_simplifier_shared.cc
compiler/optimizing/live_ranges_test.cc
compiler/optimizing/load_store_elimination.cc
compiler/optimizing/nodes.cc
compiler/optimizing/nodes.h
compiler/optimizing/nodes_test.cc
compiler/optimizing/prepare_for_register_allocation.cc
compiler/optimizing/pretty_printer.h
compiler/optimizing/reference_type_propagation.cc
compiler/optimizing/ssa_builder.cc
compiler/optimizing/ssa_liveness_analysis.cc
compiler/optimizing/ssa_phi_elimination.cc
compiler/utils/intrusive_forward_list.h [new file with mode: 0644]
compiler/utils/intrusive_forward_list_test.cc [new file with mode: 0644]
runtime/base/macros.h
runtime/jni_internal_test.cc