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

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 and merge with ToT 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
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,
1138 class P4, class P5, class P6, class P7>
1139 HInstruction* AddUncasted(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) {
1140 return AddInstruction(new(zone()) I(p1, p2, p3, p4, p5, p6, p7));
1028 } 1141 }
1029 1142
1030 template<class I, class P1, class P2, class P3, 1143 template<class I, class P1, class P2, class P3,
1031 class P4, class P5, class P6, class P7> 1144 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) { 1145 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) {
1033 return static_cast<I*>(AddInstruction( 1146 return I::cast(AddInstruction(new(zone()) I(p1, p2, p3, p4, p5, p6, p7)));
1034 new(zone()) I(p1, p2, p3, p4, p5, p6, p7))); 1147 }
1148
1149 template<class I, class P1, class P2, class P3, class P4,
1150 class P5, class P6, class P7, class P8>
1151 HInstruction* AddUncasted(P1 p1, P2 p2, P3 p3, P4 p4,
1152 P5 p5, P6 p6, P7 p7, P8 p8) {
1153 return AddInstruction(new(zone()) I(p1, p2, p3, p4, p5, p6, p7, p8));
1035 } 1154 }
1036 1155
1037 template<class I, class P1, class P2, class P3, class P4, 1156 template<class I, class P1, class P2, class P3, class P4,
1038 class P5, class P6, class P7, class P8> 1157 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) { 1158 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) {
1040 return static_cast<I*>(AddInstruction( 1159 return I::cast(
1041 new(zone()) I(p1, p2, p3, p4, p5, p6, p7, p8))); 1160 AddInstruction(new(zone()) I(p1, p2, p3, p4, p5, p6, p7, p8)));
1042 } 1161 }
1043 1162
1163 void AddSimulate(BailoutId id,
1164 RemovableSimulate removable = FIXED_SIMULATE);
1165
1044 void IncrementInNoSideEffectsScope() { 1166 void IncrementInNoSideEffectsScope() {
1045 no_side_effects_scope_count_++; 1167 no_side_effects_scope_count_++;
1046 } 1168 }
1047 1169
1048 void DecrementInNoSideEffectsScope() { 1170 void DecrementInNoSideEffectsScope() {
1049 no_side_effects_scope_count_--; 1171 no_side_effects_scope_count_--;
1050 } 1172 }
1051 1173
1052 protected: 1174 protected:
1053 virtual bool BuildGraph() = 0; 1175 virtual bool BuildGraph() = 0;
(...skipping 28 matching lines...) Expand all
1082 HValue* object, 1204 HValue* object,
1083 HValue* key, 1205 HValue* key,
1084 HValue* val, 1206 HValue* val,
1085 HCheckMaps* mapcheck, 1207 HCheckMaps* mapcheck,
1086 bool is_js_array, 1208 bool is_js_array,
1087 ElementsKind elements_kind, 1209 ElementsKind elements_kind,
1088 bool is_store, 1210 bool is_store,
1089 LoadKeyedHoleMode load_mode, 1211 LoadKeyedHoleMode load_mode,
1090 KeyedAccessStoreMode store_mode); 1212 KeyedAccessStoreMode store_mode);
1091 1213
1092 HLoadNamedField* AddLoad(
1093 HValue *object,
1094 HObjectAccess access,
1095 HValue *typecheck = NULL);
1096
1097 HLoadNamedField* BuildLoadNamedField( 1214 HLoadNamedField* BuildLoadNamedField(
1098 HValue* object, 1215 HValue* object,
1099 HObjectAccess access, 1216 HObjectAccess access);
1100 Representation representation);
1101 1217
1102 HInstruction* AddExternalArrayElementAccess( 1218 HInstruction* AddExternalArrayElementAccess(
1103 HValue* external_elements, 1219 HValue* external_elements,
1104 HValue* checked_key, 1220 HValue* checked_key,
1105 HValue* val, 1221 HValue* val,
1106 HValue* dependency, 1222 HValue* dependency,
1107 ElementsKind elements_kind, 1223 ElementsKind elements_kind,
1108 bool is_store); 1224 bool is_store);
1109 1225
1110 HInstruction* AddFastElementAccess( 1226 HInstruction* AddFastElementAccess(
1111 HValue* elements, 1227 HValue* elements,
1112 HValue* checked_key, 1228 HValue* checked_key,
1113 HValue* val, 1229 HValue* val,
1114 HValue* dependency, 1230 HValue* dependency,
1115 ElementsKind elements_kind, 1231 ElementsKind elements_kind,
1116 bool is_store, 1232 bool is_store,
1117 LoadKeyedHoleMode load_mode, 1233 LoadKeyedHoleMode load_mode,
1118 KeyedAccessStoreMode store_mode); 1234 KeyedAccessStoreMode store_mode);
1119 1235
1120 HLoadNamedField* BuildLoadNamedField(HValue* object, HObjectAccess access);
1121 HStoreNamedField* AddStore(HValue *object, HObjectAccess access, HValue *val);
1122 HStoreNamedField* AddStoreMapConstant(HValue *object, Handle<Map>); 1236 HStoreNamedField* AddStoreMapConstant(HValue *object, Handle<Map>);
1123 HLoadNamedField* AddLoadElements(HValue *object, HValue *typecheck = NULL); 1237 HLoadNamedField* AddLoadElements(HValue *object, HValue *typecheck = NULL);
1124 HLoadNamedField* AddLoadFixedArrayLength(HValue *object); 1238 HLoadNamedField* AddLoadFixedArrayLength(HValue *object);
1125 1239
1126 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin, HValue* context); 1240 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin);
1127 1241
1128 HValue* TruncateToNumber(HValue* value, Handle<Type>* expected); 1242 HValue* TruncateToNumber(HValue* value, Handle<Type>* expected);
1129 1243
1130 void PushAndAdd(HInstruction* instr); 1244 void PushAndAdd(HInstruction* instr);
1131 1245
1132 void FinishExitWithHardDeoptimization(HBasicBlock* continuation); 1246 void FinishExitWithHardDeoptimization(HBasicBlock* continuation);
1133 1247
1134 void AddIncrementCounter(StatsCounter* counter, 1248 void AddIncrementCounter(StatsCounter* counter,
1135 HValue* context); 1249 HValue* context);
1136 1250
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 builder_->IncrementInNoSideEffectsScope(); 1421 builder_->IncrementInNoSideEffectsScope();
1308 } 1422 }
1309 ~NoObservableSideEffectsScope() { 1423 ~NoObservableSideEffectsScope() {
1310 builder_->DecrementInNoSideEffectsScope(); 1424 builder_->DecrementInNoSideEffectsScope();
1311 } 1425 }
1312 1426
1313 private: 1427 private:
1314 HGraphBuilder* builder_; 1428 HGraphBuilder* builder_;
1315 }; 1429 };
1316 1430
1317 HValue* BuildNewElementsCapacity(HValue* context, 1431 HValue* BuildNewElementsCapacity(HValue* old_capacity);
1318 HValue* old_capacity);
1319 1432
1320 void BuildNewSpaceArrayCheck(HValue* length, 1433 void BuildNewSpaceArrayCheck(HValue* length,
1321 ElementsKind kind); 1434 ElementsKind kind);
1322 1435
1323 class JSArrayBuilder { 1436 class JSArrayBuilder {
1324 public: 1437 public:
1325 JSArrayBuilder(HGraphBuilder* builder, 1438 JSArrayBuilder(HGraphBuilder* builder,
1326 ElementsKind kind, 1439 ElementsKind kind,
1327 HValue* allocation_site_payload, 1440 HValue* allocation_site_payload,
1328 HValue* constructor_function, 1441 HValue* constructor_function,
(...skipping 13 matching lines...) Expand all
1342 int elements_size() const { 1455 int elements_size() const {
1343 return IsFastDoubleElementsKind(kind_) ? kDoubleSize : kPointerSize; 1456 return IsFastDoubleElementsKind(kind_) ? kDoubleSize : kPointerSize;
1344 } 1457 }
1345 HGraphBuilder* builder() { return builder_; } 1458 HGraphBuilder* builder() { return builder_; }
1346 HGraph* graph() { return builder_->graph(); } 1459 HGraph* graph() { return builder_->graph(); }
1347 int initial_capacity() { 1460 int initial_capacity() {
1348 STATIC_ASSERT(JSArray::kPreallocatedArrayElements > 0); 1461 STATIC_ASSERT(JSArray::kPreallocatedArrayElements > 0);
1349 return JSArray::kPreallocatedArrayElements; 1462 return JSArray::kPreallocatedArrayElements;
1350 } 1463 }
1351 1464
1352 HValue* EmitMapCode(HValue* context); 1465 HValue* EmitMapCode();
1353 HValue* EmitInternalMapCode(); 1466 HValue* EmitInternalMapCode();
1354 HValue* EstablishEmptyArrayAllocationSize(); 1467 HValue* EstablishEmptyArrayAllocationSize();
1355 HValue* EstablishAllocationSize(HValue* length_node); 1468 HValue* EstablishAllocationSize(HValue* length_node);
1356 HValue* AllocateArray(HValue* size_in_bytes, HValue* capacity, 1469 HValue* AllocateArray(HValue* size_in_bytes, HValue* capacity,
1357 HValue* length_field, bool fill_with_hole); 1470 HValue* length_field, bool fill_with_hole);
1358 1471
1359 HGraphBuilder* builder_; 1472 HGraphBuilder* builder_;
1360 ElementsKind kind_; 1473 ElementsKind kind_;
1361 AllocationSiteMode mode_; 1474 AllocationSiteMode mode_;
1362 HValue* allocation_site_payload_; 1475 HValue* allocation_site_payload_;
1363 HValue* constructor_function_; 1476 HValue* constructor_function_;
1364 HInnerAllocatedObject* elements_location_; 1477 HInnerAllocatedObject* elements_location_;
1365 }; 1478 };
1366 1479
1367 HValue* BuildAllocateElements(HValue* context, 1480 HValue* BuildAllocateElements(ElementsKind kind,
1368 ElementsKind kind,
1369 HValue* capacity); 1481 HValue* capacity);
1370 1482
1371 void BuildInitializeElementsHeader(HValue* elements, 1483 void BuildInitializeElementsHeader(HValue* elements,
1372 ElementsKind kind, 1484 ElementsKind kind,
1373 HValue* capacity); 1485 HValue* capacity);
1374 1486
1375 HValue* BuildAllocateElementsAndInitializeElementsHeader(HValue* context, 1487 HValue* BuildAllocateElementsAndInitializeElementsHeader(ElementsKind kind,
1376 ElementsKind kind,
1377 HValue* capacity); 1488 HValue* capacity);
1378 1489
1379 // array must have been allocated with enough room for 1490 // array must have been allocated with enough room for
1380 // 1) the JSArray, 2) a AllocationMemento if mode requires it, 1491 // 1) the JSArray, 2) a AllocationMemento if mode requires it,
1381 // 3) a FixedArray or FixedDoubleArray. 1492 // 3) a FixedArray or FixedDoubleArray.
1382 // A pointer to the Fixed(Double)Array is returned. 1493 // A pointer to the Fixed(Double)Array is returned.
1383 HInnerAllocatedObject* BuildJSArrayHeader(HValue* array, 1494 HInnerAllocatedObject* BuildJSArrayHeader(HValue* array,
1384 HValue* array_map, 1495 HValue* array_map,
1385 AllocationSiteMode mode, 1496 AllocationSiteMode mode,
1386 ElementsKind elements_kind, 1497 ElementsKind elements_kind,
1387 HValue* allocation_site_payload, 1498 HValue* allocation_site_payload,
1388 HValue* length_field); 1499 HValue* length_field);
1389 1500
1390 HValue* BuildGrowElementsCapacity(HValue* object, 1501 HValue* BuildGrowElementsCapacity(HValue* object,
1391 HValue* elements, 1502 HValue* elements,
1392 ElementsKind kind, 1503 ElementsKind kind,
1393 ElementsKind new_kind, 1504 ElementsKind new_kind,
1394 HValue* length, 1505 HValue* length,
1395 HValue* new_capacity); 1506 HValue* new_capacity);
1396 1507
1397 void BuildFillElementsWithHole(HValue* context, 1508 void BuildFillElementsWithHole(HValue* elements,
1398 HValue* elements,
1399 ElementsKind elements_kind, 1509 ElementsKind elements_kind,
1400 HValue* from, 1510 HValue* from,
1401 HValue* to); 1511 HValue* to);
1402 1512
1403 void BuildCopyElements(HValue* context, 1513 void BuildCopyElements(HValue* from_elements,
1404 HValue* from_elements,
1405 ElementsKind from_elements_kind, 1514 ElementsKind from_elements_kind,
1406 HValue* to_elements, 1515 HValue* to_elements,
1407 ElementsKind to_elements_kind, 1516 ElementsKind to_elements_kind,
1408 HValue* length, 1517 HValue* length,
1409 HValue* capacity); 1518 HValue* capacity);
1410 1519
1411 HValue* BuildCloneShallowArray(HContext* context, 1520 HValue* BuildCloneShallowArray(HValue* boilerplate,
1412 HValue* boilerplate,
1413 HValue* allocation_site, 1521 HValue* allocation_site,
1414 AllocationSiteMode mode, 1522 AllocationSiteMode mode,
1415 ElementsKind kind, 1523 ElementsKind kind,
1416 int length); 1524 int length);
1417 1525
1418 HInstruction* BuildUnaryMathOp( 1526 HInstruction* BuildUnaryMathOp(
1419 HValue* value, Handle<Type> type, Token::Value token); 1527 HValue* value, Handle<Type> type, Token::Value token);
1420 1528
1421 void BuildCompareNil( 1529 void BuildCompareNil(
1422 HValue* value, 1530 HValue* value,
1423 Handle<Type> type, 1531 Handle<Type> type,
1424 int position, 1532 int position,
1425 HIfContinuation* continuation); 1533 HIfContinuation* continuation);
1426 1534
1427 HValue* BuildCreateAllocationMemento(HValue* previous_object, 1535 HValue* BuildCreateAllocationMemento(HValue* previous_object,
1428 int previous_object_size, 1536 int previous_object_size,
1429 HValue* payload); 1537 HValue* payload);
1430 1538
1431 HInstruction* BuildGetNativeContext(HValue* context); 1539 HInstruction* BuildGetNativeContext();
1432 HInstruction* BuildGetArrayFunction(HValue* context); 1540 HInstruction* BuildGetArrayFunction();
1433 1541
1434 private: 1542 private:
1435 HGraphBuilder(); 1543 HGraphBuilder();
1436 1544
1437 void PadEnvironmentForContinuation(HBasicBlock* from, 1545 void PadEnvironmentForContinuation(HBasicBlock* from,
1438 HBasicBlock* continuation); 1546 HBasicBlock* continuation);
1439 1547
1440 CompilationInfo* info_; 1548 CompilationInfo* info_;
1441 HGraph* graph_; 1549 HGraph* graph_;
1442 HBasicBlock* current_block_; 1550 HBasicBlock* current_block_;
1443 int no_side_effects_scope_count_; 1551 int no_side_effects_scope_count_;
1444 }; 1552 };
1445 1553
1446 1554
1447 template<> 1555 template<>
1448 inline HDeoptimize* HGraphBuilder::Add(Deoptimizer::BailoutType type) { 1556 inline HInstruction* HGraphBuilder::AddUncasted<HDeoptimize>(
1557 Deoptimizer::BailoutType type) {
1449 if (type == Deoptimizer::SOFT) { 1558 if (type == Deoptimizer::SOFT) {
1450 isolate()->counters()->soft_deopts_requested()->Increment(); 1559 isolate()->counters()->soft_deopts_requested()->Increment();
1451 if (FLAG_always_opt) return NULL; 1560 if (FLAG_always_opt) return NULL;
1452 } 1561 }
1453 if (current_block()->IsDeoptimizing()) return NULL; 1562 if (current_block()->IsDeoptimizing()) return NULL;
1454 HDeoptimize* instr = new(zone()) HDeoptimize(type); 1563 HDeoptimize* instr = New<HDeoptimize>(type);
1455 AddInstruction(instr); 1564 AddInstruction(instr);
1456 if (type == Deoptimizer::SOFT) { 1565 if (type == Deoptimizer::SOFT) {
1457 isolate()->counters()->soft_deopts_inserted()->Increment(); 1566 isolate()->counters()->soft_deopts_inserted()->Increment();
1458 graph()->set_has_soft_deoptimize(true); 1567 graph()->set_has_soft_deoptimize(true);
1459 } 1568 }
1460 current_block()->MarkAsDeoptimizing(); 1569 current_block()->MarkAsDeoptimizing();
1461 return instr; 1570 return instr;
1462 } 1571 }
1463 1572
1464 1573
1465 template<> 1574 template<>
1466 inline HSimulate* HGraphBuilder::Add(BailoutId id, 1575 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>(
1467 RemovableSimulate removable) { 1576 Deoptimizer::BailoutType type) {
1577 return static_cast<HDeoptimize*>(AddUncasted<HDeoptimize>(type));
1578 }
1579
1580
1581 template<>
1582 inline HInstruction* HGraphBuilder::AddUncasted<HSimulate>(
1583 BailoutId id,
1584 RemovableSimulate removable) {
1468 HSimulate* instr = current_block()->CreateSimulate(id, removable); 1585 HSimulate* instr = current_block()->CreateSimulate(id, removable);
1469 AddInstruction(instr); 1586 AddInstruction(instr);
1470 return instr; 1587 return instr;
1471 } 1588 }
1472 1589
1473 1590
1474 template<> 1591 template<>
1475 inline HSimulate* HGraphBuilder::Add(BailoutId id) { 1592 inline HInstruction* HGraphBuilder::NewUncasted<HLoadNamedField>(
1476 return Add<HSimulate>(id, FIXED_SIMULATE); 1593 HValue* object, HObjectAccess access) {
1594 return NewUncasted<HLoadNamedField>(object, access,
1595 static_cast<HValue*>(NULL));
1477 } 1596 }
1478 1597
1479 1598
1480 template<> 1599 template<>
1481 inline HReturn* HGraphBuilder::Add(HValue* value) { 1600 inline HInstruction* HGraphBuilder::AddUncasted<HLoadNamedField>(
1482 HValue* context = environment()->LookupContext(); 1601 HValue* object, HObjectAccess access) {
1602 return AddUncasted<HLoadNamedField>(object, access,
1603 static_cast<HValue*>(NULL));
1604 }
1605
1606
1607 template<>
1608 inline HInstruction* HGraphBuilder::AddUncasted<HSimulate>(BailoutId id) {
1609 return AddUncasted<HSimulate>(id, FIXED_SIMULATE);
1610 }
1611
1612
1613 template<>
1614 inline HInstruction* HGraphBuilder::AddUncasted<HReturn>(HValue* value) {
1483 int num_parameters = graph()->info()->num_parameters(); 1615 int num_parameters = graph()->info()->num_parameters();
1484 HValue* params = Add<HConstant>(num_parameters); 1616 HValue* params = AddUncasted<HConstant>(num_parameters);
1485 HReturn* return_instruction = new(graph()->zone()) 1617 HReturn* return_instruction = New<HReturn>(value, params);
1486 HReturn(value, context, params);
1487 current_block()->FinishExit(return_instruction); 1618 current_block()->FinishExit(return_instruction);
1488 return return_instruction; 1619 return return_instruction;
1489 } 1620 }
1490 1621
1491 1622
1492 template<> 1623 template<>
1493 inline HReturn* HGraphBuilder::Add(HConstant* p1) { 1624 inline HInstruction* HGraphBuilder::AddUncasted<HReturn>(HConstant* value) {
1494 return Add<HReturn>(static_cast<HValue*>(p1)); 1625 return AddUncasted<HReturn>(static_cast<HValue*>(value));
1495 } 1626 }
1496 1627
1497 1628
1629 template<>
1630 inline HInstruction* HGraphBuilder::NewUncasted<HContext>() {
1631 return HContext::New(zone());
1632 }
1633
1634
1498 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { 1635 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor {
1499 public: 1636 public:
1500 // A class encapsulating (lazily-allocated) break and continue blocks for 1637 // A class encapsulating (lazily-allocated) break and continue blocks for
1501 // a breakable statement. Separated from BreakAndContinueScope so that it 1638 // a breakable statement. Separated from BreakAndContinueScope so that it
1502 // can have a separate lifetime. 1639 // can have a separate lifetime.
1503 class BreakAndContinueInfo BASE_EMBEDDED { 1640 class BreakAndContinueInfo BASE_EMBEDDED {
1504 public: 1641 public:
1505 explicit BreakAndContinueInfo(BreakableStatement* target, 1642 explicit BreakAndContinueInfo(BreakableStatement* target,
1506 int drop_extra = 0) 1643 int drop_extra = 0)
1507 : target_(target), 1644 : target_(target),
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 explicit HOptimizedGraphBuilder(CompilationInfo* info); 1690 explicit HOptimizedGraphBuilder(CompilationInfo* info);
1554 1691
1555 virtual bool BuildGraph(); 1692 virtual bool BuildGraph();
1556 1693
1557 // Simple accessors. 1694 // Simple accessors.
1558 BreakAndContinueScope* break_scope() const { return break_scope_; } 1695 BreakAndContinueScope* break_scope() const { return break_scope_; }
1559 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } 1696 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; }
1560 1697
1561 bool inline_bailout() { return inline_bailout_; } 1698 bool inline_bailout() { return inline_bailout_; }
1562 1699
1700 HValue* context() { return environment()->context(); }
1701
1563 void Bailout(const char* reason); 1702 void Bailout(const char* reason);
1564 1703
1565 HBasicBlock* CreateJoin(HBasicBlock* first, 1704 HBasicBlock* CreateJoin(HBasicBlock* first,
1566 HBasicBlock* second, 1705 HBasicBlock* second,
1567 BailoutId join_id); 1706 BailoutId join_id);
1568 1707
1569 FunctionState* function_state() const { return function_state_; } 1708 FunctionState* function_state() const { return function_state_; }
1570 1709
1571 void VisitDeclarations(ZoneList<Declaration*>* declarations); 1710 void VisitDeclarations(ZoneList<Declaration*>* declarations);
1572 1711
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1828 HValue* receiver, 1967 HValue* receiver,
1829 SmallMapList* types, 1968 SmallMapList* types,
1830 Handle<String> name); 1969 Handle<String> name);
1831 void HandleLiteralCompareTypeof(CompareOperation* expr, 1970 void HandleLiteralCompareTypeof(CompareOperation* expr,
1832 Expression* sub_expr, 1971 Expression* sub_expr,
1833 Handle<String> check); 1972 Handle<String> check);
1834 void HandleLiteralCompareNil(CompareOperation* expr, 1973 void HandleLiteralCompareNil(CompareOperation* expr,
1835 Expression* sub_expr, 1974 Expression* sub_expr,
1836 NilValue nil); 1975 NilValue nil);
1837 1976
1838 HInstruction* BuildStringCharCodeAt(HValue* context, 1977 HInstruction* BuildStringCharCodeAt(HValue* string,
1839 HValue* string,
1840 HValue* index); 1978 HValue* index);
1841 HInstruction* BuildBinaryOperation(BinaryOperation* expr, 1979 HInstruction* BuildBinaryOperation(BinaryOperation* expr,
1842 HValue* left, 1980 HValue* left,
1843 HValue* right); 1981 HValue* right);
1844 HInstruction* BuildIncrement(bool returns_original_input, 1982 HInstruction* BuildIncrement(bool returns_original_input,
1845 CountOperation* expr); 1983 CountOperation* expr);
1846 HInstruction* BuildLoadKeyedGeneric(HValue* object, 1984 HInstruction* BuildLoadKeyedGeneric(HValue* object,
1847 HValue* key); 1985 HValue* key);
1848 1986
1849 HInstruction* TryBuildConsolidatedElementLoad(HValue* object, 1987 HInstruction* TryBuildConsolidatedElementLoad(HValue* object,
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
2161 EmbeddedVector<char, 64> filename_; 2299 EmbeddedVector<char, 64> filename_;
2162 HeapStringAllocator string_allocator_; 2300 HeapStringAllocator string_allocator_;
2163 StringStream trace_; 2301 StringStream trace_;
2164 int indent_; 2302 int indent_;
2165 }; 2303 };
2166 2304
2167 2305
2168 } } // namespace v8::internal 2306 } } // namespace v8::internal
2169 2307
2170 #endif // V8_HYDROGEN_H_ 2308 #endif // V8_HYDROGEN_H_
OLDNEW
« no previous file with comments | « src/code-stubs-hydrogen.cc ('k') | src/hydrogen.cc » ('j') | src/hydrogen.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698