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 18 matching lines...) Expand all Loading... |
29 #define V8_HYDROGEN_H_ | 29 #define V8_HYDROGEN_H_ |
30 | 30 |
31 #include "v8.h" | 31 #include "v8.h" |
32 | 32 |
33 #include "allocation.h" | 33 #include "allocation.h" |
34 #include "ast.h" | 34 #include "ast.h" |
35 #include "compiler.h" | 35 #include "compiler.h" |
36 #include "hydrogen-instructions.h" | 36 #include "hydrogen-instructions.h" |
37 #include "type-info.h" | 37 #include "type-info.h" |
38 #include "zone.h" | 38 #include "zone.h" |
| 39 #include "scopes.h" |
39 | 40 |
40 namespace v8 { | 41 namespace v8 { |
41 namespace internal { | 42 namespace internal { |
42 | 43 |
43 // Forward declarations. | 44 // Forward declarations. |
44 class BitVector; | 45 class BitVector; |
45 class FunctionState; | 46 class FunctionState; |
46 class HEnvironment; | 47 class HEnvironment; |
47 class HGraph; | 48 class HGraph; |
48 class HLoopInformation; | 49 class HLoopInformation; |
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 void set_current_block(HBasicBlock* block) { current_block_ = block; } | 934 void set_current_block(HBasicBlock* block) { current_block_ = block; } |
934 HEnvironment* environment() const { | 935 HEnvironment* environment() const { |
935 return current_block()->last_environment(); | 936 return current_block()->last_environment(); |
936 } | 937 } |
937 Zone* zone() const { return info_->zone(); } | 938 Zone* zone() const { return info_->zone(); } |
938 HGraph* graph() const { return graph_; } | 939 HGraph* graph() const { return graph_; } |
939 Isolate* isolate() const { return graph_->isolate(); } | 940 Isolate* isolate() const { return graph_->isolate(); } |
940 | 941 |
941 HGraph* CreateGraph(); | 942 HGraph* CreateGraph(); |
942 | 943 |
| 944 // Bailout environment manipulation. |
| 945 void Push(HValue* value) { environment()->Push(value); } |
| 946 HValue* Pop() { return environment()->Pop(); } |
| 947 |
943 // Adding instructions. | 948 // Adding instructions. |
944 HInstruction* AddInstruction(HInstruction* instr); | 949 HInstruction* AddInstruction(HInstruction* instr); |
945 void AddSimulate(BailoutId id, | 950 void AddSimulate(BailoutId id, |
946 RemovableSimulate removable = FIXED_SIMULATE); | 951 RemovableSimulate removable = FIXED_SIMULATE); |
947 HBoundsCheck* AddBoundsCheck( | 952 HBoundsCheck* AddBoundsCheck( |
948 HValue* index, | 953 HValue* index, |
949 HValue* length, | 954 HValue* length, |
950 BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY, | 955 BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY, |
951 Representation r = Representation::None()); | 956 Representation r = Representation::None()); |
952 | 957 |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 private: | 1201 private: |
1197 HGraphBuilder* builder_; | 1202 HGraphBuilder* builder_; |
1198 }; | 1203 }; |
1199 | 1204 |
1200 HValue* BuildNewElementsCapacity(HValue* context, | 1205 HValue* BuildNewElementsCapacity(HValue* context, |
1201 HValue* old_capacity); | 1206 HValue* old_capacity); |
1202 | 1207 |
1203 void BuildNewSpaceArrayCheck(HValue* length, | 1208 void BuildNewSpaceArrayCheck(HValue* length, |
1204 ElementsKind kind); | 1209 ElementsKind kind); |
1205 | 1210 |
| 1211 class JSArrayBuilder { |
| 1212 public: |
| 1213 JSArrayBuilder(HGraphBuilder* builder, |
| 1214 ElementsKind kind, |
| 1215 HValue* allocation_site_payload, |
| 1216 AllocationSiteMode mode); |
| 1217 |
| 1218 HValue* AllocateEmptyArray(); |
| 1219 HValue* AllocateArray(HValue* capacity, HValue* length_field, |
| 1220 bool fill_with_hole); |
| 1221 HValue* GetElementsLocation() { return elements_location_; } |
| 1222 |
| 1223 private: |
| 1224 Zone* zone() const { return builder_->zone(); } |
| 1225 int elements_size() const { |
| 1226 return IsFastDoubleElementsKind(kind_) ? kDoubleSize : kPointerSize; |
| 1227 } |
| 1228 HInstruction* AddInstruction(HInstruction* instr) { |
| 1229 return builder_->AddInstruction(instr); |
| 1230 } |
| 1231 HGraphBuilder* builder() { return builder_; } |
| 1232 HGraph* graph() { return builder_->graph(); } |
| 1233 int initial_capacity() { |
| 1234 STATIC_ASSERT(JSArray::kPreallocatedArrayElements > 0); |
| 1235 return JSArray::kPreallocatedArrayElements; |
| 1236 } |
| 1237 |
| 1238 HValue* EmitMapCode(HValue* context); |
| 1239 HValue* EstablishEmptyArrayAllocationSize(); |
| 1240 HValue* EstablishAllocationSize(HValue* length_node); |
| 1241 HValue* AllocateArray(HValue* size_in_bytes, HValue* capacity, |
| 1242 HValue* length_field, bool fill_with_hole); |
| 1243 |
| 1244 HGraphBuilder* builder_; |
| 1245 ElementsKind kind_; |
| 1246 AllocationSiteMode mode_; |
| 1247 HValue* allocation_site_payload_; |
| 1248 HInnerAllocatedObject* elements_location_; |
| 1249 }; |
| 1250 |
1206 HValue* BuildAllocateElements(HValue* context, | 1251 HValue* BuildAllocateElements(HValue* context, |
1207 ElementsKind kind, | 1252 ElementsKind kind, |
1208 HValue* capacity); | 1253 HValue* capacity); |
1209 | 1254 |
1210 void BuildInitializeElements(HValue* elements, | 1255 void BuildInitializeElements(HValue* elements, |
1211 ElementsKind kind, | 1256 ElementsKind kind, |
1212 HValue* capacity); | 1257 HValue* capacity); |
1213 | 1258 |
1214 HValue* BuildAllocateAndInitializeElements(HValue* context, | 1259 HValue* BuildAllocateAndInitializeElements(HValue* context, |
1215 ElementsKind kind, | 1260 ElementsKind kind, |
1216 HValue* capacity); | 1261 HValue* capacity); |
1217 | 1262 |
| 1263 // array must have been allocated with enough room for |
| 1264 // 1) the JSArray, 2) a AllocationSiteInfo if mode requires it, |
| 1265 // 3) a FixedArray or FixedDoubleArray. |
| 1266 // A pointer to the Fixed(Double)Array is returned. |
| 1267 HInnerAllocatedObject* BuildJSArrayHeader(HValue* array, |
| 1268 HValue* array_map, |
| 1269 AllocationSiteMode mode, |
| 1270 HValue* allocation_site_payload, |
| 1271 HValue* length_field); |
| 1272 |
1218 HValue* BuildGrowElementsCapacity(HValue* object, | 1273 HValue* BuildGrowElementsCapacity(HValue* object, |
1219 HValue* elements, | 1274 HValue* elements, |
1220 ElementsKind kind, | 1275 ElementsKind kind, |
1221 HValue* length, | 1276 HValue* length, |
1222 HValue* new_capacity); | 1277 HValue* new_capacity); |
1223 | 1278 |
1224 void BuildFillElementsWithHole(HValue* context, | 1279 void BuildFillElementsWithHole(HValue* context, |
1225 HValue* elements, | 1280 HValue* elements, |
1226 ElementsKind elements_kind, | 1281 ElementsKind elements_kind, |
1227 HValue* from, | 1282 HValue* from, |
1228 HValue* to); | 1283 HValue* to); |
1229 | 1284 |
1230 void BuildCopyElements(HValue* context, | 1285 void BuildCopyElements(HValue* context, |
1231 HValue* from_elements, | 1286 HValue* from_elements, |
1232 ElementsKind from_elements_kind, | 1287 ElementsKind from_elements_kind, |
1233 HValue* to_elements, | 1288 HValue* to_elements, |
1234 ElementsKind to_elements_kind, | 1289 ElementsKind to_elements_kind, |
1235 HValue* length, | 1290 HValue* length, |
1236 HValue* capacity); | 1291 HValue* capacity); |
1237 | 1292 |
1238 HValue* BuildCloneShallowArray(HContext* context, | 1293 HValue* BuildCloneShallowArray(HContext* context, |
1239 HValue* boilerplate, | 1294 HValue* boilerplate, |
1240 AllocationSiteMode mode, | 1295 AllocationSiteMode mode, |
1241 ElementsKind kind, | 1296 ElementsKind kind, |
1242 int length); | 1297 int length); |
1243 | 1298 |
| 1299 HValue* BuildCreateAllocationSiteInfo(HValue* previous_object, |
| 1300 int previous_object_size, |
| 1301 HValue* payload); |
| 1302 |
1244 private: | 1303 private: |
1245 HGraphBuilder(); | 1304 HGraphBuilder(); |
1246 CompilationInfo* info_; | 1305 CompilationInfo* info_; |
1247 HGraph* graph_; | 1306 HGraph* graph_; |
1248 HBasicBlock* current_block_; | 1307 HBasicBlock* current_block_; |
1249 int no_side_effects_scope_count_; | 1308 int no_side_effects_scope_count_; |
1250 }; | 1309 }; |
1251 | 1310 |
1252 | 1311 |
1253 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { | 1312 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1312 virtual bool BuildGraph(); | 1371 virtual bool BuildGraph(); |
1313 | 1372 |
1314 // Simple accessors. | 1373 // Simple accessors. |
1315 BreakAndContinueScope* break_scope() const { return break_scope_; } | 1374 BreakAndContinueScope* break_scope() const { return break_scope_; } |
1316 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } | 1375 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } |
1317 | 1376 |
1318 bool inline_bailout() { return inline_bailout_; } | 1377 bool inline_bailout() { return inline_bailout_; } |
1319 | 1378 |
1320 void AddSoftDeoptimize(); | 1379 void AddSoftDeoptimize(); |
1321 | 1380 |
1322 // Bailout environment manipulation. | |
1323 void Push(HValue* value) { environment()->Push(value); } | |
1324 HValue* Pop() { return environment()->Pop(); } | |
1325 | |
1326 void Bailout(const char* reason); | 1381 void Bailout(const char* reason); |
1327 | 1382 |
1328 HBasicBlock* CreateJoin(HBasicBlock* first, | 1383 HBasicBlock* CreateJoin(HBasicBlock* first, |
1329 HBasicBlock* second, | 1384 HBasicBlock* second, |
1330 BailoutId join_id); | 1385 BailoutId join_id); |
1331 | 1386 |
1332 TypeFeedbackOracle* oracle() const { return function_state()->oracle(); } | 1387 TypeFeedbackOracle* oracle() const { return function_state()->oracle(); } |
1333 | 1388 |
1334 FunctionState* function_state() const { return function_state_; } | 1389 FunctionState* function_state() const { return function_state_; } |
1335 | 1390 |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1931 EmbeddedVector<char, 64> filename_; | 1986 EmbeddedVector<char, 64> filename_; |
1932 HeapStringAllocator string_allocator_; | 1987 HeapStringAllocator string_allocator_; |
1933 StringStream trace_; | 1988 StringStream trace_; |
1934 int indent_; | 1989 int indent_; |
1935 }; | 1990 }; |
1936 | 1991 |
1937 | 1992 |
1938 } } // namespace v8::internal | 1993 } } // namespace v8::internal |
1939 | 1994 |
1940 #endif // V8_HYDROGEN_H_ | 1995 #endif // V8_HYDROGEN_H_ |
OLD | NEW |