summaryrefslogtreecommitdiff
path: root/deps/v8/src/flags.cc
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2018-03-07 08:54:53 +0100
committerMichaël Zasso <targos@protonmail.com>2018-03-07 16:48:52 +0100
commit88786fecff336342a56e6f2e7ff3b286be716e47 (patch)
tree92e6ba5b8ac8dae1a058988d20c9d27bfa654390 /deps/v8/src/flags.cc
parent4e86f9b5ab83cbabf43839385bf383e6a7ef7d19 (diff)
downloadnode-new-88786fecff336342a56e6f2e7ff3b286be716e47.tar.gz
deps: update V8 to 6.5.254.31
PR-URL: https://github.com/nodejs/node/pull/18453 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yang Guo <yangguo@chromium.org> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'deps/v8/src/flags.cc')
-rw-r--r--deps/v8/src/flags.cc78
1 files changed, 22 insertions, 56 deletions
diff --git a/deps/v8/src/flags.cc b/deps/v8/src/flags.cc
index a51a4e7d71..693e514e94 100644
--- a/deps/v8/src/flags.cc
+++ b/deps/v8/src/flags.cc
@@ -5,7 +5,6 @@
#include "src/flags.h"
#include <cctype>
-#include <cerrno>
#include <cstdlib>
#include <sstream>
@@ -40,7 +39,6 @@ struct Flag {
TYPE_INT,
TYPE_UINT,
TYPE_FLOAT,
- TYPE_SIZE_T,
TYPE_STRING,
TYPE_ARGS
};
@@ -83,11 +81,6 @@ struct Flag {
return reinterpret_cast<double*>(valptr_);
}
- size_t* size_t_variable() const {
- DCHECK(type_ == TYPE_SIZE_T);
- return reinterpret_cast<size_t*>(valptr_);
- }
-
const char* string_value() const {
DCHECK(type_ == TYPE_STRING);
return *reinterpret_cast<const char**>(valptr_);
@@ -126,11 +119,6 @@ struct Flag {
return *reinterpret_cast<const double*>(defptr_);
}
- size_t size_t_default() const {
- DCHECK(type_ == TYPE_SIZE_T);
- return *reinterpret_cast<const size_t*>(defptr_);
- }
-
const char* string_default() const {
DCHECK(type_ == TYPE_STRING);
return *reinterpret_cast<const char* const *>(defptr_);
@@ -154,8 +142,6 @@ struct Flag {
return *uint_variable() == uint_default();
case TYPE_FLOAT:
return *float_variable() == float_default();
- case TYPE_SIZE_T:
- return *size_t_variable() == size_t_default();
case TYPE_STRING: {
const char* str1 = string_value();
const char* str2 = string_default();
@@ -187,9 +173,6 @@ struct Flag {
case TYPE_FLOAT:
*float_variable() = float_default();
break;
- case TYPE_SIZE_T:
- *size_t_variable() = size_t_default();
- break;
case TYPE_STRING:
set_string_value(string_default(), false);
break;
@@ -218,8 +201,6 @@ static const char* Type2String(Flag::FlagType type) {
case Flag::TYPE_UINT:
return "uint";
case Flag::TYPE_FLOAT: return "float";
- case Flag::TYPE_SIZE_T:
- return "size_t";
case Flag::TYPE_STRING: return "string";
case Flag::TYPE_ARGS: return "arguments";
}
@@ -246,9 +227,6 @@ std::ostream& operator<<(std::ostream& os, const Flag& flag) { // NOLINT
case Flag::TYPE_FLOAT:
os << *flag.float_variable();
break;
- case Flag::TYPE_SIZE_T:
- os << *flag.size_t_variable();
- break;
case Flag::TYPE_STRING: {
const char* str = flag.string_value();
os << (str ? str : "nullptr");
@@ -380,27 +358,6 @@ static Flag* FindFlag(const char* name) {
return nullptr;
}
-template <typename T>
-bool TryParseUnsigned(Flag* flag, const char* arg, const char* value,
- char** endp, T* out_val) {
- // We do not use strtoul because it accepts negative numbers.
- // Rejects values >= 2**63 when T is 64 bits wide but that
- // seems like an acceptable trade-off.
- uint64_t max = static_cast<uint64_t>(std::numeric_limits<T>::max());
- errno = 0;
- int64_t val = static_cast<int64_t>(strtoll(value, endp, 10));
- if (val < 0 || static_cast<uint64_t>(val) > max || errno != 0) {
- PrintF(stderr,
- "Error: Value for flag %s of type %s is out of bounds "
- "[0-%" PRIu64
- "]\n"
- "Try --help for options\n",
- arg, Type2String(flag->type()), max);
- return false;
- }
- *out_val = static_cast<T>(val);
- return true;
-}
// static
int FlagList::SetFlagsFromCommandLine(int* argc,
@@ -465,21 +422,27 @@ int FlagList::SetFlagsFromCommandLine(int* argc,
case Flag::TYPE_INT:
*flag->int_variable() = static_cast<int>(strtol(value, &endp, 10));
break;
- case Flag::TYPE_UINT:
- if (!TryParseUnsigned(flag, arg, value, &endp,
- flag->uint_variable())) {
+ case Flag::TYPE_UINT: {
+ // We do not use strtoul because it accepts negative numbers.
+ int64_t val = static_cast<int64_t>(strtoll(value, &endp, 10));
+ if (val < 0 || val > std::numeric_limits<unsigned int>::max()) {
+ PrintF(stderr,
+ "Error: Value for flag %s of type %s is out of bounds "
+ "[0-%" PRIu64
+ "]\n"
+ "Try --help for options\n",
+ arg, Type2String(flag->type()),
+ static_cast<uint64_t>(
+ std::numeric_limits<unsigned int>::max()));
return_code = j;
+ break;
}
+ *flag->uint_variable() = static_cast<unsigned int>(val);
break;
+ }
case Flag::TYPE_FLOAT:
*flag->float_variable() = strtod(value, &endp);
break;
- case Flag::TYPE_SIZE_T:
- if (!TryParseUnsigned(flag, arg, value, &endp,
- flag->size_t_variable())) {
- return_code = j;
- }
- break;
case Flag::TYPE_STRING:
flag->set_string_value(value ? StrDup(value) : nullptr, true);
break;
@@ -619,10 +582,13 @@ void FlagList::PrintHelp() {
" run the new debugging shell\n\n"
"Options:\n";
- for (size_t i = 0; i < num_flags; ++i) {
- Flag* f = &flags[i];
- os << " --" << f->name() << " (" << f->comment() << ")\n"
- << " type: " << Type2String(f->type()) << " default: " << *f
+ for (const Flag& f : flags) {
+ os << " --";
+ for (const char* c = f.name(); *c != '\0'; ++c) {
+ os << NormalizeChar(*c);
+ }
+ os << " (" << f.comment() << ")\n"
+ << " type: " << Type2String(f.type()) << " default: " << f
<< "\n";
}
}