Commit 941afb69 authored by Michael Achenbach's avatar Michael Achenbach Committed by Commit Bot

[test] Deprecate v8-testing.h

The file contains testing features only used in d8. This CL prepares
deprecation and moves the logic into d8.cc.

Bug: v8:9941
Change-Id: I71de4cfd41d8f9fa209f936744cb170856365a6e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1899774Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Auto-Submit: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64800}
parent e309b2d9
......@@ -11,10 +11,9 @@
* Testing support for the V8 JavaScript engine.
*/
namespace v8 {
class V8_EXPORT Testing {
public:
enum StressType {
enum V8_DEPRECATED("Don't use this (d8-specific testing logic).") StressType {
kStressTypeOpt,
kStressTypeDeopt
};
......@@ -22,27 +21,30 @@ class V8_EXPORT Testing {
/**
* Set the type of stressing to do. The default if not set is kStressTypeOpt.
*/
V8_DEPRECATED("Don't use this (d8-specific testing logic).")
static void SetStressRunType(StressType type);
/**
* Get the number of runs of a given test that is required to get the full
* stress coverage.
*/
V8_DEPRECATED("Don't use this (d8-specific testing logic).")
static int GetStressRuns();
/**
* Indicate the number of the run which is about to start. The value of run
* should be between 0 and one less than the result from GetStressRuns()
*/
V8_DEPRECATED("Don't use this (d8-specific testing logic).")
static void PrepareStressRun(int run);
/**
* Force deoptimization of all functions.
*/
V8_DEPRECATED("Don't use this (d8-specific testing logic).")
static void DeoptimizeAll(Isolate* isolate);
};
} // namespace v8
#endif // V8_V8_TEST_H_
......@@ -10603,13 +10603,11 @@ void HeapProfiler::RemoveBuildEmbedderGraphCallback(
callback, data);
}
v8::Testing::StressType internal::Testing::stress_type_ =
v8::Testing::kStressTypeOpt;
// Deprecated.
void Testing::SetStressRunType(Testing::StressType type) {
internal::Testing::set_stress_type(type);
}
// Deprecated.
int Testing::GetStressRuns() {
if (internal::FLAG_stress_runs != 0) return internal::FLAG_stress_runs;
#ifdef DEBUG
......@@ -10621,6 +10619,7 @@ int Testing::GetStressRuns() {
#endif
}
// Deprecated.
void Testing::PrepareStressRun(int run) {
static const char* kLazyOptimizations =
"--prepare-always-opt "
......@@ -10636,6 +10635,7 @@ void Testing::PrepareStressRun(int run) {
}
}
// Deprecated.
void Testing::DeoptimizeAll(Isolate* isolate) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::HandleScope scope(i_isolate);
......
......@@ -558,17 +558,6 @@ void InvokeAccessorGetterCallback(
void InvokeFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info,
v8::FunctionCallback callback);
class Testing {
public:
static v8::Testing::StressType stress_type() { return stress_type_; }
static void set_stress_type(v8::Testing::StressType stress_type) {
stress_type_ = stress_type;
}
private:
static v8::Testing::StressType stress_type_;
};
} // namespace internal
} // namespace v8
......
......@@ -31,6 +31,7 @@
#include "src/d8/d8-platforms.h"
#include "src/d8/d8.h"
#include "src/debug/debug-interface.h"
#include "src/deoptimizer/deoptimizer.h"
#include "src/diagnostics/basic-block-profiler.h"
#include "src/execution/vm-state-inl.h"
#include "src/init/v8.h"
......@@ -3444,6 +3445,52 @@ class Deserializer : public ValueDeserializer::Delegate {
DISALLOW_COPY_AND_ASSIGN(Deserializer);
};
class D8Testing {
public:
/**
* Get the number of runs of a given test that is required to get the full
* stress coverage.
*/
static int GetStressRuns() {
if (internal::FLAG_stress_runs != 0) return internal::FLAG_stress_runs;
#ifdef DEBUG
// In debug mode the code runs much slower so stressing will only make two
// runs.
return 2;
#else
return 5;
#endif
}
/**
* Indicate the number of the run which is about to start. The value of run
* should be between 0 and one less than the result from GetStressRuns()
*/
static void PrepareStressRun(int run) {
static const char* kLazyOptimizations =
"--prepare-always-opt "
"--max-inlined-bytecode-size=999999 "
"--max-inlined-bytecode-size-cumulative=999999 "
"--noalways-opt";
static const char* kForcedOptimizations = "--always-opt";
if (run == GetStressRuns() - 1) {
V8::SetFlagsFromString(kForcedOptimizations);
} else {
V8::SetFlagsFromString(kLazyOptimizations);
}
}
/**
* Force deoptimization of all functions.
*/
static void DeoptimizeAll(Isolate* isolate) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::HandleScope scope(i_isolate);
i::Deoptimizer::DeoptimizeAll(i_isolate);
}
};
std::unique_ptr<SerializationData> Shell::SerializeValue(
Isolate* isolate, Local<Value> value, Local<Value> transfer) {
bool ok;
......@@ -3641,17 +3688,16 @@ int Shell::Main(int argc, char* argv[]) {
}
if (options.stress_opt) {
Testing::SetStressRunType(Testing::kStressTypeOpt);
options.stress_runs = Testing::GetStressRuns();
options.stress_runs = D8Testing::GetStressRuns();
for (int i = 0; i < options.stress_runs && result == 0; i++) {
printf("============ Stress %d/%d ============\n", i + 1,
options.stress_runs);
Testing::PrepareStressRun(i);
D8Testing::PrepareStressRun(i);
bool last_run = i == options.stress_runs - 1;
result = RunMain(isolate, argc, argv, last_run);
}
printf("======== Full Deoptimization =======\n");
Testing::DeoptimizeAll(isolate);
D8Testing::DeoptimizeAll(isolate);
} else if (i::FLAG_stress_runs > 0) {
options.stress_runs = i::FLAG_stress_runs;
for (int i = 0; i < options.stress_runs && result == 0; i++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment