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

Unified Diff: src/arm64/lithium-arm64.h

Issue 308313002: ARM64: Avoid regeneration of constants. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 months 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
« no previous file with comments | « no previous file | src/arm64/lithium-arm64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/arm64/lithium-arm64.h
diff --git a/src/arm64/lithium-arm64.h b/src/arm64/lithium-arm64.h
index be053ddbbda026ab18a97d07433d04b43f8fbcc3..fc6e667c6061295788eea765721d57f7616cff96 100644
--- a/src/arm64/lithium-arm64.h
+++ b/src/arm64/lithium-arm64.h
@@ -3012,6 +3012,50 @@ class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
};
+class ConstantCache {
+ public:
+ ConstantCache() {}
+
+ class ConstantCacheLevel {
+ public:
+ void Cache(HConstant* constant) { cached_constants_.insert(constant); }
+ bool IsCached(HConstant* constant) {
+ return cached_constants_.find(constant) != cached_constants_.end();
+ }
+
+ private:
+ std::set<HConstant*> cached_constants_;
+ };
+
+ void Clear() { cache_levels_.clear(); }
+
+ void Cache(HConstant* constant, HBasicBlock* block) {
+ cache_levels_[block].Cache(constant);
+ }
+
+ bool IsCached(HConstant* constant, HBasicBlock* block) {
+ HBasicBlock* base_block = block;
+ std::map<HBasicBlock*, ConstantCacheLevel>::iterator it;
+ while (block != NULL) {
+ it = cache_levels_.find(block);
+ if (it != cache_levels_.end() && it->second.IsCached(constant)) {
+ if (base_block != block) {
+ // Avoid traversing the dominator blocks multiple times for the same
+ // constant.
+ cache_levels_[block].Cache(constant);
+ }
+ return true;
+ }
+ block = block->dominator();
+ }
+ return false;
+ }
+
+ private:
+ std::map<HBasicBlock*, ConstantCacheLevel> cache_levels_;
+};
+
+
class LChunkBuilder;
class LPlatformChunk V8_FINAL : public LChunk {
public:
@@ -3055,6 +3099,13 @@ class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
static bool HasMagicNumberForDivision(int32_t divisor);
+ bool IsCachedConstant(HConstant* constant, HBasicBlock* block) {
+ return constant_cache_.IsCached(constant, block);
+ }
+ void CacheConstant(HConstant* constant, HBasicBlock* block) {
+ constant_cache_.Cache(constant, block);
+ }
+
private:
enum Status {
UNUSED,
@@ -3205,6 +3256,7 @@ class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
HInstruction* current_instruction_;
HBasicBlock* current_block_;
LAllocator* allocator_;
+ ConstantCache constant_cache_;
DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
};
« no previous file with comments | « no previous file | src/arm64/lithium-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698