Chromium Code Reviews| Index: runtime/vm/precompiler.cc |
| diff --git a/runtime/vm/precompiler.cc b/runtime/vm/precompiler.cc |
| index 61470ad7f44fb4b8616c7d1267607f10f03519dc..2df113f5e0e30f03c321ae5d7b6afb598449c7fd 100644 |
| --- a/runtime/vm/precompiler.cc |
| +++ b/runtime/vm/precompiler.cc |
| @@ -129,6 +129,11 @@ void Precompiler::DoCompileAll( |
| DedupStackmaps(); |
| DedupStackmapLists(); |
| +#if defined(PRODUCT) |
|
Ivan Posva
2016/02/04 18:00:03
Please use a release flag to control this. This wi
rmacnak
2016/02/04 19:29:47
Done.
|
| + // Reduces binary size but obfuscates profiler results. |
| + DedupInstructions(); |
| +#endif |
| + |
| I->object_store()->set_compile_time_constants(Array::null_array()); |
| I->object_store()->set_unique_dynamic_targets(Array::null_array()); |
| @@ -1188,6 +1193,52 @@ void Precompiler::DedupStackmapLists() { |
| } |
| +void Precompiler::DedupInstructions() { |
| + class DedupInstructionsVisitor : public FunctionVisitor { |
| + public: |
| + explicit DedupInstructionsVisitor(Zone* zone) : |
| + zone_(zone), |
| + canonical_instructions_(), |
| + code_(Code::Handle(zone)), |
| + instructions_(Instructions::Handle(zone)) { |
| + } |
| + |
| + void VisitFunction(const Function& function) { |
| + if (!function.HasCode()) { |
| + ASSERT(function.HasImplicitClosureFunction()); |
| + return; |
| + } |
| + code_ = function.CurrentCode(); |
| + instructions_ = code_.instructions(); |
| + instructions_ = DedupInstructions(instructions_); |
|
Ivan Posva
2016/02/04 18:00:03
This function is a bit unfortunately named due to
rmacnak
2016/02/04 19:29:47
Changed to DedupOneInstructions
|
| + code_.SetActiveInstructions(instructions_.raw()); |
| + code_.set_instructions(instructions_.raw()); |
| + function.SetInstructions(code_); // Update cached entry point. |
| + } |
| + |
| + RawInstructions* DedupInstructions(const Instructions& instructions) { |
| + const Instructions* set_instructions = |
| + canonical_instructions_.Lookup(&instructions); |
| + if (set_instructions == NULL) { |
| + canonical_instructions_.Insert( |
| + &Instructions::ZoneHandle(zone_, instructions.raw())); |
| + return instructions.raw(); |
| + } else { |
| + return set_instructions->raw(); |
|
Ivan Posva
2016/02/04 18:00:03
cached_instructions?
rmacnak
2016/02/04 19:29:47
Changed to canonical_instructions_ and changed can
|
| + } |
| + } |
| + |
| + private: |
| + Zone* zone_; |
| + InstructionsSet canonical_instructions_; |
| + Code& code_; |
| + Instructions& instructions_; |
| + }; |
| + |
| + DedupInstructionsVisitor visitor(Z); |
| + VisitFunctions(&visitor); |
| +} |
| + |
| void Precompiler::VisitFunctions(FunctionVisitor* visitor) { |
| Library& lib = Library::Handle(Z); |
| Class& cls = Class::Handle(Z); |