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

Side by Side Diff: src/hydrogen.h

Issue 6902202: Be more discriminating about uses of the arguments object in optimized code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Simplified. Created 9 years, 7 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
« no previous file with comments | « no previous file | src/hydrogen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 int local_count_; 432 int local_count_;
433 HEnvironment* outer_; 433 HEnvironment* outer_;
434 int pop_count_; 434 int pop_count_;
435 int push_count_; 435 int push_count_;
436 int ast_id_; 436 int ast_id_;
437 }; 437 };
438 438
439 439
440 class HGraphBuilder; 440 class HGraphBuilder;
441 441
442 enum ArgumentsAllowedFlag {
443 ARGUMENTS_NOT_ALLOWED,
444 ARGUMENTS_ALLOWED
445 };
446
442 // This class is not BASE_EMBEDDED because our inlining implementation uses 447 // This class is not BASE_EMBEDDED because our inlining implementation uses
443 // new and delete. 448 // new and delete.
444 class AstContext { 449 class AstContext {
445 public: 450 public:
446 bool IsEffect() const { return kind_ == Expression::kEffect; } 451 bool IsEffect() const { return kind_ == Expression::kEffect; }
447 bool IsValue() const { return kind_ == Expression::kValue; } 452 bool IsValue() const { return kind_ == Expression::kValue; }
448 bool IsTest() const { return kind_ == Expression::kTest; } 453 bool IsTest() const { return kind_ == Expression::kTest; }
449 454
450 // 'Fill' this context with a hydrogen value. The value is assumed to 455 // 'Fill' this context with a hydrogen value. The value is assumed to
451 // have already been inserted in the instruction stream (or not need to 456 // have already been inserted in the instruction stream (or not need to
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 } 495 }
491 virtual ~EffectContext(); 496 virtual ~EffectContext();
492 497
493 virtual void ReturnValue(HValue* value); 498 virtual void ReturnValue(HValue* value);
494 virtual void ReturnInstruction(HInstruction* instr, int ast_id); 499 virtual void ReturnInstruction(HInstruction* instr, int ast_id);
495 }; 500 };
496 501
497 502
498 class ValueContext: public AstContext { 503 class ValueContext: public AstContext {
499 public: 504 public:
500 explicit ValueContext(HGraphBuilder* owner) 505 explicit ValueContext(HGraphBuilder* owner, ArgumentsAllowedFlag flag)
501 : AstContext(owner, Expression::kValue) { 506 : AstContext(owner, Expression::kValue), flag_(flag) {
502 } 507 }
503 virtual ~ValueContext(); 508 virtual ~ValueContext();
504 509
505 virtual void ReturnValue(HValue* value); 510 virtual void ReturnValue(HValue* value);
506 virtual void ReturnInstruction(HInstruction* instr, int ast_id); 511 virtual void ReturnInstruction(HInstruction* instr, int ast_id);
512
513 bool arguments_allowed() { return flag_ == ARGUMENTS_ALLOWED; }
514
515 private:
516 ArgumentsAllowedFlag flag_;
507 }; 517 };
508 518
509 519
510 class TestContext: public AstContext { 520 class TestContext: public AstContext {
511 public: 521 public:
512 TestContext(HGraphBuilder* owner, 522 TestContext(HGraphBuilder* owner,
513 HBasicBlock* if_true, 523 HBasicBlock* if_true,
514 HBasicBlock* if_false) 524 HBasicBlock* if_false)
515 : AstContext(owner, Expression::kTest), 525 : AstContext(owner, Expression::kTest),
516 if_true_(if_true), 526 if_true_(if_true),
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 } 669 }
660 670
661 // Adding instructions. 671 // Adding instructions.
662 HInstruction* AddInstruction(HInstruction* instr); 672 HInstruction* AddInstruction(HInstruction* instr);
663 void AddSimulate(int id); 673 void AddSimulate(int id);
664 674
665 // Bailout environment manipulation. 675 // Bailout environment manipulation.
666 void Push(HValue* value) { environment()->Push(value); } 676 void Push(HValue* value) { environment()->Push(value); }
667 HValue* Pop() { return environment()->Pop(); } 677 HValue* Pop() { return environment()->Pop(); }
668 678
679 void Bailout(const char* reason);
680
669 private: 681 private:
670 // Type of a member function that generates inline code for a native function. 682 // Type of a member function that generates inline code for a native function.
671 typedef void (HGraphBuilder::*InlineFunctionGenerator)(CallRuntime* call); 683 typedef void (HGraphBuilder::*InlineFunctionGenerator)(CallRuntime* call);
672 684
673 // Forward declarations for inner scope classes. 685 // Forward declarations for inner scope classes.
674 class SubgraphScope; 686 class SubgraphScope;
675 687
676 static const InlineFunctionGenerator kInlineFunctionGenerators[]; 688 static const InlineFunctionGenerator kInlineFunctionGenerators[];
677 689
678 static const int kMaxCallPolymorphism = 4; 690 static const int kMaxCallPolymorphism = 4;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 } 725 }
714 726
715 // Generators for inline runtime functions. 727 // Generators for inline runtime functions.
716 #define INLINE_FUNCTION_GENERATOR_DECLARATION(Name, argc, ressize) \ 728 #define INLINE_FUNCTION_GENERATOR_DECLARATION(Name, argc, ressize) \
717 void Generate##Name(CallRuntime* call); 729 void Generate##Name(CallRuntime* call);
718 730
719 INLINE_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_DECLARATION) 731 INLINE_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_DECLARATION)
720 INLINE_RUNTIME_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_DECLARATION) 732 INLINE_RUNTIME_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_DECLARATION)
721 #undef INLINE_FUNCTION_GENERATOR_DECLARATION 733 #undef INLINE_FUNCTION_GENERATOR_DECLARATION
722 734
723 void Bailout(const char* reason);
724
725 void PreProcessOsrEntry(IterationStatement* statement); 735 void PreProcessOsrEntry(IterationStatement* statement);
726 // True iff. we are compiling for OSR and the statement is the entry. 736 // True iff. we are compiling for OSR and the statement is the entry.
727 bool HasOsrEntryAt(IterationStatement* statement); 737 bool HasOsrEntryAt(IterationStatement* statement);
728 738
729 HBasicBlock* CreateJoin(HBasicBlock* first, 739 HBasicBlock* CreateJoin(HBasicBlock* first,
730 HBasicBlock* second, 740 HBasicBlock* second,
731 int join_id); 741 int join_id);
732 742
733 // Create a back edge in the flow graph. body_exit is the predecessor 743 // Create a back edge in the flow graph. body_exit is the predecessor
734 // block and loop_entry is the successor block. loop_successor is the 744 // block and loop_entry is the successor block. loop_successor is the
735 // block where control flow exits the loop normally (e.g., via failure of 745 // block where control flow exits the loop normally (e.g., via failure of
736 // the condition) and break_block is the block where control flow breaks 746 // the condition) and break_block is the block where control flow breaks
737 // from the loop. All blocks except loop_entry can be NULL. The return 747 // from the loop. All blocks except loop_entry can be NULL. The return
738 // value is the new successor block which is the join of loop_successor 748 // value is the new successor block which is the join of loop_successor
739 // and break_block, or NULL. 749 // and break_block, or NULL.
740 HBasicBlock* CreateLoop(IterationStatement* statement, 750 HBasicBlock* CreateLoop(IterationStatement* statement,
741 HBasicBlock* loop_entry, 751 HBasicBlock* loop_entry,
742 HBasicBlock* body_exit, 752 HBasicBlock* body_exit,
743 HBasicBlock* loop_successor, 753 HBasicBlock* loop_successor,
744 HBasicBlock* break_block); 754 HBasicBlock* break_block);
745 755
746 HBasicBlock* JoinContinue(IterationStatement* statement, 756 HBasicBlock* JoinContinue(IterationStatement* statement,
747 HBasicBlock* exit_block, 757 HBasicBlock* exit_block,
748 HBasicBlock* continue_block); 758 HBasicBlock* continue_block);
749 759
750 HValue* Top() const { return environment()->Top(); } 760 HValue* Top() const { return environment()->Top(); }
751 void Drop(int n) { environment()->Drop(n); } 761 void Drop(int n) { environment()->Drop(n); }
752 void Bind(Variable* var, HValue* value) { environment()->Bind(var, value); } 762 void Bind(Variable* var, HValue* value) { environment()->Bind(var, value); }
753 763
754 void VisitForValue(Expression* expr); 764 // The value of the arguments object is allowed in some but not most value
765 // contexts. (It's allowed in all effect contexts and disallowed in all
766 // test contexts.)
767 void VisitForValue(Expression* expr,
768 ArgumentsAllowedFlag flag = ARGUMENTS_NOT_ALLOWED);
755 void VisitForTypeOf(Expression* expr); 769 void VisitForTypeOf(Expression* expr);
756 void VisitForEffect(Expression* expr); 770 void VisitForEffect(Expression* expr);
757 void VisitForControl(Expression* expr, 771 void VisitForControl(Expression* expr,
758 HBasicBlock* true_block, 772 HBasicBlock* true_block,
759 HBasicBlock* false_block); 773 HBasicBlock* false_block);
760 774
761 // Visit an argument subexpression and emit a push to the outgoing 775 // Visit an argument subexpression and emit a push to the outgoing
762 // arguments. 776 // arguments.
763 void VisitArgument(Expression* expr); 777 void VisitArgument(Expression* expr);
764 void VisitArgumentList(ZoneList<Expression*>* arguments); 778 void VisitArgumentList(ZoneList<Expression*>* arguments);
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 const char* filename_; 1155 const char* filename_;
1142 HeapStringAllocator string_allocator_; 1156 HeapStringAllocator string_allocator_;
1143 StringStream trace_; 1157 StringStream trace_;
1144 int indent_; 1158 int indent_;
1145 }; 1159 };
1146 1160
1147 1161
1148 } } // namespace v8::internal 1162 } } // namespace v8::internal
1149 1163
1150 #endif // V8_HYDROGEN_H_ 1164 #endif // V8_HYDROGEN_H_
OLDNEW
« no previous file with comments | « no previous file | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698