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/deoptimizer.h" | 8 #include "src/deoptimizer.h" |
9 #include "src/frames-inl.h" | 9 #include "src/frames-inl.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 return *isolate->factory()->NewNumber(uint64_to_double(result)); | 23 return *isolate->factory()->NewNumber(uint64_to_double(result)); |
24 } | 24 } |
25 | 25 |
26 RUNTIME_FUNCTION(Runtime_DeoptimizeFunction) { | 26 RUNTIME_FUNCTION(Runtime_DeoptimizeFunction) { |
27 HandleScope scope(isolate); | 27 HandleScope scope(isolate); |
28 DCHECK(args.length() == 1); | 28 DCHECK(args.length() == 1); |
29 | 29 |
30 // This function is used by fuzzers to get coverage in compiler. | 30 // This function is used by fuzzers to get coverage in compiler. |
31 // Ignore calls on non-function objects to avoid runtime errors. | 31 // Ignore calls on non-function objects to avoid runtime errors. |
32 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0); | 32 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0); |
33 // If it is not a JSFunction, just return. | |
34 if (!function_object->IsJSFunction()) { | 33 if (!function_object->IsJSFunction()) { |
35 return isolate->heap()->undefined_value(); | 34 return isolate->heap()->undefined_value(); |
36 } | 35 } |
37 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); | 36 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); |
38 | 37 |
39 if (!function->IsOptimized()) return isolate->heap()->undefined_value(); | 38 if (!function->IsOptimized()) return isolate->heap()->undefined_value(); |
40 | 39 |
41 // TODO(turbofan): Deoptimization is not supported yet. | 40 // TODO(turbofan): Deoptimization is not supported yet. |
42 if (function->code()->is_turbofanned() && | 41 if (function->code()->is_turbofanned() && |
43 function->shared()->asm_function() && !FLAG_turbo_asm_deoptimization) { | 42 function->shared()->asm_function() && !FLAG_turbo_asm_deoptimization) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 HandleScope scope(isolate); | 103 HandleScope scope(isolate); |
105 | 104 |
106 // This function is used by fuzzers, ignore calls with bogus arguments count. | 105 // This function is used by fuzzers, ignore calls with bogus arguments count. |
107 if (args.length() != 1 && args.length() != 2) { | 106 if (args.length() != 1 && args.length() != 2) { |
108 return isolate->heap()->undefined_value(); | 107 return isolate->heap()->undefined_value(); |
109 } | 108 } |
110 | 109 |
111 // This function is used by fuzzers to get coverage for optimizations | 110 // This function is used by fuzzers to get coverage for optimizations |
112 // in compiler. Ignore calls on non-function objects to avoid runtime errors. | 111 // in compiler. Ignore calls on non-function objects to avoid runtime errors. |
113 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0); | 112 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0); |
114 // If it is not a JSFunction, just return. | |
115 if (!function_object->IsJSFunction()) { | 113 if (!function_object->IsJSFunction()) { |
116 return isolate->heap()->undefined_value(); | 114 return isolate->heap()->undefined_value(); |
117 } | 115 } |
118 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); | 116 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); |
119 | 117 |
120 // The following condition was lifted from the DCHECK inside | 118 // The following condition was lifted from the DCHECK inside |
121 // JSFunction::MarkForOptimization(). | 119 // JSFunction::MarkForOptimization(). |
122 if (!(function->shared()->allows_lazy_compilation() || | 120 if (!(function->shared()->allows_lazy_compilation() || |
123 (function->code()->kind() == Code::FUNCTION && | 121 (function->code()->kind() == Code::FUNCTION && |
124 !function->shared()->optimization_disabled()))) { | 122 !function->shared()->optimization_disabled()))) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 return isolate->heap()->undefined_value(); | 203 return isolate->heap()->undefined_value(); |
206 } | 204 } |
207 | 205 |
208 | 206 |
209 RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) { | 207 RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) { |
210 HandleScope scope(isolate); | 208 HandleScope scope(isolate); |
211 DCHECK(args.length() == 1 || args.length() == 2); | 209 DCHECK(args.length() == 1 || args.length() == 2); |
212 if (!isolate->use_crankshaft()) { | 210 if (!isolate->use_crankshaft()) { |
213 return Smi::FromInt(4); // 4 == "never". | 211 return Smi::FromInt(4); // 4 == "never". |
214 } | 212 } |
| 213 |
| 214 // This function is used by fuzzers to get coverage for optimizations |
| 215 // in compiler. Ignore calls on non-function objects to avoid runtime errors. |
| 216 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0); |
| 217 if (!function_object->IsJSFunction()) { |
| 218 return isolate->heap()->undefined_value(); |
| 219 } |
| 220 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); |
| 221 |
215 bool sync_with_compiler_thread = true; | 222 bool sync_with_compiler_thread = true; |
216 if (args.length() == 2) { | 223 if (args.length() == 2) { |
217 CONVERT_ARG_HANDLE_CHECKED(String, sync, 1); | 224 CONVERT_ARG_HANDLE_CHECKED(Object, sync_object, 1); |
| 225 if (!sync_object->IsString()) return isolate->heap()->undefined_value(); |
| 226 Handle<String> sync = Handle<String>::cast(sync_object); |
218 if (sync->IsOneByteEqualTo(STATIC_CHAR_VECTOR("no sync"))) { | 227 if (sync->IsOneByteEqualTo(STATIC_CHAR_VECTOR("no sync"))) { |
219 sync_with_compiler_thread = false; | 228 sync_with_compiler_thread = false; |
220 } | 229 } |
221 } | 230 } |
222 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 231 |
223 if (isolate->concurrent_recompilation_enabled() && | 232 if (isolate->concurrent_recompilation_enabled() && |
224 sync_with_compiler_thread) { | 233 sync_with_compiler_thread) { |
225 while (function->IsInOptimizationQueue()) { | 234 while (function->IsInOptimizationQueue()) { |
226 isolate->optimizing_compile_dispatcher()->InstallOptimizedFunctions(); | 235 isolate->optimizing_compile_dispatcher()->InstallOptimizedFunctions(); |
227 base::OS::Sleep(base::TimeDelta::FromMilliseconds(50)); | 236 base::OS::Sleep(base::TimeDelta::FromMilliseconds(50)); |
228 } | 237 } |
229 } | 238 } |
230 if (FLAG_always_opt || FLAG_prepare_always_opt) { | 239 if (FLAG_always_opt || FLAG_prepare_always_opt) { |
231 // With --always-opt, optimization status expectations might not | 240 // With --always-opt, optimization status expectations might not |
232 // match up, so just return a sentinel. | 241 // match up, so just return a sentinel. |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 | 589 |
581 RUNTIME_FUNCTION(Runtime_SpeciesProtector) { | 590 RUNTIME_FUNCTION(Runtime_SpeciesProtector) { |
582 SealHandleScope shs(isolate); | 591 SealHandleScope shs(isolate); |
583 DCHECK_EQ(0, args.length()); | 592 DCHECK_EQ(0, args.length()); |
584 return isolate->heap()->ToBoolean(isolate->IsArraySpeciesLookupChainIntact()); | 593 return isolate->heap()->ToBoolean(isolate->IsArraySpeciesLookupChainIntact()); |
585 } | 594 } |
586 | 595 |
587 | 596 |
588 } // namespace internal | 597 } // namespace internal |
589 } // namespace v8 | 598 } // namespace v8 |
OLD | NEW |