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 4272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4283 | 4283 |
4284 void HOptimizedGraphBuilder::VisitExpressions(ZoneList<Expression*>* exprs, | 4284 void HOptimizedGraphBuilder::VisitExpressions(ZoneList<Expression*>* exprs, |
4285 ArgumentsAllowedFlag flag) { | 4285 ArgumentsAllowedFlag flag) { |
4286 for (int i = 0; i < exprs->length(); ++i) { | 4286 for (int i = 0; i < exprs->length(); ++i) { |
4287 CHECK_ALIVE(VisitForValue(exprs->at(i), flag)); | 4287 CHECK_ALIVE(VisitForValue(exprs->at(i), flag)); |
4288 } | 4288 } |
4289 } | 4289 } |
4290 | 4290 |
4291 | 4291 |
4292 bool HOptimizedGraphBuilder::BuildGraph() { | 4292 bool HOptimizedGraphBuilder::BuildGraph() { |
4293 if (current_info()->function()->is_generator()) { | |
4294 Bailout(kFunctionIsAGenerator); | |
4295 return false; | |
4296 } | |
4297 Scope* scope = current_info()->scope(); | 4293 Scope* scope = current_info()->scope(); |
4298 if (scope->HasIllegalRedeclaration()) { | |
4299 Bailout(kFunctionWithIllegalRedeclaration); | |
4300 return false; | |
4301 } | |
4302 if (scope->calls_eval()) { | |
4303 Bailout(kFunctionCallsEval); | |
4304 return false; | |
4305 } | |
4306 SetUpScope(scope); | 4294 SetUpScope(scope); |
4307 | 4295 |
4308 // Add an edge to the body entry. This is warty: the graph's start | 4296 // Add an edge to the body entry. This is warty: the graph's start |
4309 // environment will be used by the Lithium translation as the initial | 4297 // environment will be used by the Lithium translation as the initial |
4310 // environment on graph entry, but it has now been mutated by the | 4298 // environment on graph entry, but it has now been mutated by the |
4311 // Hydrogen translation of the instructions in the start block. This | 4299 // Hydrogen translation of the instructions in the start block. This |
4312 // environment uses values which have not been defined yet. These | 4300 // environment uses values which have not been defined yet. These |
4313 // Hydrogen instructions will then be replayed by the Lithium | 4301 // Hydrogen instructions will then be replayed by the Lithium |
4314 // translation, so they cannot have an environment effect. The edge to | 4302 // translation, so they cannot have an environment effect. The edge to |
4315 // the body's entry block (along with some special logic for the start | 4303 // the body's entry block (along with some special logic for the start |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4531 // Initialize specials and locals to undefined. | 4519 // Initialize specials and locals to undefined. |
4532 for (int i = environment()->parameter_count() + 1; | 4520 for (int i = environment()->parameter_count() + 1; |
4533 i < environment()->length(); | 4521 i < environment()->length(); |
4534 ++i) { | 4522 ++i) { |
4535 environment()->Bind(i, undefined_constant); | 4523 environment()->Bind(i, undefined_constant); |
4536 } | 4524 } |
4537 | 4525 |
4538 // Handle the arguments and arguments shadow variables specially (they do | 4526 // Handle the arguments and arguments shadow variables specially (they do |
4539 // not have declarations). | 4527 // not have declarations). |
4540 if (scope->arguments() != NULL) { | 4528 if (scope->arguments() != NULL) { |
4541 if (!scope->arguments()->IsStackAllocated()) { | |
4542 return Bailout(kContextAllocatedArguments); | |
4543 } | |
4544 | |
4545 environment()->Bind(scope->arguments(), | 4529 environment()->Bind(scope->arguments(), |
4546 graph()->GetArgumentsObject()); | 4530 graph()->GetArgumentsObject()); |
4547 } | 4531 } |
4548 } | 4532 } |
4549 | 4533 |
4550 | 4534 |
4551 Type* HOptimizedGraphBuilder::ToType(Handle<Map> map) { | 4535 Type* HOptimizedGraphBuilder::ToType(Handle<Map> map) { |
4552 return IC::MapToType<Type>(map, zone()); | 4536 return IC::MapToType<Type>(map, zone()); |
4553 } | 4537 } |
4554 | 4538 |
(...skipping 3369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7924 if (!Compiler::ParseAndAnalyze(&target_info)) { | 7908 if (!Compiler::ParseAndAnalyze(&target_info)) { |
7925 if (target_info.isolate()->has_pending_exception()) { | 7909 if (target_info.isolate()->has_pending_exception()) { |
7926 // Parse or scope error, never optimize this function. | 7910 // Parse or scope error, never optimize this function. |
7927 SetStackOverflow(); | 7911 SetStackOverflow(); |
7928 target_shared->DisableOptimization(kParseScopeError); | 7912 target_shared->DisableOptimization(kParseScopeError); |
7929 } | 7913 } |
7930 TraceInline(target, caller, "parse failure"); | 7914 TraceInline(target, caller, "parse failure"); |
7931 return false; | 7915 return false; |
7932 } | 7916 } |
7933 | 7917 |
7934 if (target_info.scope()->HasIllegalRedeclaration()) { | |
7935 TraceInline(target, caller, "target has illegal redeclaration"); | |
7936 return false; | |
7937 } | |
7938 | |
7939 if (target_info.scope()->num_heap_slots() > 0) { | 7918 if (target_info.scope()->num_heap_slots() > 0) { |
7940 TraceInline(target, caller, "target has context-allocated variables"); | 7919 TraceInline(target, caller, "target has context-allocated variables"); |
7941 return false; | 7920 return false; |
7942 } | 7921 } |
7943 FunctionLiteral* function = target_info.function(); | 7922 FunctionLiteral* function = target_info.function(); |
7944 | 7923 |
7945 // The following conditions must be checked again after re-parsing, because | 7924 // The following conditions must be checked again after re-parsing, because |
7946 // earlier the information might not have been complete due to lazy parsing. | 7925 // earlier the information might not have been complete due to lazy parsing. |
7947 nodes_added = function->ast_node_count(); | 7926 nodes_added = function->ast_node_count(); |
7948 if (nodes_added > Min(FLAG_max_inlined_nodes, kUnlimitedMaxInlinedNodes)) { | 7927 if (nodes_added > Min(FLAG_max_inlined_nodes, kUnlimitedMaxInlinedNodes)) { |
7949 TraceInline(target, caller, "target AST is too large [late]"); | 7928 TraceInline(target, caller, "target AST is too large [late]"); |
7950 return false; | 7929 return false; |
7951 } | 7930 } |
7952 if (function->dont_optimize()) { | 7931 if (function->dont_optimize()) { |
7953 TraceInline(target, caller, "target contains unsupported syntax [late]"); | 7932 TraceInline(target, caller, "target contains unsupported syntax [late]"); |
7954 return false; | 7933 return false; |
7955 } | 7934 } |
7956 | 7935 |
7957 // If the function uses the arguments object check that inlining of functions | 7936 // If the function uses the arguments object check that inlining of functions |
7958 // with arguments object is enabled and the arguments-variable is | 7937 // with arguments object is enabled and the arguments-variable is |
7959 // stack allocated. | 7938 // stack allocated. |
7960 if (function->scope()->arguments() != NULL) { | 7939 if (function->scope()->arguments() != NULL) { |
7961 if (!FLAG_inline_arguments) { | 7940 if (!FLAG_inline_arguments) { |
7962 TraceInline(target, caller, "target uses arguments object"); | 7941 TraceInline(target, caller, "target uses arguments object"); |
7963 return false; | 7942 return false; |
7964 } | 7943 } |
7965 | |
7966 if (!function->scope()->arguments()->IsStackAllocated()) { | |
7967 TraceInline(target, | |
7968 caller, | |
7969 "target uses non-stackallocated arguments object"); | |
7970 return false; | |
7971 } | |
7972 } | 7944 } |
7973 | 7945 |
7974 // All declarations must be inlineable. | 7946 // All declarations must be inlineable. |
7975 ZoneList<Declaration*>* decls = target_info.scope()->declarations(); | 7947 ZoneList<Declaration*>* decls = target_info.scope()->declarations(); |
7976 int decl_count = decls->length(); | 7948 int decl_count = decls->length(); |
7977 for (int i = 0; i < decl_count; ++i) { | 7949 for (int i = 0; i < decl_count; ++i) { |
7978 if (!decls->at(i)->IsInlineable()) { | 7950 if (!decls->at(i)->IsInlineable()) { |
7979 TraceInline(target, caller, "target has non-trivial declaration"); | 7951 TraceInline(target, caller, "target has non-trivial declaration"); |
7980 return false; | 7952 return false; |
7981 } | 7953 } |
(...skipping 4803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12785 if (ShouldProduceTraceOutput()) { | 12757 if (ShouldProduceTraceOutput()) { |
12786 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12758 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
12787 } | 12759 } |
12788 | 12760 |
12789 #ifdef DEBUG | 12761 #ifdef DEBUG |
12790 graph_->Verify(false); // No full verify. | 12762 graph_->Verify(false); // No full verify. |
12791 #endif | 12763 #endif |
12792 } | 12764 } |
12793 | 12765 |
12794 } } // namespace v8::internal | 12766 } } // namespace v8::internal |
OLD | NEW |