Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: src/hydrogen.h

Issue 21356002: Improve instruction creating/adding shorthand in HGraphBuilder (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/code-stubs-hydrogen.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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* NewUncasted() { return I::New(zone(), context()); }
1000
1001 template<class I>
1002 I* New() { return I::cast(NewUncasted<I>()); }
1003
1004 template<class I>
1005 HInstruction* AddUncasted() { return AddInstruction(NewUncasted<I>());}
1006
1007 template<class I>
1008 I* Add() { return I::cast(AddUncasted<I>());}
1009
1010 template<class I, class P1>
1011 HInstruction* NewUncasted(P1 p1) {
1012 return I::New(zone(), context(), p1);
1013 }
1014
1015 template<class I, class P1>
1016 I* New(P1 p1) { return I::cast(NewUncasted<I>(p1)); }
1017
1018 template<class I, class P1>
1019 HInstruction* AddUncasted(P1 p1) {
1020 HInstruction* result = AddInstruction(NewUncasted<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 }
998 1027
999 template<class I, class P1> 1028 template<class I, class P1>
1000 I* Add(P1 p1) { 1029 I* Add(P1 p1) {
1001 return static_cast<I*>(AddInstruction(new(zone()) I(p1))); 1030 return I::cast(AddUncasted<I>(p1));
1031 }
1032
1033 template<class I, class P1, class P2>
1034 HInstruction* NewUncasted(P1 p1, P2 p2) {
1035 return I::New(zone(), context(), p1, p2);
1036 }
1037
1038 template<class I, class P1, class P2>
1039 I* New(P1 p1, P2 p2) {
1040 return I::cast(NewUncasted<I>(p1, p2));
1041 }
1042
1043 template<class I, class P1, class P2>
1044 HInstruction* AddUncasted(P1 p1, P2 p2) {
1045 HInstruction* result = AddInstruction(NewUncasted<I>(p1, p2));
1046 // Specializations must have their parameters properly casted
1047 // to avoid landing here.
1048 ASSERT(!result->IsSimulate());
1049 return result;
1002 } 1050 }
1003 1051
1004 template<class I, class P1, class P2> 1052 template<class I, class P1, class P2>
1005 I* Add(P1 p1, P2 p2) { 1053 I* Add(P1 p1, P2 p2) {
1006 return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2))); 1054 return static_cast<I*>(AddUncasted<I>(p1, p2));
1055 }
1056
1057 template<class I, class P1, class P2, class P3>
1058 HInstruction* NewUncasted(P1 p1, P2 p2, P3 p3) {
1059 return I::New(zone(), context(), p1, p2, p3);
1060 }
1061
1062 template<class I, class P1, class P2, class P3>
1063 I* New(P1 p1, P2 p2, P3 p3) {
1064 return I::cast(NewUncasted<I>(p1, p2, p3));
1065 }
1066
1067 template<class I, class P1, class P2, class P3>
1068 HInstruction* AddUncasted(P1 p1, P2 p2, P3 p3) {
1069 return AddInstruction(NewUncasted<I>(p1, p2, p3));
1007 } 1070 }
1008 1071
1009 template<class I, class P1, class P2, class P3> 1072 template<class I, class P1, class P2, class P3>
1010 I* Add(P1 p1, P2 p2, P3 p3) { 1073 I* Add(P1 p1, P2 p2, P3 p3) {
1011 return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2, p3))); 1074 return I::cast(AddUncasted<I>(p1, p2, p3));
1075 }
1076
1077 template<class I, class P1, class P2, class P3, class P4>
1078 HInstruction* NewUncasted(P1 p1, P2 p2, P3 p3, P4 p4) {
1079 return I::New(zone(), context(), p1, p2, p3, p4);
1080 }
1081
1082 template<class I, class P1, class P2, class P3, class P4>
1083 I* New(P1 p1, P2 p2, P3 p3, P4 p4) {
1084 return I::cast(NewUncasted<I>(p1, p2, p3, p4));
1085 }
1086
1087 template<class I, class P1, class P2, class P3, class P4>
1088 HInstruction* AddUncasted(P1 p1, P2 p2, P3 p3, P4 p4) {
1089 return AddInstruction(NewUncasted<I>(p1, p2, p3, p4));
1012 } 1090 }
1013 1091
1014 template<class I, class P1, class P2, class P3, class P4> 1092 template<class I, class P1, class P2, class P3, class P4>
1015 I* Add(P1 p1, P2 p2, P3 p3, P4 p4) { 1093 I* Add(P1 p1, P2 p2, P3 p3, P4 p4) {
1016 return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2, p3, p4))); 1094 return I::cast(AddUncasted<I>(p1, p2, p3, p4));
1095 }
1096
1097 template<class I, class P1, class P2, class P3, class P4, class P5>
1098 HInstruction* NewUncasted(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) {
1099 return I::New(zone(), context(), p1, p2, p3, p4, p5);
1100 }
1101
1102 template<class I, class P1, class P2, class P3, class P4, class P5>
1103 I* New(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) {
1104 return I::cast(NewUncasted<I>(p1, p2, p3, p4, p5));
1105 }
1106
1107 template<class I, class P1, class P2, class P3, class P4, class P5>
1108 HInstruction* AddUncasted(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) {
1109 return AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5));
1017 } 1110 }
1018 1111
1019 template<class I, class P1, class P2, class P3, class P4, class P5> 1112 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) { 1113 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) {
1021 return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2, p3, p4, p5))); 1114 return I::cast(AddUncasted<I>(p1, p2, p3, p4, p5));
1115 }
1116
1117 template<class I, class P1, class P2, class P3, class P4, class P5, class P6>
1118 HInstruction* NewUncasted(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) {
1119 return I::New(zone(), context(), p1, p2, p3, p4, p5, p6);
1120 }
1121
1122 template<class I, class P1, class P2, class P3, class P4, class P5, class P6>
1123 I* New(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) {
1124 return I::cast(NewUncasted<I>(p1, p2, p3, p4, p5, p6));
1125 }
1126
1127 template<class I, class P1, class P2, class P3, class P4, class P5, class P6>
1128 HInstruction* AddUncasted(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) {
1129 return AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6));
1022 } 1130 }
1023 1131
1024 template<class I, class P1, class P2, class P3, class P4, class P5, class P6> 1132 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) { 1133 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) {
1026 return static_cast<I*>(AddInstruction( 1134 return I::cast(AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6)));
1027 new(zone()) I(p1, p2, p3, p4, p5, p6))); 1135 }
1136
1137 template<class I, class P1, class P2, class P3, class P4,
1138 class P5, class P6, class P7>
1139 HInstruction* NewUncasted(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) {
1140 return I::New(zone(), context(), p1, p2, p3, p4, p5, p6, p7);
1141 }
1142
1143 template<class I, class P1, class P2, class P3, class P4,
1144 class P5, class P6, class P7>
1145 I* New(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) {
1146 return I::cast(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7));
1147 }
1148
1149 template<class I, class P1, class P2, class P3,
1150 class P4, class P5, class P6, class P7>
1151 HInstruction* AddUncasted(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) {
1152 return AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7));
1028 } 1153 }
1029 1154
1030 template<class I, class P1, class P2, class P3, 1155 template<class I, class P1, class P2, class P3,
1031 class P4, class P5, class P6, class P7> 1156 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) { 1157 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) {
1033 return static_cast<I*>(AddInstruction( 1158 return I::cast(AddInstruction(NewUncasted<I>(p1, p2, p3, p4,
1034 new(zone()) I(p1, p2, p3, p4, p5, p6, p7))); 1159 p5, p6, p7)));
1160 }
1161
1162 template<class I, class P1, class P2, class P3, class P4,
1163 class P5, class P6, class P7, class P8>
1164 HInstruction* NewUncasted(P1 p1, P2 p2, P3 p3, P4 p4,
1165 P5 p5, P6 p6, P7 p7, P8 p8) {
1166 return I::New(zone(), context(), p1, p2, p3, p4, p5, p6, p7, p8);
1167 }
1168
1169 template<class I, class P1, class P2, class P3, class P4,
1170 class P5, class P6, class P7, class P8>
1171 I* New(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) {
1172 return I::cast(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7, p8));
1173 }
1174
1175 template<class I, class P1, class P2, class P3, class P4,
1176 class P5, class P6, class P7, class P8>
1177 HInstruction* AddUncasted(P1 p1, P2 p2, P3 p3, P4 p4,
1178 P5 p5, P6 p6, P7 p7, P8 p8) {
1179 return AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7, p8));
1035 } 1180 }
1036 1181
1037 template<class I, class P1, class P2, class P3, class P4, 1182 template<class I, class P1, class P2, class P3, class P4,
1038 class P5, class P6, class P7, class P8> 1183 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) { 1184 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) {
1040 return static_cast<I*>(AddInstruction( 1185 return I::cast(
1041 new(zone()) I(p1, p2, p3, p4, p5, p6, p7, p8))); 1186 AddInstruction(NewUncasted<I>(p1, p2, p3, p4, p5, p6, p7, p8)));
1042 } 1187 }
1188
1189 void AddSimulate(BailoutId id,
1190 RemovableSimulate removable = FIXED_SIMULATE);
1043 1191
1044 void IncrementInNoSideEffectsScope() { 1192 void IncrementInNoSideEffectsScope() {
1045 no_side_effects_scope_count_++; 1193 no_side_effects_scope_count_++;
1046 } 1194 }
1047 1195
1048 void DecrementInNoSideEffectsScope() { 1196 void DecrementInNoSideEffectsScope() {
1049 no_side_effects_scope_count_--; 1197 no_side_effects_scope_count_--;
1050 } 1198 }
1051 1199
1052 protected: 1200 protected:
(...skipping 29 matching lines...) Expand all
1082 HValue* object, 1230 HValue* object,
1083 HValue* key, 1231 HValue* key,
1084 HValue* val, 1232 HValue* val,
1085 HCheckMaps* mapcheck, 1233 HCheckMaps* mapcheck,
1086 bool is_js_array, 1234 bool is_js_array,
1087 ElementsKind elements_kind, 1235 ElementsKind elements_kind,
1088 bool is_store, 1236 bool is_store,
1089 LoadKeyedHoleMode load_mode, 1237 LoadKeyedHoleMode load_mode,
1090 KeyedAccessStoreMode store_mode); 1238 KeyedAccessStoreMode store_mode);
1091 1239
1092 HLoadNamedField* AddLoad(
1093 HValue *object,
1094 HObjectAccess access,
1095 HValue *typecheck = NULL);
1096
1097 HLoadNamedField* BuildLoadNamedField( 1240 HLoadNamedField* BuildLoadNamedField(
1098 HValue* object, 1241 HValue* object,
1099 HObjectAccess access, 1242 HObjectAccess access);
1100 Representation representation);
1101 1243
1102 HInstruction* AddExternalArrayElementAccess( 1244 HInstruction* AddExternalArrayElementAccess(
1103 HValue* external_elements, 1245 HValue* external_elements,
1104 HValue* checked_key, 1246 HValue* checked_key,
1105 HValue* val, 1247 HValue* val,
1106 HValue* dependency, 1248 HValue* dependency,
1107 ElementsKind elements_kind, 1249 ElementsKind elements_kind,
1108 bool is_store); 1250 bool is_store);
1109 1251
1110 HInstruction* AddFastElementAccess( 1252 HInstruction* AddFastElementAccess(
1111 HValue* elements, 1253 HValue* elements,
1112 HValue* checked_key, 1254 HValue* checked_key,
1113 HValue* val, 1255 HValue* val,
1114 HValue* dependency, 1256 HValue* dependency,
1115 ElementsKind elements_kind, 1257 ElementsKind elements_kind,
1116 bool is_store, 1258 bool is_store,
1117 LoadKeyedHoleMode load_mode, 1259 LoadKeyedHoleMode load_mode,
1118 KeyedAccessStoreMode store_mode); 1260 KeyedAccessStoreMode store_mode);
1119 1261
1120 HLoadNamedField* BuildLoadNamedField(HValue* object, HObjectAccess access);
1121 HStoreNamedField* AddStore(HValue *object, HObjectAccess access, HValue *val);
1122 HStoreNamedField* AddStoreMapConstant(HValue *object, Handle<Map>); 1262 HStoreNamedField* AddStoreMapConstant(HValue *object, Handle<Map>);
1123 HLoadNamedField* AddLoadElements(HValue *object, HValue *typecheck = NULL); 1263 HLoadNamedField* AddLoadElements(HValue *object, HValue *typecheck = NULL);
1124 HLoadNamedField* AddLoadFixedArrayLength(HValue *object); 1264 HLoadNamedField* AddLoadFixedArrayLength(HValue *object);
1125 1265
1126 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin, HValue* context); 1266 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin);
1127 1267
1128 HValue* TruncateToNumber(HValue* value, Handle<Type>* expected); 1268 HValue* TruncateToNumber(HValue* value, Handle<Type>* expected);
1129 1269
1130 void PushAndAdd(HInstruction* instr); 1270 void PushAndAdd(HInstruction* instr);
1131 1271
1132 void FinishExitWithHardDeoptimization(HBasicBlock* continuation); 1272 void FinishExitWithHardDeoptimization(HBasicBlock* continuation);
1133 1273
1134 void AddIncrementCounter(StatsCounter* counter, 1274 void AddIncrementCounter(StatsCounter* counter,
1135 HValue* context); 1275 HValue* context);
1136 1276
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 builder_->IncrementInNoSideEffectsScope(); 1447 builder_->IncrementInNoSideEffectsScope();
1308 } 1448 }
1309 ~NoObservableSideEffectsScope() { 1449 ~NoObservableSideEffectsScope() {
1310 builder_->DecrementInNoSideEffectsScope(); 1450 builder_->DecrementInNoSideEffectsScope();
1311 } 1451 }
1312 1452
1313 private: 1453 private:
1314 HGraphBuilder* builder_; 1454 HGraphBuilder* builder_;
1315 }; 1455 };
1316 1456
1317 HValue* BuildNewElementsCapacity(HValue* context, 1457 HValue* BuildNewElementsCapacity(HValue* old_capacity);
1318 HValue* old_capacity);
1319 1458
1320 void BuildNewSpaceArrayCheck(HValue* length, 1459 void BuildNewSpaceArrayCheck(HValue* length,
1321 ElementsKind kind); 1460 ElementsKind kind);
1322 1461
1323 class JSArrayBuilder { 1462 class JSArrayBuilder {
1324 public: 1463 public:
1325 JSArrayBuilder(HGraphBuilder* builder, 1464 JSArrayBuilder(HGraphBuilder* builder,
1326 ElementsKind kind, 1465 ElementsKind kind,
1327 HValue* allocation_site_payload, 1466 HValue* allocation_site_payload,
1328 HValue* constructor_function, 1467 HValue* constructor_function,
(...skipping 13 matching lines...) Expand all
1342 int elements_size() const { 1481 int elements_size() const {
1343 return IsFastDoubleElementsKind(kind_) ? kDoubleSize : kPointerSize; 1482 return IsFastDoubleElementsKind(kind_) ? kDoubleSize : kPointerSize;
1344 } 1483 }
1345 HGraphBuilder* builder() { return builder_; } 1484 HGraphBuilder* builder() { return builder_; }
1346 HGraph* graph() { return builder_->graph(); } 1485 HGraph* graph() { return builder_->graph(); }
1347 int initial_capacity() { 1486 int initial_capacity() {
1348 STATIC_ASSERT(JSArray::kPreallocatedArrayElements > 0); 1487 STATIC_ASSERT(JSArray::kPreallocatedArrayElements > 0);
1349 return JSArray::kPreallocatedArrayElements; 1488 return JSArray::kPreallocatedArrayElements;
1350 } 1489 }
1351 1490
1352 HValue* EmitMapCode(HValue* context); 1491 HValue* EmitMapCode();
1353 HValue* EmitInternalMapCode(); 1492 HValue* EmitInternalMapCode();
1354 HValue* EstablishEmptyArrayAllocationSize(); 1493 HValue* EstablishEmptyArrayAllocationSize();
1355 HValue* EstablishAllocationSize(HValue* length_node); 1494 HValue* EstablishAllocationSize(HValue* length_node);
1356 HValue* AllocateArray(HValue* size_in_bytes, HValue* capacity, 1495 HValue* AllocateArray(HValue* size_in_bytes, HValue* capacity,
1357 HValue* length_field, bool fill_with_hole); 1496 HValue* length_field, bool fill_with_hole);
1358 1497
1359 HGraphBuilder* builder_; 1498 HGraphBuilder* builder_;
1360 ElementsKind kind_; 1499 ElementsKind kind_;
1361 AllocationSiteMode mode_; 1500 AllocationSiteMode mode_;
1362 HValue* allocation_site_payload_; 1501 HValue* allocation_site_payload_;
1363 HValue* constructor_function_; 1502 HValue* constructor_function_;
1364 HInnerAllocatedObject* elements_location_; 1503 HInnerAllocatedObject* elements_location_;
1365 }; 1504 };
1366 1505
1367 HValue* BuildAllocateElements(HValue* context, 1506 HValue* BuildAllocateElements(ElementsKind kind,
1368 ElementsKind kind,
1369 HValue* capacity); 1507 HValue* capacity);
1370 1508
1371 void BuildInitializeElementsHeader(HValue* elements, 1509 void BuildInitializeElementsHeader(HValue* elements,
1372 ElementsKind kind, 1510 ElementsKind kind,
1373 HValue* capacity); 1511 HValue* capacity);
1374 1512
1375 HValue* BuildAllocateElementsAndInitializeElementsHeader(HValue* context, 1513 HValue* BuildAllocateElementsAndInitializeElementsHeader(ElementsKind kind,
1376 ElementsKind kind,
1377 HValue* capacity); 1514 HValue* capacity);
1378 1515
1379 // array must have been allocated with enough room for 1516 // array must have been allocated with enough room for
1380 // 1) the JSArray, 2) a AllocationMemento if mode requires it, 1517 // 1) the JSArray, 2) a AllocationMemento if mode requires it,
1381 // 3) a FixedArray or FixedDoubleArray. 1518 // 3) a FixedArray or FixedDoubleArray.
1382 // A pointer to the Fixed(Double)Array is returned. 1519 // A pointer to the Fixed(Double)Array is returned.
1383 HInnerAllocatedObject* BuildJSArrayHeader(HValue* array, 1520 HInnerAllocatedObject* BuildJSArrayHeader(HValue* array,
1384 HValue* array_map, 1521 HValue* array_map,
1385 AllocationSiteMode mode, 1522 AllocationSiteMode mode,
1386 ElementsKind elements_kind, 1523 ElementsKind elements_kind,
1387 HValue* allocation_site_payload, 1524 HValue* allocation_site_payload,
1388 HValue* length_field); 1525 HValue* length_field);
1389 1526
1390 HValue* BuildGrowElementsCapacity(HValue* object, 1527 HValue* BuildGrowElementsCapacity(HValue* object,
1391 HValue* elements, 1528 HValue* elements,
1392 ElementsKind kind, 1529 ElementsKind kind,
1393 ElementsKind new_kind, 1530 ElementsKind new_kind,
1394 HValue* length, 1531 HValue* length,
1395 HValue* new_capacity); 1532 HValue* new_capacity);
1396 1533
1397 void BuildFillElementsWithHole(HValue* context, 1534 void BuildFillElementsWithHole(HValue* elements,
1398 HValue* elements,
1399 ElementsKind elements_kind, 1535 ElementsKind elements_kind,
1400 HValue* from, 1536 HValue* from,
1401 HValue* to); 1537 HValue* to);
1402 1538
1403 void BuildCopyElements(HValue* context, 1539 void BuildCopyElements(HValue* from_elements,
1404 HValue* from_elements,
1405 ElementsKind from_elements_kind, 1540 ElementsKind from_elements_kind,
1406 HValue* to_elements, 1541 HValue* to_elements,
1407 ElementsKind to_elements_kind, 1542 ElementsKind to_elements_kind,
1408 HValue* length, 1543 HValue* length,
1409 HValue* capacity); 1544 HValue* capacity);
1410 1545
1411 HValue* BuildCloneShallowArray(HContext* context, 1546 HValue* BuildCloneShallowArray(HValue* boilerplate,
1412 HValue* boilerplate,
1413 HValue* allocation_site, 1547 HValue* allocation_site,
1414 AllocationSiteMode mode, 1548 AllocationSiteMode mode,
1415 ElementsKind kind, 1549 ElementsKind kind,
1416 int length); 1550 int length);
1417 1551
1418 HInstruction* BuildUnaryMathOp( 1552 HInstruction* BuildUnaryMathOp(
1419 HValue* value, Handle<Type> type, Token::Value token); 1553 HValue* value, Handle<Type> type, Token::Value token);
1420 1554
1421 void BuildCompareNil( 1555 void BuildCompareNil(
1422 HValue* value, 1556 HValue* value,
1423 Handle<Type> type, 1557 Handle<Type> type,
1424 int position, 1558 int position,
1425 HIfContinuation* continuation); 1559 HIfContinuation* continuation);
1426 1560
1427 HValue* BuildCreateAllocationMemento(HValue* previous_object, 1561 HValue* BuildCreateAllocationMemento(HValue* previous_object,
1428 int previous_object_size, 1562 int previous_object_size,
1429 HValue* payload); 1563 HValue* payload);
1430 1564
1431 HInstruction* BuildGetNativeContext(HValue* context); 1565 HInstruction* BuildGetNativeContext();
1432 HInstruction* BuildGetArrayFunction(HValue* context); 1566 HInstruction* BuildGetArrayFunction();
1433 1567
1434 private: 1568 private:
1435 HGraphBuilder(); 1569 HGraphBuilder();
1436 1570
1437 void PadEnvironmentForContinuation(HBasicBlock* from, 1571 void PadEnvironmentForContinuation(HBasicBlock* from,
1438 HBasicBlock* continuation); 1572 HBasicBlock* continuation);
1439 1573
1440 CompilationInfo* info_; 1574 CompilationInfo* info_;
1441 HGraph* graph_; 1575 HGraph* graph_;
1442 HBasicBlock* current_block_; 1576 HBasicBlock* current_block_;
1443 int no_side_effects_scope_count_; 1577 int no_side_effects_scope_count_;
1444 }; 1578 };
1445 1579
1446 1580
1447 template<> 1581 template<>
1448 inline HDeoptimize* HGraphBuilder::Add(Deoptimizer::BailoutType type) { 1582 inline HInstruction* HGraphBuilder::AddUncasted<HDeoptimize>(
1583 Deoptimizer::BailoutType type) {
1449 if (type == Deoptimizer::SOFT) { 1584 if (type == Deoptimizer::SOFT) {
1450 isolate()->counters()->soft_deopts_requested()->Increment(); 1585 isolate()->counters()->soft_deopts_requested()->Increment();
1451 if (FLAG_always_opt) return NULL; 1586 if (FLAG_always_opt) return NULL;
1452 } 1587 }
1453 if (current_block()->IsDeoptimizing()) return NULL; 1588 if (current_block()->IsDeoptimizing()) return NULL;
1454 HDeoptimize* instr = new(zone()) HDeoptimize(type); 1589 HDeoptimize* instr = New<HDeoptimize>(type);
1455 AddInstruction(instr); 1590 AddInstruction(instr);
1456 if (type == Deoptimizer::SOFT) { 1591 if (type == Deoptimizer::SOFT) {
1457 isolate()->counters()->soft_deopts_inserted()->Increment(); 1592 isolate()->counters()->soft_deopts_inserted()->Increment();
1458 graph()->set_has_soft_deoptimize(true); 1593 graph()->set_has_soft_deoptimize(true);
1459 } 1594 }
1460 current_block()->MarkAsDeoptimizing(); 1595 current_block()->MarkAsDeoptimizing();
1461 return instr; 1596 return instr;
1462 } 1597 }
1463 1598
1464 1599
1465 template<> 1600 template<>
1466 inline HSimulate* HGraphBuilder::Add(BailoutId id, 1601 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>(
1467 RemovableSimulate removable) { 1602 Deoptimizer::BailoutType type) {
1603 return static_cast<HDeoptimize*>(AddUncasted<HDeoptimize>(type));
1604 }
1605
1606
1607 template<>
1608 inline HInstruction* HGraphBuilder::AddUncasted<HSimulate>(
1609 BailoutId id,
1610 RemovableSimulate removable) {
1468 HSimulate* instr = current_block()->CreateSimulate(id, removable); 1611 HSimulate* instr = current_block()->CreateSimulate(id, removable);
1469 AddInstruction(instr); 1612 AddInstruction(instr);
1470 return instr; 1613 return instr;
1471 } 1614 }
1472 1615
1473 1616
1474 template<> 1617 template<>
1475 inline HSimulate* HGraphBuilder::Add(BailoutId id) { 1618 inline HInstruction* HGraphBuilder::NewUncasted<HLoadNamedField>(
1476 return Add<HSimulate>(id, FIXED_SIMULATE); 1619 HValue* object, HObjectAccess access) {
1620 return NewUncasted<HLoadNamedField>(object, access,
1621 static_cast<HValue*>(NULL));
1477 } 1622 }
1478 1623
1479 1624
1480 template<> 1625 template<>
1481 inline HReturn* HGraphBuilder::Add(HValue* value) { 1626 inline HInstruction* HGraphBuilder::AddUncasted<HLoadNamedField>(
1482 HValue* context = environment()->LookupContext(); 1627 HValue* object, HObjectAccess access) {
1628 return AddUncasted<HLoadNamedField>(object, access,
1629 static_cast<HValue*>(NULL));
1630 }
1631
1632
1633 template<>
1634 inline HInstruction* HGraphBuilder::AddUncasted<HSimulate>(BailoutId id) {
1635 return AddUncasted<HSimulate>(id, FIXED_SIMULATE);
1636 }
1637
1638
1639 template<>
1640 inline HInstruction* HGraphBuilder::AddUncasted<HReturn>(HValue* value) {
1483 int num_parameters = graph()->info()->num_parameters(); 1641 int num_parameters = graph()->info()->num_parameters();
1484 HValue* params = Add<HConstant>(num_parameters); 1642 HValue* params = AddUncasted<HConstant>(num_parameters);
1485 HReturn* return_instruction = new(graph()->zone()) 1643 HReturn* return_instruction = New<HReturn>(value, params);
1486 HReturn(value, context, params);
1487 current_block()->FinishExit(return_instruction); 1644 current_block()->FinishExit(return_instruction);
1488 return return_instruction; 1645 return return_instruction;
1489 } 1646 }
1490 1647
1491 1648
1492 template<> 1649 template<>
1493 inline HReturn* HGraphBuilder::Add(HConstant* p1) { 1650 inline HInstruction* HGraphBuilder::AddUncasted<HReturn>(HConstant* value) {
1494 return Add<HReturn>(static_cast<HValue*>(p1)); 1651 return AddUncasted<HReturn>(static_cast<HValue*>(value));
1495 } 1652 }
1496 1653
1497 1654
1655 template<>
1656 inline HInstruction* HGraphBuilder::NewUncasted<HContext>() {
1657 return HContext::New(zone());
1658 }
1659
1660
1498 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { 1661 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor {
1499 public: 1662 public:
1500 // A class encapsulating (lazily-allocated) break and continue blocks for 1663 // A class encapsulating (lazily-allocated) break and continue blocks for
1501 // a breakable statement. Separated from BreakAndContinueScope so that it 1664 // a breakable statement. Separated from BreakAndContinueScope so that it
1502 // can have a separate lifetime. 1665 // can have a separate lifetime.
1503 class BreakAndContinueInfo BASE_EMBEDDED { 1666 class BreakAndContinueInfo BASE_EMBEDDED {
1504 public: 1667 public:
1505 explicit BreakAndContinueInfo(BreakableStatement* target, 1668 explicit BreakAndContinueInfo(BreakableStatement* target,
1506 int drop_extra = 0) 1669 int drop_extra = 0)
1507 : target_(target), 1670 : target_(target),
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 explicit HOptimizedGraphBuilder(CompilationInfo* info); 1716 explicit HOptimizedGraphBuilder(CompilationInfo* info);
1554 1717
1555 virtual bool BuildGraph(); 1718 virtual bool BuildGraph();
1556 1719
1557 // Simple accessors. 1720 // Simple accessors.
1558 BreakAndContinueScope* break_scope() const { return break_scope_; } 1721 BreakAndContinueScope* break_scope() const { return break_scope_; }
1559 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } 1722 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; }
1560 1723
1561 bool inline_bailout() { return inline_bailout_; } 1724 bool inline_bailout() { return inline_bailout_; }
1562 1725
1726 HValue* context() { return environment()->context(); }
1727
1563 void Bailout(const char* reason); 1728 void Bailout(const char* reason);
1564 1729
1565 HBasicBlock* CreateJoin(HBasicBlock* first, 1730 HBasicBlock* CreateJoin(HBasicBlock* first,
1566 HBasicBlock* second, 1731 HBasicBlock* second,
1567 BailoutId join_id); 1732 BailoutId join_id);
1568 1733
1569 FunctionState* function_state() const { return function_state_; } 1734 FunctionState* function_state() const { return function_state_; }
1570 1735
1571 void VisitDeclarations(ZoneList<Declaration*>* declarations); 1736 void VisitDeclarations(ZoneList<Declaration*>* declarations);
1572 1737
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1828 HValue* receiver, 1993 HValue* receiver,
1829 SmallMapList* types, 1994 SmallMapList* types,
1830 Handle<String> name); 1995 Handle<String> name);
1831 void HandleLiteralCompareTypeof(CompareOperation* expr, 1996 void HandleLiteralCompareTypeof(CompareOperation* expr,
1832 Expression* sub_expr, 1997 Expression* sub_expr,
1833 Handle<String> check); 1998 Handle<String> check);
1834 void HandleLiteralCompareNil(CompareOperation* expr, 1999 void HandleLiteralCompareNil(CompareOperation* expr,
1835 Expression* sub_expr, 2000 Expression* sub_expr,
1836 NilValue nil); 2001 NilValue nil);
1837 2002
1838 HInstruction* BuildStringCharCodeAt(HValue* context, 2003 HInstruction* BuildStringCharCodeAt(HValue* string,
1839 HValue* string,
1840 HValue* index); 2004 HValue* index);
1841 HInstruction* BuildBinaryOperation(BinaryOperation* expr, 2005 HInstruction* BuildBinaryOperation(BinaryOperation* expr,
1842 HValue* left, 2006 HValue* left,
1843 HValue* right); 2007 HValue* right);
1844 HInstruction* BuildIncrement(bool returns_original_input, 2008 HInstruction* BuildIncrement(bool returns_original_input,
1845 CountOperation* expr); 2009 CountOperation* expr);
1846 HInstruction* BuildLoadKeyedGeneric(HValue* object, 2010 HInstruction* BuildLoadKeyedGeneric(HValue* object,
1847 HValue* key); 2011 HValue* key);
1848 2012
1849 HInstruction* TryBuildConsolidatedElementLoad(HValue* object, 2013 HInstruction* TryBuildConsolidatedElementLoad(HValue* object,
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
2161 EmbeddedVector<char, 64> filename_; 2325 EmbeddedVector<char, 64> filename_;
2162 HeapStringAllocator string_allocator_; 2326 HeapStringAllocator string_allocator_;
2163 StringStream trace_; 2327 StringStream trace_;
2164 int indent_; 2328 int indent_;
2165 }; 2329 };
2166 2330
2167 2331
2168 } } // namespace v8::internal 2332 } } // namespace v8::internal
2169 2333
2170 #endif // V8_HYDROGEN_H_ 2334 #endif // V8_HYDROGEN_H_
OLDNEW
« no previous file with comments | « src/code-stubs-hydrogen.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698