Commit 5f652b84 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[flags] Receive length as size_t

This is one step towards removing the {StrLength} helper and using
{size_t} consistently instead.

R=mstarzinger@chromium.org

Bug: v8:8834
Change-Id: Ibcdfd579531a259d490c39a8e8c96d469a5a4aac
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1578901
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60974}
parent de93b808
......@@ -8636,7 +8636,11 @@ class V8_EXPORT V8 {
/**
* Sets V8 flags from a string.
*/
static void SetFlagsFromString(const char* str, int length);
static void SetFlagsFromString(const char* str);
static void SetFlagsFromString(const char* str, size_t length);
V8_DEPRECATE_SOON("use size_t version",
static void SetFlagsFromString(const char* str,
int length));
/**
* Sets V8 flags from the command line.
......
......@@ -891,11 +891,19 @@ void V8::SetDcheckErrorHandler(DcheckErrorCallback that) {
v8::base::SetDcheckFunction(that);
}
void V8::SetFlagsFromString(const char* str, int length) {
void V8::SetFlagsFromString(const char* str) {
SetFlagsFromString(str, strlen(str));
}
void V8::SetFlagsFromString(const char* str, size_t length) {
i::FlagList::SetFlagsFromString(str, length);
i::FlagList::EnforceFlagImplications();
}
void V8::SetFlagsFromString(const char* str, int length) {
CHECK_LE(0, length);
SetFlagsFromString(str, static_cast<size_t>(length));
}
void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags);
......@@ -10494,12 +10502,6 @@ int Testing::GetStressRuns() {
#endif
}
static void SetFlagsFromString(const char* flags) {
V8::SetFlagsFromString(flags, i::StrLength(flags));
}
void Testing::PrepareStressRun(int run) {
static const char* kLazyOptimizations =
"--prepare-always-opt "
......@@ -10513,22 +10515,22 @@ void Testing::PrepareStressRun(int run) {
static const char* kDeoptEvery13Times = "--deopt-every-n-times=13";
if (internal::Testing::stress_type() == Testing::kStressTypeDeopt &&
internal::FLAG_deopt_every_n_times == 0) {
SetFlagsFromString(kDeoptEvery13Times);
V8::SetFlagsFromString(kDeoptEvery13Times);
}
#ifdef DEBUG
// As stressing in debug mode only make two runs skip the deopt stressing
// here.
if (run == GetStressRuns() - 1) {
SetFlagsFromString(kForcedOptimizations);
V8::SetFlagsFromString(kForcedOptimizations);
} else {
SetFlagsFromString(kLazyOptimizations);
V8::SetFlagsFromString(kLazyOptimizations);
}
#else
if (run == GetStressRuns() - 1) {
SetFlagsFromString(kForcedOptimizations);
V8::SetFlagsFromString(kForcedOptimizations);
} else if (run != GetStressRuns() - 2) {
SetFlagsFromString(kLazyOptimizations);
V8::SetFlagsFromString(kLazyOptimizations);
}
#endif
}
......
......@@ -2794,12 +2794,6 @@ void Worker::PostMessageOut(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
}
void SetFlagsFromString(const char* flags) {
v8::V8::SetFlagsFromString(flags, static_cast<int>(strlen(flags)));
}
bool Shell::SetOptions(int argc, char* argv[]) {
bool logfile_per_isolate = false;
for (int i = 0; i < argc; i++) {
......@@ -2976,7 +2970,7 @@ bool Shell::SetOptions(int argc, char* argv[]) {
current->End(argc);
if (!logfile_per_isolate && options.num_isolates) {
SetFlagsFromString("--nologfile_per_isolate");
V8::SetFlagsFromString("--no-logfile-per-isolate");
}
return true;
......@@ -3414,10 +3408,10 @@ int Shell::Main(int argc, char* argv[]) {
}
if (i::FLAG_trace_turbo_cfg_file == nullptr) {
SetFlagsFromString("--trace-turbo-cfg-file=turbo.cfg");
V8::SetFlagsFromString("--trace-turbo-cfg-file=turbo.cfg");
}
if (i::FLAG_redirect_code_traces_to == nullptr) {
SetFlagsFromString("--redirect-code-traces-to=code.asm");
V8::SetFlagsFromString("--redirect-code-traces-to=code.asm");
}
v8::V8::InitializePlatform(g_platform.get());
v8::V8::Initialize();
......
......@@ -526,14 +526,14 @@ static char* SkipBlackSpace(char* p) {
// static
int FlagList::SetFlagsFromString(const char* str, int len) {
int FlagList::SetFlagsFromString(const char* str, size_t len) {
// make a 0-terminated copy of str
ScopedVector<char> copy0(len + 1);
MemCopy(copy0.start(), str, len);
std::unique_ptr<char[]> copy0{NewArray<char>(len + 1)};
MemCopy(copy0.get(), str, len);
copy0[len] = '\0';
// strip leading white space
char* copy = SkipWhiteSpace(copy0.start());
char* copy = SkipWhiteSpace(copy0.get());
// count the number of 'arguments'
int argc = 1; // be compatible with SetFlagsFromCommandLine()
......@@ -557,7 +557,6 @@ int FlagList::SetFlagsFromString(const char* str, int len) {
return SetFlagsFromCommandLine(&argc, argv.start(), false);
}
// static
void FlagList::ResetAllFlags() {
for (size_t i = 0; i < num_flags; ++i) {
......
......@@ -51,7 +51,7 @@ class V8_EXPORT_PRIVATE FlagList {
// Set the flag values by parsing the string str. Splits string into argc
// substrings argv[], each of which consisting of non-white-space chars,
// and then calls SetFlagsFromCommandLine() and returns its result.
static int SetFlagsFromString(const char* str, int len);
static int SetFlagsFromString(const char* str, size_t len);
// Reset all flags to their default value.
static void ResetAllFlags();
......
......@@ -257,8 +257,7 @@ void VTUNEJITInterface::event_handler(const v8::JitCodeEvent* event) {
} // namespace internal
v8::JitCodeEventHandler GetVtuneCodeEventHandler() {
v8::V8::SetFlagsFromString("--nocompact_code_space",
(int)strlen("--nocompact_code_space"));
v8::V8::SetFlagsFromString("--no-compact-code-space");
return vTune::internal::VTUNEJITInterface::event_handler;
}
......
......@@ -5144,7 +5144,7 @@ TEST(MessageObjectLeak) {
CompileRun(test);
const char* flag = "--turbo-filter=*";
FlagList::SetFlagsFromString(flag, StrLength(flag));
FlagList::SetFlagsFromString(flag, strlen(flag));
FLAG_always_opt = true;
CompileRun(test);
......
......@@ -80,7 +80,7 @@ TEST(Flags2b) {
"-notesting-maybe-bool-flag "
"-testing_float_flag=.25 "
"--testing_string_flag no_way! ";
CHECK_EQ(0, FlagList::SetFlagsFromString(str, StrLength(str)));
CHECK_EQ(0, FlagList::SetFlagsFromString(str, strlen(str)));
CHECK(!FLAG_testing_bool_flag);
CHECK(FLAG_testing_maybe_bool_flag.has_value);
CHECK(!FLAG_testing_maybe_bool_flag.value);
......@@ -117,7 +117,7 @@ TEST(Flags3b) {
"--testing_int_flag -666 "
"--testing_float_flag -12E10 "
"-testing-string-flag=foo-bar";
CHECK_EQ(0, FlagList::SetFlagsFromString(str, StrLength(str)));
CHECK_EQ(0, FlagList::SetFlagsFromString(str, strlen(str)));
CHECK(FLAG_testing_bool_flag);
CHECK(FLAG_testing_maybe_bool_flag.has_value);
CHECK(FLAG_testing_maybe_bool_flag.value);
......@@ -142,7 +142,7 @@ TEST(Flags4) {
TEST(Flags4b) {
SetFlagsToDefault();
const char* str = "--testing_bool_flag --foo";
CHECK_EQ(2, FlagList::SetFlagsFromString(str, StrLength(str)));
CHECK_EQ(2, FlagList::SetFlagsFromString(str, strlen(str)));
CHECK(!FLAG_testing_maybe_bool_flag.has_value);
}
......@@ -161,7 +161,7 @@ TEST(Flags5) {
TEST(Flags5b) {
SetFlagsToDefault();
const char* str = " --testing_int_flag=\"foobar\"";
CHECK_EQ(1, FlagList::SetFlagsFromString(str, StrLength(str)));
CHECK_EQ(1, FlagList::SetFlagsFromString(str, strlen(str)));
}
......@@ -180,7 +180,7 @@ TEST(Flags6) {
TEST(Flags6b) {
SetFlagsToDefault();
const char* str = " --testing-int-flag 0 --testing_float_flag ";
CHECK_EQ(3, FlagList::SetFlagsFromString(str, StrLength(str)));
CHECK_EQ(3, FlagList::SetFlagsFromString(str, strlen(str)));
}
TEST(FlagsRemoveIncomplete) {
......
......@@ -1843,7 +1843,7 @@ TEST(CodeSerializerLargeCodeObjectWithIncrementalMarking) {
ManualGCScope manual_gc_scope;
FLAG_always_opt = false;
const char* filter_flag = "--turbo-filter=NOTHING";
FlagList::SetFlagsFromString(filter_flag, StrLength(filter_flag));
FlagList::SetFlagsFromString(filter_flag, strlen(filter_flag));
FLAG_manual_evacuation_candidates_selection = true;
LocalContext context;
......
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