| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
| 9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
| 10 #include "src/frames-inl.h" | 10 #include "src/frames-inl.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 function->PrintName(); | 27 function->PrintName(); |
| 28 PrintF("]\n"); | 28 PrintF("]\n"); |
| 29 } | 29 } |
| 30 #endif | 30 #endif |
| 31 StackLimitCheck check(isolate); | 31 StackLimitCheck check(isolate); |
| 32 if (check.JsHasOverflowed(1 * KB)) return isolate->StackOverflow(); | 32 if (check.JsHasOverflowed(1 * KB)) return isolate->StackOverflow(); |
| 33 | 33 |
| 34 // Compile the target function. | 34 // Compile the target function. |
| 35 DCHECK(function->shared()->allows_lazy_compilation()); | 35 DCHECK(function->shared()->allows_lazy_compilation()); |
| 36 | 36 |
| 37 // There is one special case where we have optimized code but we | |
| 38 // couldn't find a literals array for the native context. That's with | |
| 39 // FLAG_turbo_cache_shared_code. | |
| 40 if (FLAG_turbo_cache_shared_code) { | |
| 41 SharedFunctionInfo* shared = function->shared(); | |
| 42 CodeAndLiterals result; | |
| 43 result = shared->SearchOptimizedCodeMap(*isolate->native_context(), | |
| 44 BailoutId::None()); | |
| 45 if (result.code != nullptr) { | |
| 46 function->ReplaceCode(result.code); | |
| 47 JSFunction::EnsureLiterals(function); | |
| 48 return result.code; | |
| 49 } | |
| 50 } | |
| 51 | |
| 52 Handle<Code> code; | 37 Handle<Code> code; |
| 53 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, code, | 38 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, code, |
| 54 Compiler::GetLazyCode(function)); | 39 Compiler::GetLazyCode(function)); |
| 55 DCHECK(code->IsJavaScriptCode()); | 40 DCHECK(code->IsJavaScriptCode()); |
| 56 | 41 |
| 57 function->ReplaceCode(*code); | 42 function->ReplaceCode(*code); |
| 58 JSFunction::EnsureLiterals(function); | |
| 59 return *code; | 43 return *code; |
| 60 } | 44 } |
| 61 | 45 |
| 62 | 46 |
| 63 namespace { | 47 namespace { |
| 64 | 48 |
| 65 Object* CompileOptimized(Isolate* isolate, Handle<JSFunction> function, | 49 Object* CompileOptimized(Isolate* isolate, Handle<JSFunction> function, |
| 66 Compiler::ConcurrencyMode mode) { | 50 Compiler::ConcurrencyMode mode) { |
| 67 StackLimitCheck check(isolate); | 51 StackLimitCheck check(isolate); |
| 68 if (check.JsHasOverflowed(1 * KB)) return isolate->StackOverflow(); | 52 if (check.JsHasOverflowed(1 * KB)) return isolate->StackOverflow(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 80 if (code->kind() != Code::FUNCTION && | 64 if (code->kind() != Code::FUNCTION && |
| 81 code->kind() != Code::OPTIMIZED_FUNCTION) { | 65 code->kind() != Code::OPTIMIZED_FUNCTION) { |
| 82 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 66 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 83 isolate, code, Compiler::GetUnoptimizedCode(function)); | 67 isolate, code, Compiler::GetUnoptimizedCode(function)); |
| 84 } | 68 } |
| 85 function->ReplaceCode(*code); | 69 function->ReplaceCode(*code); |
| 86 } | 70 } |
| 87 | 71 |
| 88 DCHECK(function->code()->kind() == Code::FUNCTION || | 72 DCHECK(function->code()->kind() == Code::FUNCTION || |
| 89 function->code()->kind() == Code::OPTIMIZED_FUNCTION || | 73 function->code()->kind() == Code::OPTIMIZED_FUNCTION || |
| 90 function->code()->is_interpreter_entry_trampoline() || | |
| 91 function->IsInOptimizationQueue()); | 74 function->IsInOptimizationQueue()); |
| 92 return function->code(); | 75 return function->code(); |
| 93 } | 76 } |
| 94 | 77 |
| 95 } // namespace | 78 } // namespace |
| 96 | 79 |
| 97 | 80 |
| 98 RUNTIME_FUNCTION(Runtime_CompileOptimized_Concurrent) { | 81 RUNTIME_FUNCTION(Runtime_CompileOptimized_Concurrent) { |
| 99 HandleScope scope(isolate); | 82 HandleScope scope(isolate); |
| 100 DCHECK(args.length() == 1); | 83 DCHECK(args.length() == 1); |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 DCHECK(is_valid_language_mode(args.smi_at(3))); | 423 DCHECK(is_valid_language_mode(args.smi_at(3))); |
| 441 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(3)); | 424 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(3)); |
| 442 DCHECK(args[4]->IsSmi()); | 425 DCHECK(args[4]->IsSmi()); |
| 443 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), | 426 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), |
| 444 isolate); | 427 isolate); |
| 445 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, | 428 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, |
| 446 language_mode, args.smi_at(4)); | 429 language_mode, args.smi_at(4)); |
| 447 } | 430 } |
| 448 } // namespace internal | 431 } // namespace internal |
| 449 } // namespace v8 | 432 } // namespace v8 |
| OLD | NEW |