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) \
|
||||
FLAG(MAYBE_BOOL, MaybeBoolFlag, nam, {false COMMA false}, 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_STRING(nam, def, cmt) FLAG(STRING, const char*, nam, def, cmt)
|
||||
#define DEFINE_ARGS(nam, cmt) FLAG(ARGS, JSArguments, nam, {0 COMMA NULL}, cmt)
|
||||
@ -542,8 +543,8 @@ DEFINE_BOOL(enable_liveedit, true, "enable liveedit experimental feature")
|
||||
DEFINE_BOOL(hard_abort, true, "abort by crashing")
|
||||
|
||||
// execution.cc
|
||||
DEFINE_INT(stack_size, V8_DEFAULT_STACK_SIZE_KB,
|
||||
"default size of stack region v8 is allowed to use (in kBytes)")
|
||||
DEFINE_INTPTR(stack_size, V8_DEFAULT_STACK_SIZE_KB,
|
||||
"default size of stack region v8 is allowed to use (in kBytes)")
|
||||
|
||||
// frames.cc
|
||||
DEFINE_INT(max_stack_trace_source_length, 300,
|
||||
@ -554,21 +555,22 @@ DEFINE_BOOL(always_inline_smi_code, false,
|
||||
"always inline smi code in non-opt code")
|
||||
|
||||
// heap.cc
|
||||
DEFINE_INT(min_semi_space_size, 0,
|
||||
"min size of a semi-space (in MBytes), the new space consists of two"
|
||||
"semi-spaces")
|
||||
DEFINE_INT(target_semi_space_size, 0,
|
||||
"target size of a semi-space (in MBytes) before triggering a GC")
|
||||
DEFINE_INT(max_semi_space_size, 0,
|
||||
"max size of a semi-space (in MBytes), the new space consists of two"
|
||||
"semi-spaces")
|
||||
DEFINE_INTPTR(min_semi_space_size, 0,
|
||||
"min size of a semi-space (in MBytes), the new space consists "
|
||||
"of two semi-spaces")
|
||||
DEFINE_INTPTR(target_semi_space_size, 0,
|
||||
"target size of a semi-space (in MBytes) before triggering a GC")
|
||||
DEFINE_INTPTR(max_semi_space_size, 0,
|
||||
"max size of a semi-space (in MBytes), the new space consists "
|
||||
"of two semi-spaces")
|
||||
DEFINE_INT(semi_space_growth_factor, 2, "factor by which to grow the new space")
|
||||
DEFINE_BOOL(experimental_new_space_growth_heuristic, false,
|
||||
"Grow the new space based on the percentage of survivors instead "
|
||||
"of their absolute value.")
|
||||
DEFINE_INT(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_INT(max_executable_size, 0, "max size of executable memory (in Mbytes)")
|
||||
DEFINE_INTPTR(max_old_space_size, 0, "max size of the old space (in Mbytes)")
|
||||
DEFINE_INTPTR(initial_old_space_size, 0, "initial old space size (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_INT(gc_interval, -1, "garbage collect after <n> allocations")
|
||||
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
|
||||
// initialized as to avoid requiring static constructors.
|
||||
struct Flag {
|
||||
enum FlagType { TYPE_BOOL, TYPE_MAYBE_BOOL, TYPE_INT, TYPE_FLOAT,
|
||||
TYPE_STRING, TYPE_ARGS };
|
||||
enum FlagType { TYPE_BOOL, TYPE_MAYBE_BOOL, TYPE_INT, TYPE_INTPTR,
|
||||
TYPE_FLOAT, TYPE_STRING, TYPE_ARGS };
|
||||
|
||||
FlagType type_; // What type of flag, bool, int, or string.
|
||||
const char* name_; // Name of the flag, ex "my_flag".
|
||||
@ -61,6 +61,11 @@ struct Flag {
|
||||
return reinterpret_cast<int*>(valptr_);
|
||||
}
|
||||
|
||||
intptr_t* intptr_variable() const {
|
||||
DCHECK(type_ == TYPE_INTPTR);
|
||||
return reinterpret_cast<intptr_t*>(valptr_);
|
||||
}
|
||||
|
||||
double* float_variable() const {
|
||||
DCHECK(type_ == TYPE_FLOAT);
|
||||
return reinterpret_cast<double*>(valptr_);
|
||||
@ -94,6 +99,11 @@ struct Flag {
|
||||
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 {
|
||||
DCHECK(type_ == TYPE_FLOAT);
|
||||
return *reinterpret_cast<const double*>(defptr_);
|
||||
@ -118,6 +128,8 @@ struct Flag {
|
||||
return maybe_bool_variable()->has_value == false;
|
||||
case TYPE_INT:
|
||||
return *int_variable() == int_default();
|
||||
case TYPE_INTPTR:
|
||||
return *intptr_variable() == intptr_default();
|
||||
case TYPE_FLOAT:
|
||||
return *float_variable() == float_default();
|
||||
case TYPE_STRING: {
|
||||
@ -146,6 +158,9 @@ struct Flag {
|
||||
case TYPE_INT:
|
||||
*int_variable() = int_default();
|
||||
break;
|
||||
case TYPE_INTPTR:
|
||||
*intptr_variable() = intptr_default();
|
||||
break;
|
||||
case TYPE_FLOAT:
|
||||
*float_variable() = float_default();
|
||||
break;
|
||||
@ -174,6 +189,7 @@ static const char* Type2String(Flag::FlagType type) {
|
||||
case Flag::TYPE_BOOL: return "bool";
|
||||
case Flag::TYPE_MAYBE_BOOL: return "maybe_bool";
|
||||
case Flag::TYPE_INT: return "int";
|
||||
case Flag::TYPE_INTPTR: return "intptr_t";
|
||||
case Flag::TYPE_FLOAT: return "float";
|
||||
case Flag::TYPE_STRING: return "string";
|
||||
case Flag::TYPE_ARGS: return "arguments";
|
||||
@ -196,6 +212,9 @@ std::ostream& operator<<(std::ostream& os, const Flag& flag) { // NOLINT
|
||||
case Flag::TYPE_INT:
|
||||
os << *flag.int_variable();
|
||||
break;
|
||||
case Flag::TYPE_INTPTR:
|
||||
os << *flag.intptr_variable();
|
||||
break;
|
||||
case Flag::TYPE_FLOAT:
|
||||
os << *flag.float_variable();
|
||||
break;
|
||||
@ -396,6 +415,11 @@ int FlagList::SetFlagsFromCommandLine(int* argc,
|
||||
case Flag::TYPE_INT:
|
||||
*flag->int_variable() = strtol(value, &endp, 10); // NOLINT
|
||||
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:
|
||||
*flag->float_variable() = strtod(value, &endp);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user