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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
10 #include "src/compiler-dispatcher/optimizing-compile-dispatcher.h" | 10 #include "src/compiler-dispatcher/optimizing-compile-dispatcher.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 RUNTIME_FUNCTION(Runtime_NeverOptimizeFunction) { | 229 RUNTIME_FUNCTION(Runtime_NeverOptimizeFunction) { |
230 HandleScope scope(isolate); | 230 HandleScope scope(isolate); |
231 DCHECK_EQ(1, args.length()); | 231 DCHECK_EQ(1, args.length()); |
232 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 232 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
233 function->shared()->set_disable_optimization_reason( | 233 function->shared()->set_disable_optimization_reason( |
234 kOptimizationDisabledForTest); | 234 kOptimizationDisabledForTest); |
235 function->shared()->set_optimization_disabled(true); | 235 function->shared()->set_optimization_disabled(true); |
236 return isolate->heap()->undefined_value(); | 236 return isolate->heap()->undefined_value(); |
237 } | 237 } |
238 | 238 |
239 | |
240 RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) { | 239 RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) { |
241 HandleScope scope(isolate); | 240 HandleScope scope(isolate); |
242 DCHECK(args.length() == 1 || args.length() == 2); | 241 DCHECK(args.length() == 1 || args.length() == 2); |
| 242 int status = 0; |
243 if (!isolate->use_crankshaft()) { | 243 if (!isolate->use_crankshaft()) { |
244 return Smi::FromInt(4); // 4 == "never". | 244 status |= static_cast<int>(OptimizationStatus::kNeverOptimize); |
| 245 } |
| 246 if (FLAG_always_opt || FLAG_prepare_always_opt) { |
| 247 status |= static_cast<int>(OptimizationStatus::kAlwaysOptimize); |
| 248 } |
| 249 if (FLAG_deopt_every_n_times) { |
| 250 status |= static_cast<int>(OptimizationStatus::kMaybeDeopted); |
245 } | 251 } |
246 | 252 |
247 // This function is used by fuzzers to get coverage for optimizations | 253 // This function is used by fuzzers to get coverage for optimizations |
248 // in compiler. Ignore calls on non-function objects to avoid runtime errors. | 254 // in compiler. Ignore calls on non-function objects to avoid runtime errors. |
249 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0); | 255 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0); |
250 if (!function_object->IsJSFunction()) { | 256 if (!function_object->IsJSFunction()) { |
251 return isolate->heap()->undefined_value(); | 257 return Smi::FromInt(status); |
252 } | 258 } |
253 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); | 259 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); |
| 260 status |= static_cast<int>(OptimizationStatus::kIsFunction); |
254 | 261 |
255 bool sync_with_compiler_thread = true; | 262 bool sync_with_compiler_thread = true; |
256 if (args.length() == 2) { | 263 if (args.length() == 2) { |
257 CONVERT_ARG_HANDLE_CHECKED(Object, sync_object, 1); | 264 CONVERT_ARG_HANDLE_CHECKED(Object, sync_object, 1); |
258 if (!sync_object->IsString()) return isolate->heap()->undefined_value(); | 265 if (!sync_object->IsString()) return isolate->heap()->undefined_value(); |
259 Handle<String> sync = Handle<String>::cast(sync_object); | 266 Handle<String> sync = Handle<String>::cast(sync_object); |
260 if (sync->IsOneByteEqualTo(STATIC_CHAR_VECTOR("no sync"))) { | 267 if (sync->IsOneByteEqualTo(STATIC_CHAR_VECTOR("no sync"))) { |
261 sync_with_compiler_thread = false; | 268 sync_with_compiler_thread = false; |
262 } | 269 } |
263 } | 270 } |
264 | 271 |
265 if (isolate->concurrent_recompilation_enabled() && | 272 if (isolate->concurrent_recompilation_enabled() && |
266 sync_with_compiler_thread) { | 273 sync_with_compiler_thread) { |
267 while (function->IsInOptimizationQueue()) { | 274 while (function->IsInOptimizationQueue()) { |
268 isolate->optimizing_compile_dispatcher()->InstallOptimizedFunctions(); | 275 isolate->optimizing_compile_dispatcher()->InstallOptimizedFunctions(); |
269 base::OS::Sleep(base::TimeDelta::FromMilliseconds(50)); | 276 base::OS::Sleep(base::TimeDelta::FromMilliseconds(50)); |
270 } | 277 } |
271 } | 278 } |
272 if (FLAG_always_opt || FLAG_prepare_always_opt) { | 279 if (function->IsOptimized()) { |
273 // With --always-opt, optimization status expectations might not | 280 status |= static_cast<int>(OptimizationStatus::kOptimized); |
274 // match up, so just return a sentinel. | 281 if (function->code()->is_turbofanned()) { |
275 return Smi::FromInt(3); // 3 == "always". | 282 status |= static_cast<int>(OptimizationStatus::kTurboFanned); |
276 } | 283 } |
277 if (FLAG_deopt_every_n_times) { | |
278 return Smi::FromInt(6); // 6 == "maybe deopted". | |
279 } | |
280 if (function->IsOptimized() && function->code()->is_turbofanned()) { | |
281 return Smi::FromInt(7); // 7 == "TurboFan compiler". | |
282 } | 284 } |
283 if (function->IsInterpreted()) { | 285 if (function->IsInterpreted()) { |
284 return Smi::FromInt(8); // 8 == "Interpreted". | 286 status |= static_cast<int>(OptimizationStatus::kInterpreted); |
285 } | 287 } |
286 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes". | 288 return Smi::FromInt(status); |
287 : Smi::FromInt(2); // 2 == "no". | |
288 } | 289 } |
289 | 290 |
290 | 291 |
291 RUNTIME_FUNCTION(Runtime_UnblockConcurrentRecompilation) { | 292 RUNTIME_FUNCTION(Runtime_UnblockConcurrentRecompilation) { |
292 DCHECK_EQ(0, args.length()); | 293 DCHECK_EQ(0, args.length()); |
293 if (FLAG_block_concurrent_recompilation && | 294 if (FLAG_block_concurrent_recompilation && |
294 isolate->concurrent_recompilation_enabled()) { | 295 isolate->concurrent_recompilation_enabled()) { |
295 isolate->optimizing_compile_dispatcher()->Unblock(); | 296 isolate->optimizing_compile_dispatcher()->Unblock(); |
296 } | 297 } |
297 return isolate->heap()->undefined_value(); | 298 return isolate->heap()->undefined_value(); |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 CHECK(HeapObject::cast(*object)->map()->IsMap()); | 856 CHECK(HeapObject::cast(*object)->map()->IsMap()); |
856 } else { | 857 } else { |
857 CHECK(object->IsSmi()); | 858 CHECK(object->IsSmi()); |
858 } | 859 } |
859 #endif | 860 #endif |
860 return isolate->heap()->ToBoolean(true); | 861 return isolate->heap()->ToBoolean(true); |
861 } | 862 } |
862 | 863 |
863 } // namespace internal | 864 } // namespace internal |
864 } // namespace v8 | 865 } // namespace v8 |
OLD | NEW |