| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 // have already been inserted in the instruction stream (or not need to | 438 // have already been inserted in the instruction stream (or not need to |
| 439 // be, e.g., HPhi). Call this function in tail position in the Visit | 439 // be, e.g., HPhi). Call this function in tail position in the Visit |
| 440 // functions for expressions. | 440 // functions for expressions. |
| 441 virtual void ReturnValue(HValue* value) = 0; | 441 virtual void ReturnValue(HValue* value) = 0; |
| 442 | 442 |
| 443 // Add a hydrogen instruction to the instruction stream (recording an | 443 // Add a hydrogen instruction to the instruction stream (recording an |
| 444 // environment simulation if necessary) and then fill this context with | 444 // environment simulation if necessary) and then fill this context with |
| 445 // the instruction as value. | 445 // the instruction as value. |
| 446 virtual void ReturnInstruction(HInstruction* instr, int ast_id) = 0; | 446 virtual void ReturnInstruction(HInstruction* instr, int ast_id) = 0; |
| 447 | 447 |
| 448 virtual bool IsTypeof() { return false; } |
| 449 |
| 448 protected: | 450 protected: |
| 449 AstContext(HGraphBuilder* owner, Expression::Context kind); | 451 AstContext(HGraphBuilder* owner, Expression::Context kind); |
| 450 virtual ~AstContext(); | 452 virtual ~AstContext(); |
| 451 | 453 |
| 452 HGraphBuilder* owner() const { return owner_; } | 454 HGraphBuilder* owner() const { return owner_; } |
| 453 | 455 |
| 454 // We want to be able to assert, in a context-specific way, that the stack | 456 // We want to be able to assert, in a context-specific way, that the stack |
| 455 // height makes sense when the context is filled. | 457 // height makes sense when the context is filled. |
| 456 #ifdef DEBUG | 458 #ifdef DEBUG |
| 457 int original_length_; | 459 int original_length_; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 472 virtual ~EffectContext(); | 474 virtual ~EffectContext(); |
| 473 | 475 |
| 474 virtual void ReturnValue(HValue* value); | 476 virtual void ReturnValue(HValue* value); |
| 475 virtual void ReturnInstruction(HInstruction* instr, int ast_id); | 477 virtual void ReturnInstruction(HInstruction* instr, int ast_id); |
| 476 }; | 478 }; |
| 477 | 479 |
| 478 | 480 |
| 479 class ValueContext: public AstContext { | 481 class ValueContext: public AstContext { |
| 480 public: | 482 public: |
| 481 explicit ValueContext(HGraphBuilder* owner) | 483 explicit ValueContext(HGraphBuilder* owner) |
| 482 : AstContext(owner, Expression::kValue) { | 484 : AstContext(owner, Expression::kValue), is_typeof_(false) { |
| 483 } | 485 } |
| 484 virtual ~ValueContext(); | 486 virtual ~ValueContext(); |
| 485 | 487 |
| 486 virtual void ReturnValue(HValue* value); | 488 virtual void ReturnValue(HValue* value); |
| 487 virtual void ReturnInstruction(HInstruction* instr, int ast_id); | 489 virtual void ReturnInstruction(HInstruction* instr, int ast_id); |
| 490 virtual bool IsTypeof() { return is_typeof_; } |
| 491 void MarkAsTypeof() { is_typeof_ = true; } |
| 492 |
| 493 private: |
| 494 bool is_typeof_; |
| 488 }; | 495 }; |
| 489 | 496 |
| 490 | 497 |
| 491 class TestContext: public AstContext { | 498 class TestContext: public AstContext { |
| 492 public: | 499 public: |
| 493 TestContext(HGraphBuilder* owner, | 500 TestContext(HGraphBuilder* owner, |
| 494 HBasicBlock* if_true, | 501 HBasicBlock* if_true, |
| 495 HBasicBlock* if_false) | 502 HBasicBlock* if_false) |
| 496 : AstContext(owner, Expression::kTest), | 503 : AstContext(owner, Expression::kTest), |
| 497 if_true_(if_true), | 504 if_true_(if_true), |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 | 727 |
| 721 HBasicBlock* JoinContinue(IterationStatement* statement, | 728 HBasicBlock* JoinContinue(IterationStatement* statement, |
| 722 HBasicBlock* exit_block, | 729 HBasicBlock* exit_block, |
| 723 HBasicBlock* continue_block); | 730 HBasicBlock* continue_block); |
| 724 | 731 |
| 725 HValue* Top() const { return environment()->Top(); } | 732 HValue* Top() const { return environment()->Top(); } |
| 726 void Drop(int n) { environment()->Drop(n); } | 733 void Drop(int n) { environment()->Drop(n); } |
| 727 void Bind(Variable* var, HValue* value) { environment()->Bind(var, value); } | 734 void Bind(Variable* var, HValue* value) { environment()->Bind(var, value); } |
| 728 | 735 |
| 729 void VisitForValue(Expression* expr); | 736 void VisitForValue(Expression* expr); |
| 737 void VisitForTypeofValue(Expression* expr); |
| 730 void VisitForEffect(Expression* expr); | 738 void VisitForEffect(Expression* expr); |
| 731 void VisitForControl(Expression* expr, | 739 void VisitForControl(Expression* expr, |
| 732 HBasicBlock* true_block, | 740 HBasicBlock* true_block, |
| 733 HBasicBlock* false_block); | 741 HBasicBlock* false_block); |
| 734 | 742 |
| 735 // Visit an argument subexpression and emit a push to the outgoing | 743 // Visit an argument subexpression and emit a push to the outgoing |
| 736 // arguments. | 744 // arguments. |
| 737 void VisitArgument(Expression* expr); | 745 void VisitArgument(Expression* expr); |
| 738 void VisitArgumentList(ZoneList<Expression*>* arguments); | 746 void VisitArgumentList(ZoneList<Expression*>* arguments); |
| 739 | 747 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 755 virtual void VisitStatements(ZoneList<Statement*>* statements); | 763 virtual void VisitStatements(ZoneList<Statement*>* statements); |
| 756 | 764 |
| 757 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | 765 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
| 758 AST_NODE_LIST(DECLARE_VISIT) | 766 AST_NODE_LIST(DECLARE_VISIT) |
| 759 #undef DECLARE_VISIT | 767 #undef DECLARE_VISIT |
| 760 | 768 |
| 761 HBasicBlock* CreateBasicBlock(HEnvironment* env); | 769 HBasicBlock* CreateBasicBlock(HEnvironment* env); |
| 762 HBasicBlock* CreateLoopHeaderBlock(); | 770 HBasicBlock* CreateLoopHeaderBlock(); |
| 763 | 771 |
| 764 // Helpers for flow graph construction. | 772 // Helpers for flow graph construction. |
| 765 void LookupGlobalPropertyCell(Variable* var, | 773 bool LookupGlobalPropertyCell(Variable* var, |
| 766 LookupResult* lookup, | 774 LookupResult* lookup, |
| 767 bool is_store); | 775 bool is_store); |
| 768 | 776 |
| 769 bool TryArgumentsAccess(Property* expr); | 777 bool TryArgumentsAccess(Property* expr); |
| 770 bool TryCallApply(Call* expr); | 778 bool TryCallApply(Call* expr); |
| 771 bool TryInline(Call* expr); | 779 bool TryInline(Call* expr); |
| 772 bool TryInlineBuiltinFunction(Call* expr, | 780 bool TryInlineBuiltinFunction(Call* expr, |
| 773 HValue* receiver, | 781 HValue* receiver, |
| 774 Handle<Map> receiver_map, | 782 Handle<Map> receiver_map, |
| 775 CheckType check_type); | 783 CheckType check_type); |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 const char* filename_; | 1102 const char* filename_; |
| 1095 HeapStringAllocator string_allocator_; | 1103 HeapStringAllocator string_allocator_; |
| 1096 StringStream trace_; | 1104 StringStream trace_; |
| 1097 int indent_; | 1105 int indent_; |
| 1098 }; | 1106 }; |
| 1099 | 1107 |
| 1100 | 1108 |
| 1101 } } // namespace v8::internal | 1109 } } // namespace v8::internal |
| 1102 | 1110 |
| 1103 #endif // V8_HYDROGEN_H_ | 1111 #endif // V8_HYDROGEN_H_ |
| OLD | NEW |