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

Side by Side Diff: src/compiler.cc

Issue 21340002: Generate a custom OSR entrypoint for OSR compiles on all platforms, and transition to optimized cod… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Use FixedArray::OffsetAt and add comment to codegen. Created 7 years, 4 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 | « src/compiler.h ('k') | src/deoptimizer.h » ('j') | src/runtime.cc » ('J')
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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 // The encoding is as a signed value, with parameters and receiver using 354 // The encoding is as a signed value, with parameters and receiver using
355 // the negative indices and locals the non-negative ones. 355 // the negative indices and locals the non-negative ones.
356 const int parameter_limit = -LUnallocated::kMinFixedSlotIndex; 356 const int parameter_limit = -LUnallocated::kMinFixedSlotIndex;
357 Scope* scope = info()->scope(); 357 Scope* scope = info()->scope();
358 if ((scope->num_parameters() + 1) > parameter_limit) { 358 if ((scope->num_parameters() + 1) > parameter_limit) {
359 info()->set_bailout_reason("too many parameters"); 359 info()->set_bailout_reason("too many parameters");
360 return AbortOptimization(); 360 return AbortOptimization();
361 } 361 }
362 362
363 const int locals_limit = LUnallocated::kMaxFixedSlotIndex; 363 const int locals_limit = LUnallocated::kMaxFixedSlotIndex;
364 if (!info()->osr_ast_id().IsNone() && 364 if (info()->is_osr() &&
365 scope->num_parameters() + 1 + scope->num_stack_slots() > locals_limit) { 365 scope->num_parameters() + 1 + scope->num_stack_slots() > locals_limit) {
366 info()->set_bailout_reason("too many parameters/locals"); 366 info()->set_bailout_reason("too many parameters/locals");
367 return AbortOptimization(); 367 return AbortOptimization();
368 } 368 }
369 369
370 // Take --hydrogen-filter into account. 370 // Take --hydrogen-filter into account.
371 if (!info()->closure()->PassesHydrogenFilter()) { 371 if (!info()->closure()->PassesHydrogenFilter()) {
372 info()->SetCode(code); 372 info()->SetCode(code);
373 return SetLastStatus(BAILED_OUT); 373 return SetLastStatus(BAILED_OUT);
374 } 374 }
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 // Do not send compilation event for the same code twice. 865 // Do not send compilation event for the same code twice.
866 return; 866 return;
867 } 867 }
868 Compiler::RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared); 868 Compiler::RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared);
869 } 869 }
870 870
871 871
872 static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { 872 static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) {
873 Handle<Code> code = info->code(); 873 Handle<Code> code = info->code();
874 if (FLAG_cache_optimized_code && 874 if (FLAG_cache_optimized_code &&
875 info->osr_ast_id().IsNone() && 875 !info->is_osr() &&
876 code->kind() == Code::OPTIMIZED_FUNCTION) { 876 code->kind() == Code::OPTIMIZED_FUNCTION) {
877 Handle<JSFunction> function = info->closure(); 877 Handle<JSFunction> function = info->closure();
878 Handle<SharedFunctionInfo> shared(function->shared()); 878 Handle<SharedFunctionInfo> shared(function->shared());
879 Handle<FixedArray> literals(function->literals()); 879 Handle<FixedArray> literals(function->literals());
880 Handle<Context> native_context(function->context()->native_context()); 880 Handle<Context> native_context(function->context()->native_context());
881 SharedFunctionInfo::AddToOptimizedCodeMap( 881 SharedFunctionInfo::AddToOptimizedCodeMap(
882 shared, native_context, code, literals); 882 shared, native_context, code, literals);
883 } 883 }
884 } 884 }
885 885
886 886
887 static bool InstallCodeFromOptimizedCodeMap(CompilationInfo* info) { 887 static bool InstallCodeFromOptimizedCodeMap(CompilationInfo* info) {
888 if (FLAG_cache_optimized_code && 888 if (FLAG_cache_optimized_code &&
889 info->osr_ast_id().IsNone() && 889 !info->is_osr() &&
890 info->IsOptimizing()) { 890 info->IsOptimizing()) {
891 Handle<SharedFunctionInfo> shared = info->shared_info(); 891 Handle<SharedFunctionInfo> shared = info->shared_info();
892 Handle<JSFunction> function = info->closure(); 892 Handle<JSFunction> function = info->closure();
893 ASSERT(!function.is_null()); 893 ASSERT(!function.is_null());
894 Handle<Context> native_context(function->context()->native_context()); 894 Handle<Context> native_context(function->context()->native_context());
895 int index = shared->SearchOptimizedCodeMap(*native_context); 895 int index = shared->SearchOptimizedCodeMap(*native_context);
896 if (index > 0) { 896 if (index > 0) {
897 if (FLAG_trace_opt) { 897 if (FLAG_trace_opt) {
898 PrintF("[found optimized code for "); 898 PrintF("[found optimized code for ");
899 function->ShortPrint(); 899 function->ShortPrint();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 936
937 // Compile the code. 937 // Compile the code.
938 if (!MakeCode(info)) { 938 if (!MakeCode(info)) {
939 if (!isolate->has_pending_exception()) { 939 if (!isolate->has_pending_exception()) {
940 isolate->StackOverflow(); 940 isolate->StackOverflow();
941 } 941 }
942 } else { 942 } else {
943 InstallCodeCommon(info); 943 InstallCodeCommon(info);
944 944
945 if (info->IsOptimizing()) { 945 if (info->IsOptimizing()) {
946 // Optimized code successfully created.
946 Handle<Code> code = info->code(); 947 Handle<Code> code = info->code();
947 ASSERT(shared->scope_info() != ScopeInfo::Empty(isolate)); 948 ASSERT(shared->scope_info() != ScopeInfo::Empty(isolate));
948 info->closure()->ReplaceCode(*code); 949 if (!info->is_osr()) {
949 InsertCodeIntoOptimizedCodeMap(info); 950 // Only replace the code if it was not an OSR compile.
951 info->closure()->ReplaceCode(*code);
952 InsertCodeIntoOptimizedCodeMap(info);
953 }
950 return true; 954 return true;
951 } else { 955 } else if (!info->is_osr()) {
956 // Compilation failed. Replace with full code if not OSR compile.
952 return InstallFullCode(info); 957 return InstallFullCode(info);
953 } 958 }
954 } 959 }
955 } 960 }
956 961
957 ASSERT(info->code().is_null()); 962 ASSERT(info->code().is_null());
958 return false; 963 return false;
959 } 964 }
960 965
961 966
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 // Trace if the appropriate trace flag is set and the phase name's first 1256 // Trace if the appropriate trace flag is set and the phase name's first
1252 // character is in the FLAG_trace_phase command line parameter. 1257 // character is in the FLAG_trace_phase command line parameter.
1253 bool tracing_on = info()->IsStub() ? 1258 bool tracing_on = info()->IsStub() ?
1254 FLAG_trace_hydrogen_stubs : 1259 FLAG_trace_hydrogen_stubs :
1255 FLAG_trace_hydrogen; 1260 FLAG_trace_hydrogen;
1256 return (tracing_on && 1261 return (tracing_on &&
1257 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); 1262 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL);
1258 } 1263 }
1259 1264
1260 } } // namespace v8::internal 1265 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/deoptimizer.h » ('j') | src/runtime.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698