| 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" |
| 11 #include "src/full-codegen/full-codegen.h" | 11 #include "src/full-codegen/full-codegen.h" |
| 12 #include "src/isolate-inl.h" | 12 #include "src/isolate-inl.h" |
| 13 #include "src/messages.h" | 13 #include "src/messages.h" |
| 14 #include "src/v8threads.h" | 14 #include "src/v8threads.h" |
| 15 #include "src/vm-state-inl.h" | 15 #include "src/vm-state-inl.h" |
| 16 | 16 |
| 17 namespace v8 { | 17 namespace v8 { |
| 18 namespace internal { | 18 namespace internal { |
| 19 | 19 |
| 20 RUNTIME_FUNCTION(Runtime_CompileLazy) { | 20 RUNTIME_FUNCTION(Runtime_CompileLazy) { |
| 21 HandleScope scope(isolate); | 21 HandleScope scope(isolate); |
| 22 DCHECK(args.length() == 1); | 22 DCHECK_EQ(1, args.length()); |
| 23 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 23 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 24 | 24 |
| 25 #ifdef DEBUG | 25 #ifdef DEBUG |
| 26 if (FLAG_trace_lazy && !function->shared()->is_compiled()) { | 26 if (FLAG_trace_lazy && !function->shared()->is_compiled()) { |
| 27 PrintF("[unoptimized: "); | 27 PrintF("[unoptimized: "); |
| 28 function->PrintName(); | 28 function->PrintName(); |
| 29 PrintF("]\n"); | 29 PrintF("]\n"); |
| 30 } | 30 } |
| 31 #endif | 31 #endif |
| 32 | 32 |
| 33 StackLimitCheck check(isolate); | 33 StackLimitCheck check(isolate); |
| 34 if (check.JsHasOverflowed(1 * KB)) return isolate->StackOverflow(); | 34 if (check.JsHasOverflowed(1 * KB)) return isolate->StackOverflow(); |
| 35 if (!Compiler::Compile(function, Compiler::KEEP_EXCEPTION)) { | 35 if (!Compiler::Compile(function, Compiler::KEEP_EXCEPTION)) { |
| 36 return isolate->heap()->exception(); | 36 return isolate->heap()->exception(); |
| 37 } | 37 } |
| 38 DCHECK(function->is_compiled()); | 38 DCHECK(function->is_compiled()); |
| 39 return function->code(); | 39 return function->code(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 RUNTIME_FUNCTION(Runtime_CompileBaseline) { |
| 43 HandleScope scope(isolate); |
| 44 DCHECK_EQ(1, args.length()); |
| 45 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 46 StackLimitCheck check(isolate); |
| 47 if (check.JsHasOverflowed(1 * KB)) return isolate->StackOverflow(); |
| 48 if (!Compiler::CompileBaseline(function)) { |
| 49 return isolate->heap()->exception(); |
| 50 } |
| 51 DCHECK(function->is_compiled()); |
| 52 return function->code(); |
| 53 } |
| 42 | 54 |
| 43 RUNTIME_FUNCTION(Runtime_CompileOptimized_Concurrent) { | 55 RUNTIME_FUNCTION(Runtime_CompileOptimized_Concurrent) { |
| 44 HandleScope scope(isolate); | 56 HandleScope scope(isolate); |
| 45 DCHECK(args.length() == 1); | 57 DCHECK_EQ(1, args.length()); |
| 46 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 58 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 47 StackLimitCheck check(isolate); | 59 StackLimitCheck check(isolate); |
| 48 if (check.JsHasOverflowed(1 * KB)) return isolate->StackOverflow(); | 60 if (check.JsHasOverflowed(1 * KB)) return isolate->StackOverflow(); |
| 49 if (!Compiler::CompileOptimized(function, Compiler::CONCURRENT)) { | 61 if (!Compiler::CompileOptimized(function, Compiler::CONCURRENT)) { |
| 50 return isolate->heap()->exception(); | 62 return isolate->heap()->exception(); |
| 51 } | 63 } |
| 52 DCHECK(function->is_compiled()); | 64 DCHECK(function->is_compiled()); |
| 53 return function->code(); | 65 return function->code(); |
| 54 } | 66 } |
| 55 | 67 |
| 56 | 68 |
| 57 RUNTIME_FUNCTION(Runtime_CompileOptimized_NotConcurrent) { | 69 RUNTIME_FUNCTION(Runtime_CompileOptimized_NotConcurrent) { |
| 58 HandleScope scope(isolate); | 70 HandleScope scope(isolate); |
| 59 DCHECK(args.length() == 1); | 71 DCHECK_EQ(1, args.length()); |
| 60 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 72 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 61 StackLimitCheck check(isolate); | 73 StackLimitCheck check(isolate); |
| 62 if (check.JsHasOverflowed(1 * KB)) return isolate->StackOverflow(); | 74 if (check.JsHasOverflowed(1 * KB)) return isolate->StackOverflow(); |
| 63 if (!Compiler::CompileOptimized(function, Compiler::NOT_CONCURRENT)) { | 75 if (!Compiler::CompileOptimized(function, Compiler::NOT_CONCURRENT)) { |
| 64 return isolate->heap()->exception(); | 76 return isolate->heap()->exception(); |
| 65 } | 77 } |
| 66 DCHECK(function->is_compiled()); | 78 DCHECK(function->is_compiled()); |
| 67 return function->code(); | 79 return function->code(); |
| 68 } | 80 } |
| 69 | 81 |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 DCHECK(is_valid_language_mode(args.smi_at(3))); | 370 DCHECK(is_valid_language_mode(args.smi_at(3))); |
| 359 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(3)); | 371 LanguageMode language_mode = static_cast<LanguageMode>(args.smi_at(3)); |
| 360 DCHECK(args[4]->IsSmi()); | 372 DCHECK(args[4]->IsSmi()); |
| 361 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), | 373 Handle<SharedFunctionInfo> outer_info(args.at<JSFunction>(2)->shared(), |
| 362 isolate); | 374 isolate); |
| 363 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, | 375 return CompileGlobalEval(isolate, args.at<String>(1), outer_info, |
| 364 language_mode, args.smi_at(4), args.smi_at(5)); | 376 language_mode, args.smi_at(4), args.smi_at(5)); |
| 365 } | 377 } |
| 366 } // namespace internal | 378 } // namespace internal |
| 367 } // namespace v8 | 379 } // namespace v8 |
| OLD | NEW |