| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_ARM64_LITHIUM_ARM64_H_ | 5 #ifndef V8_ARM64_LITHIUM_ARM64_H_ |
| 6 #define V8_ARM64_LITHIUM_ARM64_H_ | 6 #define V8_ARM64_LITHIUM_ARM64_H_ |
| 7 | 7 |
| 8 #include "heap.h" |
| 8 #include "hydrogen.h" | 9 #include "hydrogen.h" |
| 9 #include "lithium-allocator.h" | 10 #include "lithium-allocator.h" |
| 10 #include "lithium.h" | 11 #include "lithium.h" |
| 11 #include "safepoint-table.h" | 12 #include "safepoint-table.h" |
| 12 #include "utils.h" | 13 #include "utils.h" |
| 13 | 14 |
| 14 namespace v8 { | 15 namespace v8 { |
| 15 namespace internal { | 16 namespace internal { |
| 16 | 17 |
| 17 // Forward declarations. | 18 // Forward declarations. |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 bool Is##type() const { return opcode() == k##type; } | 225 bool Is##type() const { return opcode() == k##type; } |
| 225 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE) | 226 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE) |
| 226 #undef DECLARE_PREDICATE | 227 #undef DECLARE_PREDICATE |
| 227 | 228 |
| 228 // Declare virtual predicates for instructions that don't have | 229 // Declare virtual predicates for instructions that don't have |
| 229 // an opcode. | 230 // an opcode. |
| 230 virtual bool IsGap() const { return false; } | 231 virtual bool IsGap() const { return false; } |
| 231 | 232 |
| 232 virtual bool IsControl() const { return false; } | 233 virtual bool IsControl() const { return false; } |
| 233 | 234 |
| 235 // Indicates wether it is more efficient to regenerate the value rather than |
| 236 // spill and reload it. |
| 237 virtual bool PreferRegenerateToSpill() const { return false; } |
| 238 |
| 234 void set_environment(LEnvironment* env) { environment_ = env; } | 239 void set_environment(LEnvironment* env) { environment_ = env; } |
| 235 LEnvironment* environment() const { return environment_; } | 240 LEnvironment* environment() const { return environment_; } |
| 236 bool HasEnvironment() const { return environment_ != NULL; } | 241 bool HasEnvironment() const { return environment_ != NULL; } |
| 237 | 242 |
| 238 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } | 243 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } |
| 239 LPointerMap* pointer_map() const { return pointer_map_.get(); } | 244 LPointerMap* pointer_map() const { return pointer_map_.get(); } |
| 240 bool HasPointerMap() const { return pointer_map_.is_set(); } | 245 bool HasPointerMap() const { return pointer_map_.is_set(); } |
| 241 | 246 |
| 242 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; } | 247 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; } |
| 243 HValue* hydrogen_value() const { return hydrogen_value_; } | 248 HValue* hydrogen_value() const { return hydrogen_value_; } |
| (...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1191 | 1196 |
| 1192 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; | 1197 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; |
| 1193 }; | 1198 }; |
| 1194 | 1199 |
| 1195 | 1200 |
| 1196 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 0> { | 1201 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 0> { |
| 1197 public: | 1202 public: |
| 1198 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d") | 1203 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d") |
| 1199 DECLARE_HYDROGEN_ACCESSOR(Constant) | 1204 DECLARE_HYDROGEN_ACCESSOR(Constant) |
| 1200 | 1205 |
| 1206 virtual bool PreferRegenerateToSpill() const V8_OVERRIDE { return true; } |
| 1207 |
| 1201 double value() const { return hydrogen()->DoubleValue(); } | 1208 double value() const { return hydrogen()->DoubleValue(); } |
| 1202 }; | 1209 }; |
| 1203 | 1210 |
| 1204 | 1211 |
| 1205 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> { | 1212 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> { |
| 1206 public: | 1213 public: |
| 1207 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e") | 1214 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e") |
| 1208 DECLARE_HYDROGEN_ACCESSOR(Constant) | 1215 DECLARE_HYDROGEN_ACCESSOR(Constant) |
| 1209 | 1216 |
| 1217 virtual bool PreferRegenerateToSpill() const V8_OVERRIDE { return true; } |
| 1218 |
| 1210 ExternalReference value() const { | 1219 ExternalReference value() const { |
| 1211 return hydrogen()->ExternalReferenceValue(); | 1220 return hydrogen()->ExternalReferenceValue(); |
| 1212 } | 1221 } |
| 1213 }; | 1222 }; |
| 1214 | 1223 |
| 1215 | 1224 |
| 1216 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> { | 1225 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> { |
| 1217 public: | 1226 public: |
| 1218 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i") | 1227 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i") |
| 1219 DECLARE_HYDROGEN_ACCESSOR(Constant) | 1228 DECLARE_HYDROGEN_ACCESSOR(Constant) |
| 1220 | 1229 |
| 1230 virtual bool PreferRegenerateToSpill() const V8_OVERRIDE { return true; } |
| 1231 |
| 1221 int32_t value() const { return hydrogen()->Integer32Value(); } | 1232 int32_t value() const { return hydrogen()->Integer32Value(); } |
| 1222 }; | 1233 }; |
| 1223 | 1234 |
| 1224 | 1235 |
| 1225 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> { | 1236 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> { |
| 1226 public: | 1237 public: |
| 1227 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s") | 1238 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s") |
| 1228 DECLARE_HYDROGEN_ACCESSOR(Constant) | 1239 DECLARE_HYDROGEN_ACCESSOR(Constant) |
| 1229 | 1240 |
| 1241 virtual bool PreferRegenerateToSpill() const V8_OVERRIDE { return true; } |
| 1242 |
| 1230 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); } | 1243 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); } |
| 1231 }; | 1244 }; |
| 1232 | 1245 |
| 1233 | 1246 |
| 1234 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> { | 1247 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> { |
| 1235 public: | 1248 public: |
| 1236 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t") | 1249 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t") |
| 1237 DECLARE_HYDROGEN_ACCESSOR(Constant) | 1250 DECLARE_HYDROGEN_ACCESSOR(Constant) |
| 1238 | 1251 |
| 1239 Handle<Object> value(Isolate* isolate) const { | 1252 Handle<Object> value(Isolate* isolate) const { |
| (...skipping 1771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3011 LOperand* function() { return inputs_[1]; } | 3024 LOperand* function() { return inputs_[1]; } |
| 3012 }; | 3025 }; |
| 3013 | 3026 |
| 3014 | 3027 |
| 3015 class ConstantCache { | 3028 class ConstantCache { |
| 3016 public: | 3029 public: |
| 3017 ConstantCache() {} | 3030 ConstantCache() {} |
| 3018 | 3031 |
| 3019 class ConstantCacheLevel { | 3032 class ConstantCacheLevel { |
| 3020 public: | 3033 public: |
| 3021 void Cache(HConstant* constant) { cached_constants_.insert(constant); } | 3034 void Cache(HConstant* constant, LInstruction* instr) { |
| 3022 bool IsCached(HConstant* constant) { | 3035 cached_constants_[constant] = instr; |
| 3023 return cached_constants_.find(constant) != cached_constants_.end(); | 3036 } |
| 3037 LInstruction* CachedLInstructionFor(HConstant* constant) { |
| 3038 std::map<HConstant*, LInstruction*>::iterator it; |
| 3039 it = cached_constants_.find(constant); |
| 3040 return (it == cached_constants_.end()) ? NULL : it->second; |
| 3024 } | 3041 } |
| 3025 | 3042 |
| 3026 private: | 3043 private: |
| 3027 std::set<HConstant*> cached_constants_; | 3044 std::map<HConstant*, LInstruction*> cached_constants_; |
| 3028 }; | 3045 }; |
| 3029 | 3046 |
| 3030 void Clear() { cache_levels_.clear(); } | 3047 void Clear() { cache_levels_.clear(); } |
| 3031 | 3048 |
| 3032 void Cache(HConstant* constant, HBasicBlock* block) { | 3049 void Cache(HConstant* constant, LInstruction* instr, HBasicBlock* block) { |
| 3033 cache_levels_[block].Cache(constant); | 3050 cache_levels_[block].Cache(constant, instr); |
| 3034 } | 3051 } |
| 3035 | 3052 |
| 3036 bool IsCached(HConstant* constant, HBasicBlock* block) { | 3053 LInstruction* CachedLInstructionFor(HConstant* constant, HBasicBlock* block) { |
| 3037 HBasicBlock* base_block = block; | 3054 HBasicBlock* base_block = block; |
| 3038 std::map<HBasicBlock*, ConstantCacheLevel>::iterator it; | 3055 std::map<HBasicBlock*, ConstantCacheLevel>::iterator it; |
| 3056 LInstruction* instr; |
| 3057 // Look for the constant in the specified block or the dominator blocks. |
| 3039 while (block != NULL) { | 3058 while (block != NULL) { |
| 3040 it = cache_levels_.find(block); | 3059 it = cache_levels_.find(block); |
| 3041 if (it != cache_levels_.end() && it->second.IsCached(constant)) { | 3060 if (it != cache_levels_.end()) { |
| 3042 if (base_block != block) { | 3061 instr = it->second.CachedLInstructionFor(constant); |
| 3043 // Avoid traversing the dominator blocks multiple times for the same | 3062 if (instr != NULL) { |
| 3044 // constant. | 3063 if (base_block != block) { |
| 3045 cache_levels_[block].Cache(constant); | 3064 // Avoid traversing the dominator blocks multiple times for the same |
| 3065 // constant. |
| 3066 cache_levels_[block].Cache(constant, instr); |
| 3067 } |
| 3068 return instr; |
| 3046 } | 3069 } |
| 3047 return true; | |
| 3048 } | 3070 } |
| 3049 block = block->dominator(); | 3071 block = block->dominator(); |
| 3050 } | 3072 } |
| 3051 return false; | 3073 return NULL; |
| 3052 } | 3074 } |
| 3053 | 3075 |
| 3054 private: | 3076 private: |
| 3055 std::map<HBasicBlock*, ConstantCacheLevel> cache_levels_; | 3077 std::map<HBasicBlock*, ConstantCacheLevel> cache_levels_; |
| 3056 }; | 3078 }; |
| 3057 | 3079 |
| 3058 | 3080 |
| 3059 class LChunkBuilder; | 3081 class LChunkBuilder; |
| 3060 class LPlatformChunk V8_FINAL : public LChunk { | 3082 class LPlatformChunk V8_FINAL : public LChunk { |
| 3061 public: | 3083 public: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3092 LInstruction* DoDivI(HBinaryOperation* instr); | 3114 LInstruction* DoDivI(HBinaryOperation* instr); |
| 3093 LInstruction* DoModByPowerOf2I(HMod* instr); | 3115 LInstruction* DoModByPowerOf2I(HMod* instr); |
| 3094 LInstruction* DoModByConstI(HMod* instr); | 3116 LInstruction* DoModByConstI(HMod* instr); |
| 3095 LInstruction* DoModI(HMod* instr); | 3117 LInstruction* DoModI(HMod* instr); |
| 3096 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr); | 3118 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr); |
| 3097 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr); | 3119 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr); |
| 3098 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr); | 3120 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr); |
| 3099 | 3121 |
| 3100 static bool HasMagicNumberForDivision(int32_t divisor); | 3122 static bool HasMagicNumberForDivision(int32_t divisor); |
| 3101 | 3123 |
| 3102 bool IsCachedConstant(HConstant* constant, HBasicBlock* block) { | 3124 LInstruction* CachedLInstructionFor(HConstant* constant, HBasicBlock* block) { |
| 3103 return constant_cache_.IsCached(constant, block); | 3125 return constant_cache_.CachedLInstructionFor(constant, block); |
| 3104 } | 3126 } |
| 3105 void CacheConstant(HConstant* constant, HBasicBlock* block) { | 3127 void CacheConstant(HConstant* constant, LInstruction* instr, |
| 3106 constant_cache_.Cache(constant, block); | 3128 HBasicBlock* block) { |
| 3129 constant_cache_.Cache(constant, instr, block); |
| 3107 } | 3130 } |
| 3108 | 3131 |
| 3109 private: | 3132 private: |
| 3110 enum Status { | 3133 enum Status { |
| 3111 UNUSED, | 3134 UNUSED, |
| 3112 BUILDING, | 3135 BUILDING, |
| 3113 DONE, | 3136 DONE, |
| 3114 ABORTED | 3137 ABORTED |
| 3115 }; | 3138 }; |
| 3116 | 3139 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3260 | 3283 |
| 3261 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); | 3284 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); |
| 3262 }; | 3285 }; |
| 3263 | 3286 |
| 3264 #undef DECLARE_HYDROGEN_ACCESSOR | 3287 #undef DECLARE_HYDROGEN_ACCESSOR |
| 3265 #undef DECLARE_CONCRETE_INSTRUCTION | 3288 #undef DECLARE_CONCRETE_INSTRUCTION |
| 3266 | 3289 |
| 3267 } } // namespace v8::internal | 3290 } } // namespace v8::internal |
| 3268 | 3291 |
| 3269 #endif // V8_ARM64_LITHIUM_ARM64_H_ | 3292 #endif // V8_ARM64_LITHIUM_ARM64_H_ |
| OLD | NEW |