Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: src/hydrogen.cc

Issue 9221011: Collect AstNode type information (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: refactor to AstVisitor approach Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 4780 matching lines...) Expand 10 before | Expand all | Expand 10 after
4791 : CALL_AS_METHOD; 4791 : CALL_AS_METHOD;
4792 4792
4793 // Precondition: call is monomorphic and we have found a target with the 4793 // Precondition: call is monomorphic and we have found a target with the
4794 // appropriate arity. 4794 // appropriate arity.
4795 Handle<JSFunction> caller = info()->closure(); 4795 Handle<JSFunction> caller = info()->closure();
4796 Handle<JSFunction> target = expr->target(); 4796 Handle<JSFunction> target = expr->target();
4797 Handle<SharedFunctionInfo> target_shared(target->shared()); 4797 Handle<SharedFunctionInfo> target_shared(target->shared());
4798 4798
4799 // Do a quick check on source code length to avoid parsing large 4799 // Do a quick check on source code length to avoid parsing large
4800 // inlining candidates. 4800 // inlining candidates.
4801 if ((FLAG_limit_inlining && target->shared()->SourceSize() > kMaxSourceSize) 4801 if ((FLAG_limit_inlining && target_shared->SourceSize() > kMaxSourceSize)
4802 || target->shared()->SourceSize() > kUnlimitedMaxSourceSize) { 4802 || target_shared->SourceSize() > kUnlimitedMaxSourceSize) {
4803 TraceInline(target, caller, "target text too big"); 4803 TraceInline(target, caller, "target text too big");
4804 return false; 4804 return false;
4805 } 4805 }
4806 4806
4807 // Target must be inlineable. 4807 // Target must be inlineable.
4808 if (!target->IsInlineable()) { 4808 if (!target->IsInlineable()) {
4809 TraceInline(target, caller, "target not inlineable"); 4809 TraceInline(target, caller, "target not inlineable");
4810 return false; 4810 return false;
4811 } 4811 }
4812 if (target_shared->dont_inline() || target_shared->dont_crankshaft()) {
4813 TraceInline(target, caller, "target contains unsupported syntax");
4814 return false;
4815 }
4812 4816
4813 #if !defined(V8_TARGET_ARCH_IA32) 4817 #if !defined(V8_TARGET_ARCH_IA32)
4814 // Target must be able to use caller's context. 4818 // Target must be able to use caller's context.
4815 CompilationInfo* outer_info = info(); 4819 CompilationInfo* outer_info = info();
4816 if (target->context() != outer_info->closure()->context() || 4820 if (target->context() != outer_info->closure()->context() ||
4817 outer_info->scope()->contains_with() || 4821 outer_info->scope()->contains_with() ||
4818 outer_info->scope()->num_heap_slots() > 0) { 4822 outer_info->scope()->num_heap_slots() > 0) {
4819 TraceInline(target, caller, "target requires context change"); 4823 TraceInline(target, caller, "target requires context change");
4820 return false; 4824 return false;
4821 } 4825 }
(...skipping 24 matching lines...) Expand all
4846 } 4850 }
4847 } 4851 }
4848 4852
4849 // We don't want to add more than a certain number of nodes from inlining. 4853 // We don't want to add more than a certain number of nodes from inlining.
4850 if ((FLAG_limit_inlining && inlined_count_ > kMaxInlinedNodes) || 4854 if ((FLAG_limit_inlining && inlined_count_ > kMaxInlinedNodes) ||
4851 inlined_count_ > kUnlimitedMaxInlinedNodes) { 4855 inlined_count_ > kUnlimitedMaxInlinedNodes) {
4852 TraceInline(target, caller, "cumulative AST node limit reached"); 4856 TraceInline(target, caller, "cumulative AST node limit reached");
4853 return false; 4857 return false;
4854 } 4858 }
4855 4859
4856 int count_before = AstNode::Count();
4857
4858 // Parse and allocate variables. 4860 // Parse and allocate variables.
4859 CompilationInfo target_info(target); 4861 CompilationInfo target_info(target);
4860 if (!ParserApi::Parse(&target_info, kNoParsingFlags) || 4862 if (!ParserApi::Parse(&target_info, kNoParsingFlags) ||
4861 !Scope::Analyze(&target_info)) { 4863 !Scope::Analyze(&target_info)) {
4862 if (target_info.isolate()->has_pending_exception()) { 4864 if (target_info.isolate()->has_pending_exception()) {
4863 // Parse or scope error, never optimize this function. 4865 // Parse or scope error, never optimize this function.
4864 SetStackOverflow(); 4866 SetStackOverflow();
4865 target_shared->DisableOptimization(*target); 4867 target_shared->DisableOptimization(*target);
4866 } 4868 }
4867 TraceInline(target, caller, "parse failure"); 4869 TraceInline(target, caller, "parse failure");
4868 return false; 4870 return false;
4869 } 4871 }
4870 4872
4871 if (target_info.scope()->num_heap_slots() > 0) { 4873 if (target_info.scope()->num_heap_slots() > 0) {
4872 TraceInline(target, caller, "target has context-allocated variables"); 4874 TraceInline(target, caller, "target has context-allocated variables");
4873 return false; 4875 return false;
4874 } 4876 }
4875 FunctionLiteral* function = target_info.function(); 4877 FunctionLiteral* function = target_info.function();
4876 4878
4877 // Count the number of AST nodes added by inlining this call. 4879 // Count the number of AST nodes added by inlining this call.
4878 int nodes_added = AstNode::Count() - count_before; 4880 int nodes_added = function->AstNodeCount();
4879 if ((FLAG_limit_inlining && nodes_added > kMaxInlinedSize) || 4881 if ((FLAG_limit_inlining && nodes_added > kMaxInlinedSize) ||
4880 nodes_added > kUnlimitedMaxInlinedSize) { 4882 nodes_added > kUnlimitedMaxInlinedSize) {
4881 TraceInline(target, caller, "target AST is too large"); 4883 TraceInline(target, caller, "target AST is too large");
4882 return false; 4884 return false;
4883 } 4885 }
4884 4886
4885 // Don't inline functions that uses the arguments object. 4887 // Don't inline functions that uses the arguments object.
4886 if (function->scope()->arguments() != NULL) { 4888 if (function->scope()->arguments() != NULL) {
4887 TraceInline(target, caller, "target requires special argument handling"); 4889 TraceInline(target, caller, "target requires special argument handling");
4888 return false; 4890 return false;
4889 } 4891 }
4890 4892
4891 // All declarations must be inlineable. 4893 // All declarations must be inlineable.
4892 ZoneList<Declaration*>* decls = target_info.scope()->declarations(); 4894 ZoneList<Declaration*>* decls = target_info.scope()->declarations();
4893 int decl_count = decls->length(); 4895 int decl_count = decls->length();
4894 for (int i = 0; i < decl_count; ++i) { 4896 for (int i = 0; i < decl_count; ++i) {
4895 if (!decls->at(i)->IsInlineable()) { 4897 if (!decls->at(i)->IsInlineable()) {
4896 TraceInline(target, caller, "target has non-trivial declaration"); 4898 TraceInline(target, caller, "target has non-trivial declaration");
4897 return false; 4899 return false;
4898 } 4900 }
4899 } 4901 }
4900 // All statements in the body must be inlineable.
4901 for (int i = 0, count = function->body()->length(); i < count; ++i) {
4902 if (!function->body()->at(i)->IsInlineable()) {
4903 TraceInline(target, caller, "target contains unsupported syntax");
4904 return false;
4905 }
4906 }
4907 4902
4908 // Generate the deoptimization data for the unoptimized version of 4903 // Generate the deoptimization data for the unoptimized version of
4909 // the target function if we don't already have it. 4904 // the target function if we don't already have it.
4910 if (!target_shared->has_deoptimization_support()) { 4905 if (!target_shared->has_deoptimization_support()) {
4911 // Note that we compile here using the same AST that we will use for 4906 // Note that we compile here using the same AST that we will use for
4912 // generating the optimized inline code. 4907 // generating the optimized inline code.
4913 target_info.EnableDeoptimizationSupport(); 4908 target_info.EnableDeoptimizationSupport();
4914 if (!FullCodeGenerator::MakeCode(&target_info)) { 4909 if (!FullCodeGenerator::MakeCode(&target_info)) {
4915 TraceInline(target, caller, "could not generate deoptimization info"); 4910 TraceInline(target, caller, "could not generate deoptimization info");
4916 return false; 4911 return false;
(...skipping 2536 matching lines...) Expand 10 before | Expand all | Expand 10 after
7453 } 7448 }
7454 } 7449 }
7455 7450
7456 #ifdef DEBUG 7451 #ifdef DEBUG
7457 if (graph_ != NULL) graph_->Verify(false); // No full verify. 7452 if (graph_ != NULL) graph_->Verify(false); // No full verify.
7458 if (allocator_ != NULL) allocator_->Verify(); 7453 if (allocator_ != NULL) allocator_->Verify();
7459 #endif 7454 #endif
7460 } 7455 }
7461 7456
7462 } } // namespace v8::internal 7457 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698