Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: src/runtime/runtime-test.cc

Issue 2655223003: Revert of [tests] Make assertOptimized()/assertUnoptimized() great again. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/test-api-interceptors.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
239 RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) { 240 RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) {
240 HandleScope scope(isolate); 241 HandleScope scope(isolate);
241 DCHECK(args.length() == 1 || args.length() == 2); 242 DCHECK(args.length() == 1 || args.length() == 2);
242 int status = 0;
243 if (!isolate->use_crankshaft()) { 243 if (!isolate->use_crankshaft()) {
244 status |= static_cast<int>(OptimizationStatus::kNeverOptimize); 244 return Smi::FromInt(4); // 4 == "never".
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);
251 } 245 }
252 246
253 // This function is used by fuzzers to get coverage for optimizations 247 // This function is used by fuzzers to get coverage for optimizations
254 // in compiler. Ignore calls on non-function objects to avoid runtime errors. 248 // in compiler. Ignore calls on non-function objects to avoid runtime errors.
255 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0); 249 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0);
256 if (!function_object->IsJSFunction()) { 250 if (!function_object->IsJSFunction()) {
257 return Smi::FromInt(status); 251 return isolate->heap()->undefined_value();
258 } 252 }
259 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); 253 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
260 status |= static_cast<int>(OptimizationStatus::kIsFunction);
261 254
262 bool sync_with_compiler_thread = true; 255 bool sync_with_compiler_thread = true;
263 if (args.length() == 2) { 256 if (args.length() == 2) {
264 CONVERT_ARG_HANDLE_CHECKED(Object, sync_object, 1); 257 CONVERT_ARG_HANDLE_CHECKED(Object, sync_object, 1);
265 if (!sync_object->IsString()) return isolate->heap()->undefined_value(); 258 if (!sync_object->IsString()) return isolate->heap()->undefined_value();
266 Handle<String> sync = Handle<String>::cast(sync_object); 259 Handle<String> sync = Handle<String>::cast(sync_object);
267 if (sync->IsOneByteEqualTo(STATIC_CHAR_VECTOR("no sync"))) { 260 if (sync->IsOneByteEqualTo(STATIC_CHAR_VECTOR("no sync"))) {
268 sync_with_compiler_thread = false; 261 sync_with_compiler_thread = false;
269 } 262 }
270 } 263 }
271 264
272 if (isolate->concurrent_recompilation_enabled() && 265 if (isolate->concurrent_recompilation_enabled() &&
273 sync_with_compiler_thread) { 266 sync_with_compiler_thread) {
274 while (function->IsInOptimizationQueue()) { 267 while (function->IsInOptimizationQueue()) {
275 isolate->optimizing_compile_dispatcher()->InstallOptimizedFunctions(); 268 isolate->optimizing_compile_dispatcher()->InstallOptimizedFunctions();
276 base::OS::Sleep(base::TimeDelta::FromMilliseconds(50)); 269 base::OS::Sleep(base::TimeDelta::FromMilliseconds(50));
277 } 270 }
278 } 271 }
279 if (function->IsOptimized()) { 272 if (FLAG_always_opt || FLAG_prepare_always_opt) {
280 status |= static_cast<int>(OptimizationStatus::kOptimized); 273 // With --always-opt, optimization status expectations might not
281 if (function->code()->is_turbofanned()) { 274 // match up, so just return a sentinel.
282 status |= static_cast<int>(OptimizationStatus::kTurboFanned); 275 return Smi::FromInt(3); // 3 == "always".
283 } 276 }
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".
284 } 282 }
285 if (function->IsInterpreted()) { 283 if (function->IsInterpreted()) {
286 status |= static_cast<int>(OptimizationStatus::kInterpreted); 284 return Smi::FromInt(8); // 8 == "Interpreted".
287 } 285 }
288 return Smi::FromInt(status); 286 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes".
287 : Smi::FromInt(2); // 2 == "no".
289 } 288 }
290 289
291 290
292 RUNTIME_FUNCTION(Runtime_UnblockConcurrentRecompilation) { 291 RUNTIME_FUNCTION(Runtime_UnblockConcurrentRecompilation) {
293 DCHECK_EQ(0, args.length()); 292 DCHECK_EQ(0, args.length());
294 if (FLAG_block_concurrent_recompilation && 293 if (FLAG_block_concurrent_recompilation &&
295 isolate->concurrent_recompilation_enabled()) { 294 isolate->concurrent_recompilation_enabled()) {
296 isolate->optimizing_compile_dispatcher()->Unblock(); 295 isolate->optimizing_compile_dispatcher()->Unblock();
297 } 296 }
298 return isolate->heap()->undefined_value(); 297 return isolate->heap()->undefined_value();
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 CHECK(HeapObject::cast(*object)->map()->IsMap()); 855 CHECK(HeapObject::cast(*object)->map()->IsMap());
857 } else { 856 } else {
858 CHECK(object->IsSmi()); 857 CHECK(object->IsSmi());
859 } 858 }
860 #endif 859 #endif
861 return isolate->heap()->ToBoolean(true); 860 return isolate->heap()->ToBoolean(true);
862 } 861 }
863 862
864 } // namespace internal 863 } // namespace internal
865 } // namespace v8 864 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/test-api-interceptors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698