| 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);
|
| };
|
|
|