OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/crankshaft/hydrogen.h" | 5 #include "src/crankshaft/hydrogen.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/allocation-site-scopes.h" | 9 #include "src/allocation-site-scopes.h" |
10 #include "src/ast/ast-numbering.h" | 10 #include "src/ast/ast-numbering.h" |
(...skipping 6886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6897 if (maps != NULL && receiver->HasMonomorphicJSObjectType()) { | 6897 if (maps != NULL && receiver->HasMonomorphicJSObjectType()) { |
6898 if (maps->length() > 0) { | 6898 if (maps->length() > 0) { |
6899 Map* root_map = receiver->GetMonomorphicJSObjectMap()->FindRootMap(); | 6899 Map* root_map = receiver->GetMonomorphicJSObjectMap()->FindRootMap(); |
6900 maps->FilterForPossibleTransitions(root_map); | 6900 maps->FilterForPossibleTransitions(root_map); |
6901 monomorphic = maps->length() == 1; | 6901 monomorphic = maps->length() == 1; |
6902 } else { | 6902 } else { |
6903 // No type feedback, see if we can infer the type. This is safely | 6903 // No type feedback, see if we can infer the type. This is safely |
6904 // possible if the receiver had a known map at some point, and no | 6904 // possible if the receiver had a known map at some point, and no |
6905 // map-changing stores have happened to it since. | 6905 // map-changing stores have happened to it since. |
6906 Handle<Map> candidate_map = receiver->GetMonomorphicJSObjectMap(); | 6906 Handle<Map> candidate_map = receiver->GetMonomorphicJSObjectMap(); |
6907 if (candidate_map->is_observed()) return false; | |
6908 for (HInstruction* current = builder->current_block()->last(); | 6907 for (HInstruction* current = builder->current_block()->last(); |
6909 current != nullptr; current = current->previous()) { | 6908 current != nullptr; current = current->previous()) { |
6910 if (current->IsBlockEntry()) break; | 6909 if (current->IsBlockEntry()) break; |
6911 if (current->CheckChangesFlag(kMaps)) { | 6910 if (current->CheckChangesFlag(kMaps)) { |
6912 // Only allow map changes that store the candidate map. We don't | 6911 // Only allow map changes that store the candidate map. We don't |
6913 // need to care which object the map is being written into. | 6912 // need to care which object the map is being written into. |
6914 if (!current->IsStoreNamedField()) break; | 6913 if (!current->IsStoreNamedField()) break; |
6915 HStoreNamedField* map_change = HStoreNamedField::cast(current); | 6914 HStoreNamedField* map_change = HStoreNamedField::cast(current); |
6916 if (!map_change->value()->IsConstant()) break; | 6915 if (!map_change->value()->IsConstant()) break; |
6917 HConstant* map_constant = HConstant::cast(map_change->value()); | 6916 HConstant* map_constant = HConstant::cast(map_change->value()); |
(...skipping 1991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8909 return descriptors->GetDetails(number).IsReadOnly(); | 8908 return descriptors->GetDetails(number).IsReadOnly(); |
8910 } | 8909 } |
8911 | 8910 |
8912 | 8911 |
8913 // static | 8912 // static |
8914 bool HOptimizedGraphBuilder::CanInlineArrayResizeOperation( | 8913 bool HOptimizedGraphBuilder::CanInlineArrayResizeOperation( |
8915 Handle<Map> receiver_map) { | 8914 Handle<Map> receiver_map) { |
8916 return !receiver_map.is_null() && receiver_map->prototype()->IsJSObject() && | 8915 return !receiver_map.is_null() && receiver_map->prototype()->IsJSObject() && |
8917 receiver_map->instance_type() == JS_ARRAY_TYPE && | 8916 receiver_map->instance_type() == JS_ARRAY_TYPE && |
8918 IsFastElementsKind(receiver_map->elements_kind()) && | 8917 IsFastElementsKind(receiver_map->elements_kind()) && |
8919 !receiver_map->is_dictionary_map() && !receiver_map->is_observed() && | 8918 !receiver_map->is_dictionary_map() && receiver_map->is_extensible() && |
8920 receiver_map->is_extensible() && | |
8921 (!receiver_map->is_prototype_map() || receiver_map->is_stable()) && | 8919 (!receiver_map->is_prototype_map() || receiver_map->is_stable()) && |
8922 !IsReadOnlyLengthDescriptor(receiver_map); | 8920 !IsReadOnlyLengthDescriptor(receiver_map); |
8923 } | 8921 } |
8924 | 8922 |
8925 | 8923 |
8926 bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall( | 8924 bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall( |
8927 Call* expr, Handle<JSFunction> function, Handle<Map> receiver_map, | 8925 Call* expr, Handle<JSFunction> function, Handle<Map> receiver_map, |
8928 int args_count_no_receiver) { | 8926 int args_count_no_receiver) { |
8929 if (!function->shared()->HasBuiltinFunctionId()) return false; | 8927 if (!function->shared()->HasBuiltinFunctionId()) return false; |
8930 BuiltinFunctionId id = function->shared()->builtin_function_id(); | 8928 BuiltinFunctionId id = function->shared()->builtin_function_id(); |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9287 ast_context()->ReturnValue(result); | 9285 ast_context()->ReturnValue(result); |
9288 return true; | 9286 return true; |
9289 } | 9287 } |
9290 case kArrayIndexOf: | 9288 case kArrayIndexOf: |
9291 case kArrayLastIndexOf: { | 9289 case kArrayLastIndexOf: { |
9292 if (receiver_map.is_null()) return false; | 9290 if (receiver_map.is_null()) return false; |
9293 if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false; | 9291 if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false; |
9294 if (!receiver_map->prototype()->IsJSObject()) return false; | 9292 if (!receiver_map->prototype()->IsJSObject()) return false; |
9295 ElementsKind kind = receiver_map->elements_kind(); | 9293 ElementsKind kind = receiver_map->elements_kind(); |
9296 if (!IsFastElementsKind(kind)) return false; | 9294 if (!IsFastElementsKind(kind)) return false; |
9297 if (receiver_map->is_observed()) return false; | |
9298 if (argument_count != 2) return false; | 9295 if (argument_count != 2) return false; |
9299 if (!receiver_map->is_extensible()) return false; | 9296 if (!receiver_map->is_extensible()) return false; |
9300 | 9297 |
9301 // If there may be elements accessors in the prototype chain, the fast | 9298 // If there may be elements accessors in the prototype chain, the fast |
9302 // inlined version can't be used. | 9299 // inlined version can't be used. |
9303 if (receiver_map->DictionaryElementsInPrototypeChainOnly()) return false; | 9300 if (receiver_map->DictionaryElementsInPrototypeChainOnly()) return false; |
9304 | 9301 |
9305 // If there currently can be no elements accessors on the prototype chain, | 9302 // If there currently can be no elements accessors on the prototype chain, |
9306 // it doesn't mean that there won't be any later. Install a full prototype | 9303 // it doesn't mean that there won't be any later. Install a full prototype |
9307 // chain check to trap element accessors being installed on the prototype | 9304 // chain check to trap element accessors being installed on the prototype |
(...skipping 4424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13732 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13729 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13733 } | 13730 } |
13734 | 13731 |
13735 #ifdef DEBUG | 13732 #ifdef DEBUG |
13736 graph_->Verify(false); // No full verify. | 13733 graph_->Verify(false); // No full verify. |
13737 #endif | 13734 #endif |
13738 } | 13735 } |
13739 | 13736 |
13740 } // namespace internal | 13737 } // namespace internal |
13741 } // namespace v8 | 13738 } // namespace v8 |
OLD | NEW |