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_push_pop_delta_(0), | |
danno
2013/05/08 16:24:27
This is a bit long :-)
How about just no_side_effe
ulan
2013/05/10 08:40:43
Done.
| |
937 no_side_effects_scope_count_(0) {} | 938 no_side_effects_scope_count_(0) {} |
938 virtual ~HGraphBuilder() {} | 939 virtual ~HGraphBuilder() {} |
939 | 940 |
940 HBasicBlock* current_block() const { return current_block_; } | 941 HBasicBlock* current_block() const { return current_block_; } |
941 void set_current_block(HBasicBlock* block) { current_block_ = block; } | 942 void set_current_block(HBasicBlock* block) { current_block_ = block; } |
942 HEnvironment* environment() const { | 943 HEnvironment* environment() const { |
943 return current_block()->last_environment(); | 944 return current_block()->last_environment(); |
944 } | 945 } |
945 Zone* zone() const { return info_->zone(); } | 946 Zone* zone() const { return info_->zone(); } |
946 HGraph* graph() const { return graph_; } | 947 HGraph* graph() const { return graph_; } |
(...skipping 11 matching lines...) Expand all Loading... | |
958 RemovableSimulate removable = FIXED_SIMULATE); | 959 RemovableSimulate removable = FIXED_SIMULATE); |
959 HBoundsCheck* AddBoundsCheck( | 960 HBoundsCheck* AddBoundsCheck( |
960 HValue* index, | 961 HValue* index, |
961 HValue* length, | 962 HValue* length, |
962 BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY, | 963 BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY, |
963 Representation r = Representation::None()); | 964 Representation r = Representation::None()); |
964 | 965 |
965 HReturn* AddReturn(HValue* value); | 966 HReturn* AddReturn(HValue* value); |
966 | 967 |
967 void IncrementInNoSideEffectsScope() { | 968 void IncrementInNoSideEffectsScope() { |
969 if (no_side_effects_scope_count_ == 0) { | |
970 no_side_effects_scope_environment_push_pop_delta_ = | |
971 environment()->push_count() - environment()->pop_count(); | |
972 } | |
968 no_side_effects_scope_count_++; | 973 no_side_effects_scope_count_++; |
969 } | 974 } |
970 | 975 |
971 void DecrementInNoSideEffectsScope() { | 976 void DecrementInNoSideEffectsScope() { |
972 no_side_effects_scope_count_--; | 977 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_push_pop_delta_, | |
981 environment()->push_count() - environment()->pop_count()); | |
982 no_side_effects_scope_environment_push_pop_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_push_pop_delta_ >= 0; | |
973 } | 994 } |
974 | 995 |
975 protected: | 996 protected: |
976 virtual bool BuildGraph() = 0; | 997 virtual bool BuildGraph() = 0; |
977 | 998 |
978 HBasicBlock* CreateBasicBlock(HEnvironment* env); | 999 HBasicBlock* CreateBasicBlock(HEnvironment* env); |
979 HBasicBlock* CreateLoopHeaderBlock(); | 1000 HBasicBlock* CreateLoopHeaderBlock(); |
980 | 1001 |
981 HValue* BuildCheckNonSmi(HValue* object); | 1002 HValue* BuildCheckNonSmi(HValue* object); |
982 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); | 1003 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1325 HValue* payload); | 1346 HValue* payload); |
1326 | 1347 |
1327 HInstruction* BuildGetNativeContext(HValue* context); | 1348 HInstruction* BuildGetNativeContext(HValue* context); |
1328 HInstruction* BuildGetArrayFunction(HValue* context); | 1349 HInstruction* BuildGetArrayFunction(HValue* context); |
1329 | 1350 |
1330 private: | 1351 private: |
1331 HGraphBuilder(); | 1352 HGraphBuilder(); |
1332 CompilationInfo* info_; | 1353 CompilationInfo* info_; |
1333 HGraph* graph_; | 1354 HGraph* graph_; |
1334 HBasicBlock* current_block_; | 1355 HBasicBlock* current_block_; |
1356 int no_side_effects_scope_environment_push_pop_delta_; | |
1335 int no_side_effects_scope_count_; | 1357 int no_side_effects_scope_count_; |
1336 }; | 1358 }; |
1337 | 1359 |
1338 | 1360 |
1339 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { | 1361 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { |
1340 public: | 1362 public: |
1341 enum BreakType { BREAK, CONTINUE }; | 1363 enum BreakType { BREAK, CONTINUE }; |
1342 enum SwitchType { UNKNOWN_SWITCH, SMI_SWITCH, STRING_SWITCH }; | 1364 enum SwitchType { UNKNOWN_SWITCH, SMI_SWITCH, STRING_SWITCH }; |
1343 | 1365 |
1344 // A class encapsulating (lazily-allocated) break and continue blocks for | 1366 // A class encapsulating (lazily-allocated) break and continue blocks for |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2013 EmbeddedVector<char, 64> filename_; | 2035 EmbeddedVector<char, 64> filename_; |
2014 HeapStringAllocator string_allocator_; | 2036 HeapStringAllocator string_allocator_; |
2015 StringStream trace_; | 2037 StringStream trace_; |
2016 int indent_; | 2038 int indent_; |
2017 }; | 2039 }; |
2018 | 2040 |
2019 | 2041 |
2020 } } // namespace v8::internal | 2042 } } // namespace v8::internal |
2021 | 2043 |
2022 #endif // V8_HYDROGEN_H_ | 2044 #endif // V8_HYDROGEN_H_ |
OLD | NEW |