| 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 12 matching lines...) Expand all Loading... |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_HYDROGEN_H_ | 28 #ifndef V8_HYDROGEN_H_ |
| 29 #define V8_HYDROGEN_H_ | 29 #define V8_HYDROGEN_H_ |
| 30 | 30 |
| 31 #include "v8.h" | 31 #include "v8.h" |
| 32 | 32 |
| 33 #include "accessors.h" |
| 33 #include "allocation.h" | 34 #include "allocation.h" |
| 34 #include "ast.h" | 35 #include "ast.h" |
| 35 #include "compiler.h" | 36 #include "compiler.h" |
| 36 #include "hydrogen-instructions.h" | 37 #include "hydrogen-instructions.h" |
| 37 #include "zone.h" | 38 #include "zone.h" |
| 38 #include "scopes.h" | 39 #include "scopes.h" |
| 39 | 40 |
| 40 namespace v8 { | 41 namespace v8 { |
| 41 namespace internal { | 42 namespace internal { |
| 42 | 43 |
| (...skipping 1730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1773 virtual bool BuildGraph() V8_OVERRIDE; | 1774 virtual bool BuildGraph() V8_OVERRIDE; |
| 1774 | 1775 |
| 1775 // Simple accessors. | 1776 // Simple accessors. |
| 1776 BreakAndContinueScope* break_scope() const { return break_scope_; } | 1777 BreakAndContinueScope* break_scope() const { return break_scope_; } |
| 1777 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } | 1778 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } |
| 1778 | 1779 |
| 1779 bool inline_bailout() { return inline_bailout_; } | 1780 bool inline_bailout() { return inline_bailout_; } |
| 1780 | 1781 |
| 1781 HValue* context() { return environment()->context(); } | 1782 HValue* context() { return environment()->context(); } |
| 1782 | 1783 |
| 1784 HOsrBuilder* osr() const { return osr_; } |
| 1785 |
| 1783 void Bailout(BailoutReason reason); | 1786 void Bailout(BailoutReason reason); |
| 1784 | 1787 |
| 1785 HBasicBlock* CreateJoin(HBasicBlock* first, | 1788 HBasicBlock* CreateJoin(HBasicBlock* first, |
| 1786 HBasicBlock* second, | 1789 HBasicBlock* second, |
| 1787 BailoutId join_id); | 1790 BailoutId join_id); |
| 1788 | 1791 |
| 1789 FunctionState* function_state() const { return function_state_; } | 1792 FunctionState* function_state() const { return function_state_; } |
| 1790 | 1793 |
| 1791 void VisitDeclarations(ZoneList<Declaration*>* declarations); | 1794 void VisitDeclarations(ZoneList<Declaration*>* declarations); |
| 1792 | 1795 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1878 // the condition) and break_block is the block where control flow breaks | 1881 // the condition) and break_block is the block where control flow breaks |
| 1879 // from the loop. All blocks except loop_entry can be NULL. The return | 1882 // from the loop. All blocks except loop_entry can be NULL. The return |
| 1880 // value is the new successor block which is the join of loop_successor | 1883 // value is the new successor block which is the join of loop_successor |
| 1881 // and break_block, or NULL. | 1884 // and break_block, or NULL. |
| 1882 HBasicBlock* CreateLoop(IterationStatement* statement, | 1885 HBasicBlock* CreateLoop(IterationStatement* statement, |
| 1883 HBasicBlock* loop_entry, | 1886 HBasicBlock* loop_entry, |
| 1884 HBasicBlock* body_exit, | 1887 HBasicBlock* body_exit, |
| 1885 HBasicBlock* loop_successor, | 1888 HBasicBlock* loop_successor, |
| 1886 HBasicBlock* break_block); | 1889 HBasicBlock* break_block); |
| 1887 | 1890 |
| 1891 // Build a loop entry |
| 1892 HBasicBlock* BuildLoopEntry(); |
| 1893 |
| 1894 // Builds a loop entry respectful of OSR requirements |
| 1895 HBasicBlock* BuildLoopEntry(IterationStatement* statement); |
| 1896 |
| 1888 HBasicBlock* JoinContinue(IterationStatement* statement, | 1897 HBasicBlock* JoinContinue(IterationStatement* statement, |
| 1889 HBasicBlock* exit_block, | 1898 HBasicBlock* exit_block, |
| 1890 HBasicBlock* continue_block); | 1899 HBasicBlock* continue_block); |
| 1891 | 1900 |
| 1892 HValue* Top() const { return environment()->Top(); } | 1901 HValue* Top() const { return environment()->Top(); } |
| 1893 void Drop(int n) { environment()->Drop(n); } | 1902 void Drop(int n) { environment()->Drop(n); } |
| 1894 void Bind(Variable* var, HValue* value) { environment()->Bind(var, value); } | 1903 void Bind(Variable* var, HValue* value) { environment()->Bind(var, value); } |
| 1895 bool IsEligibleForEnvironmentLivenessAnalysis(Variable* var, | 1904 bool IsEligibleForEnvironmentLivenessAnalysis(Variable* var, |
| 1896 int index, | 1905 int index, |
| 1897 HValue* value, | 1906 HValue* value, |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2039 bool CanLoadMonomorphic(); | 2048 bool CanLoadMonomorphic(); |
| 2040 | 2049 |
| 2041 // Checks whether all types behave uniform when loading name. If all maps | 2050 // Checks whether all types behave uniform when loading name. If all maps |
| 2042 // behave the same, a single monomorphic load instruction can be emitted, | 2051 // behave the same, a single monomorphic load instruction can be emitted, |
| 2043 // guarded by a single map-checks instruction that whether the receiver is | 2052 // guarded by a single map-checks instruction that whether the receiver is |
| 2044 // an instance of any of the types. | 2053 // an instance of any of the types. |
| 2045 // This method skips the first type in types, assuming that this | 2054 // This method skips the first type in types, assuming that this |
| 2046 // PropertyAccessInfo is built for types->first(). | 2055 // PropertyAccessInfo is built for types->first(). |
| 2047 bool CanLoadAsMonomorphic(SmallMapList* types); | 2056 bool CanLoadAsMonomorphic(SmallMapList* types); |
| 2048 | 2057 |
| 2049 bool IsStringLength() { | 2058 bool IsJSObjectFieldAccessor() { |
| 2050 return map_->instance_type() < FIRST_NONSTRING_TYPE && | 2059 int offset; // unused |
| 2051 name_->Equals(isolate()->heap()->length_string()); | 2060 return Accessors::IsJSObjectFieldAccessor(map_, name_, &offset); |
| 2052 } | 2061 } |
| 2053 | 2062 |
| 2054 bool IsArrayLength() { | 2063 bool GetJSObjectFieldAccess(HObjectAccess* access) { |
| 2055 return map_->instance_type() == JS_ARRAY_TYPE && | 2064 if (IsStringLength()) { |
| 2056 name_->Equals(isolate()->heap()->length_string()); | 2065 *access = HObjectAccess::ForStringLength(); |
| 2057 } | 2066 return true; |
| 2058 | 2067 } else if (IsArrayLength()) { |
| 2059 bool IsTypedArrayLength() { | 2068 *access = HObjectAccess::ForArrayLength(map_->elements_kind()); |
| 2060 return map_->instance_type() == JS_TYPED_ARRAY_TYPE && | 2069 return true; |
| 2061 name_->Equals(isolate()->heap()->length_string()); | 2070 } else { |
| 2071 int offset; |
| 2072 if (Accessors::IsJSObjectFieldAccessor(map_, name_, &offset)) { |
| 2073 *access = HObjectAccess::ForJSObjectOffset(offset); |
| 2074 return true; |
| 2075 } |
| 2076 return false; |
| 2077 } |
| 2062 } | 2078 } |
| 2063 | 2079 |
| 2064 bool has_holder() { return !holder_.is_null(); } | 2080 bool has_holder() { return !holder_.is_null(); } |
| 2065 | 2081 |
| 2066 LookupResult* lookup() { return &lookup_; } | 2082 LookupResult* lookup() { return &lookup_; } |
| 2067 Handle<Map> map() { return map_; } | 2083 Handle<Map> map() { return map_; } |
| 2068 Handle<JSObject> holder() { return holder_; } | 2084 Handle<JSObject> holder() { return holder_; } |
| 2069 Handle<JSFunction> accessor() { return accessor_; } | 2085 Handle<JSFunction> accessor() { return accessor_; } |
| 2070 Handle<Object> constant() { return constant_; } | 2086 Handle<Object> constant() { return constant_; } |
| 2071 HObjectAccess access() { return access_; } | 2087 HObjectAccess access() { return access_; } |
| 2072 | 2088 |
| 2073 private: | 2089 private: |
| 2074 Isolate* isolate() { return lookup_.isolate(); } | 2090 Isolate* isolate() { return lookup_.isolate(); } |
| 2075 | 2091 |
| 2092 bool IsStringLength() { |
| 2093 return map_->instance_type() < FIRST_NONSTRING_TYPE && |
| 2094 name_->Equals(isolate()->heap()->length_string()); |
| 2095 } |
| 2096 |
| 2097 bool IsArrayLength() { |
| 2098 return map_->instance_type() == JS_ARRAY_TYPE && |
| 2099 name_->Equals(isolate()->heap()->length_string()); |
| 2100 } |
| 2101 |
| 2076 bool LoadResult(Handle<Map> map); | 2102 bool LoadResult(Handle<Map> map); |
| 2077 bool LookupDescriptor(); | 2103 bool LookupDescriptor(); |
| 2078 bool LookupInPrototypes(); | 2104 bool LookupInPrototypes(); |
| 2079 bool IsCompatibleForLoad(PropertyAccessInfo* other); | 2105 bool IsCompatibleForLoad(PropertyAccessInfo* other); |
| 2080 | 2106 |
| 2081 void GeneralizeRepresentation(Representation r) { | 2107 void GeneralizeRepresentation(Representation r) { |
| 2082 access_ = access_.WithRepresentation( | 2108 access_ = access_.WithRepresentation( |
| 2083 access_.representation().generalize(r)); | 2109 access_.representation().generalize(r)); |
| 2084 } | 2110 } |
| 2085 | 2111 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2166 HValue* val, | 2192 HValue* val, |
| 2167 Expression* expr, | 2193 Expression* expr, |
| 2168 BailoutId ast_id, | 2194 BailoutId ast_id, |
| 2169 int position, | 2195 int position, |
| 2170 bool is_store, | 2196 bool is_store, |
| 2171 bool* has_side_effects); | 2197 bool* has_side_effects); |
| 2172 | 2198 |
| 2173 HInstruction* BuildLoadNamedGeneric(HValue* object, | 2199 HInstruction* BuildLoadNamedGeneric(HValue* object, |
| 2174 Handle<String> name, | 2200 Handle<String> name, |
| 2175 Property* expr); | 2201 Property* expr); |
| 2176 HInstruction* BuildCallGetter(HValue* object, | |
| 2177 Handle<Map> map, | |
| 2178 Handle<JSFunction> getter, | |
| 2179 Handle<JSObject> holder); | |
| 2180 | 2202 |
| 2181 HCheckMaps* AddCheckMap(HValue* object, Handle<Map> map); | 2203 HCheckMaps* AddCheckMap(HValue* object, Handle<Map> map); |
| 2182 | 2204 |
| 2183 void BuildLoad(Property* property, | 2205 void BuildLoad(Property* property, |
| 2184 int position, | 2206 int position, |
| 2185 BailoutId ast_id); | 2207 BailoutId ast_id); |
| 2186 void PushLoad(Property* property, | 2208 void PushLoad(Property* property, |
| 2187 HValue* object, | 2209 HValue* object, |
| 2188 HValue* key, | 2210 HValue* key, |
| 2189 int position); | 2211 int position); |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2439 } | 2461 } |
| 2440 | 2462 |
| 2441 private: | 2463 private: |
| 2442 HGraphBuilder* builder_; | 2464 HGraphBuilder* builder_; |
| 2443 }; | 2465 }; |
| 2444 | 2466 |
| 2445 | 2467 |
| 2446 } } // namespace v8::internal | 2468 } } // namespace v8::internal |
| 2447 | 2469 |
| 2448 #endif // V8_HYDROGEN_H_ | 2470 #endif // V8_HYDROGEN_H_ |
| OLD | NEW |