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

Side by Side Diff: src/hydrogen-instructions.h

Issue 15533004: Liveness analysis for environment slots in Hydrogen (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 7 years, 6 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 | « src/hydrogen-environment-liveness.cc ('k') | src/hydrogen-instructions.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 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 V(Constant) \ 104 V(Constant) \
105 V(Context) \ 105 V(Context) \
106 V(DebugBreak) \ 106 V(DebugBreak) \
107 V(DeclareGlobals) \ 107 V(DeclareGlobals) \
108 V(DeleteProperty) \ 108 V(DeleteProperty) \
109 V(Deoptimize) \ 109 V(Deoptimize) \
110 V(Div) \ 110 V(Div) \
111 V(DummyUse) \ 111 V(DummyUse) \
112 V(ElementsKind) \ 112 V(ElementsKind) \
113 V(EnterInlined) \ 113 V(EnterInlined) \
114 V(EnvironmentMarker) \
114 V(FixedArrayBaseLength) \ 115 V(FixedArrayBaseLength) \
115 V(ForceRepresentation) \ 116 V(ForceRepresentation) \
116 V(FunctionLiteral) \ 117 V(FunctionLiteral) \
117 V(GetCachedArrayIndex) \ 118 V(GetCachedArrayIndex) \
118 V(GlobalObject) \ 119 V(GlobalObject) \
119 V(GlobalReceiver) \ 120 V(GlobalReceiver) \
120 V(Goto) \ 121 V(Goto) \
121 V(HasCachedArrayIndexAndBranch) \ 122 V(HasCachedArrayIndexAndBranch) \
122 V(HasInstanceTypeAndBranch) \ 123 V(HasInstanceTypeAndBranch) \
123 V(InductionVariableAnnotation) \ 124 V(InductionVariableAnnotation) \
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 kUint32, 806 kUint32,
806 // If a phi is involved in the evaluation of a numeric constraint the 807 // If a phi is involved in the evaluation of a numeric constraint the
807 // recursion can cause an endless cycle: we use this flag to exit the loop. 808 // recursion can cause an endless cycle: we use this flag to exit the loop.
808 kNumericConstraintEvaluationInProgress, 809 kNumericConstraintEvaluationInProgress,
809 // This flag is set to true after the SetupInformativeDefinitions() pass 810 // This flag is set to true after the SetupInformativeDefinitions() pass
810 // has processed this instruction. 811 // has processed this instruction.
811 kIDefsProcessingDone, 812 kIDefsProcessingDone,
812 kHasNoObservableSideEffects, 813 kHasNoObservableSideEffects,
813 // Indicates the instruction is live during dead code elimination. 814 // Indicates the instruction is live during dead code elimination.
814 kIsLive, 815 kIsLive,
815 kLastFlag = kIDefsProcessingDone 816
817 // HEnvironmentMarkers are deleted before dead code
818 // elimination takes place, so they can repurpose the kIsLive flag:
819 kEndsLiveRange = kIsLive,
820
821 // TODO(everyone): Don't forget to update this!
822 kLastFlag = kIsLive
816 }; 823 };
817 824
818 STATIC_ASSERT(kLastFlag < kBitsPerInt); 825 STATIC_ASSERT(kLastFlag < kBitsPerInt);
819 826
820 static const int kChangesToDependsFlagsLeftShift = 1; 827 static const int kChangesToDependsFlagsLeftShift = 1;
821 828
822 static GVNFlag ChangesFlagFromInt(int x) { 829 static GVNFlag ChangesFlagFromInt(int x) {
823 return static_cast<GVNFlag>(x * 2); 830 return static_cast<GVNFlag>(x * 2);
824 } 831 }
825 static GVNFlag DependsOnFlagFromInt(int x) { 832 static GVNFlag DependsOnFlagFromInt(int x) {
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 virtual Representation RequiredInputRepresentation(int index) { 1477 virtual Representation RequiredInputRepresentation(int index) {
1471 return Representation::None(); 1478 return Representation::None();
1472 } 1479 }
1473 1480
1474 DECLARE_CONCRETE_INSTRUCTION(DebugBreak) 1481 DECLARE_CONCRETE_INSTRUCTION(DebugBreak)
1475 }; 1482 };
1476 1483
1477 1484
1478 class HDeoptimize: public HControlInstruction { 1485 class HDeoptimize: public HControlInstruction {
1479 public: 1486 public:
1480 HDeoptimize(int environment_length, Zone* zone) 1487 HDeoptimize(int environment_length,
1481 : values_(environment_length, zone) { } 1488 int first_local_index,
1489 int first_expression_index,
1490 Zone* zone)
1491 : values_(environment_length, zone),
1492 first_local_index_(first_local_index),
1493 first_expression_index_(first_expression_index) { }
1482 1494
1483 virtual Representation RequiredInputRepresentation(int index) { 1495 virtual Representation RequiredInputRepresentation(int index) {
1484 return Representation::None(); 1496 return Representation::None();
1485 } 1497 }
1486 1498
1487 virtual int OperandCount() { return values_.length(); } 1499 virtual int OperandCount() { return values_.length(); }
1488 virtual HValue* OperandAt(int index) const { return values_[index]; } 1500 virtual HValue* OperandAt(int index) const { return values_[index]; }
1489 virtual void PrintDataTo(StringStream* stream); 1501 virtual void PrintDataTo(StringStream* stream);
1490 1502
1491 virtual int SuccessorCount() { return 0; } 1503 virtual int SuccessorCount() { return 0; }
1492 virtual HBasicBlock* SuccessorAt(int i) { 1504 virtual HBasicBlock* SuccessorAt(int i) {
1493 UNREACHABLE(); 1505 UNREACHABLE();
1494 return NULL; 1506 return NULL;
1495 } 1507 }
1496 virtual void SetSuccessorAt(int i, HBasicBlock* block) { 1508 virtual void SetSuccessorAt(int i, HBasicBlock* block) {
1497 UNREACHABLE(); 1509 UNREACHABLE();
1498 } 1510 }
1499 1511
1500 void AddEnvironmentValue(HValue* value, Zone* zone) { 1512 void AddEnvironmentValue(HValue* value, Zone* zone) {
1501 values_.Add(NULL, zone); 1513 values_.Add(NULL, zone);
1502 SetOperandAt(values_.length() - 1, value); 1514 SetOperandAt(values_.length() - 1, value);
1503 } 1515 }
1516 int first_local_index() { return first_local_index_; }
1517 int first_expression_index() { return first_expression_index_; }
1504 1518
1505 DECLARE_CONCRETE_INSTRUCTION(Deoptimize) 1519 DECLARE_CONCRETE_INSTRUCTION(Deoptimize)
1506 1520
1507 enum UseEnvironment { 1521 enum UseEnvironment {
1508 kNoUses, 1522 kNoUses,
1509 kUseAll 1523 kUseAll
1510 }; 1524 };
1511 1525
1512 protected: 1526 protected:
1513 virtual void InternalSetOperandAt(int index, HValue* value) { 1527 virtual void InternalSetOperandAt(int index, HValue* value) {
1514 values_[index] = value; 1528 values_[index] = value;
1515 } 1529 }
1516 1530
1517 private: 1531 private:
1518 ZoneList<HValue*> values_; 1532 ZoneList<HValue*> values_;
1533 int first_local_index_;
1534 int first_expression_index_;
1519 }; 1535 };
1520 1536
1521 1537
1522 class HGoto: public HTemplateControlInstruction<1, 0> { 1538 class HGoto: public HTemplateControlInstruction<1, 0> {
1523 public: 1539 public:
1524 explicit HGoto(HBasicBlock* target) { 1540 explicit HGoto(HBasicBlock* target) {
1525 SetSuccessorAt(0, target); 1541 SetSuccessorAt(0, target);
1526 } 1542 }
1527 1543
1528 virtual Representation RequiredInputRepresentation(int index) { 1544 virtual Representation RequiredInputRepresentation(int index) {
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1820 } 1836 }
1821 bool HasAssignedIndexAt(int index) const { 1837 bool HasAssignedIndexAt(int index) const {
1822 return assigned_indexes_[index] != kNoIndex; 1838 return assigned_indexes_[index] != kNoIndex;
1823 } 1839 }
1824 void AddAssignedValue(int index, HValue* value) { 1840 void AddAssignedValue(int index, HValue* value) {
1825 AddValue(index, value); 1841 AddValue(index, value);
1826 } 1842 }
1827 void AddPushedValue(HValue* value) { 1843 void AddPushedValue(HValue* value) {
1828 AddValue(kNoIndex, value); 1844 AddValue(kNoIndex, value);
1829 } 1845 }
1846 int ToOperandIndex(int environment_index) {
1847 for (int i = 0; i < assigned_indexes_.length(); ++i) {
1848 if (assigned_indexes_[i] == environment_index) return i;
1849 }
1850 return -1;
1851 }
1830 virtual int OperandCount() { return values_.length(); } 1852 virtual int OperandCount() { return values_.length(); }
1831 virtual HValue* OperandAt(int index) const { return values_[index]; } 1853 virtual HValue* OperandAt(int index) const { return values_[index]; }
1832 1854
1833 virtual Representation RequiredInputRepresentation(int index) { 1855 virtual Representation RequiredInputRepresentation(int index) {
1834 return Representation::None(); 1856 return Representation::None();
1835 } 1857 }
1836 1858
1837 void MergeWith(ZoneList<HSimulate*>* list); 1859 void MergeWith(ZoneList<HSimulate*>* list);
1838 bool is_candidate_for_removal() { return removable_ == REMOVABLE_SIMULATE; } 1860 bool is_candidate_for_removal() { return removable_ == REMOVABLE_SIMULATE; }
1839 1861
1840 DECLARE_CONCRETE_INSTRUCTION(Simulate) 1862 DECLARE_CONCRETE_INSTRUCTION(Simulate)
1841 1863
1842 #ifdef DEBUG 1864 #ifdef DEBUG
1843 virtual void Verify(); 1865 virtual void Verify();
1866 void set_closure(Handle<JSFunction> closure) { closure_ = closure; }
1867 Handle<JSFunction> closure() const { return closure_; }
1844 #endif 1868 #endif
1845 1869
1846 protected: 1870 protected:
1847 virtual void InternalSetOperandAt(int index, HValue* value) { 1871 virtual void InternalSetOperandAt(int index, HValue* value) {
1848 values_[index] = value; 1872 values_[index] = value;
1849 } 1873 }
1850 1874
1851 private: 1875 private:
1852 static const int kNoIndex = -1; 1876 static const int kNoIndex = -1;
1853 void AddValue(int index, HValue* value) { 1877 void AddValue(int index, HValue* value) {
1854 assigned_indexes_.Add(index, zone_); 1878 assigned_indexes_.Add(index, zone_);
1855 // Resize the list of pushed values. 1879 // Resize the list of pushed values.
1856 values_.Add(NULL, zone_); 1880 values_.Add(NULL, zone_);
1857 // Set the operand through the base method in HValue to make sure that the 1881 // Set the operand through the base method in HValue to make sure that the
1858 // use lists are correctly updated. 1882 // use lists are correctly updated.
1859 SetOperandAt(values_.length() - 1, value); 1883 SetOperandAt(values_.length() - 1, value);
1860 } 1884 }
1861 BailoutId ast_id_; 1885 BailoutId ast_id_;
1862 int pop_count_; 1886 int pop_count_;
1863 ZoneList<HValue*> values_; 1887 ZoneList<HValue*> values_;
1864 ZoneList<int> assigned_indexes_; 1888 ZoneList<int> assigned_indexes_;
1865 Zone* zone_; 1889 Zone* zone_;
1866 RemovableSimulate removable_; 1890 RemovableSimulate removable_;
1891
1892 #ifdef DEBUG
1893 Handle<JSFunction> closure_;
1894 #endif
1867 }; 1895 };
1868 1896
1869 1897
1898 class HEnvironmentMarker: public HTemplateInstruction<1> {
1899 public:
1900 enum Kind { BIND, LOOKUP };
1901
1902 HEnvironmentMarker(Kind kind, int index)
1903 : kind_(kind), index_(index), next_simulate_(NULL) { }
1904
1905 Kind kind() { return kind_; }
1906 int index() { return index_; }
1907 HSimulate* next_simulate() { return next_simulate_; }
1908 void set_next_simulate(HSimulate* simulate) {
1909 next_simulate_ = simulate;
1910 }
1911
1912 virtual Representation RequiredInputRepresentation(int index) {
1913 return Representation::None();
1914 }
1915
1916 virtual void PrintDataTo(StringStream* stream);
1917
1918 #ifdef DEBUG
1919 void set_closure(Handle<JSFunction> closure) {
1920 ASSERT(closure_.is_null());
1921 ASSERT(!closure.is_null());
1922 closure_ = closure;
1923 }
1924 Handle<JSFunction> closure() const { return closure_; }
1925 #endif
1926
1927 DECLARE_CONCRETE_INSTRUCTION(EnvironmentMarker);
1928
1929 private:
1930 Kind kind_;
1931 int index_;
1932 HSimulate* next_simulate_;
1933
1934 #ifdef DEBUG
1935 Handle<JSFunction> closure_;
1936 #endif
1937 };
1938
1939
1870 class HStackCheck: public HTemplateInstruction<1> { 1940 class HStackCheck: public HTemplateInstruction<1> {
1871 public: 1941 public:
1872 enum Type { 1942 enum Type {
1873 kFunctionEntry, 1943 kFunctionEntry,
1874 kBackwardsBranch 1944 kBackwardsBranch
1875 }; 1945 };
1876 1946
1877 HStackCheck(HValue* context, Type type) : type_(type) { 1947 HStackCheck(HValue* context, Type type) : type_(type) {
1878 SetOperandAt(0, context); 1948 SetOperandAt(0, context);
1879 SetGVNFlag(kChangesNewSpacePromotion); 1949 SetGVNFlag(kChangesNewSpacePromotion);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1913 1983
1914 1984
1915 class HEnterInlined: public HTemplateInstruction<0> { 1985 class HEnterInlined: public HTemplateInstruction<0> {
1916 public: 1986 public:
1917 HEnterInlined(Handle<JSFunction> closure, 1987 HEnterInlined(Handle<JSFunction> closure,
1918 int arguments_count, 1988 int arguments_count,
1919 FunctionLiteral* function, 1989 FunctionLiteral* function,
1920 InliningKind inlining_kind, 1990 InliningKind inlining_kind,
1921 Variable* arguments_var, 1991 Variable* arguments_var,
1922 ZoneList<HValue*>* arguments_values, 1992 ZoneList<HValue*>* arguments_values,
1923 bool undefined_receiver) 1993 bool undefined_receiver,
1994 Zone* zone)
1924 : closure_(closure), 1995 : closure_(closure),
1925 arguments_count_(arguments_count), 1996 arguments_count_(arguments_count),
1926 arguments_pushed_(false), 1997 arguments_pushed_(false),
1927 function_(function), 1998 function_(function),
1928 inlining_kind_(inlining_kind), 1999 inlining_kind_(inlining_kind),
1929 arguments_var_(arguments_var), 2000 arguments_var_(arguments_var),
1930 arguments_values_(arguments_values), 2001 arguments_values_(arguments_values),
1931 undefined_receiver_(undefined_receiver) { 2002 undefined_receiver_(undefined_receiver),
2003 return_targets_(2, zone) {
1932 } 2004 }
1933 2005
2006 void RegisterReturnTarget(HBasicBlock* return_target, Zone* zone);
2007 ZoneList<HBasicBlock*>* return_targets() { return &return_targets_; }
2008
1934 virtual void PrintDataTo(StringStream* stream); 2009 virtual void PrintDataTo(StringStream* stream);
1935 2010
1936 Handle<JSFunction> closure() const { return closure_; } 2011 Handle<JSFunction> closure() const { return closure_; }
1937 int arguments_count() const { return arguments_count_; } 2012 int arguments_count() const { return arguments_count_; }
1938 bool arguments_pushed() const { return arguments_pushed_; } 2013 bool arguments_pushed() const { return arguments_pushed_; }
1939 void set_arguments_pushed() { arguments_pushed_ = true; } 2014 void set_arguments_pushed() { arguments_pushed_ = true; }
1940 FunctionLiteral* function() const { return function_; } 2015 FunctionLiteral* function() const { return function_; }
1941 InliningKind inlining_kind() const { return inlining_kind_; } 2016 InliningKind inlining_kind() const { return inlining_kind_; }
1942 bool undefined_receiver() const { return undefined_receiver_; } 2017 bool undefined_receiver() const { return undefined_receiver_; }
1943 2018
1944 virtual Representation RequiredInputRepresentation(int index) { 2019 virtual Representation RequiredInputRepresentation(int index) {
1945 return Representation::None(); 2020 return Representation::None();
1946 } 2021 }
1947 2022
1948 Variable* arguments_var() { return arguments_var_; } 2023 Variable* arguments_var() { return arguments_var_; }
1949 ZoneList<HValue*>* arguments_values() { return arguments_values_; } 2024 ZoneList<HValue*>* arguments_values() { return arguments_values_; }
1950 2025
1951 DECLARE_CONCRETE_INSTRUCTION(EnterInlined) 2026 DECLARE_CONCRETE_INSTRUCTION(EnterInlined)
1952 2027
1953 private: 2028 private:
1954 Handle<JSFunction> closure_; 2029 Handle<JSFunction> closure_;
1955 int arguments_count_; 2030 int arguments_count_;
1956 bool arguments_pushed_; 2031 bool arguments_pushed_;
1957 FunctionLiteral* function_; 2032 FunctionLiteral* function_;
1958 InliningKind inlining_kind_; 2033 InliningKind inlining_kind_;
1959 Variable* arguments_var_; 2034 Variable* arguments_var_;
1960 ZoneList<HValue*>* arguments_values_; 2035 ZoneList<HValue*>* arguments_values_;
1961 bool undefined_receiver_; 2036 bool undefined_receiver_;
2037 ZoneList<HBasicBlock*> return_targets_;
1962 }; 2038 };
1963 2039
1964 2040
1965 class HLeaveInlined: public HTemplateInstruction<0> { 2041 class HLeaveInlined: public HTemplateInstruction<0> {
1966 public: 2042 public:
1967 HLeaveInlined() { } 2043 HLeaveInlined() { }
1968 2044
1969 virtual Representation RequiredInputRepresentation(int index) { 2045 virtual Representation RequiredInputRepresentation(int index) {
1970 return Representation::None(); 2046 return Representation::None();
1971 } 2047 }
(...skipping 4489 matching lines...) Expand 10 before | Expand all | Expand 10 after
6461 virtual bool IsDeletable() const { return true; } 6537 virtual bool IsDeletable() const { return true; }
6462 }; 6538 };
6463 6539
6464 6540
6465 #undef DECLARE_INSTRUCTION 6541 #undef DECLARE_INSTRUCTION
6466 #undef DECLARE_CONCRETE_INSTRUCTION 6542 #undef DECLARE_CONCRETE_INSTRUCTION
6467 6543
6468 } } // namespace v8::internal 6544 } } // namespace v8::internal
6469 6545
6470 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 6546 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen-environment-liveness.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698