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/hydrogen.h" | 5 #include "src/hydrogen.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 5427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5438 expr->pattern(), | 5438 expr->pattern(), |
5439 expr->flags(), | 5439 expr->flags(), |
5440 expr->literal_index()); | 5440 expr->literal_index()); |
5441 return ast_context()->ReturnInstruction(instr, expr->id()); | 5441 return ast_context()->ReturnInstruction(instr, expr->id()); |
5442 } | 5442 } |
5443 | 5443 |
5444 | 5444 |
5445 static bool CanInlinePropertyAccess(Handle<Map> map) { | 5445 static bool CanInlinePropertyAccess(Handle<Map> map) { |
5446 if (map->instance_type() == HEAP_NUMBER_TYPE) return true; | 5446 if (map->instance_type() == HEAP_NUMBER_TYPE) return true; |
5447 if (map->instance_type() < FIRST_NONSTRING_TYPE) return true; | 5447 if (map->instance_type() < FIRST_NONSTRING_TYPE) return true; |
5448 return map->IsJSObjectMap() && | 5448 return map->IsJSObjectMap() && !map->is_dictionary_map() && |
5449 !map->is_dictionary_map() && | 5449 !map->has_named_interceptor() && |
5450 !map->has_named_interceptor(); | 5450 // TODO(verwaest): Whitelist contexts to which we have access. |
5451 !map->is_access_check_needed(); | |
5451 } | 5452 } |
5452 | 5453 |
5453 | 5454 |
5454 // Determines whether the given array or object literal boilerplate satisfies | 5455 // Determines whether the given array or object literal boilerplate satisfies |
5455 // all limits to be considered for fast deep-copying and computes the total | 5456 // all limits to be considered for fast deep-copying and computes the total |
5456 // size of all objects that are part of the graph. | 5457 // size of all objects that are part of the graph. |
5457 static bool IsFastLiteral(Handle<JSObject> boilerplate, | 5458 static bool IsFastLiteral(Handle<JSObject> boilerplate, |
5458 int max_depth, | 5459 int max_depth, |
5459 int* max_properties) { | 5460 int* max_properties) { |
5460 if (boilerplate->map()->is_deprecated() && | 5461 if (boilerplate->map()->is_deprecated() && |
(...skipping 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6949 return BuildUncheckedMonomorphicElementAccess( | 6950 return BuildUncheckedMonomorphicElementAccess( |
6950 checked_object, key, val, | 6951 checked_object, key, val, |
6951 map->instance_type() == JS_ARRAY_TYPE, | 6952 map->instance_type() == JS_ARRAY_TYPE, |
6952 map->elements_kind(), access_type, | 6953 map->elements_kind(), access_type, |
6953 load_mode, store_mode); | 6954 load_mode, store_mode); |
6954 } | 6955 } |
6955 | 6956 |
6956 | 6957 |
6957 static bool CanInlineElementAccess(Handle<Map> map) { | 6958 static bool CanInlineElementAccess(Handle<Map> map) { |
6958 return map->IsJSObjectMap() && !map->has_slow_elements_kind() && | 6959 return map->IsJSObjectMap() && !map->has_slow_elements_kind() && |
6959 !map->has_indexed_interceptor(); | 6960 !map->has_indexed_interceptor() && !map->is_access_check_needed(); |
6960 } | 6961 } |
6961 | 6962 |
6962 | 6963 |
6963 HInstruction* HOptimizedGraphBuilder::TryBuildConsolidatedElementLoad( | 6964 HInstruction* HOptimizedGraphBuilder::TryBuildConsolidatedElementLoad( |
6964 HValue* object, | 6965 HValue* object, |
6965 HValue* key, | 6966 HValue* key, |
6966 HValue* val, | 6967 HValue* val, |
6967 SmallMapList* maps) { | 6968 SmallMapList* maps) { |
6968 // For polymorphic loads of similar elements kinds (i.e. all tagged or all | 6969 // For polymorphic loads of similar elements kinds (i.e. all tagged or all |
6969 // double), always use the "worst case" code without a transition. This is | 6970 // double), always use the "worst case" code without a transition. This is |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7809 int nodes_added = target_shared->ast_node_count(); | 7810 int nodes_added = target_shared->ast_node_count(); |
7810 return nodes_added; | 7811 return nodes_added; |
7811 } | 7812 } |
7812 | 7813 |
7813 | 7814 |
7814 bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target, | 7815 bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target, |
7815 int arguments_count, | 7816 int arguments_count, |
7816 HValue* implicit_return_value, | 7817 HValue* implicit_return_value, |
7817 BailoutId ast_id, BailoutId return_id, | 7818 BailoutId ast_id, BailoutId return_id, |
7818 InliningKind inlining_kind) { | 7819 InliningKind inlining_kind) { |
7820 if (target->context()->native_context() != | |
7821 top_info()->closure()->context()->native_context()) { | |
7822 return false; | |
7823 } | |
7819 int nodes_added = InliningAstSize(target); | 7824 int nodes_added = InliningAstSize(target); |
7820 if (nodes_added == kNotInlinable) return false; | 7825 if (nodes_added == kNotInlinable) return false; |
7821 | 7826 |
7822 Handle<JSFunction> caller = current_info()->closure(); | 7827 Handle<JSFunction> caller = current_info()->closure(); |
7823 | 7828 |
7824 if (nodes_added > Min(FLAG_max_inlined_nodes, kUnlimitedMaxInlinedNodes)) { | 7829 if (nodes_added > Min(FLAG_max_inlined_nodes, kUnlimitedMaxInlinedNodes)) { |
7825 TraceInline(target, caller, "target AST is too large [early]"); | 7830 TraceInline(target, caller, "target AST is too large [early]"); |
7826 return false; | 7831 return false; |
7827 } | 7832 } |
7828 | 7833 |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8636 kCallApiSetter); | 8641 kCallApiSetter); |
8637 } | 8642 } |
8638 | 8643 |
8639 | 8644 |
8640 bool HOptimizedGraphBuilder::TryInlineApiCall(Handle<JSFunction> function, | 8645 bool HOptimizedGraphBuilder::TryInlineApiCall(Handle<JSFunction> function, |
8641 HValue* receiver, | 8646 HValue* receiver, |
8642 SmallMapList* receiver_maps, | 8647 SmallMapList* receiver_maps, |
8643 int argc, | 8648 int argc, |
8644 BailoutId ast_id, | 8649 BailoutId ast_id, |
8645 ApiCallType call_type) { | 8650 ApiCallType call_type) { |
8651 if (function->context()->native_context() != | |
8652 top_info()->closure()->context()->native_context()) { | |
Erik Corry
2015/03/26 11:20:57
You have this several places.
How about SameNativ
| |
8653 return false; | |
8654 } | |
8646 CallOptimization optimization(function); | 8655 CallOptimization optimization(function); |
8647 if (!optimization.is_simple_api_call()) return false; | 8656 if (!optimization.is_simple_api_call()) return false; |
8648 Handle<Map> holder_map; | 8657 Handle<Map> holder_map; |
8649 for (int i = 0; i < receiver_maps->length(); ++i) { | 8658 for (int i = 0; i < receiver_maps->length(); ++i) { |
8650 auto map = receiver_maps->at(i); | 8659 auto map = receiver_maps->at(i); |
8651 // Don't inline calls to receivers requiring accesschecks. | 8660 // Don't inline calls to receivers requiring accesschecks. |
8652 if (map->is_access_check_needed() && | 8661 if (map->is_access_check_needed() && |
8653 map->instance_type() != JS_GLOBAL_PROXY_TYPE) { | 8662 map->instance_type() != JS_GLOBAL_PROXY_TYPE) { |
8654 return false; | 8663 return false; |
8655 } | 8664 } |
(...skipping 4741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13397 if (ShouldProduceTraceOutput()) { | 13406 if (ShouldProduceTraceOutput()) { |
13398 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13407 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13399 } | 13408 } |
13400 | 13409 |
13401 #ifdef DEBUG | 13410 #ifdef DEBUG |
13402 graph_->Verify(false); // No full verify. | 13411 graph_->Verify(false); // No full verify. |
13403 #endif | 13412 #endif |
13404 } | 13413 } |
13405 | 13414 |
13406 } } // namespace v8::internal | 13415 } } // namespace v8::internal |
OLD | NEW |