2013-09-26 16:25:57 +00:00
|
|
|
// Copyright 2013 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2013-09-26 16:25:57 +00:00
|
|
|
|
|
|
|
#ifndef V8_HYDROGEN_CHECK_ELIMINATION_H_
|
|
|
|
#define V8_HYDROGEN_CHECK_ELIMINATION_H_
|
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/hydrogen.h"
|
|
|
|
#include "src/hydrogen-alias-analysis.h"
|
2013-09-26 16:25:57 +00:00
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
|
|
|
|
// Remove CheckMaps instructions through flow- and branch-sensitive analysis.
|
|
|
|
class HCheckEliminationPhase : public HPhase {
|
|
|
|
public:
|
|
|
|
explicit HCheckEliminationPhase(HGraph* graph)
|
2014-06-02 12:17:05 +00:00
|
|
|
: HPhase("H_Check Elimination", graph), aliasing_(),
|
|
|
|
string_maps_(kStringMapsSize, zone()) {
|
|
|
|
// Compute the set of string maps.
|
|
|
|
#define ADD_STRING_MAP(type, size, name, Name) \
|
|
|
|
string_maps_.Add(Unique<Map>::CreateImmovable( \
|
|
|
|
graph->isolate()->factory()->name##_map()), zone());
|
|
|
|
STRING_TYPE_LIST(ADD_STRING_MAP)
|
|
|
|
#undef ADD_STRING_MAP
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK_EQ(kStringMapsSize, string_maps_.size());
|
2013-12-02 08:09:17 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
redundant_ = 0;
|
|
|
|
removed_ = 0;
|
|
|
|
removed_cho_ = 0;
|
2014-06-02 12:17:05 +00:00
|
|
|
removed_cit_ = 0;
|
2013-12-02 08:09:17 +00:00
|
|
|
narrowed_ = 0;
|
|
|
|
loads_ = 0;
|
|
|
|
empty_ = 0;
|
|
|
|
compares_true_ = 0;
|
|
|
|
compares_false_ = 0;
|
|
|
|
transitions_ = 0;
|
|
|
|
#endif
|
|
|
|
}
|
2013-09-26 16:25:57 +00:00
|
|
|
|
|
|
|
void Run();
|
|
|
|
|
2013-11-28 15:50:54 +00:00
|
|
|
friend class HCheckTable;
|
|
|
|
|
2013-09-26 16:25:57 +00:00
|
|
|
private:
|
2014-06-02 12:17:05 +00:00
|
|
|
const UniqueSet<Map>* string_maps() const { return &string_maps_; }
|
|
|
|
|
2013-11-28 15:50:54 +00:00
|
|
|
void PrintStats();
|
|
|
|
|
|
|
|
HAliasAnalyzer* aliasing_;
|
2014-06-02 12:17:05 +00:00
|
|
|
#define COUNT(type, size, name, Name) + 1
|
|
|
|
static const int kStringMapsSize = 0 STRING_TYPE_LIST(COUNT);
|
|
|
|
#undef COUNT
|
|
|
|
UniqueSet<Map> string_maps_;
|
2013-12-02 08:09:17 +00:00
|
|
|
#ifdef DEBUG
|
2013-11-28 15:50:54 +00:00
|
|
|
int redundant_;
|
|
|
|
int removed_;
|
2013-11-29 12:37:35 +00:00
|
|
|
int removed_cho_;
|
2014-06-02 12:17:05 +00:00
|
|
|
int removed_cit_;
|
2013-11-28 15:50:54 +00:00
|
|
|
int narrowed_;
|
|
|
|
int loads_;
|
|
|
|
int empty_;
|
|
|
|
int compares_true_;
|
|
|
|
int compares_false_;
|
|
|
|
int transitions_;
|
2013-12-02 08:09:17 +00:00
|
|
|
#endif
|
2013-09-26 16:25:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} } // namespace v8::internal
|
|
|
|
|
|
|
|
#endif // V8_HYDROGEN_CHECK_ELIMINATION_H_
|