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 10 matching lines...) Expand all Loading... |
21 HandleScope scope(isolate); | 21 HandleScope scope(isolate); |
22 DCHECK(args.length() == 1); | 22 DCHECK(args.length() == 1); |
23 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 23 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
24 #ifdef DEBUG | 24 #ifdef DEBUG |
25 if (FLAG_trace_lazy && !function->shared()->is_compiled()) { | 25 if (FLAG_trace_lazy && !function->shared()->is_compiled()) { |
26 PrintF("[unoptimized: "); | 26 PrintF("[unoptimized: "); |
27 function->PrintName(); | 27 function->PrintName(); |
28 PrintF("]\n"); | 28 PrintF("]\n"); |
29 } | 29 } |
30 #endif | 30 #endif |
| 31 StackLimitCheck check(isolate); |
| 32 if (check.JsHasOverflowed(1 * KB)) return isolate->StackOverflow(); |
31 | 33 |
32 // Compile the target function. | 34 // Compile the target function. |
33 DCHECK(function->shared()->allows_lazy_compilation()); | 35 DCHECK(function->shared()->allows_lazy_compilation()); |
34 | 36 |
35 Handle<Code> code; | 37 Handle<Code> code; |
36 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, code, | 38 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, code, |
37 Compiler::GetLazyCode(function)); | 39 Compiler::GetLazyCode(function)); |
38 DCHECK(code->IsJavaScriptCode()); | 40 DCHECK(code->IsJavaScriptCode()); |
39 | 41 |
40 function->ReplaceCode(*code); | 42 function->ReplaceCode(*code); |
41 return *code; | 43 return *code; |
42 } | 44 } |
43 | 45 |
44 | 46 |
45 RUNTIME_FUNCTION(Runtime_CompileOptimized) { | 47 RUNTIME_FUNCTION(Runtime_CompileOptimized) { |
46 HandleScope scope(isolate); | 48 HandleScope scope(isolate); |
47 DCHECK(args.length() == 2); | 49 DCHECK(args.length() == 2); |
48 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 50 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
49 CONVERT_BOOLEAN_ARG_CHECKED(concurrent, 1); | 51 CONVERT_BOOLEAN_ARG_CHECKED(concurrent, 1); |
50 | 52 |
| 53 StackLimitCheck check(isolate); |
| 54 if (check.JsHasOverflowed(1 * KB)) return isolate->StackOverflow(); |
| 55 |
51 Compiler::ConcurrencyMode mode = | 56 Compiler::ConcurrencyMode mode = |
52 concurrent ? Compiler::CONCURRENT : Compiler::NOT_CONCURRENT; | 57 concurrent ? Compiler::CONCURRENT : Compiler::NOT_CONCURRENT; |
53 Handle<Code> code; | 58 Handle<Code> code; |
54 Handle<Code> unoptimized(function->shared()->code()); | 59 Handle<Code> unoptimized(function->shared()->code()); |
55 if (Compiler::GetOptimizedCode(function, unoptimized, mode).ToHandle(&code)) { | 60 if (Compiler::GetOptimizedCode(function, unoptimized, mode).ToHandle(&code)) { |
56 // Optimization succeeded, return optimized code. | 61 // Optimization succeeded, return optimized code. |
57 function->ReplaceCode(*code); | 62 function->ReplaceCode(*code); |
58 } else { | 63 } else { |
59 // Optimization failed, get unoptimized code. | 64 // Optimization failed, get unoptimized code. |
60 if (isolate->has_pending_exception()) { // Possible stack overflow. | 65 if (isolate->has_pending_exception()) { // Possible stack overflow. |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 DCHECK(is_valid_language_mode(args.smi_at(3))); | 439 DCHECK(is_valid_language_mode(args.smi_at(3))); |
435 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(3)); | 440 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(3)); |
436 DCHECK(args[4]->IsSmi()); | 441 DCHECK(args[4]->IsSmi()); |
437 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), | 442 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), |
438 isolate); | 443 isolate); |
439 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, | 444 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, |
440 language_mode, args.smi_at(4)); | 445 language_mode, args.smi_at(4)); |
441 } | 446 } |
442 } // namespace internal | 447 } // namespace internal |
443 } // namespace v8 | 448 } // namespace v8 |
OLD | NEW |