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 1927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1938 const char* failure_reason); | 1938 const char* failure_reason); |
1939 | 1939 |
1940 void HandleGlobalVariableAssignment(Variable* var, | 1940 void HandleGlobalVariableAssignment(Variable* var, |
1941 HValue* value, | 1941 HValue* value, |
1942 int position, | 1942 int position, |
1943 BailoutId ast_id); | 1943 BailoutId ast_id); |
1944 | 1944 |
1945 void HandlePropertyAssignment(Assignment* expr); | 1945 void HandlePropertyAssignment(Assignment* expr); |
1946 void HandleCompoundAssignment(Assignment* expr); | 1946 void HandleCompoundAssignment(Assignment* expr); |
1947 void HandlePolymorphicLoadNamedField(int position, | 1947 void HandlePolymorphicLoadNamedField(int position, |
1948 BailoutId ast_id, | |
1948 BailoutId return_id, | 1949 BailoutId return_id, |
1949 HValue* object, | 1950 HValue* object, |
1950 SmallMapList* types, | 1951 SmallMapList* types, |
1951 Handle<String> name); | 1952 Handle<String> name); |
1952 HInstruction* TryLoadPolymorphicAsMonomorphic(HValue* object, | 1953 |
1953 SmallMapList* types, | 1954 class PropertyAccessInfo { |
1954 Handle<String> name); | 1955 public: |
1956 PropertyAccessInfo(Isolate* isolate, Handle<Map> map, Handle<String> name) | |
1957 : lookup_(isolate), | |
1958 map_(map), | |
1959 name_(name), | |
1960 access_(HObjectAccess::ForMap()) { } | |
1961 | |
1962 // Checkes whether this PropertyAccessInfo can be handled as a monomorphic | |
1963 // load named. It additionally fills in the fields necessary to generate the | |
1964 // lookup code. | |
1965 bool CanLoadMonomorphic(); | |
1966 | |
1967 // Checks whether all types behave uniform when loading name. If all maps | |
1968 // behave the same, a single monomorphic load instruction can be emitted, | |
1969 // guarded by a single map-checks instruction that whether the receiver is | |
1970 // an instance of any of the types. | |
1971 // This method skips the first type in types, assuming that this | |
1972 // PropertyAccessInfo is built for types->first(). | |
1973 bool CanLoadAsMonomorphic(SmallMapList* types); | |
1974 | |
1975 bool IsStringLength() { | |
1976 return map_->instance_type() < FIRST_NONSTRING_TYPE && | |
1977 name_->Equals(isolate()->heap()->length_string()); | |
1978 } | |
1979 | |
1980 bool IsArrayLength() { | |
1981 return map_->instance_type() == JS_ARRAY_TYPE && | |
titzer
2013/09/17 15:46:29
I don't think we want to rely on the name here. Sh
Toon Verwaest
2013/09/17 18:24:31
We didn't do a lookup because that would find nati
| |
1982 name_->Equals(isolate()->heap()->length_string()); | |
1983 } | |
1984 | |
1985 bool has_holder() { return !holder_.is_null(); } | |
1986 | |
1987 LookupResult* lookup() { return &lookup_; } | |
1988 Handle<Map> map() { return map_; } | |
1989 Handle<JSObject> holder() { return holder_; } | |
1990 Handle<JSFunction> accessor() { return accessor_; } | |
1991 Handle<Object> constant() { return constant_; } | |
1992 HObjectAccess access() { return access_; } | |
1993 | |
1994 private: | |
1995 Isolate* isolate() { return lookup_.isolate(); } | |
1996 | |
1997 bool LoadResult(Handle<Map> map); | |
1998 bool LookupDescriptor(); | |
1999 bool LookupInPrototypes(); | |
2000 bool IsCompatibleForLoad(PropertyAccessInfo* other); | |
2001 | |
2002 void GeneralizeRepresentation(Representation r) { | |
2003 access_ = access_.WithRepresentation( | |
2004 access_.representation().generalize(r)); | |
2005 } | |
2006 | |
2007 LookupResult lookup_; | |
2008 Handle<Map> map_; | |
2009 Handle<String> name_; | |
2010 Handle<JSObject> holder_; | |
2011 Handle<JSFunction> accessor_; | |
2012 Handle<Object> constant_; | |
2013 HObjectAccess access_; | |
2014 }; | |
2015 | |
2016 HInstruction* BuildLoadMonomorphic(PropertyAccessInfo* info, | |
2017 HValue* object, | |
2018 HInstruction* checked_object, | |
2019 BailoutId ast_id, | |
2020 BailoutId return_id, | |
2021 bool can_inline_accessor = true); | |
2022 | |
1955 void HandlePolymorphicStoreNamedField(int position, | 2023 void HandlePolymorphicStoreNamedField(int position, |
1956 BailoutId assignment_id, | 2024 BailoutId assignment_id, |
1957 HValue* object, | 2025 HValue* object, |
1958 HValue* value, | 2026 HValue* value, |
1959 SmallMapList* types, | 2027 SmallMapList* types, |
1960 Handle<String> name); | 2028 Handle<String> name); |
1961 bool TryStorePolymorphicAsMonomorphic(int position, | 2029 bool TryStorePolymorphicAsMonomorphic(int position, |
1962 BailoutId assignment_id, | 2030 BailoutId assignment_id, |
1963 HValue* object, | 2031 HValue* object, |
1964 HValue* value, | 2032 HValue* value, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2023 bool is_store, | 2091 bool is_store, |
2024 bool* has_side_effects); | 2092 bool* has_side_effects); |
2025 | 2093 |
2026 HInstruction* BuildLoadNamedGeneric(HValue* object, | 2094 HInstruction* BuildLoadNamedGeneric(HValue* object, |
2027 Handle<String> name, | 2095 Handle<String> name, |
2028 Property* expr); | 2096 Property* expr); |
2029 HInstruction* BuildCallGetter(HValue* object, | 2097 HInstruction* BuildCallGetter(HValue* object, |
2030 Handle<Map> map, | 2098 Handle<Map> map, |
2031 Handle<JSFunction> getter, | 2099 Handle<JSFunction> getter, |
2032 Handle<JSObject> holder); | 2100 Handle<JSObject> holder); |
2033 HInstruction* BuildLoadNamedMonomorphic(HValue* object, | |
2034 Handle<String> name, | |
2035 Handle<Map> map); | |
2036 | 2101 |
2037 HCheckMaps* AddCheckMap(HValue* object, Handle<Map> map); | 2102 HCheckMaps* AddCheckMap(HValue* object, Handle<Map> map); |
2038 | 2103 |
2039 void BuildLoad(Property* property, | 2104 void BuildLoad(Property* property, |
2040 int position, | 2105 int position, |
2041 BailoutId ast_id); | 2106 BailoutId ast_id); |
2042 void PushLoad(Property* property, | 2107 void PushLoad(Property* property, |
2043 HValue* object, | 2108 HValue* object, |
2044 HValue* key, | 2109 HValue* key, |
2045 int position); | 2110 int position); |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2300 } | 2365 } |
2301 | 2366 |
2302 private: | 2367 private: |
2303 HGraphBuilder* builder_; | 2368 HGraphBuilder* builder_; |
2304 }; | 2369 }; |
2305 | 2370 |
2306 | 2371 |
2307 } } // namespace v8::internal | 2372 } } // namespace v8::internal |
2308 | 2373 |
2309 #endif // V8_HYDROGEN_H_ | 2374 #endif // V8_HYDROGEN_H_ |
OLD | NEW |