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

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

Issue 11414201: Make HJSArrayLength more likely to have identical GVNs. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years 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
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 1911 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 DECLARE_CONCRETE_INSTRUCTION(CallRuntime) 1922 DECLARE_CONCRETE_INSTRUCTION(CallRuntime)
1923 1923
1924 private: 1924 private:
1925 const Runtime::Function* c_function_; 1925 const Runtime::Function* c_function_;
1926 Handle<String> name_; 1926 Handle<String> name_;
1927 }; 1927 };
1928 1928
1929 1929
1930 class HJSArrayLength: public HTemplateInstruction<2> { 1930 class HJSArrayLength: public HTemplateInstruction<2> {
1931 public: 1931 public:
1932 HJSArrayLength(HValue* value, HValue* typecheck, 1932 static HJSArrayLength* Create(HGraph* graph,
1933 HType type = HType::Tagged()) { 1933 HValue* value,
1934 set_type(type); 1934 HValue* typecheck,
1935 // The length of an array is stored as a tagged value in the array 1935 HType type = HType::Tagged());
1936 // object. It is guaranteed to be 32 bit integer, but it can be
1937 // represented as either a smi or heap number.
1938 SetOperandAt(0, value);
1939 SetOperandAt(1, typecheck);
1940 set_representation(Representation::Tagged());
1941 SetFlag(kUseGVN);
1942 SetGVNFlag(kDependsOnArrayLengths);
1943 SetGVNFlag(kDependsOnMaps);
1944 }
1945 1936
1946 virtual Representation RequiredInputRepresentation(int index) { 1937 virtual Representation RequiredInputRepresentation(int index) {
1947 return Representation::Tagged(); 1938 return Representation::Tagged();
1948 } 1939 }
1949 1940
1950 virtual void PrintDataTo(StringStream* stream); 1941 virtual void PrintDataTo(StringStream* stream);
1951 1942
1943 const HValue* value() const { return OperandAt(0); }
1952 HValue* value() { return OperandAt(0); } 1944 HValue* value() { return OperandAt(0); }
1953 HValue* typecheck() { return OperandAt(1); } 1945 HValue* typecheck() { return OperandAt(1); }
1954 1946
1955 DECLARE_CONCRETE_INSTRUCTION(JSArrayLength) 1947 DECLARE_CONCRETE_INSTRUCTION(JSArrayLength)
1956 1948
1957 protected: 1949 protected:
1958 virtual bool DataEquals(HValue* other_raw) { return true; } 1950 virtual bool DataEquals(HValue* other_raw) { return true; }
1959 1951
1960 private: 1952 private:
1961 virtual bool IsDeletable() const { return true; } 1953 virtual bool IsDeletable() const { return true; }
1954
1955 HJSArrayLength(HValue* value, HValue* typecheck,
1956 HType type = HType::Tagged()) {
1957 set_type(type);
1958 // The length of an array is stored as a tagged value in the array
1959 // object. It is guaranteed to be 32 bit integer, but it can be
1960 // represented as either a smi or heap number.
1961 SetOperandAt(0, value);
1962 SetOperandAt(1, typecheck);
1963 set_representation(Representation::Tagged());
1964 SetFlag(kUseGVN);
1965 SetGVNFlag(kDependsOnArrayLengths);
1966 SetGVNFlag(kDependsOnMaps);
1967 }
1962 }; 1968 };
1963 1969
1964 1970
1965 class HFixedArrayBaseLength: public HUnaryOperation { 1971 class HFixedArrayBaseLength: public HUnaryOperation {
1966 public: 1972 public:
1967 explicit HFixedArrayBaseLength(HValue* value) : HUnaryOperation(value) { 1973 explicit HFixedArrayBaseLength(HValue* value) : HUnaryOperation(value) {
1968 set_type(HType::Smi()); 1974 set_type(HType::Smi());
1969 set_representation(Representation::Tagged()); 1975 set_representation(Representation::Tagged());
1970 SetFlag(kUseGVN); 1976 SetFlag(kUseGVN);
1971 SetGVNFlag(kDependsOnArrayLengths); 1977 SetGVNFlag(kDependsOnArrayLengths);
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
2254 2260
2255 virtual Representation RequiredInputRepresentation(int index) { 2261 virtual Representation RequiredInputRepresentation(int index) {
2256 return Representation::Tagged(); 2262 return Representation::Tagged();
2257 } 2263 }
2258 2264
2259 virtual void PrintDataTo(StringStream* stream); 2265 virtual void PrintDataTo(StringStream* stream);
2260 virtual HType CalculateInferredType(); 2266 virtual HType CalculateInferredType();
2261 2267
2262 HValue* value() { return OperandAt(0); } 2268 HValue* value() { return OperandAt(0); }
2263 SmallMapList* map_set() { return &map_set_; } 2269 SmallMapList* map_set() { return &map_set_; }
2270 bool has_dependency() { return OperandAt(1) != OperandAt(0); }
2264 2271
2265 DECLARE_CONCRETE_INSTRUCTION(CheckMaps) 2272 DECLARE_CONCRETE_INSTRUCTION(CheckMaps)
2266 2273
2267 protected: 2274 protected:
2268 virtual bool DataEquals(HValue* other) { 2275 virtual bool DataEquals(HValue* other) {
2269 HCheckMaps* b = HCheckMaps::cast(other); 2276 HCheckMaps* b = HCheckMaps::cast(other);
2270 // Relies on the fact that map_set has been sorted before. 2277 // Relies on the fact that map_set has been sorted before.
2271 if (map_set()->length() != b->map_set()->length()) return false; 2278 if (map_set()->length() != b->map_set()->length()) return false;
2272 for (int i = 0; i < map_set()->length(); i++) { 2279 for (int i = 0; i < map_set()->length(); i++) {
2273 if (!map_set()->at(i).is_identical_to(b->map_set()->at(i))) return false; 2280 if (!map_set()->at(i).is_identical_to(b->map_set()->at(i))) return false;
(...skipping 3116 matching lines...) Expand 10 before | Expand all | Expand 10 after
5390 virtual bool IsDeletable() const { return true; } 5397 virtual bool IsDeletable() const { return true; }
5391 }; 5398 };
5392 5399
5393 5400
5394 #undef DECLARE_INSTRUCTION 5401 #undef DECLARE_INSTRUCTION
5395 #undef DECLARE_CONCRETE_INSTRUCTION 5402 #undef DECLARE_CONCRETE_INSTRUCTION
5396 5403
5397 } } // namespace v8::internal 5404 } } // namespace v8::internal
5398 5405
5399 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 5406 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« src/hydrogen.cc ('K') | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698