OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 live_edit_tracker.RecordFunctionInfo(result, literal, info.zone()); | 1034 live_edit_tracker.RecordFunctionInfo(result, literal, info.zone()); |
1035 return result; | 1035 return result; |
1036 } | 1036 } |
1037 | 1037 |
1038 | 1038 |
1039 MUST_USE_RESULT static MaybeHandle<Code> GetCodeFromOptimizedCodeMap( | 1039 MUST_USE_RESULT static MaybeHandle<Code> GetCodeFromOptimizedCodeMap( |
1040 Handle<JSFunction> function, | 1040 Handle<JSFunction> function, |
1041 BailoutId osr_ast_id) { | 1041 BailoutId osr_ast_id) { |
1042 if (FLAG_cache_optimized_code) { | 1042 if (FLAG_cache_optimized_code) { |
1043 Handle<SharedFunctionInfo> shared(function->shared()); | 1043 Handle<SharedFunctionInfo> shared(function->shared()); |
| 1044 // Bound functions are not cached. |
| 1045 if (shared->bound()) return MaybeHandle<Code>(); |
1044 DisallowHeapAllocation no_gc; | 1046 DisallowHeapAllocation no_gc; |
1045 int index = shared->SearchOptimizedCodeMap( | 1047 int index = shared->SearchOptimizedCodeMap( |
1046 function->context()->native_context(), osr_ast_id); | 1048 function->context()->native_context(), osr_ast_id); |
1047 if (index > 0) { | 1049 if (index > 0) { |
1048 if (FLAG_trace_opt) { | 1050 if (FLAG_trace_opt) { |
1049 PrintF("[found optimized code for "); | 1051 PrintF("[found optimized code for "); |
1050 function->ShortPrint(); | 1052 function->ShortPrint(); |
1051 if (!osr_ast_id.IsNone()) { | 1053 if (!osr_ast_id.IsNone()) { |
1052 PrintF(" at OSR AST id %d", osr_ast_id.ToInt()); | 1054 PrintF(" at OSR AST id %d", osr_ast_id.ToInt()); |
1053 } | 1055 } |
1054 PrintF("]\n"); | 1056 PrintF("]\n"); |
1055 } | 1057 } |
1056 FixedArray* literals = shared->GetLiteralsFromOptimizedCodeMap(index); | 1058 FixedArray* literals = shared->GetLiteralsFromOptimizedCodeMap(index); |
1057 if (literals != NULL) function->set_literals(literals); | 1059 if (literals != NULL) function->set_literals(literals); |
1058 return Handle<Code>(shared->GetCodeFromOptimizedCodeMap(index)); | 1060 return Handle<Code>(shared->GetCodeFromOptimizedCodeMap(index)); |
1059 } | 1061 } |
1060 } | 1062 } |
1061 return MaybeHandle<Code>(); | 1063 return MaybeHandle<Code>(); |
1062 } | 1064 } |
1063 | 1065 |
1064 | 1066 |
1065 static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { | 1067 static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { |
1066 Handle<Code> code = info->code(); | 1068 Handle<Code> code = info->code(); |
1067 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do. | 1069 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do. |
1068 | 1070 |
1069 // Cache optimized code. | 1071 // Cache optimized code. |
1070 if (FLAG_cache_optimized_code) { | 1072 if (FLAG_cache_optimized_code) { |
1071 Handle<JSFunction> function = info->closure(); | 1073 Handle<JSFunction> function = info->closure(); |
1072 Handle<SharedFunctionInfo> shared(function->shared()); | 1074 Handle<SharedFunctionInfo> shared(function->shared()); |
| 1075 // Do not cache bound functions. |
| 1076 if (shared->bound()) return; |
1073 Handle<FixedArray> literals(function->literals()); | 1077 Handle<FixedArray> literals(function->literals()); |
1074 Handle<Context> native_context(function->context()->native_context()); | 1078 Handle<Context> native_context(function->context()->native_context()); |
1075 SharedFunctionInfo::AddToOptimizedCodeMap( | 1079 SharedFunctionInfo::AddToOptimizedCodeMap( |
1076 shared, native_context, code, literals, info->osr_ast_id()); | 1080 shared, native_context, code, literals, info->osr_ast_id()); |
1077 } | 1081 } |
1078 } | 1082 } |
1079 | 1083 |
1080 | 1084 |
1081 static bool CompileOptimizedPrologue(CompilationInfo* info) { | 1085 static bool CompileOptimizedPrologue(CompilationInfo* info) { |
1082 if (!Parser::Parse(info)) return false; | 1086 if (!Parser::Parse(info)) return false; |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 AllowHandleDereference allow_deref; | 1300 AllowHandleDereference allow_deref; |
1297 bool tracing_on = info()->IsStub() | 1301 bool tracing_on = info()->IsStub() |
1298 ? FLAG_trace_hydrogen_stubs | 1302 ? FLAG_trace_hydrogen_stubs |
1299 : (FLAG_trace_hydrogen && | 1303 : (FLAG_trace_hydrogen && |
1300 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1304 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
1301 return (tracing_on && | 1305 return (tracing_on && |
1302 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1306 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
1303 } | 1307 } |
1304 | 1308 |
1305 } } // namespace v8::internal | 1309 } } // namespace v8::internal |
OLD | NEW |