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 28 matching lines...) Expand all Loading... | |
| 39 | 39 |
| 40 namespace v8 { | 40 namespace v8 { |
| 41 namespace internal { | 41 namespace internal { |
| 42 | 42 |
| 43 // Forward declarations. | 43 // Forward declarations. |
| 44 class BitVector; | 44 class BitVector; |
| 45 class FunctionState; | 45 class FunctionState; |
| 46 class HEnvironment; | 46 class HEnvironment; |
| 47 class HGraph; | 47 class HGraph; |
| 48 class HLoopInformation; | 48 class HLoopInformation; |
| 49 class HOsrBuilder; | |
| 49 class HTracer; | 50 class HTracer; |
| 50 class LAllocator; | 51 class LAllocator; |
| 51 class LChunk; | 52 class LChunk; |
| 52 class LiveRange; | 53 class LiveRange; |
| 53 | 54 |
| 54 | 55 |
| 55 class HBasicBlock: public ZoneObject { | 56 class HBasicBlock: public ZoneObject { |
| 56 public: | 57 public: |
| 57 explicit HBasicBlock(HGraph* graph); | 58 explicit HBasicBlock(HGraph* graph); |
| 58 virtual ~HBasicBlock() { } | 59 virtual ~HBasicBlock() { } |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 if (id >= 0 && id < values_.length()) return values_[id]; | 353 if (id >= 0 && id < values_.length()) return values_[id]; |
| 353 return NULL; | 354 return NULL; |
| 354 } | 355 } |
| 355 | 356 |
| 356 bool Optimize(SmartArrayPointer<char>* bailout_reason); | 357 bool Optimize(SmartArrayPointer<char>* bailout_reason); |
| 357 | 358 |
| 358 #ifdef DEBUG | 359 #ifdef DEBUG |
| 359 void Verify(bool do_full_verify) const; | 360 void Verify(bool do_full_verify) const; |
| 360 #endif | 361 #endif |
| 361 | 362 |
| 362 bool has_osr_loop_entry() { | 363 bool has_osr() { |
| 363 return osr_loop_entry_.is_set(); | 364 return osr_ != NULL; |
| 364 } | 365 } |
| 365 | 366 |
| 366 HBasicBlock* osr_loop_entry() { | 367 void set_osr(HOsrBuilder* osr) { |
| 367 return osr_loop_entry_.get(); | 368 osr_ = osr; |
| 368 } | 369 } |
| 369 | 370 |
| 370 void set_osr_loop_entry(HBasicBlock* entry) { | 371 HOsrBuilder* osr() { |
| 371 osr_loop_entry_.set(entry); | 372 return osr_; |
| 372 } | |
| 373 | |
| 374 ZoneList<HUnknownOSRValue*>* osr_values() { | |
| 375 return osr_values_.get(); | |
| 376 } | |
| 377 | |
| 378 void set_osr_values(ZoneList<HUnknownOSRValue*>* values) { | |
| 379 osr_values_.set(values); | |
| 380 } | 373 } |
| 381 | 374 |
| 382 int update_type_change_checksum(int delta) { | 375 int update_type_change_checksum(int delta) { |
| 383 type_change_checksum_ += delta; | 376 type_change_checksum_ += delta; |
| 384 return type_change_checksum_; | 377 return type_change_checksum_; |
| 385 } | 378 } |
| 386 | 379 |
| 387 void update_maximum_environment_size(int environment_size) { | 380 void update_maximum_environment_size(int environment_size) { |
| 388 if (environment_size > maximum_environment_size_) { | 381 if (environment_size > maximum_environment_size_) { |
| 389 maximum_environment_size_ = environment_size; | 382 maximum_environment_size_ = environment_size; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 478 SetOncePointer<HConstant> constant_0_; | 471 SetOncePointer<HConstant> constant_0_; |
| 479 SetOncePointer<HConstant> constant_1_; | 472 SetOncePointer<HConstant> constant_1_; |
| 480 SetOncePointer<HConstant> constant_minus1_; | 473 SetOncePointer<HConstant> constant_minus1_; |
| 481 SetOncePointer<HConstant> constant_true_; | 474 SetOncePointer<HConstant> constant_true_; |
| 482 SetOncePointer<HConstant> constant_false_; | 475 SetOncePointer<HConstant> constant_false_; |
| 483 SetOncePointer<HConstant> constant_the_hole_; | 476 SetOncePointer<HConstant> constant_the_hole_; |
| 484 SetOncePointer<HConstant> constant_null_; | 477 SetOncePointer<HConstant> constant_null_; |
| 485 SetOncePointer<HConstant> constant_invalid_context_; | 478 SetOncePointer<HConstant> constant_invalid_context_; |
| 486 SetOncePointer<HArgumentsObject> arguments_object_; | 479 SetOncePointer<HArgumentsObject> arguments_object_; |
| 487 | 480 |
| 488 SetOncePointer<HBasicBlock> osr_loop_entry_; | 481 HOsrBuilder* osr_; |
| 489 SetOncePointer<ZoneList<HUnknownOSRValue*> > osr_values_; | |
| 490 | 482 |
| 491 CompilationInfo* info_; | 483 CompilationInfo* info_; |
| 492 Zone* zone_; | 484 Zone* zone_; |
| 493 | 485 |
| 494 bool is_recursive_; | 486 bool is_recursive_; |
| 495 bool use_optimistic_licm_; | 487 bool use_optimistic_licm_; |
| 496 bool has_soft_deoptimize_; | 488 bool has_soft_deoptimize_; |
| 497 bool depends_on_empty_array_proto_elements_; | 489 bool depends_on_empty_array_proto_elements_; |
| 498 int type_change_checksum_; | 490 int type_change_checksum_; |
| 499 int maximum_environment_size_; | 491 int maximum_environment_size_; |
| (...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1419 HInstruction* BuildGetArrayFunction(HValue* context); | 1411 HInstruction* BuildGetArrayFunction(HValue* context); |
| 1420 | 1412 |
| 1421 private: | 1413 private: |
| 1422 HGraphBuilder(); | 1414 HGraphBuilder(); |
| 1423 CompilationInfo* info_; | 1415 CompilationInfo* info_; |
| 1424 HGraph* graph_; | 1416 HGraph* graph_; |
| 1425 HBasicBlock* current_block_; | 1417 HBasicBlock* current_block_; |
| 1426 int no_side_effects_scope_count_; | 1418 int no_side_effects_scope_count_; |
| 1427 }; | 1419 }; |
| 1428 | 1420 |
| 1421 // Responsible for building graph parts related to OSR and otherwise | |
| 1422 // setting up the graph to do an OSR compile. | |
| 1423 class HOsrBuilder { | |
|
Michael Starzinger
2013/07/03 10:54:12
Since the implementation has been factored out int
| |
| 1424 public: | |
| 1425 explicit HOsrBuilder(HOptimizedGraphBuilder* builder) | |
| 1426 : builder_(builder), | |
| 1427 osr_entry_(NULL), | |
| 1428 osr_loop_entry_(NULL), | |
| 1429 osr_values_(NULL) { } | |
| 1430 // Creates the loop entry block for the given statement, setting up OSR | |
| 1431 // entries as necessary, and sets the current block to the new block. | |
| 1432 HBasicBlock* BuildPossibleOsrLoopEntry(IterationStatement* statement); | |
| 1433 | |
| 1434 // Process the hydrogen graph after it has been completed, performing | |
| 1435 // any OSR-specific cleanups or changes. | |
| 1436 void FinishGraph(); | |
| 1437 | |
| 1438 // Process the OSR values and phis after initial graph optimization. | |
| 1439 void FinishOsrValues(); | |
| 1440 | |
| 1441 private: | |
| 1442 HBasicBlock* BuildLoopEntry(); | |
| 1443 bool HasOsrEntryAt(IterationStatement* statement); | |
| 1444 | |
| 1445 HOptimizedGraphBuilder* builder_; | |
| 1446 HBasicBlock* osr_entry_; | |
| 1447 HBasicBlock* osr_loop_entry_; | |
| 1448 ZoneList<HUnknownOSRValue*>* osr_values_; | |
| 1449 }; | |
| 1429 | 1450 |
| 1430 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { | 1451 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { |
| 1431 public: | 1452 public: |
| 1432 // A class encapsulating (lazily-allocated) break and continue blocks for | 1453 // A class encapsulating (lazily-allocated) break and continue blocks for |
| 1433 // a breakable statement. Separated from BreakAndContinueScope so that it | 1454 // a breakable statement. Separated from BreakAndContinueScope so that it |
| 1434 // can have a separate lifetime. | 1455 // can have a separate lifetime. |
| 1435 class BreakAndContinueInfo BASE_EMBEDDED { | 1456 class BreakAndContinueInfo BASE_EMBEDDED { |
| 1436 public: | 1457 public: |
| 1437 explicit BreakAndContinueInfo(BreakableStatement* target, | 1458 explicit BreakAndContinueInfo(BreakableStatement* target, |
| 1438 int drop_extra = 0) | 1459 int drop_extra = 0) |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1577 void VisitTypeof(UnaryOperation* expr); | 1598 void VisitTypeof(UnaryOperation* expr); |
| 1578 void VisitSub(UnaryOperation* expr); | 1599 void VisitSub(UnaryOperation* expr); |
| 1579 void VisitBitNot(UnaryOperation* expr); | 1600 void VisitBitNot(UnaryOperation* expr); |
| 1580 void VisitNot(UnaryOperation* expr); | 1601 void VisitNot(UnaryOperation* expr); |
| 1581 | 1602 |
| 1582 void VisitComma(BinaryOperation* expr); | 1603 void VisitComma(BinaryOperation* expr); |
| 1583 void VisitLogicalExpression(BinaryOperation* expr); | 1604 void VisitLogicalExpression(BinaryOperation* expr); |
| 1584 void VisitArithmeticExpression(BinaryOperation* expr); | 1605 void VisitArithmeticExpression(BinaryOperation* expr); |
| 1585 | 1606 |
| 1586 bool PreProcessOsrEntry(IterationStatement* statement); | 1607 bool PreProcessOsrEntry(IterationStatement* statement); |
| 1587 // True iff. we are compiling for OSR and the statement is the entry. | |
| 1588 bool HasOsrEntryAt(IterationStatement* statement); | |
| 1589 void VisitLoopBody(IterationStatement* stmt, | 1608 void VisitLoopBody(IterationStatement* stmt, |
| 1590 HBasicBlock* loop_entry, | 1609 HBasicBlock* loop_entry, |
| 1591 BreakAndContinueInfo* break_info); | 1610 BreakAndContinueInfo* break_info); |
| 1592 | 1611 |
| 1593 // Create a back edge in the flow graph. body_exit is the predecessor | 1612 // Create a back edge in the flow graph. body_exit is the predecessor |
| 1594 // block and loop_entry is the successor block. loop_successor is the | 1613 // block and loop_entry is the successor block. loop_successor is the |
| 1595 // block where control flow exits the loop normally (e.g., via failure of | 1614 // block where control flow exits the loop normally (e.g., via failure of |
| 1596 // the condition) and break_block is the block where control flow breaks | 1615 // the condition) and break_block is the block where control flow breaks |
| 1597 // from the loop. All blocks except loop_entry can be NULL. The return | 1616 // from the loop. All blocks except loop_entry can be NULL. The return |
| 1598 // value is the new successor block which is the join of loop_successor | 1617 // value is the new successor block which is the join of loop_successor |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1940 AstContext* ast_context_; | 1959 AstContext* ast_context_; |
| 1941 | 1960 |
| 1942 // A stack of breakable statements entered. | 1961 // A stack of breakable statements entered. |
| 1943 BreakAndContinueScope* break_scope_; | 1962 BreakAndContinueScope* break_scope_; |
| 1944 | 1963 |
| 1945 int inlined_count_; | 1964 int inlined_count_; |
| 1946 ZoneList<Handle<Object> > globals_; | 1965 ZoneList<Handle<Object> > globals_; |
| 1947 | 1966 |
| 1948 bool inline_bailout_; | 1967 bool inline_bailout_; |
| 1949 | 1968 |
| 1969 HOsrBuilder osr_; | |
| 1970 | |
| 1950 friend class FunctionState; // Pushes and pops the state stack. | 1971 friend class FunctionState; // Pushes and pops the state stack. |
| 1951 friend class AstContext; // Pushes and pops the AST context stack. | 1972 friend class AstContext; // Pushes and pops the AST context stack. |
| 1952 friend class KeyedLoadFastElementStub; | 1973 friend class KeyedLoadFastElementStub; |
| 1974 friend class HOsrBuilder; | |
| 1953 | 1975 |
| 1954 DISALLOW_COPY_AND_ASSIGN(HOptimizedGraphBuilder); | 1976 DISALLOW_COPY_AND_ASSIGN(HOptimizedGraphBuilder); |
| 1955 }; | 1977 }; |
| 1956 | 1978 |
| 1957 | 1979 |
| 1958 Zone* AstContext::zone() const { return owner_->zone(); } | 1980 Zone* AstContext::zone() const { return owner_->zone(); } |
| 1959 | 1981 |
| 1960 | 1982 |
| 1961 class HStatistics: public Malloced { | 1983 class HStatistics: public Malloced { |
| 1962 public: | 1984 public: |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2095 EmbeddedVector<char, 64> filename_; | 2117 EmbeddedVector<char, 64> filename_; |
| 2096 HeapStringAllocator string_allocator_; | 2118 HeapStringAllocator string_allocator_; |
| 2097 StringStream trace_; | 2119 StringStream trace_; |
| 2098 int indent_; | 2120 int indent_; |
| 2099 }; | 2121 }; |
| 2100 | 2122 |
| 2101 | 2123 |
| 2102 } } // namespace v8::internal | 2124 } } // namespace v8::internal |
| 2103 | 2125 |
| 2104 #endif // V8_HYDROGEN_H_ | 2126 #endif // V8_HYDROGEN_H_ |
| OLD | NEW |