Chromium Code Reviews| 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 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 576 HValue* Lookup(Variable* variable) const { | 576 HValue* Lookup(Variable* variable) const { |
| 577 return Lookup(IndexFor(variable)); | 577 return Lookup(IndexFor(variable)); |
| 578 } | 578 } |
| 579 | 579 |
| 580 HValue* Lookup(int index) const { | 580 HValue* Lookup(int index) const { |
| 581 HValue* result = values_[index]; | 581 HValue* result = values_[index]; |
| 582 ASSERT(result != NULL); | 582 ASSERT(result != NULL); |
| 583 return result; | 583 return result; |
| 584 } | 584 } |
| 585 | 585 |
| 586 HValue* LookupContext() const { | 586 HValue* context() const { |
| 587 // Return first special. | 587 // Return first special. |
| 588 return Lookup(parameter_count()); | 588 return Lookup(parameter_count()); |
| 589 } | 589 } |
| 590 | 590 |
| 591 void Push(HValue* value) { | 591 void Push(HValue* value) { |
| 592 ASSERT(value != NULL); | 592 ASSERT(value != NULL); |
| 593 ++push_count_; | 593 ++push_count_; |
| 594 values_.Add(value, zone()); | 594 values_.Add(value, zone()); |
| 595 } | 595 } |
| 596 | 596 |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 983 HGraph* graph() const { return graph_; } | 983 HGraph* graph() const { return graph_; } |
| 984 Isolate* isolate() const { return graph_->isolate(); } | 984 Isolate* isolate() const { return graph_->isolate(); } |
| 985 CompilationInfo* top_info() { return info_; } | 985 CompilationInfo* top_info() { return info_; } |
| 986 | 986 |
| 987 HGraph* CreateGraph(); | 987 HGraph* CreateGraph(); |
| 988 | 988 |
| 989 // Bailout environment manipulation. | 989 // Bailout environment manipulation. |
| 990 void Push(HValue* value) { environment()->Push(value); } | 990 void Push(HValue* value) { environment()->Push(value); } |
| 991 HValue* Pop() { return environment()->Pop(); } | 991 HValue* Pop() { return environment()->Pop(); } |
| 992 | 992 |
| 993 virtual HValue* context() = 0; | |
| 994 | |
| 993 // Adding instructions. | 995 // Adding instructions. |
| 994 HInstruction* AddInstruction(HInstruction* instr); | 996 HInstruction* AddInstruction(HInstruction* instr); |
| 995 | 997 |
| 996 template<class I> | 998 template<class I> |
| 997 I* Add() { return static_cast<I*>(AddInstruction(new(zone()) I())); } | 999 HInstruction* New() { return I::New(zone(), context()); } |
| 1000 | |
| 1001 template<class I> | |
| 1002 I* NewAndCast() { return I::cast(New<I>()); } | |
| 1003 | |
| 1004 template<class I> | |
| 1005 HInstruction* Add() { return AddInstruction(New<I>());} | |
| 1006 | |
| 1007 template<class I> | |
| 1008 I* AddAndCast() { return I::cast(Add<I>());} | |
| 998 | 1009 |
| 999 template<class I, class P1> | 1010 template<class I, class P1> |
| 1000 I* Add(P1 p1) { | 1011 HInstruction* New(P1 p1) { |
| 1001 return static_cast<I*>(AddInstruction(new(zone()) I(p1))); | 1012 return I::New(zone(), context(), p1); |
| 1013 } | |
| 1014 | |
| 1015 template<class I, class P1> | |
| 1016 I* NewAndCast(P1 p1) { return I::cast(New<I>(p1)); } | |
| 1017 | |
| 1018 template<class I, class P1> | |
| 1019 HInstruction* Add(P1 p1) { | |
| 1020 HInstruction* result = AddInstruction(New<I>(p1)); | |
| 1021 // Specializations must have their parameters properly casted | |
| 1022 // to avoid landing here. | |
| 1023 ASSERT(!result->IsReturn() && !result->IsSimulate() && | |
| 1024 !result->IsDeoptimize()); | |
| 1025 return result; | |
| 1026 } | |
| 1027 | |
| 1028 template<class I, class P1> | |
| 1029 I* AddAndCast(P1 p1) { | |
| 1030 return I::cast(Add<I>(p1)); | |
| 1002 } | 1031 } |
| 1003 | 1032 |
| 1004 template<class I, class P1, class P2> | 1033 template<class I, class P1, class P2> |
| 1005 I* Add(P1 p1, P2 p2) { | 1034 HInstruction* New(P1 p1, P2 p2) { return I::New(zone(), context(), p1, p2); } |
| 1006 return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2))); | 1035 |
| 1036 template<class I, class P1, class P2> | |
| 1037 I* NewAndCast(P1 p1, P2 p2) { return I::cast(New<I>(p1, p2)); } | |
| 1038 | |
| 1039 template<class I, class P1, class P2> | |
| 1040 HInstruction* Add(P1 p1, P2 p2) { | |
| 1041 HInstruction* result = AddInstruction(New<I>(p1, p2)); | |
| 1042 // Specializations must have their parameters properly casted | |
| 1043 // to avoid landing here. | |
| 1044 ASSERT(!result->IsSimulate()); | |
| 1045 return result; | |
| 1046 } | |
| 1047 | |
| 1048 template<class I, class P1, class P2> | |
| 1049 I* AddAndCast(P1 p1, P2 p2) { | |
| 1050 return static_cast<I*>(Add<I>(p1, p2)); | |
| 1007 } | 1051 } |
| 1008 | 1052 |
| 1009 template<class I, class P1, class P2, class P3> | 1053 template<class I, class P1, class P2, class P3> |
| 1010 I* Add(P1 p1, P2 p2, P3 p3) { | 1054 HInstruction* New(P1 p1, P2 p2, P3 p3) { |
| 1011 return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2, p3))); | 1055 return I::New(zone(), context(), p1, p2, p3); |
| 1056 } | |
| 1057 | |
| 1058 template<class I, class P1, class P2, class P3> | |
| 1059 I* NewAndCast(P1 p1, P2 p2, P3 p3) { | |
| 1060 return I::cast(New<I>(p1, p2, p3)); | |
| 1061 } | |
| 1062 | |
| 1063 template<class I, class P1, class P2, class P3> | |
| 1064 HInstruction* Add(P1 p1, P2 p2, P3 p3) { | |
| 1065 return AddInstruction(New<I>(p1, p2, p3)); | |
| 1066 } | |
| 1067 | |
| 1068 template<class I, class P1, class P2, class P3> | |
| 1069 I* AddAndCast(P1 p1, P2 p2, P3 p3) { | |
| 1070 return I::cast(Add<I>(p1, p2, p3)); | |
| 1012 } | 1071 } |
| 1013 | 1072 |
| 1014 template<class I, class P1, class P2, class P3, class P4> | 1073 template<class I, class P1, class P2, class P3, class P4> |
| 1015 I* Add(P1 p1, P2 p2, P3 p3, P4 p4) { | 1074 HInstruction* New(P1 p1, P2 p2, P3 p3, P4 p4) { |
| 1016 return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2, p3, p4))); | 1075 return I::New(zone(), context(), p1, p2, p3, p4); |
| 1076 } | |
| 1077 | |
| 1078 template<class I, class P1, class P2, class P3, class P4> | |
| 1079 I* NewAndCast(P1 p1, P2 p2, P3 p3, P4 p4) { | |
| 1080 return I::cast(New<I>(p1, p2, p3, p4)); | |
| 1081 } | |
| 1082 | |
| 1083 template<class I, class P1, class P2, class P3, class P4> | |
| 1084 HInstruction* Add(P1 p1, P2 p2, P3 p3, P4 p4) { | |
| 1085 return AddInstruction(New<I>(p1, p2, p3, p4)); | |
| 1086 } | |
| 1087 | |
| 1088 template<class I, class P1, class P2, class P3, class P4> | |
| 1089 I* AddAndCast(P1 p1, P2 p2, P3 p3, P4 p4) { | |
| 1090 return I::cast(Add<I>(p1, p2, p3, p4)); | |
| 1017 } | 1091 } |
| 1018 | 1092 |
| 1019 template<class I, class P1, class P2, class P3, class P4, class P5> | 1093 template<class I, class P1, class P2, class P3, class P4, class P5> |
| 1020 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) { | 1094 HInstruction* New(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) { |
| 1021 return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2, p3, p4, p5))); | 1095 return I::New(zone(), context(), p1, p2, p3, p4, p5); |
| 1096 } | |
| 1097 | |
| 1098 template<class I, class P1, class P2, class P3, class P4, class P5> | |
| 1099 I* NewAndCast(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) { | |
| 1100 return I::cast(New<I>(p1, p2, p3, p4, p5)); | |
| 1101 } | |
| 1102 | |
| 1103 template<class I, class P1, class P2, class P3, class P4, class P5> | |
| 1104 HInstruction* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) { | |
| 1105 return AddInstruction(New<I>(p1, p2, p3, p4, p5)); | |
| 1106 } | |
| 1107 | |
| 1108 template<class I, class P1, class P2, class P3, class P4, class P5> | |
| 1109 I* AddAndCast(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) { | |
| 1110 return I::cast(Add<I>(p1, p2, p3, p4, p5)); | |
| 1022 } | 1111 } |
| 1023 | 1112 |
| 1024 template<class I, class P1, class P2, class P3, class P4, class P5, class P6> | 1113 template<class I, class P1, class P2, class P3, class P4, class P5, class P6> |
| 1025 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) { | 1114 HInstruction* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) { |
| 1026 return static_cast<I*>(AddInstruction( | 1115 return AddInstruction(new(zone()) I(p1, p2, p3, p4, p5, p6)); |
| 1027 new(zone()) I(p1, p2, p3, p4, p5, p6))); | 1116 } |
| 1117 | |
| 1118 template<class I, class P1, class P2, class P3, class P4, class P5, class P6> | |
| 1119 I* AddAndCast(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) { | |
| 1120 return I::cast(AddInstruction(new(zone()) I(p1, p2, p3, p4, p5, p6))); | |
| 1028 } | 1121 } |
| 1029 | 1122 |
| 1030 template<class I, class P1, class P2, class P3, | 1123 template<class I, class P1, class P2, class P3, |
| 1031 class P4, class P5, class P6, class P7> | 1124 class P4, class P5, class P6, class P7> |
| 1032 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) { | 1125 HInstruction* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) { |
| 1033 return static_cast<I*>(AddInstruction( | 1126 return AddInstruction(new(zone()) I(p1, p2, p3, p4, p5, p6, p7)); |
| 1034 new(zone()) I(p1, p2, p3, p4, p5, p6, p7))); | 1127 } |
| 1128 | |
| 1129 template<class I, class P1, class P2, class P3, | |
| 1130 class P4, class P5, class P6, class P7> | |
| 1131 I* AddAndCast(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) { | |
| 1132 return I::cast(AddInstruction(new(zone()) I(p1, p2, p3, p4, p5, p6, p7))); | |
| 1035 } | 1133 } |
| 1036 | 1134 |
| 1037 template<class I, class P1, class P2, class P3, class P4, | 1135 template<class I, class P1, class P2, class P3, class P4, |
| 1038 class P5, class P6, class P7, class P8> | 1136 class P5, class P6, class P7, class P8> |
| 1039 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { | 1137 HInstruction* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { |
| 1040 return static_cast<I*>(AddInstruction( | 1138 return AddInstruction(new(zone()) I(p1, p2, p3, p4, p5, p6, p7, p8)); |
| 1041 new(zone()) I(p1, p2, p3, p4, p5, p6, p7, p8))); | |
| 1042 } | 1139 } |
| 1043 | 1140 |
| 1141 template<class I, class P1, class P2, class P3, class P4, | |
| 1142 class P5, class P6, class P7, class P8> | |
| 1143 I* AddAndCast(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { | |
| 1144 return I::cast( | |
| 1145 AddInstruction(new(zone()) I(p1, p2, p3, p4, p5, p6, p7, p8))); | |
| 1146 } | |
| 1147 | |
| 1148 void AddSimulate(BailoutId id, | |
| 1149 RemovableSimulate removable = FIXED_SIMULATE); | |
| 1150 | |
| 1044 void IncrementInNoSideEffectsScope() { | 1151 void IncrementInNoSideEffectsScope() { |
| 1045 no_side_effects_scope_count_++; | 1152 no_side_effects_scope_count_++; |
| 1046 } | 1153 } |
| 1047 | 1154 |
| 1048 void DecrementInNoSideEffectsScope() { | 1155 void DecrementInNoSideEffectsScope() { |
| 1049 no_side_effects_scope_count_--; | 1156 no_side_effects_scope_count_--; |
| 1050 } | 1157 } |
| 1051 | 1158 |
| 1052 protected: | 1159 protected: |
| 1053 virtual bool BuildGraph() = 0; | 1160 virtual bool BuildGraph() = 0; |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1082 HValue* object, | 1189 HValue* object, |
| 1083 HValue* key, | 1190 HValue* key, |
| 1084 HValue* val, | 1191 HValue* val, |
| 1085 HCheckMaps* mapcheck, | 1192 HCheckMaps* mapcheck, |
| 1086 bool is_js_array, | 1193 bool is_js_array, |
| 1087 ElementsKind elements_kind, | 1194 ElementsKind elements_kind, |
| 1088 bool is_store, | 1195 bool is_store, |
| 1089 LoadKeyedHoleMode load_mode, | 1196 LoadKeyedHoleMode load_mode, |
| 1090 KeyedAccessStoreMode store_mode); | 1197 KeyedAccessStoreMode store_mode); |
| 1091 | 1198 |
| 1092 HLoadNamedField* AddLoad( | |
| 1093 HValue *object, | |
| 1094 HObjectAccess access, | |
| 1095 HValue *typecheck = NULL); | |
| 1096 | |
| 1097 HLoadNamedField* BuildLoadNamedField( | 1199 HLoadNamedField* BuildLoadNamedField( |
| 1098 HValue* object, | 1200 HValue* object, |
| 1099 HObjectAccess access, | 1201 HObjectAccess access); |
| 1100 Representation representation); | |
| 1101 | 1202 |
| 1102 HInstruction* AddExternalArrayElementAccess( | 1203 HInstruction* AddExternalArrayElementAccess( |
| 1103 HValue* external_elements, | 1204 HValue* external_elements, |
| 1104 HValue* checked_key, | 1205 HValue* checked_key, |
| 1105 HValue* val, | 1206 HValue* val, |
| 1106 HValue* dependency, | 1207 HValue* dependency, |
| 1107 ElementsKind elements_kind, | 1208 ElementsKind elements_kind, |
| 1108 bool is_store); | 1209 bool is_store); |
| 1109 | 1210 |
| 1110 HInstruction* AddFastElementAccess( | 1211 HInstruction* AddFastElementAccess( |
| 1111 HValue* elements, | 1212 HValue* elements, |
| 1112 HValue* checked_key, | 1213 HValue* checked_key, |
| 1113 HValue* val, | 1214 HValue* val, |
| 1114 HValue* dependency, | 1215 HValue* dependency, |
| 1115 ElementsKind elements_kind, | 1216 ElementsKind elements_kind, |
| 1116 bool is_store, | 1217 bool is_store, |
| 1117 LoadKeyedHoleMode load_mode, | 1218 LoadKeyedHoleMode load_mode, |
| 1118 KeyedAccessStoreMode store_mode); | 1219 KeyedAccessStoreMode store_mode); |
| 1119 | 1220 |
| 1120 HLoadNamedField* BuildLoadNamedField(HValue* object, HObjectAccess access); | |
| 1121 HStoreNamedField* AddStore(HValue *object, HObjectAccess access, HValue *val); | |
| 1122 HStoreNamedField* AddStoreMapConstant(HValue *object, Handle<Map>); | 1221 HStoreNamedField* AddStoreMapConstant(HValue *object, Handle<Map>); |
| 1123 HLoadNamedField* AddLoadElements(HValue *object, HValue *typecheck = NULL); | 1222 HLoadNamedField* AddLoadElements(HValue *object, HValue *typecheck = NULL); |
| 1124 HLoadNamedField* AddLoadFixedArrayLength(HValue *object); | 1223 HLoadNamedField* AddLoadFixedArrayLength(HValue *object); |
| 1125 | 1224 |
| 1126 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin, HValue* context); | 1225 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin); |
| 1127 | 1226 |
| 1128 HValue* TruncateToNumber(HValue* value, Handle<Type>* expected); | 1227 HValue* TruncateToNumber(HValue* value, Handle<Type>* expected); |
| 1129 | 1228 |
| 1130 void PushAndAdd(HInstruction* instr); | 1229 void PushAndAdd(HInstruction* instr); |
| 1131 | 1230 |
| 1132 void FinishExitWithHardDeoptimization(HBasicBlock* continuation); | 1231 void FinishExitWithHardDeoptimization(HBasicBlock* continuation); |
| 1133 | 1232 |
| 1134 void AddIncrementCounter(StatsCounter* counter, | 1233 void AddIncrementCounter(StatsCounter* counter, |
| 1135 HValue* context); | 1234 HValue* context); |
| 1136 | 1235 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1307 builder_->IncrementInNoSideEffectsScope(); | 1406 builder_->IncrementInNoSideEffectsScope(); |
| 1308 } | 1407 } |
| 1309 ~NoObservableSideEffectsScope() { | 1408 ~NoObservableSideEffectsScope() { |
| 1310 builder_->DecrementInNoSideEffectsScope(); | 1409 builder_->DecrementInNoSideEffectsScope(); |
| 1311 } | 1410 } |
| 1312 | 1411 |
| 1313 private: | 1412 private: |
| 1314 HGraphBuilder* builder_; | 1413 HGraphBuilder* builder_; |
| 1315 }; | 1414 }; |
| 1316 | 1415 |
| 1317 HValue* BuildNewElementsCapacity(HValue* context, | 1416 HValue* BuildNewElementsCapacity(HValue* old_capacity); |
| 1318 HValue* old_capacity); | |
| 1319 | 1417 |
| 1320 void BuildNewSpaceArrayCheck(HValue* length, | 1418 void BuildNewSpaceArrayCheck(HValue* length, |
| 1321 ElementsKind kind); | 1419 ElementsKind kind); |
| 1322 | 1420 |
| 1323 class JSArrayBuilder { | 1421 class JSArrayBuilder { |
| 1324 public: | 1422 public: |
| 1325 JSArrayBuilder(HGraphBuilder* builder, | 1423 JSArrayBuilder(HGraphBuilder* builder, |
| 1326 ElementsKind kind, | 1424 ElementsKind kind, |
| 1327 HValue* allocation_site_payload, | 1425 HValue* allocation_site_payload, |
| 1328 HValue* constructor_function, | 1426 HValue* constructor_function, |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1342 int elements_size() const { | 1440 int elements_size() const { |
| 1343 return IsFastDoubleElementsKind(kind_) ? kDoubleSize : kPointerSize; | 1441 return IsFastDoubleElementsKind(kind_) ? kDoubleSize : kPointerSize; |
| 1344 } | 1442 } |
| 1345 HGraphBuilder* builder() { return builder_; } | 1443 HGraphBuilder* builder() { return builder_; } |
| 1346 HGraph* graph() { return builder_->graph(); } | 1444 HGraph* graph() { return builder_->graph(); } |
| 1347 int initial_capacity() { | 1445 int initial_capacity() { |
| 1348 STATIC_ASSERT(JSArray::kPreallocatedArrayElements > 0); | 1446 STATIC_ASSERT(JSArray::kPreallocatedArrayElements > 0); |
| 1349 return JSArray::kPreallocatedArrayElements; | 1447 return JSArray::kPreallocatedArrayElements; |
| 1350 } | 1448 } |
| 1351 | 1449 |
| 1352 HValue* EmitMapCode(HValue* context); | 1450 HValue* EmitMapCode(); |
| 1353 HValue* EmitInternalMapCode(); | 1451 HValue* EmitInternalMapCode(); |
| 1354 HValue* EstablishEmptyArrayAllocationSize(); | 1452 HValue* EstablishEmptyArrayAllocationSize(); |
| 1355 HValue* EstablishAllocationSize(HValue* length_node); | 1453 HValue* EstablishAllocationSize(HValue* length_node); |
| 1356 HValue* AllocateArray(HValue* size_in_bytes, HValue* capacity, | 1454 HValue* AllocateArray(HValue* size_in_bytes, HValue* capacity, |
| 1357 HValue* length_field, bool fill_with_hole); | 1455 HValue* length_field, bool fill_with_hole); |
| 1358 | 1456 |
| 1359 HGraphBuilder* builder_; | 1457 HGraphBuilder* builder_; |
| 1360 ElementsKind kind_; | 1458 ElementsKind kind_; |
| 1361 AllocationSiteMode mode_; | 1459 AllocationSiteMode mode_; |
| 1362 HValue* allocation_site_payload_; | 1460 HValue* allocation_site_payload_; |
| 1363 HValue* constructor_function_; | 1461 HValue* constructor_function_; |
| 1364 HInnerAllocatedObject* elements_location_; | 1462 HInnerAllocatedObject* elements_location_; |
| 1365 }; | 1463 }; |
| 1366 | 1464 |
| 1367 HValue* BuildAllocateElements(HValue* context, | 1465 HValue* BuildAllocateElements(ElementsKind kind, |
| 1368 ElementsKind kind, | |
| 1369 HValue* capacity); | 1466 HValue* capacity); |
| 1370 | 1467 |
| 1371 void BuildInitializeElementsHeader(HValue* elements, | 1468 void BuildInitializeElementsHeader(HValue* elements, |
| 1372 ElementsKind kind, | 1469 ElementsKind kind, |
| 1373 HValue* capacity); | 1470 HValue* capacity); |
| 1374 | 1471 |
| 1375 HValue* BuildAllocateElementsAndInitializeElementsHeader(HValue* context, | 1472 HValue* BuildAllocateElementsAndInitializeElementsHeader(ElementsKind kind, |
| 1376 ElementsKind kind, | |
| 1377 HValue* capacity); | 1473 HValue* capacity); |
| 1378 | 1474 |
| 1379 // array must have been allocated with enough room for | 1475 // array must have been allocated with enough room for |
| 1380 // 1) the JSArray, 2) a AllocationMemento if mode requires it, | 1476 // 1) the JSArray, 2) a AllocationMemento if mode requires it, |
| 1381 // 3) a FixedArray or FixedDoubleArray. | 1477 // 3) a FixedArray or FixedDoubleArray. |
| 1382 // A pointer to the Fixed(Double)Array is returned. | 1478 // A pointer to the Fixed(Double)Array is returned. |
| 1383 HInnerAllocatedObject* BuildJSArrayHeader(HValue* array, | 1479 HInnerAllocatedObject* BuildJSArrayHeader(HValue* array, |
| 1384 HValue* array_map, | 1480 HValue* array_map, |
| 1385 AllocationSiteMode mode, | 1481 AllocationSiteMode mode, |
| 1386 ElementsKind elements_kind, | 1482 ElementsKind elements_kind, |
| 1387 HValue* allocation_site_payload, | 1483 HValue* allocation_site_payload, |
| 1388 HValue* length_field); | 1484 HValue* length_field); |
| 1389 | 1485 |
| 1390 HValue* BuildGrowElementsCapacity(HValue* object, | 1486 HValue* BuildGrowElementsCapacity(HValue* object, |
| 1391 HValue* elements, | 1487 HValue* elements, |
| 1392 ElementsKind kind, | 1488 ElementsKind kind, |
| 1393 ElementsKind new_kind, | 1489 ElementsKind new_kind, |
| 1394 HValue* length, | 1490 HValue* length, |
| 1395 HValue* new_capacity); | 1491 HValue* new_capacity); |
| 1396 | 1492 |
| 1397 void BuildFillElementsWithHole(HValue* context, | 1493 void BuildFillElementsWithHole(HValue* elements, |
| 1398 HValue* elements, | |
| 1399 ElementsKind elements_kind, | 1494 ElementsKind elements_kind, |
| 1400 HValue* from, | 1495 HValue* from, |
| 1401 HValue* to); | 1496 HValue* to); |
| 1402 | 1497 |
| 1403 void BuildCopyElements(HValue* context, | 1498 void BuildCopyElements(HValue* from_elements, |
| 1404 HValue* from_elements, | |
| 1405 ElementsKind from_elements_kind, | 1499 ElementsKind from_elements_kind, |
| 1406 HValue* to_elements, | 1500 HValue* to_elements, |
| 1407 ElementsKind to_elements_kind, | 1501 ElementsKind to_elements_kind, |
| 1408 HValue* length, | 1502 HValue* length, |
| 1409 HValue* capacity); | 1503 HValue* capacity); |
| 1410 | 1504 |
| 1411 HValue* BuildCloneShallowArray(HContext* context, | 1505 HValue* BuildCloneShallowArray(HValue* boilerplate, |
| 1412 HValue* boilerplate, | |
| 1413 HValue* allocation_site, | 1506 HValue* allocation_site, |
| 1414 AllocationSiteMode mode, | 1507 AllocationSiteMode mode, |
| 1415 ElementsKind kind, | 1508 ElementsKind kind, |
| 1416 int length); | 1509 int length); |
| 1417 | 1510 |
| 1511 HValue* BuildKeyHash(HValue* key); | |
|
Toon Verwaest
2013/07/31 12:56:37
Left-over declaration from a different CL?
danno
2013/07/31 14:10:09
Done.
| |
| 1512 | |
| 1418 HInstruction* BuildUnaryMathOp( | 1513 HInstruction* BuildUnaryMathOp( |
| 1419 HValue* value, Handle<Type> type, Token::Value token); | 1514 HValue* value, Handle<Type> type, Token::Value token); |
| 1420 | 1515 |
| 1421 void BuildCompareNil( | 1516 void BuildCompareNil( |
| 1422 HValue* value, | 1517 HValue* value, |
| 1423 Handle<Type> type, | 1518 Handle<Type> type, |
| 1424 int position, | 1519 int position, |
| 1425 HIfContinuation* continuation); | 1520 HIfContinuation* continuation); |
| 1426 | 1521 |
| 1427 HValue* BuildCreateAllocationMemento(HValue* previous_object, | 1522 HValue* BuildCreateAllocationMemento(HValue* previous_object, |
| 1428 int previous_object_size, | 1523 int previous_object_size, |
| 1429 HValue* payload); | 1524 HValue* payload); |
| 1430 | 1525 |
| 1431 HInstruction* BuildGetNativeContext(HValue* context); | 1526 HInstruction* BuildGetNativeContext(); |
| 1432 HInstruction* BuildGetArrayFunction(HValue* context); | 1527 HInstruction* BuildGetArrayFunction(); |
| 1433 | 1528 |
| 1434 private: | 1529 private: |
| 1435 HGraphBuilder(); | 1530 HGraphBuilder(); |
| 1436 | 1531 |
| 1437 void PadEnvironmentForContinuation(HBasicBlock* from, | 1532 void PadEnvironmentForContinuation(HBasicBlock* from, |
| 1438 HBasicBlock* continuation); | 1533 HBasicBlock* continuation); |
| 1439 | 1534 |
| 1440 CompilationInfo* info_; | 1535 CompilationInfo* info_; |
| 1441 HGraph* graph_; | 1536 HGraph* graph_; |
| 1442 HBasicBlock* current_block_; | 1537 HBasicBlock* current_block_; |
| 1443 int no_side_effects_scope_count_; | 1538 int no_side_effects_scope_count_; |
| 1444 }; | 1539 }; |
| 1445 | 1540 |
| 1446 | 1541 |
| 1447 template<> | 1542 template<> |
| 1448 inline HDeoptimize* HGraphBuilder::Add(Deoptimizer::BailoutType type) { | 1543 inline HInstruction* HGraphBuilder::Add<HDeoptimize>( |
| 1544 Deoptimizer::BailoutType type) { | |
| 1449 if (type == Deoptimizer::SOFT) { | 1545 if (type == Deoptimizer::SOFT) { |
| 1450 isolate()->counters()->soft_deopts_requested()->Increment(); | 1546 isolate()->counters()->soft_deopts_requested()->Increment(); |
| 1451 if (FLAG_always_opt) return NULL; | 1547 if (FLAG_always_opt) return NULL; |
| 1452 } | 1548 } |
| 1453 if (current_block()->IsDeoptimizing()) return NULL; | 1549 if (current_block()->IsDeoptimizing()) return NULL; |
| 1454 HDeoptimize* instr = new(zone()) HDeoptimize(type); | 1550 HDeoptimize* instr = NewAndCast<HDeoptimize>(type); |
| 1455 AddInstruction(instr); | 1551 AddInstruction(instr); |
| 1456 if (type == Deoptimizer::SOFT) { | 1552 if (type == Deoptimizer::SOFT) { |
| 1457 isolate()->counters()->soft_deopts_inserted()->Increment(); | 1553 isolate()->counters()->soft_deopts_inserted()->Increment(); |
| 1458 graph()->set_has_soft_deoptimize(true); | 1554 graph()->set_has_soft_deoptimize(true); |
| 1459 } | 1555 } |
| 1460 current_block()->MarkAsDeoptimizing(); | 1556 current_block()->MarkAsDeoptimizing(); |
| 1461 return instr; | 1557 return instr; |
| 1462 } | 1558 } |
| 1463 | 1559 |
| 1464 | 1560 |
| 1465 template<> | 1561 template<> |
| 1466 inline HSimulate* HGraphBuilder::Add(BailoutId id, | 1562 inline HInstruction* HGraphBuilder::Add<HSimulate>( |
| 1467 RemovableSimulate removable) { | 1563 BailoutId id, |
| 1564 RemovableSimulate removable) { | |
| 1468 HSimulate* instr = current_block()->CreateSimulate(id, removable); | 1565 HSimulate* instr = current_block()->CreateSimulate(id, removable); |
| 1469 AddInstruction(instr); | 1566 AddInstruction(instr); |
| 1470 return instr; | 1567 return instr; |
| 1471 } | 1568 } |
| 1472 | 1569 |
| 1473 | 1570 |
| 1474 template<> | 1571 template<> |
| 1475 inline HSimulate* HGraphBuilder::Add(BailoutId id) { | 1572 inline HInstruction* HGraphBuilder::New<HLoadNamedField>( |
| 1573 HValue* object, HObjectAccess access) { | |
| 1574 return New<HLoadNamedField>(object, access, static_cast<HValue*>(NULL)); | |
| 1575 } | |
| 1576 | |
| 1577 | |
| 1578 template<> | |
| 1579 inline HInstruction* HGraphBuilder::Add<HLoadNamedField>( | |
| 1580 HValue* object, HObjectAccess access) { | |
| 1581 return Add<HLoadNamedField>(object, access, static_cast<HValue*>(NULL)); | |
| 1582 } | |
| 1583 | |
| 1584 | |
| 1585 template<> | |
| 1586 inline HInstruction* HGraphBuilder::Add<HSimulate>(BailoutId id) { | |
| 1476 return Add<HSimulate>(id, FIXED_SIMULATE); | 1587 return Add<HSimulate>(id, FIXED_SIMULATE); |
| 1477 } | 1588 } |
| 1478 | 1589 |
| 1479 | 1590 |
| 1480 template<> | 1591 template<> |
| 1481 inline HReturn* HGraphBuilder::Add(HValue* value) { | 1592 inline HInstruction* HGraphBuilder::Add<HReturn>(HValue* value) { |
| 1482 HValue* context = environment()->LookupContext(); | |
| 1483 int num_parameters = graph()->info()->num_parameters(); | 1593 int num_parameters = graph()->info()->num_parameters(); |
| 1484 HValue* params = Add<HConstant>(num_parameters); | 1594 HValue* params = Add<HConstant>(num_parameters); |
| 1485 HReturn* return_instruction = new(graph()->zone()) | 1595 HReturn* return_instruction = NewAndCast<HReturn>(value, params); |
| 1486 HReturn(value, context, params); | |
| 1487 current_block()->FinishExit(return_instruction); | 1596 current_block()->FinishExit(return_instruction); |
| 1488 return return_instruction; | 1597 return return_instruction; |
| 1489 } | 1598 } |
| 1490 | 1599 |
| 1491 | 1600 |
| 1492 template<> | 1601 template<> |
| 1493 inline HReturn* HGraphBuilder::Add(HConstant* p1) { | 1602 inline HInstruction* HGraphBuilder::Add<HReturn>(HConstant* value) { |
| 1494 return Add<HReturn>(static_cast<HValue*>(p1)); | 1603 return Add<HReturn>(static_cast<HValue*>(value)); |
| 1495 } | 1604 } |
| 1496 | 1605 |
| 1497 | 1606 |
| 1607 template<> | |
| 1608 inline HInstruction* HGraphBuilder::New<HContext>() { | |
| 1609 return HContext::New(zone()); | |
| 1610 } | |
| 1611 | |
| 1612 | |
| 1498 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { | 1613 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { |
| 1499 public: | 1614 public: |
| 1500 // A class encapsulating (lazily-allocated) break and continue blocks for | 1615 // A class encapsulating (lazily-allocated) break and continue blocks for |
| 1501 // a breakable statement. Separated from BreakAndContinueScope so that it | 1616 // a breakable statement. Separated from BreakAndContinueScope so that it |
| 1502 // can have a separate lifetime. | 1617 // can have a separate lifetime. |
| 1503 class BreakAndContinueInfo BASE_EMBEDDED { | 1618 class BreakAndContinueInfo BASE_EMBEDDED { |
| 1504 public: | 1619 public: |
| 1505 explicit BreakAndContinueInfo(BreakableStatement* target, | 1620 explicit BreakAndContinueInfo(BreakableStatement* target, |
| 1506 int drop_extra = 0) | 1621 int drop_extra = 0) |
| 1507 : target_(target), | 1622 : target_(target), |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1553 explicit HOptimizedGraphBuilder(CompilationInfo* info); | 1668 explicit HOptimizedGraphBuilder(CompilationInfo* info); |
| 1554 | 1669 |
| 1555 virtual bool BuildGraph(); | 1670 virtual bool BuildGraph(); |
| 1556 | 1671 |
| 1557 // Simple accessors. | 1672 // Simple accessors. |
| 1558 BreakAndContinueScope* break_scope() const { return break_scope_; } | 1673 BreakAndContinueScope* break_scope() const { return break_scope_; } |
| 1559 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } | 1674 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } |
| 1560 | 1675 |
| 1561 bool inline_bailout() { return inline_bailout_; } | 1676 bool inline_bailout() { return inline_bailout_; } |
| 1562 | 1677 |
| 1678 HValue* context() { return environment()->context(); } | |
| 1679 | |
| 1563 void Bailout(const char* reason); | 1680 void Bailout(const char* reason); |
| 1564 | 1681 |
| 1565 HBasicBlock* CreateJoin(HBasicBlock* first, | 1682 HBasicBlock* CreateJoin(HBasicBlock* first, |
| 1566 HBasicBlock* second, | 1683 HBasicBlock* second, |
| 1567 BailoutId join_id); | 1684 BailoutId join_id); |
| 1568 | 1685 |
| 1569 FunctionState* function_state() const { return function_state_; } | 1686 FunctionState* function_state() const { return function_state_; } |
| 1570 | 1687 |
| 1571 void VisitDeclarations(ZoneList<Declaration*>* declarations); | 1688 void VisitDeclarations(ZoneList<Declaration*>* declarations); |
| 1572 | 1689 |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1828 HValue* receiver, | 1945 HValue* receiver, |
| 1829 SmallMapList* types, | 1946 SmallMapList* types, |
| 1830 Handle<String> name); | 1947 Handle<String> name); |
| 1831 void HandleLiteralCompareTypeof(CompareOperation* expr, | 1948 void HandleLiteralCompareTypeof(CompareOperation* expr, |
| 1832 Expression* sub_expr, | 1949 Expression* sub_expr, |
| 1833 Handle<String> check); | 1950 Handle<String> check); |
| 1834 void HandleLiteralCompareNil(CompareOperation* expr, | 1951 void HandleLiteralCompareNil(CompareOperation* expr, |
| 1835 Expression* sub_expr, | 1952 Expression* sub_expr, |
| 1836 NilValue nil); | 1953 NilValue nil); |
| 1837 | 1954 |
| 1838 HInstruction* BuildStringCharCodeAt(HValue* context, | 1955 HInstruction* BuildStringCharCodeAt(HValue* string, |
| 1839 HValue* string, | |
| 1840 HValue* index); | 1956 HValue* index); |
| 1841 HInstruction* BuildBinaryOperation(BinaryOperation* expr, | 1957 HInstruction* BuildBinaryOperation(BinaryOperation* expr, |
| 1842 HValue* left, | 1958 HValue* left, |
| 1843 HValue* right); | 1959 HValue* right); |
| 1844 HInstruction* BuildIncrement(bool returns_original_input, | 1960 HInstruction* BuildIncrement(bool returns_original_input, |
| 1845 CountOperation* expr); | 1961 CountOperation* expr); |
| 1846 HInstruction* BuildLoadKeyedGeneric(HValue* object, | 1962 HInstruction* BuildLoadKeyedGeneric(HValue* object, |
| 1847 HValue* key); | 1963 HValue* key); |
| 1848 | 1964 |
| 1849 HInstruction* TryBuildConsolidatedElementLoad(HValue* object, | 1965 HInstruction* TryBuildConsolidatedElementLoad(HValue* object, |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2164 EmbeddedVector<char, 64> filename_; | 2280 EmbeddedVector<char, 64> filename_; |
| 2165 HeapStringAllocator string_allocator_; | 2281 HeapStringAllocator string_allocator_; |
| 2166 StringStream trace_; | 2282 StringStream trace_; |
| 2167 int indent_; | 2283 int indent_; |
| 2168 }; | 2284 }; |
| 2169 | 2285 |
| 2170 | 2286 |
| 2171 } } // namespace v8::internal | 2287 } } // namespace v8::internal |
| 2172 | 2288 |
| 2173 #endif // V8_HYDROGEN_H_ | 2289 #endif // V8_HYDROGEN_H_ |
| OLD | NEW |