[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: Michael Starzinger <mstarzinger@chromium.org> Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Cr-Commit-Position: refs/heads/master@{#60974}
This commit is contained in:
parent
de93b80815
commit
5f652b84c0
@ -8636,7 +8636,11 @@ class V8_EXPORT V8 {
|
|||||||
/**
|
/**
|
||||||
* Sets V8 flags from a string.
|
* 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.
|
* Sets V8 flags from the command line.
|
||||||
|
26
src/api.cc
26
src/api.cc
@ -891,11 +891,19 @@ void V8::SetDcheckErrorHandler(DcheckErrorCallback that) {
|
|||||||
v8::base::SetDcheckFunction(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::SetFlagsFromString(str, length);
|
||||||
i::FlagList::EnforceFlagImplications();
|
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) {
|
void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
|
||||||
i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags);
|
i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags);
|
||||||
@ -10494,12 +10502,6 @@ int Testing::GetStressRuns() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void SetFlagsFromString(const char* flags) {
|
|
||||||
V8::SetFlagsFromString(flags, i::StrLength(flags));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Testing::PrepareStressRun(int run) {
|
void Testing::PrepareStressRun(int run) {
|
||||||
static const char* kLazyOptimizations =
|
static const char* kLazyOptimizations =
|
||||||
"--prepare-always-opt "
|
"--prepare-always-opt "
|
||||||
@ -10513,22 +10515,22 @@ void Testing::PrepareStressRun(int run) {
|
|||||||
static const char* kDeoptEvery13Times = "--deopt-every-n-times=13";
|
static const char* kDeoptEvery13Times = "--deopt-every-n-times=13";
|
||||||
if (internal::Testing::stress_type() == Testing::kStressTypeDeopt &&
|
if (internal::Testing::stress_type() == Testing::kStressTypeDeopt &&
|
||||||
internal::FLAG_deopt_every_n_times == 0) {
|
internal::FLAG_deopt_every_n_times == 0) {
|
||||||
SetFlagsFromString(kDeoptEvery13Times);
|
V8::SetFlagsFromString(kDeoptEvery13Times);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// As stressing in debug mode only make two runs skip the deopt stressing
|
// As stressing in debug mode only make two runs skip the deopt stressing
|
||||||
// here.
|
// here.
|
||||||
if (run == GetStressRuns() - 1) {
|
if (run == GetStressRuns() - 1) {
|
||||||
SetFlagsFromString(kForcedOptimizations);
|
V8::SetFlagsFromString(kForcedOptimizations);
|
||||||
} else {
|
} else {
|
||||||
SetFlagsFromString(kLazyOptimizations);
|
V8::SetFlagsFromString(kLazyOptimizations);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (run == GetStressRuns() - 1) {
|
if (run == GetStressRuns() - 1) {
|
||||||
SetFlagsFromString(kForcedOptimizations);
|
V8::SetFlagsFromString(kForcedOptimizations);
|
||||||
} else if (run != GetStressRuns() - 2) {
|
} else if (run != GetStressRuns() - 2) {
|
||||||
SetFlagsFromString(kLazyOptimizations);
|
V8::SetFlagsFromString(kLazyOptimizations);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
12
src/d8.cc
12
src/d8.cc
@ -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 Shell::SetOptions(int argc, char* argv[]) {
|
||||||
bool logfile_per_isolate = false;
|
bool logfile_per_isolate = false;
|
||||||
for (int i = 0; i < argc; i++) {
|
for (int i = 0; i < argc; i++) {
|
||||||
@ -2976,7 +2970,7 @@ bool Shell::SetOptions(int argc, char* argv[]) {
|
|||||||
current->End(argc);
|
current->End(argc);
|
||||||
|
|
||||||
if (!logfile_per_isolate && options.num_isolates) {
|
if (!logfile_per_isolate && options.num_isolates) {
|
||||||
SetFlagsFromString("--nologfile_per_isolate");
|
V8::SetFlagsFromString("--no-logfile-per-isolate");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -3414,10 +3408,10 @@ int Shell::Main(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (i::FLAG_trace_turbo_cfg_file == nullptr) {
|
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) {
|
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::InitializePlatform(g_platform.get());
|
||||||
v8::V8::Initialize();
|
v8::V8::Initialize();
|
||||||
|
@ -526,14 +526,14 @@ static char* SkipBlackSpace(char* p) {
|
|||||||
|
|
||||||
|
|
||||||
// static
|
// 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
|
// make a 0-terminated copy of str
|
||||||
ScopedVector<char> copy0(len + 1);
|
std::unique_ptr<char[]> copy0{NewArray<char>(len + 1)};
|
||||||
MemCopy(copy0.start(), str, len);
|
MemCopy(copy0.get(), str, len);
|
||||||
copy0[len] = '\0';
|
copy0[len] = '\0';
|
||||||
|
|
||||||
// strip leading white space
|
// strip leading white space
|
||||||
char* copy = SkipWhiteSpace(copy0.start());
|
char* copy = SkipWhiteSpace(copy0.get());
|
||||||
|
|
||||||
// count the number of 'arguments'
|
// count the number of 'arguments'
|
||||||
int argc = 1; // be compatible with SetFlagsFromCommandLine()
|
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);
|
return SetFlagsFromCommandLine(&argc, argv.start(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void FlagList::ResetAllFlags() {
|
void FlagList::ResetAllFlags() {
|
||||||
for (size_t i = 0; i < num_flags; ++i) {
|
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
|
// Set the flag values by parsing the string str. Splits string into argc
|
||||||
// substrings argv[], each of which consisting of non-white-space chars,
|
// substrings argv[], each of which consisting of non-white-space chars,
|
||||||
// and then calls SetFlagsFromCommandLine() and returns its result.
|
// 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.
|
// Reset all flags to their default value.
|
||||||
static void ResetAllFlags();
|
static void ResetAllFlags();
|
||||||
|
3
src/third_party/vtune/vtune-jit.cc
vendored
3
src/third_party/vtune/vtune-jit.cc
vendored
@ -257,8 +257,7 @@ void VTUNEJITInterface::event_handler(const v8::JitCodeEvent* event) {
|
|||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
v8::JitCodeEventHandler GetVtuneCodeEventHandler() {
|
v8::JitCodeEventHandler GetVtuneCodeEventHandler() {
|
||||||
v8::V8::SetFlagsFromString("--nocompact_code_space",
|
v8::V8::SetFlagsFromString("--no-compact-code-space");
|
||||||
(int)strlen("--nocompact_code_space"));
|
|
||||||
return vTune::internal::VTUNEJITInterface::event_handler;
|
return vTune::internal::VTUNEJITInterface::event_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5144,7 +5144,7 @@ TEST(MessageObjectLeak) {
|
|||||||
CompileRun(test);
|
CompileRun(test);
|
||||||
|
|
||||||
const char* flag = "--turbo-filter=*";
|
const char* flag = "--turbo-filter=*";
|
||||||
FlagList::SetFlagsFromString(flag, StrLength(flag));
|
FlagList::SetFlagsFromString(flag, strlen(flag));
|
||||||
FLAG_always_opt = true;
|
FLAG_always_opt = true;
|
||||||
|
|
||||||
CompileRun(test);
|
CompileRun(test);
|
||||||
|
@ -80,7 +80,7 @@ TEST(Flags2b) {
|
|||||||
"-notesting-maybe-bool-flag "
|
"-notesting-maybe-bool-flag "
|
||||||
"-testing_float_flag=.25 "
|
"-testing_float_flag=.25 "
|
||||||
"--testing_string_flag no_way! ";
|
"--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_bool_flag);
|
||||||
CHECK(FLAG_testing_maybe_bool_flag.has_value);
|
CHECK(FLAG_testing_maybe_bool_flag.has_value);
|
||||||
CHECK(!FLAG_testing_maybe_bool_flag.value);
|
CHECK(!FLAG_testing_maybe_bool_flag.value);
|
||||||
@ -117,7 +117,7 @@ TEST(Flags3b) {
|
|||||||
"--testing_int_flag -666 "
|
"--testing_int_flag -666 "
|
||||||
"--testing_float_flag -12E10 "
|
"--testing_float_flag -12E10 "
|
||||||
"-testing-string-flag=foo-bar";
|
"-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_bool_flag);
|
||||||
CHECK(FLAG_testing_maybe_bool_flag.has_value);
|
CHECK(FLAG_testing_maybe_bool_flag.has_value);
|
||||||
CHECK(FLAG_testing_maybe_bool_flag.value);
|
CHECK(FLAG_testing_maybe_bool_flag.value);
|
||||||
@ -142,7 +142,7 @@ TEST(Flags4) {
|
|||||||
TEST(Flags4b) {
|
TEST(Flags4b) {
|
||||||
SetFlagsToDefault();
|
SetFlagsToDefault();
|
||||||
const char* str = "--testing_bool_flag --foo";
|
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);
|
CHECK(!FLAG_testing_maybe_bool_flag.has_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ TEST(Flags5) {
|
|||||||
TEST(Flags5b) {
|
TEST(Flags5b) {
|
||||||
SetFlagsToDefault();
|
SetFlagsToDefault();
|
||||||
const char* str = " --testing_int_flag=\"foobar\"";
|
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) {
|
TEST(Flags6b) {
|
||||||
SetFlagsToDefault();
|
SetFlagsToDefault();
|
||||||
const char* str = " --testing-int-flag 0 --testing_float_flag ";
|
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) {
|
TEST(FlagsRemoveIncomplete) {
|
||||||
|
@ -1843,7 +1843,7 @@ TEST(CodeSerializerLargeCodeObjectWithIncrementalMarking) {
|
|||||||
ManualGCScope manual_gc_scope;
|
ManualGCScope manual_gc_scope;
|
||||||
FLAG_always_opt = false;
|
FLAG_always_opt = false;
|
||||||
const char* filter_flag = "--turbo-filter=NOTHING";
|
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;
|
FLAG_manual_evacuation_candidates_selection = true;
|
||||||
|
|
||||||
LocalContext context;
|
LocalContext context;
|
||||||
|
Loading…
Reference in New Issue
Block a user