diff options
Diffstat (limited to 'Source/JavaScriptCore/runtime/TestRunnerUtils.cpp')
-rw-r--r-- | Source/JavaScriptCore/runtime/TestRunnerUtils.cpp | 106 |
1 files changed, 89 insertions, 17 deletions
diff --git a/Source/JavaScriptCore/runtime/TestRunnerUtils.cpp b/Source/JavaScriptCore/runtime/TestRunnerUtils.cpp index 337c00e6e..8b85f8e35 100644 --- a/Source/JavaScriptCore/runtime/TestRunnerUtils.cpp +++ b/Source/JavaScriptCore/runtime/TestRunnerUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013-2017 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,21 +27,41 @@ #include "TestRunnerUtils.h" #include "CodeBlock.h" -#include "Operations.h" +#include "FunctionCodeBlock.h" +#include "JSCInlines.h" +#include "LLIntData.h" namespace JSC { -static FunctionExecutable* getExecutable(JSValue theFunctionValue) +FunctionExecutable* getExecutableForFunction(JSValue theFunctionValue) { - JSFunction* theFunction = jsDynamicCast<JSFunction*>(theFunctionValue); + if (!theFunctionValue.isCell()) + return nullptr; + + VM& vm = *theFunctionValue.asCell()->vm(); + JSFunction* theFunction = jsDynamicCast<JSFunction*>(vm, theFunctionValue); if (!theFunction) - return 0; + return nullptr; - FunctionExecutable* executable = jsDynamicCast<FunctionExecutable*>( + FunctionExecutable* executable = jsDynamicCast<FunctionExecutable*>(vm, theFunction->executable()); return executable; } +CodeBlock* getSomeBaselineCodeBlockForFunction(JSValue theFunctionValue) +{ + FunctionExecutable* executable = getExecutableForFunction(theFunctionValue); + if (!executable) + return 0; + + CodeBlock* baselineCodeBlock = executable->baselineCodeBlockFor(CodeForCall); + + if (!baselineCodeBlock) + baselineCodeBlock = executable->baselineCodeBlockFor(CodeForConstruct); + + return baselineCodeBlock; +} + JSValue numberOfDFGCompiles(JSValue theFunctionValue) { bool pretendToHaveManyCompiles = false; @@ -51,32 +71,51 @@ JSValue numberOfDFGCompiles(JSValue theFunctionValue) #else pretendToHaveManyCompiles = true; #endif - - if (FunctionExecutable* executable = getExecutable(theFunctionValue)) { - CodeBlock* baselineCodeBlock = executable->baselineCodeBlockFor(CodeForCall); - - if (!baselineCodeBlock) - baselineCodeBlock = executable->baselineCodeBlockFor(CodeForConstruct); - - if (!baselineCodeBlock) - return jsNumber(0); + if (CodeBlock* baselineCodeBlock = getSomeBaselineCodeBlockForFunction(theFunctionValue)) { if (pretendToHaveManyCompiles) return jsNumber(1000000.0); return jsNumber(baselineCodeBlock->numberOfDFGCompiles()); } - return jsUndefined(); + return jsNumber(0); } JSValue setNeverInline(JSValue theFunctionValue) { - if (FunctionExecutable* executable = getExecutable(theFunctionValue)) + if (FunctionExecutable* executable = getExecutableForFunction(theFunctionValue)) executable->setNeverInline(true); return jsUndefined(); } +JSValue setNeverOptimize(JSValue theFunctionValue) +{ + if (FunctionExecutable* executable = getExecutableForFunction(theFunctionValue)) + executable->setNeverOptimize(true); + + return jsUndefined(); +} + +JSValue optimizeNextInvocation(JSValue theFunctionValue) +{ +#if ENABLE(JIT) + if (CodeBlock* baselineCodeBlock = getSomeBaselineCodeBlockForFunction(theFunctionValue)) + baselineCodeBlock->optimizeNextInvocation(); +#else + UNUSED_PARAM(theFunctionValue); +#endif + + return jsUndefined(); +} + +JSValue failNextNewCodeBlock(ExecState* exec) +{ + exec->vm().setFailNextNewCodeBlock(); + + return jsUndefined(); +} + JSValue numberOfDFGCompiles(ExecState* exec) { if (exec->argumentCount() < 1) @@ -91,5 +130,38 @@ JSValue setNeverInline(ExecState* exec) return setNeverInline(exec->uncheckedArgument(0)); } +JSValue setNeverOptimize(ExecState* exec) +{ + if (exec->argumentCount() < 1) + return jsUndefined(); + return setNeverOptimize(exec->uncheckedArgument(0)); +} + +JSValue setCannotUseOSRExitFuzzing(ExecState* exec) +{ + if (exec->argumentCount() < 1) + return jsUndefined(); + + JSValue theFunctionValue = exec->uncheckedArgument(0); + if (FunctionExecutable* executable = getExecutableForFunction(theFunctionValue)) + executable->setCanUseOSRExitFuzzing(false); + + return jsUndefined(); +} + +JSValue optimizeNextInvocation(ExecState* exec) +{ + if (exec->argumentCount() < 1) + return jsUndefined(); + return optimizeNextInvocation(exec->uncheckedArgument(0)); +} + +// This is a hook called at the bitter end of some of our tests. +void finalizeStatsAtEndOfTesting() +{ + if (Options::reportLLIntStats()) + LLInt::Data::finalizeStats(); +} + } // namespace JSC |