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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1205 private: | 1210 private: |
1206 HGraphBuilder* builder_; | 1211 HGraphBuilder* builder_; |
1207 }; | 1212 }; |
1208 | 1213 |
1209 HValue* BuildNewElementsCapacity(HValue* context, | 1214 HValue* BuildNewElementsCapacity(HValue* context, |
1210 HValue* old_capacity); | 1215 HValue* old_capacity); |
1211 | 1216 |
1212 void BuildNewSpaceArrayCheck(HValue* length, | 1217 void BuildNewSpaceArrayCheck(HValue* length, |
1213 ElementsKind kind); | 1218 ElementsKind kind); |
1214 | 1219 |
| 1220 class JSArrayBuilder { |
| 1221 public: |
| 1222 JSArrayBuilder(HGraphBuilder* builder, |
| 1223 ElementsKind kind, |
| 1224 HValue* allocation_site_payload, |
| 1225 AllocationSiteMode mode); |
| 1226 |
| 1227 HValue* AllocateEmptyArray(); |
| 1228 HValue* AllocateArray(HValue* capacity, HValue* length_field, |
| 1229 bool fill_with_hole); |
| 1230 HValue* GetElementsLocation() { return elements_location_; } |
| 1231 |
| 1232 private: |
| 1233 Zone* zone() const { return builder_->zone(); } |
| 1234 int elements_size() const { |
| 1235 return IsFastDoubleElementsKind(kind_) ? kDoubleSize : kPointerSize; |
| 1236 } |
| 1237 HInstruction* AddInstruction(HInstruction* instr) { |
| 1238 return builder_->AddInstruction(instr); |
| 1239 } |
| 1240 HGraphBuilder* builder() { return builder_; } |
| 1241 HGraph* graph() { return builder_->graph(); } |
| 1242 int initial_capacity() { |
| 1243 STATIC_ASSERT(JSArray::kPreallocatedArrayElements > 0); |
| 1244 return JSArray::kPreallocatedArrayElements; |
| 1245 } |
| 1246 |
| 1247 HValue* EmitMapCode(HValue* context); |
| 1248 HValue* EstablishEmptyArrayAllocationSize(); |
| 1249 HValue* EstablishAllocationSize(HValue* length_node); |
| 1250 HValue* AllocateArray(HValue* size_in_bytes, HValue* capacity, |
| 1251 HValue* length_field, bool fill_with_hole); |
| 1252 |
| 1253 HGraphBuilder* builder_; |
| 1254 ElementsKind kind_; |
| 1255 AllocationSiteMode mode_; |
| 1256 HValue* allocation_site_payload_; |
| 1257 HInnerAllocatedObject* elements_location_; |
| 1258 }; |
| 1259 |
1215 HValue* BuildAllocateElements(HValue* context, | 1260 HValue* BuildAllocateElements(HValue* context, |
1216 ElementsKind kind, | 1261 ElementsKind kind, |
1217 HValue* capacity); | 1262 HValue* capacity); |
1218 | 1263 |
1219 void BuildInitializeElements(HValue* elements, | 1264 void BuildInitializeElements(HValue* elements, |
1220 ElementsKind kind, | 1265 ElementsKind kind, |
1221 HValue* capacity); | 1266 HValue* capacity); |
1222 | 1267 |
1223 HValue* BuildAllocateAndInitializeElements(HValue* context, | 1268 HValue* BuildAllocateAndInitializeElements(HValue* context, |
1224 ElementsKind kind, | 1269 ElementsKind kind, |
1225 HValue* capacity); | 1270 HValue* capacity); |
1226 | 1271 |
| 1272 // array must have been allocated with enough room for |
| 1273 // 1) the JSArray, 2) a AllocationSiteInfo if mode requires it, |
| 1274 // 3) a FixedArray or FixedDoubleArray. |
| 1275 // A pointer to the Fixed(Double)Array is returned. |
| 1276 HInnerAllocatedObject* BuildJSArrayHeader(HValue* array, |
| 1277 HValue* array_map, |
| 1278 AllocationSiteMode mode, |
| 1279 HValue* allocation_site_payload, |
| 1280 HValue* length_field); |
| 1281 |
1227 HValue* BuildGrowElementsCapacity(HValue* object, | 1282 HValue* BuildGrowElementsCapacity(HValue* object, |
1228 HValue* elements, | 1283 HValue* elements, |
1229 ElementsKind kind, | 1284 ElementsKind kind, |
1230 HValue* length, | 1285 HValue* length, |
1231 HValue* new_capacity); | 1286 HValue* new_capacity); |
1232 | 1287 |
1233 void BuildFillElementsWithHole(HValue* context, | 1288 void BuildFillElementsWithHole(HValue* context, |
1234 HValue* elements, | 1289 HValue* elements, |
1235 ElementsKind elements_kind, | 1290 ElementsKind elements_kind, |
1236 HValue* from, | 1291 HValue* from, |
1237 HValue* to); | 1292 HValue* to); |
1238 | 1293 |
1239 void BuildCopyElements(HValue* context, | 1294 void BuildCopyElements(HValue* context, |
1240 HValue* from_elements, | 1295 HValue* from_elements, |
1241 ElementsKind from_elements_kind, | 1296 ElementsKind from_elements_kind, |
1242 HValue* to_elements, | 1297 HValue* to_elements, |
1243 ElementsKind to_elements_kind, | 1298 ElementsKind to_elements_kind, |
1244 HValue* length, | 1299 HValue* length, |
1245 HValue* capacity); | 1300 HValue* capacity); |
1246 | 1301 |
1247 HValue* BuildCloneShallowArray(HContext* context, | 1302 HValue* BuildCloneShallowArray(HContext* context, |
1248 HValue* boilerplate, | 1303 HValue* boilerplate, |
1249 AllocationSiteMode mode, | 1304 AllocationSiteMode mode, |
1250 ElementsKind kind, | 1305 ElementsKind kind, |
1251 int length); | 1306 int length); |
1252 | 1307 |
| 1308 HValue* BuildCreateAllocationSiteInfo(HValue* previous_object, |
| 1309 int previous_object_size, |
| 1310 HValue* payload); |
| 1311 |
1253 private: | 1312 private: |
1254 HGraphBuilder(); | 1313 HGraphBuilder(); |
1255 CompilationInfo* info_; | 1314 CompilationInfo* info_; |
1256 HGraph* graph_; | 1315 HGraph* graph_; |
1257 HBasicBlock* current_block_; | 1316 HBasicBlock* current_block_; |
1258 int no_side_effects_scope_count_; | 1317 int no_side_effects_scope_count_; |
1259 }; | 1318 }; |
1260 | 1319 |
1261 | 1320 |
1262 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { | 1321 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1321 virtual bool BuildGraph(); | 1380 virtual bool BuildGraph(); |
1322 | 1381 |
1323 // Simple accessors. | 1382 // Simple accessors. |
1324 BreakAndContinueScope* break_scope() const { return break_scope_; } | 1383 BreakAndContinueScope* break_scope() const { return break_scope_; } |
1325 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } | 1384 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } |
1326 | 1385 |
1327 bool inline_bailout() { return inline_bailout_; } | 1386 bool inline_bailout() { return inline_bailout_; } |
1328 | 1387 |
1329 void AddSoftDeoptimize(); | 1388 void AddSoftDeoptimize(); |
1330 | 1389 |
1331 // Bailout environment manipulation. | |
1332 void Push(HValue* value) { environment()->Push(value); } | |
1333 HValue* Pop() { return environment()->Pop(); } | |
1334 | |
1335 void Bailout(const char* reason); | 1390 void Bailout(const char* reason); |
1336 | 1391 |
1337 HBasicBlock* CreateJoin(HBasicBlock* first, | 1392 HBasicBlock* CreateJoin(HBasicBlock* first, |
1338 HBasicBlock* second, | 1393 HBasicBlock* second, |
1339 BailoutId join_id); | 1394 BailoutId join_id); |
1340 | 1395 |
1341 TypeFeedbackOracle* oracle() const { return function_state()->oracle(); } | 1396 TypeFeedbackOracle* oracle() const { return function_state()->oracle(); } |
1342 | 1397 |
1343 FunctionState* function_state() const { return function_state_; } | 1398 FunctionState* function_state() const { return function_state_; } |
1344 | 1399 |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1940 EmbeddedVector<char, 64> filename_; | 1995 EmbeddedVector<char, 64> filename_; |
1941 HeapStringAllocator string_allocator_; | 1996 HeapStringAllocator string_allocator_; |
1942 StringStream trace_; | 1997 StringStream trace_; |
1943 int indent_; | 1998 int indent_; |
1944 }; | 1999 }; |
1945 | 2000 |
1946 | 2001 |
1947 } } // namespace v8::internal | 2002 } } // namespace v8::internal |
1948 | 2003 |
1949 #endif // V8_HYDROGEN_H_ | 2004 #endif // V8_HYDROGEN_H_ |
OLD | NEW |