| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 int position_; | 927 int position_; |
| 928 }; | 928 }; |
| 929 | 929 |
| 930 | 930 |
| 931 class HGraphBuilder { | 931 class HGraphBuilder { |
| 932 public: | 932 public: |
| 933 explicit HGraphBuilder(CompilationInfo* info) | 933 explicit HGraphBuilder(CompilationInfo* info) |
| 934 : info_(info), | 934 : info_(info), |
| 935 graph_(NULL), | 935 graph_(NULL), |
| 936 current_block_(NULL), | 936 current_block_(NULL), |
| 937 no_side_effects_scope_environment_delta_(0), | |
| 938 no_side_effects_scope_count_(0) {} | 937 no_side_effects_scope_count_(0) {} |
| 939 virtual ~HGraphBuilder() {} | 938 virtual ~HGraphBuilder() {} |
| 940 | 939 |
| 941 HBasicBlock* current_block() const { return current_block_; } | 940 HBasicBlock* current_block() const { return current_block_; } |
| 942 void set_current_block(HBasicBlock* block) { current_block_ = block; } | 941 void set_current_block(HBasicBlock* block) { current_block_ = block; } |
| 943 HEnvironment* environment() const { | 942 HEnvironment* environment() const { |
| 944 return current_block()->last_environment(); | 943 return current_block()->last_environment(); |
| 945 } | 944 } |
| 946 Zone* zone() const { return info_->zone(); } | 945 Zone* zone() const { return info_->zone(); } |
| 947 HGraph* graph() const { return graph_; } | 946 HGraph* graph() const { return graph_; } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 959 RemovableSimulate removable = FIXED_SIMULATE); | 958 RemovableSimulate removable = FIXED_SIMULATE); |
| 960 HBoundsCheck* AddBoundsCheck( | 959 HBoundsCheck* AddBoundsCheck( |
| 961 HValue* index, | 960 HValue* index, |
| 962 HValue* length, | 961 HValue* length, |
| 963 BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY, | 962 BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY, |
| 964 Representation r = Representation::None()); | 963 Representation r = Representation::None()); |
| 965 | 964 |
| 966 HReturn* AddReturn(HValue* value); | 965 HReturn* AddReturn(HValue* value); |
| 967 | 966 |
| 968 void IncrementInNoSideEffectsScope() { | 967 void IncrementInNoSideEffectsScope() { |
| 969 if (no_side_effects_scope_count_ == 0) { | |
| 970 no_side_effects_scope_environment_delta_ = | |
| 971 environment()->push_count() - environment()->pop_count(); | |
| 972 } | |
| 973 no_side_effects_scope_count_++; | 968 no_side_effects_scope_count_++; |
| 974 } | 969 } |
| 975 | 970 |
| 976 void DecrementInNoSideEffectsScope() { | 971 void DecrementInNoSideEffectsScope() { |
| 977 no_side_effects_scope_count_--; | 972 no_side_effects_scope_count_--; |
| 978 if (no_side_effects_scope_count_ == 0) { | |
| 979 // No-side-effects scope should not change push-pop delta. | |
| 980 ASSERT_EQ(no_side_effects_scope_environment_delta_, | |
| 981 environment()->push_count() - environment()->pop_count()); | |
| 982 no_side_effects_scope_environment_delta_ = 0; | |
| 983 } | |
| 984 } | |
| 985 | |
| 986 bool SafeToAddPhiInNoSideEffectsScope() { | |
| 987 // Pops and pushes after a simulate are not visible in LChunkBuilder. | |
| 988 // If the number of pops is greater than the number pushes then the | |
| 989 // environment in HGraphBuilder is shorter then the corresponding | |
| 990 // environment in LChunkBuilder. This causes non-observable phis | |
| 991 // to be pushed in the environment, which breaks deoptimization. | |
| 992 return no_side_effects_scope_count_ == 0 || | |
| 993 no_side_effects_scope_environment_delta_ >= 0; | |
| 994 } | 973 } |
| 995 | 974 |
| 996 protected: | 975 protected: |
| 997 virtual bool BuildGraph() = 0; | 976 virtual bool BuildGraph() = 0; |
| 998 | 977 |
| 999 HBasicBlock* CreateBasicBlock(HEnvironment* env); | 978 HBasicBlock* CreateBasicBlock(HEnvironment* env); |
| 1000 HBasicBlock* CreateLoopHeaderBlock(); | 979 HBasicBlock* CreateLoopHeaderBlock(); |
| 1001 | 980 |
| 1002 HValue* BuildCheckNonSmi(HValue* object); | 981 HValue* BuildCheckNonSmi(HValue* object); |
| 1003 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); | 982 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1346 HValue* payload); | 1325 HValue* payload); |
| 1347 | 1326 |
| 1348 HInstruction* BuildGetNativeContext(HValue* context); | 1327 HInstruction* BuildGetNativeContext(HValue* context); |
| 1349 HInstruction* BuildGetArrayFunction(HValue* context); | 1328 HInstruction* BuildGetArrayFunction(HValue* context); |
| 1350 | 1329 |
| 1351 private: | 1330 private: |
| 1352 HGraphBuilder(); | 1331 HGraphBuilder(); |
| 1353 CompilationInfo* info_; | 1332 CompilationInfo* info_; |
| 1354 HGraph* graph_; | 1333 HGraph* graph_; |
| 1355 HBasicBlock* current_block_; | 1334 HBasicBlock* current_block_; |
| 1356 int no_side_effects_scope_environment_delta_; | |
| 1357 int no_side_effects_scope_count_; | 1335 int no_side_effects_scope_count_; |
| 1358 }; | 1336 }; |
| 1359 | 1337 |
| 1360 | 1338 |
| 1361 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { | 1339 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { |
| 1362 public: | 1340 public: |
| 1363 enum BreakType { BREAK, CONTINUE }; | 1341 enum BreakType { BREAK, CONTINUE }; |
| 1364 enum SwitchType { UNKNOWN_SWITCH, SMI_SWITCH, STRING_SWITCH }; | 1342 enum SwitchType { UNKNOWN_SWITCH, SMI_SWITCH, STRING_SWITCH }; |
| 1365 | 1343 |
| 1366 // A class encapsulating (lazily-allocated) break and continue blocks for | 1344 // A class encapsulating (lazily-allocated) break and continue blocks for |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2035 EmbeddedVector<char, 64> filename_; | 2013 EmbeddedVector<char, 64> filename_; |
| 2036 HeapStringAllocator string_allocator_; | 2014 HeapStringAllocator string_allocator_; |
| 2037 StringStream trace_; | 2015 StringStream trace_; |
| 2038 int indent_; | 2016 int indent_; |
| 2039 }; | 2017 }; |
| 2040 | 2018 |
| 2041 | 2019 |
| 2042 } } // namespace v8::internal | 2020 } } // namespace v8::internal |
| 2043 | 2021 |
| 2044 #endif // V8_HYDROGEN_H_ | 2022 #endif // V8_HYDROGEN_H_ |
| OLD | NEW |