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

Side by Side Diff: src/compiler.cc

Issue 10701060: Remove some duplicated logic from compiler.cc. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 code_size += function->shared()->SourceSize(); 177 code_size += function->shared()->SourceSize();
178 PrintF("Compiled: %d functions with %d byte source size in %fms.\n", 178 PrintF("Compiled: %d functions with %d byte source size in %fms.\n",
179 compiled_functions, 179 compiled_functions,
180 code_size, 180 code_size,
181 compilation_time); 181 compilation_time);
182 } 182 }
183 } 183 }
184 184
185 185
186 static bool MakeCrankshaftCode(CompilationInfo* info) { 186 static bool MakeCrankshaftCode(CompilationInfo* info) {
187 // Test if we can optimize this function when asked to. We can only 187 ASSERT(V8::UseCrankshaft());
188 // do this after the scopes are computed. 188 ASSERT(info->IsOptimizing());
189 if (!V8::UseCrankshaft()) { 189 ASSERT(!info->IsCompilingForDebugging());
190 info->DisableOptimization();
191 }
192
193 // In case we are not optimizing simply return the code from
194 // the full code generator.
195 if (!info->IsOptimizing()) {
196 return FullCodeGenerator::MakeCode(info);
197 }
198 190
199 // We should never arrive here if there is not code object on the 191 // We should never arrive here if there is not code object on the
200 // shared function object. 192 // shared function object.
201 Handle<Code> code(info->shared_info()->code()); 193 Handle<Code> code(info->shared_info()->code());
202 ASSERT(code->kind() == Code::FUNCTION); 194 ASSERT(code->kind() == Code::FUNCTION);
203 195
204 // We should never arrive here if optimization has been disabled on the 196 // We should never arrive here if optimization has been disabled on the
205 // shared function info. 197 // shared function info.
206 ASSERT(!info->shared_info()->optimization_disabled()); 198 ASSERT(!info->shared_info()->optimization_disabled());
207 199
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 // function that bailed out. 315 // function that bailed out.
324 info->shared_info()->DisableOptimization(); 316 info->shared_info()->DisableOptimization();
325 } 317 }
326 // True indicates the compilation pipeline is still going, not necessarily 318 // True indicates the compilation pipeline is still going, not necessarily
327 // that we optimized the code. 319 // that we optimized the code.
328 return true; 320 return true;
329 } 321 }
330 322
331 323
332 static bool GenerateCode(CompilationInfo* info) { 324 static bool GenerateCode(CompilationInfo* info) {
333 return info->IsCompilingForDebugging() || !V8::UseCrankshaft() ? 325 bool is_optimizing = V8::UseCrankshaft() &&
334 FullCodeGenerator::MakeCode(info) : 326 !info->IsCompilingForDebugging() &&
335 MakeCrankshaftCode(info); 327 info->IsOptimizing();
328 if (is_optimizing) {
329 return MakeCrankshaftCode(info);
330 } else {
331 if (info->IsOptimizing()) {
332 // Have the CompilationInfo decide if the compilation should be
333 // BASE or NONOPT.
334 info->DisableOptimization();
335 }
336 return FullCodeGenerator::MakeCode(info);
337 }
336 } 338 }
337 339
338 340
339 static bool MakeCode(CompilationInfo* info) { 341 static bool MakeCode(CompilationInfo* info) {
340 // Precondition: code has been parsed. Postcondition: the code field in 342 // Precondition: code has been parsed. Postcondition: the code field in
341 // the compilation info is set if compilation succeeded. 343 // the compilation info is set if compilation succeeded.
342 ASSERT(info->function() != NULL); 344 ASSERT(info->function() != NULL);
343 return Rewriter::Rewrite(info) && Scope::Analyze(info) && GenerateCode(info); 345 return Rewriter::Rewrite(info) && Scope::Analyze(info) && GenerateCode(info);
344 } 346 }
345 347
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 bool allow_lazy = literal->AllowsLazyCompilation() && 757 bool allow_lazy = literal->AllowsLazyCompilation() &&
756 !LiveEditFunctionTracker::IsActive(info.isolate()) && 758 !LiveEditFunctionTracker::IsActive(info.isolate()) &&
757 (!info.isolate()->DebuggerHasBreakPoints() || allow_lazy_without_ctx); 759 (!info.isolate()->DebuggerHasBreakPoints() || allow_lazy_without_ctx);
758 760
759 Handle<ScopeInfo> scope_info(ScopeInfo::Empty()); 761 Handle<ScopeInfo> scope_info(ScopeInfo::Empty());
760 762
761 // Generate code 763 // Generate code
762 if (FLAG_lazy && allow_lazy) { 764 if (FLAG_lazy && allow_lazy) {
763 Handle<Code> code = info.isolate()->builtins()->LazyCompile(); 765 Handle<Code> code = info.isolate()->builtins()->LazyCompile();
764 info.SetCode(code); 766 info.SetCode(code);
765 } else if ((V8::UseCrankshaft() && MakeCrankshaftCode(&info)) || 767 } else if (GenerateCode(&info)) {
766 (!V8::UseCrankshaft() && FullCodeGenerator::MakeCode(&info))) {
767 ASSERT(!info.code().is_null()); 768 ASSERT(!info.code().is_null());
768 scope_info = ScopeInfo::Create(info.scope(), info.zone()); 769 scope_info = ScopeInfo::Create(info.scope(), info.zone());
769 } else { 770 } else {
770 return Handle<SharedFunctionInfo>::null(); 771 return Handle<SharedFunctionInfo>::null();
771 } 772 }
772 773
773 // Create a shared function info object. 774 // Create a shared function info object.
774 Handle<SharedFunctionInfo> result = 775 Handle<SharedFunctionInfo> result =
775 FACTORY->NewSharedFunctionInfo(literal->name(), 776 FACTORY->NewSharedFunctionInfo(literal->name(),
776 literal->materialized_literal_count(), 777 literal->materialized_literal_count(),
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 } 858 }
858 } 859 }
859 860
860 GDBJIT(AddCode(Handle<String>(shared->DebugName()), 861 GDBJIT(AddCode(Handle<String>(shared->DebugName()),
861 Handle<Script>(info->script()), 862 Handle<Script>(info->script()),
862 Handle<Code>(info->code()), 863 Handle<Code>(info->code()),
863 info)); 864 info));
864 } 865 }
865 866
866 } } // namespace v8::internal 867 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698