Fix --max_old_space_size=4096 integer overflow.
R=yangguo@chromium.org Review URL: https://codereview.chromium.org/890563003 Cr-Commit-Position: refs/heads/master@{#26371}
This commit is contained in:
parent
bbde91bfc3
commit
6253aa8908
@ -151,6 +151,7 @@ struct MaybeBoolFlag {
|
|||||||
#define DEFINE_MAYBE_BOOL(nam, cmt) \
|
#define DEFINE_MAYBE_BOOL(nam, cmt) \
|
||||||
FLAG(MAYBE_BOOL, MaybeBoolFlag, nam, {false COMMA false}, cmt)
|
FLAG(MAYBE_BOOL, MaybeBoolFlag, nam, {false COMMA false}, cmt)
|
||||||
#define DEFINE_INT(nam, def, cmt) FLAG(INT, int, nam, def, cmt)
|
#define DEFINE_INT(nam, def, cmt) FLAG(INT, int, nam, def, cmt)
|
||||||
|
#define DEFINE_INTPTR(nam, def, cmt) FLAG(INTPTR, intptr_t, nam, def, cmt)
|
||||||
#define DEFINE_FLOAT(nam, def, cmt) FLAG(FLOAT, double, nam, def, cmt)
|
#define DEFINE_FLOAT(nam, def, cmt) FLAG(FLOAT, double, nam, def, cmt)
|
||||||
#define DEFINE_STRING(nam, def, cmt) FLAG(STRING, const char*, nam, def, cmt)
|
#define DEFINE_STRING(nam, def, cmt) FLAG(STRING, const char*, nam, def, cmt)
|
||||||
#define DEFINE_ARGS(nam, cmt) FLAG(ARGS, JSArguments, nam, {0 COMMA NULL}, cmt)
|
#define DEFINE_ARGS(nam, cmt) FLAG(ARGS, JSArguments, nam, {0 COMMA NULL}, cmt)
|
||||||
@ -542,7 +543,7 @@ DEFINE_BOOL(enable_liveedit, true, "enable liveedit experimental feature")
|
|||||||
DEFINE_BOOL(hard_abort, true, "abort by crashing")
|
DEFINE_BOOL(hard_abort, true, "abort by crashing")
|
||||||
|
|
||||||
// execution.cc
|
// execution.cc
|
||||||
DEFINE_INT(stack_size, V8_DEFAULT_STACK_SIZE_KB,
|
DEFINE_INTPTR(stack_size, V8_DEFAULT_STACK_SIZE_KB,
|
||||||
"default size of stack region v8 is allowed to use (in kBytes)")
|
"default size of stack region v8 is allowed to use (in kBytes)")
|
||||||
|
|
||||||
// frames.cc
|
// frames.cc
|
||||||
@ -554,21 +555,22 @@ DEFINE_BOOL(always_inline_smi_code, false,
|
|||||||
"always inline smi code in non-opt code")
|
"always inline smi code in non-opt code")
|
||||||
|
|
||||||
// heap.cc
|
// heap.cc
|
||||||
DEFINE_INT(min_semi_space_size, 0,
|
DEFINE_INTPTR(min_semi_space_size, 0,
|
||||||
"min size of a semi-space (in MBytes), the new space consists of two"
|
"min size of a semi-space (in MBytes), the new space consists "
|
||||||
"semi-spaces")
|
"of two semi-spaces")
|
||||||
DEFINE_INT(target_semi_space_size, 0,
|
DEFINE_INTPTR(target_semi_space_size, 0,
|
||||||
"target size of a semi-space (in MBytes) before triggering a GC")
|
"target size of a semi-space (in MBytes) before triggering a GC")
|
||||||
DEFINE_INT(max_semi_space_size, 0,
|
DEFINE_INTPTR(max_semi_space_size, 0,
|
||||||
"max size of a semi-space (in MBytes), the new space consists of two"
|
"max size of a semi-space (in MBytes), the new space consists "
|
||||||
"semi-spaces")
|
"of two semi-spaces")
|
||||||
DEFINE_INT(semi_space_growth_factor, 2, "factor by which to grow the new space")
|
DEFINE_INT(semi_space_growth_factor, 2, "factor by which to grow the new space")
|
||||||
DEFINE_BOOL(experimental_new_space_growth_heuristic, false,
|
DEFINE_BOOL(experimental_new_space_growth_heuristic, false,
|
||||||
"Grow the new space based on the percentage of survivors instead "
|
"Grow the new space based on the percentage of survivors instead "
|
||||||
"of their absolute value.")
|
"of their absolute value.")
|
||||||
DEFINE_INT(max_old_space_size, 0, "max size of the old space (in Mbytes)")
|
DEFINE_INTPTR(max_old_space_size, 0, "max size of the old space (in Mbytes)")
|
||||||
DEFINE_INT(initial_old_space_size, 0, "initial old space size (in Mbytes)")
|
DEFINE_INTPTR(initial_old_space_size, 0, "initial old space size (in Mbytes)")
|
||||||
DEFINE_INT(max_executable_size, 0, "max size of executable memory (in Mbytes)")
|
DEFINE_INTPTR(max_executable_size, 0,
|
||||||
|
"max size of executable memory (in Mbytes)")
|
||||||
DEFINE_BOOL(gc_global, false, "always perform global GCs")
|
DEFINE_BOOL(gc_global, false, "always perform global GCs")
|
||||||
DEFINE_INT(gc_interval, -1, "garbage collect after <n> allocations")
|
DEFINE_INT(gc_interval, -1, "garbage collect after <n> allocations")
|
||||||
DEFINE_BOOL(trace_gc, false,
|
DEFINE_BOOL(trace_gc, false,
|
||||||
|
28
src/flags.cc
28
src/flags.cc
@ -30,8 +30,8 @@ namespace {
|
|||||||
// to the actual flag, default value, comment, etc. This is designed to be POD
|
// to the actual flag, default value, comment, etc. This is designed to be POD
|
||||||
// initialized as to avoid requiring static constructors.
|
// initialized as to avoid requiring static constructors.
|
||||||
struct Flag {
|
struct Flag {
|
||||||
enum FlagType { TYPE_BOOL, TYPE_MAYBE_BOOL, TYPE_INT, TYPE_FLOAT,
|
enum FlagType { TYPE_BOOL, TYPE_MAYBE_BOOL, TYPE_INT, TYPE_INTPTR,
|
||||||
TYPE_STRING, TYPE_ARGS };
|
TYPE_FLOAT, TYPE_STRING, TYPE_ARGS };
|
||||||
|
|
||||||
FlagType type_; // What type of flag, bool, int, or string.
|
FlagType type_; // What type of flag, bool, int, or string.
|
||||||
const char* name_; // Name of the flag, ex "my_flag".
|
const char* name_; // Name of the flag, ex "my_flag".
|
||||||
@ -61,6 +61,11 @@ struct Flag {
|
|||||||
return reinterpret_cast<int*>(valptr_);
|
return reinterpret_cast<int*>(valptr_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
intptr_t* intptr_variable() const {
|
||||||
|
DCHECK(type_ == TYPE_INTPTR);
|
||||||
|
return reinterpret_cast<intptr_t*>(valptr_);
|
||||||
|
}
|
||||||
|
|
||||||
double* float_variable() const {
|
double* float_variable() const {
|
||||||
DCHECK(type_ == TYPE_FLOAT);
|
DCHECK(type_ == TYPE_FLOAT);
|
||||||
return reinterpret_cast<double*>(valptr_);
|
return reinterpret_cast<double*>(valptr_);
|
||||||
@ -94,6 +99,11 @@ struct Flag {
|
|||||||
return *reinterpret_cast<const int*>(defptr_);
|
return *reinterpret_cast<const int*>(defptr_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int intptr_default() const {
|
||||||
|
DCHECK(type_ == TYPE_INTPTR);
|
||||||
|
return *reinterpret_cast<const intptr_t*>(defptr_);
|
||||||
|
}
|
||||||
|
|
||||||
double float_default() const {
|
double float_default() const {
|
||||||
DCHECK(type_ == TYPE_FLOAT);
|
DCHECK(type_ == TYPE_FLOAT);
|
||||||
return *reinterpret_cast<const double*>(defptr_);
|
return *reinterpret_cast<const double*>(defptr_);
|
||||||
@ -118,6 +128,8 @@ struct Flag {
|
|||||||
return maybe_bool_variable()->has_value == false;
|
return maybe_bool_variable()->has_value == false;
|
||||||
case TYPE_INT:
|
case TYPE_INT:
|
||||||
return *int_variable() == int_default();
|
return *int_variable() == int_default();
|
||||||
|
case TYPE_INTPTR:
|
||||||
|
return *intptr_variable() == intptr_default();
|
||||||
case TYPE_FLOAT:
|
case TYPE_FLOAT:
|
||||||
return *float_variable() == float_default();
|
return *float_variable() == float_default();
|
||||||
case TYPE_STRING: {
|
case TYPE_STRING: {
|
||||||
@ -146,6 +158,9 @@ struct Flag {
|
|||||||
case TYPE_INT:
|
case TYPE_INT:
|
||||||
*int_variable() = int_default();
|
*int_variable() = int_default();
|
||||||
break;
|
break;
|
||||||
|
case TYPE_INTPTR:
|
||||||
|
*intptr_variable() = intptr_default();
|
||||||
|
break;
|
||||||
case TYPE_FLOAT:
|
case TYPE_FLOAT:
|
||||||
*float_variable() = float_default();
|
*float_variable() = float_default();
|
||||||
break;
|
break;
|
||||||
@ -174,6 +189,7 @@ static const char* Type2String(Flag::FlagType type) {
|
|||||||
case Flag::TYPE_BOOL: return "bool";
|
case Flag::TYPE_BOOL: return "bool";
|
||||||
case Flag::TYPE_MAYBE_BOOL: return "maybe_bool";
|
case Flag::TYPE_MAYBE_BOOL: return "maybe_bool";
|
||||||
case Flag::TYPE_INT: return "int";
|
case Flag::TYPE_INT: return "int";
|
||||||
|
case Flag::TYPE_INTPTR: return "intptr_t";
|
||||||
case Flag::TYPE_FLOAT: return "float";
|
case Flag::TYPE_FLOAT: return "float";
|
||||||
case Flag::TYPE_STRING: return "string";
|
case Flag::TYPE_STRING: return "string";
|
||||||
case Flag::TYPE_ARGS: return "arguments";
|
case Flag::TYPE_ARGS: return "arguments";
|
||||||
@ -196,6 +212,9 @@ std::ostream& operator<<(std::ostream& os, const Flag& flag) { // NOLINT
|
|||||||
case Flag::TYPE_INT:
|
case Flag::TYPE_INT:
|
||||||
os << *flag.int_variable();
|
os << *flag.int_variable();
|
||||||
break;
|
break;
|
||||||
|
case Flag::TYPE_INTPTR:
|
||||||
|
os << *flag.intptr_variable();
|
||||||
|
break;
|
||||||
case Flag::TYPE_FLOAT:
|
case Flag::TYPE_FLOAT:
|
||||||
os << *flag.float_variable();
|
os << *flag.float_variable();
|
||||||
break;
|
break;
|
||||||
@ -396,6 +415,11 @@ int FlagList::SetFlagsFromCommandLine(int* argc,
|
|||||||
case Flag::TYPE_INT:
|
case Flag::TYPE_INT:
|
||||||
*flag->int_variable() = strtol(value, &endp, 10); // NOLINT
|
*flag->int_variable() = strtol(value, &endp, 10); // NOLINT
|
||||||
break;
|
break;
|
||||||
|
case Flag::TYPE_INTPTR:
|
||||||
|
// TODO(bnoordhuis) Use strtoll()? C++11 library feature
|
||||||
|
// that may not be available everywhere yet.
|
||||||
|
*flag->intptr_variable() = strtol(value, &endp, 10); // NOLINT
|
||||||
|
break;
|
||||||
case Flag::TYPE_FLOAT:
|
case Flag::TYPE_FLOAT:
|
||||||
*flag->float_variable() = strtod(value, &endp);
|
*flag->float_variable() = strtod(value, &endp);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user