This is a new static flag system, designed to have all flags in a central place, and compiled into the binary without requiring static constructors for registration. All flags are moved out of the specific modules and into flags.defs, with different sections for debug, release, etc. The flag variables are always defined. For example, a debug flag in release mode still exists, but is read only and set to the default value.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@296 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
deanm@chromium.org 2008-09-12 10:19:33 +00:00
parent b5d8866ced
commit 77196c5771
49 changed files with 564 additions and 796 deletions

View File

@ -41,10 +41,6 @@
namespace v8 { namespace internal {
DEFINE_bool(debug_code, false,
"generate extra code (comments, assertions) for debugging");
// -----------------------------------------------------------------------------
// Implementation of Register and CRegister
@ -272,11 +268,6 @@ enum {
};
DEFINE_bool(push_pop_elimination, true,
"eliminate redundant push/pops in assembly code");
DEFINE_bool(print_push_pop_elimination, false,
"print elimination of redundant push/pops in assembly code");
// add(sp, sp, 4) instruction (aka Pop())
static const Instr kPopInstruction =
al | 4 * B21 | 4 | LeaveCC | I | sp.code() * B16 | sp.code() * B12;
@ -469,10 +460,6 @@ void Assembler::print(Label* L) {
}
DEFINE_bool(eliminate_jumps, true, "eliminate jumps to jumps in assembly code");
DEFINE_bool(print_jump_elimination, false,
"print elimination of jumps to jumps in assembly code");
void Assembler::bind_to(Label* L, int pos) {
ASSERT(0 <= pos && pos <= pc_offset()); // must have a valid binding position
while (L->is_linked()) {

View File

@ -42,10 +42,6 @@
namespace v8 { namespace internal {
DEFINE_bool(debug_code, false,
"generate extra code (comments, assertions) for debugging");
DEFINE_bool(emit_branch_hints, false, "emit branch hints");
// -----------------------------------------------------------------------------
// Implementation of Register
@ -412,11 +408,6 @@ void Assembler::push(const Immediate& x) {
}
DEFINE_bool(push_pop_elimination, true,
"eliminate redundant push/pops in assembly code");
DEFINE_bool(print_push_pop_elimination, false,
"print elimination of redundant push/pops in assembly code");
void Assembler::push(Register src) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
@ -1180,10 +1171,6 @@ void Assembler::print(Label* L) {
}
DEFINE_bool(eliminate_jumps, true, "eliminate jumps to jumps in assembly code");
DEFINE_bool(print_jump_elimination, false,
"print elimination of jumps to jumps in assembly code");
void Assembler::bind_to(Label* L, int pos) {
EnsureSpace ensure_space(this);
last_pc_ = NULL;

View File

@ -39,11 +39,6 @@
namespace v8 { namespace internal {
DEFINE_string(expose_natives_as, NULL, "expose natives in global object");
DEFINE_string(expose_debug_as, NULL, "expose debug in global object");
DEFINE_string(natives_file, NULL, "alternative natives file"); // for debugging
DEFINE_bool(expose_gc, false, "expose gc extension"); // for debugging
// A SourceCodeCache uses a FixedArray to store pairs of
// (AsciiString*, JSFunction*), mapping names of native code files
// (runtime.js, etc.) to precompiled functions. Instead of mapping

View File

@ -50,9 +50,6 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm,
}
DEFINE_bool(inline_new, true, "use fast inline allocation");
void Builtins::Generate_JSConstructCall(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- eax: number of arguments

View File

@ -34,11 +34,6 @@
namespace v8 { namespace internal {
#ifdef DEBUG
DECLARE_bool(print_builtin_code);
#endif // DEBUG
// ----------------------------------------------------------------------------
// Support macros for defining builtins in C.
// ----------------------------------------------------------------------------

View File

@ -34,14 +34,6 @@
using namespace v8::internal;
DEFINE_bool(stack_trace_on_abort, true,
"print a stack trace if an assertion failure occurs");
#ifdef DEBUG
DEFINE_bool(enable_slow_asserts, false,
"enable asserts that are slow to execute");
#endif
static int fatal_error_handler_nesting_depth = 0;
// Contains protection against recursive calls (faults while handling faults).

View File

@ -32,10 +32,6 @@
#include "flags.h"
#ifdef DEBUG
DECLARE_bool(enable_slow_asserts);
#endif // DEBUG
extern "C" void V8_Fatal(const char* file, int line, const char* format, ...);
void API_Fatal(const char* location, const char* format, ...);

View File

@ -34,10 +34,6 @@
namespace v8 { namespace internal {
#ifdef DEBUG
DEFINE_bool(print_code_stubs, false, "print code stubs");
#endif
Handle<Code> CodeStub::GetCode() {
uint32_t key = GetKey();
int index = Heap::code_stubs()->FindNumberEntry(key);

View File

@ -37,34 +37,6 @@
namespace v8 { namespace internal {
DEFINE_bool(trace, false, "trace function calls");
DECLARE_bool(debug_info);
DECLARE_bool(debug_code);
#ifdef ENABLE_DISASSEMBLER
DEFINE_bool(print_code, false, "print generated code");
#endif
#ifdef DEBUG
DECLARE_bool(gc_greedy);
DEFINE_bool(trace_codegen, false,
"print name of functions for which code is generated");
DEFINE_bool(print_builtin_code, false, "print generated code for builtins");
DEFINE_bool(print_source, false, "pretty print source code");
DEFINE_bool(print_builtin_source, false,
"pretty print source code for builtins");
DEFINE_bool(print_ast, false, "print source AST");
DEFINE_bool(print_builtin_ast, false, "print source AST for builtins");
DEFINE_bool(trace_calls, false, "trace calls");
DEFINE_bool(trace_builtin_calls, false, "trace builtins calls");
DEFINE_string(stop_at, "", "function name where to insert a breakpoint");
#endif // DEBUG
DEFINE_bool(check_stack, true,
"check stack for overflow, interrupt, breakpoint");
class ArmCodeGenerator;

View File

@ -37,34 +37,6 @@
namespace v8 { namespace internal {
DEFINE_bool(trace, false, "trace function calls");
DEFINE_bool(defer_negation, true, "defer negation operation");
DECLARE_bool(debug_info);
DECLARE_bool(debug_code);
#ifdef ENABLE_DISASSEMBLER
DEFINE_bool(print_code, false, "print generated code");
#endif
#ifdef DEBUG
DECLARE_bool(gc_greedy);
DEFINE_bool(trace_codegen, false,
"print name of functions for which code is generated");
DEFINE_bool(print_builtin_code, false, "print generated code for builtins");
DEFINE_bool(print_source, false, "pretty print source code");
DEFINE_bool(print_builtin_source, false,
"pretty print source code for builtins");
DEFINE_bool(print_ast, false, "print source AST");
DEFINE_bool(print_builtin_ast, false, "print source AST for builtins");
DEFINE_bool(trace_calls, false, "trace calls");
DEFINE_bool(trace_builtin_calls, false, "trace builtins calls");
DEFINE_string(stop_at, "", "function name where to insert a breakpoint");
#endif // DEBUG
DEFINE_bool(check_stack, true,
"check stack for overflow, interrupt, breakpoint");
#define TOS (Operand(esp, 0))

View File

@ -34,11 +34,6 @@
namespace v8 { namespace internal {
DEFINE_bool(lazy, true, "use lazy compilation");
DEFINE_bool(debug_info, true, "add debug information to compiled functions");
DeferredCode::DeferredCode(CodeGenerator* generator)
: masm_(generator->masm()),
generator_(generator),

View File

@ -41,7 +41,6 @@ namespace v8 { namespace internal {
// install extensions with lazy compilation enabled. At the
// moment, this doesn't work for the extensions in Google3,
// and we can only run the tests with --nolazy.
DECLARE_bool(lazy);
// Forward declaration.

View File

@ -38,17 +38,6 @@
namespace v8 { namespace internal {
DEFINE_bool(strict, false, "strict error checking");
DEFINE_int(min_preparse_length, 1024,
"Minimum length for automatic enable preparsing");
DECLARE_bool(debug_info);
#ifdef DEBUG
DEFINE_bool(print_builtin_scopes, false, "print scopes for builtins");
DEFINE_bool(print_scopes, false, "print scopes");
#endif
static Handle<Code> MakeCode(FunctionLiteral* literal,
Handle<Script> script,
bool is_eval) {

View File

@ -32,14 +32,6 @@
namespace v8 { namespace internal {
#ifdef DEBUG
DEFINE_bool(trace_contexts, false, "trace contexts operations");
#else
#define FLAG_trace_contexts false
#endif
JSBuiltinsObject* Context::builtins() {
GlobalObject* object = global();
if (object->IsJSGlobalObject()) {

View File

@ -41,12 +41,6 @@
namespace v8 { namespace internal {
DEFINE_bool(remote_debugging, false, "enable remote debugging");
DEFINE_bool(trace_debug_json, false, "trace debugging JSON request/response");
DECLARE_bool(allow_natives_syntax);
DECLARE_bool(log_debugger);
static void PrintLn(v8::Local<v8::Value> value) {
v8::Local<v8::String> s = value->ToString();
char* data = NewArray<char>(s->Length() + 1);

View File

@ -154,8 +154,6 @@ Handle<Object> Execution::TryCall(Handle<JSFunction> func,
}
DEFINE_bool(call_regexp, false, "allow calls to RegExp objects");
Handle<Object> Execution::GetFunctionDelegate(Handle<Object> object) {
ASSERT(!object->IsJSFunction());

View File

@ -1,75 +0,0 @@
// Copyright 2008 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef V8_FLAGS_INL_H_
#define V8_FLAGS_INL_H_
namespace v8 { namespace internal {
bool* Flag::bool_variable() const {
ASSERT(type_ == BOOL);
return &variable_->b;
}
int* Flag::int_variable() const {
ASSERT(type_ == INT);
return &variable_->i;
}
double* Flag::float_variable() const {
ASSERT(type_ == FLOAT);
return &variable_->f;
}
const char** Flag::string_variable() const {
ASSERT(type_ == STRING);
return &variable_->s;
}
bool Flag::bool_default() const {
ASSERT(type_ == BOOL);
return default_.b;
}
int Flag::int_default() const {
ASSERT(type_ == INT);
return default_.i;
}
double Flag::float_default() const {
ASSERT(type_ == FLOAT);
return default_.f;
}
const char* Flag::string_default() const {
ASSERT(type_ == STRING);
return default_.s;
}
} } // namespace v8::internal
#endif // V8_FLAGS_INL_H_

View File

@ -34,125 +34,155 @@
namespace v8 { namespace internal {
// -----------------------------------------------------------------------------
// Helpers
// Define all of our flags.
#define FLAG_MODE_DEFINE
#include "flags.defs"
static inline char NormalizeChar(char ch) {
return ch == '_' ? '-' : ch;
}
// Define all of our flags default values.
#define FLAG_MODE_DEFINE_DEFAULTS
#include "flags.defs"
namespace {
static const char* NormalizeName(const char* name) {
int len = strlen(name);
char* result = NewArray<char>(len + 1);
for (int i = 0; i <= len; i++) {
result[i] = NormalizeChar(name[i]);
// This structure represents a single entry in the flag system, with a pointer
// 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_INT, TYPE_FLOAT, TYPE_STRING };
FlagType type_; // What type of flag, bool, int, or string.
const char* name_; // Name of the flag, ex "my_flag".
void* valptr_; // Pointer to the global flag variable.
const void* defptr_; // Pointer to the default value.
const char* cmt_; // A comment about the flags purpose.
FlagType type() const { return type_; }
const char* name() const { return name_; }
const char* comment() const { return cmt_; }
bool* bool_variable() const {
ASSERT(type_ == TYPE_BOOL);
return reinterpret_cast<bool*>(valptr_);
}
return const_cast<const char*>(result);
}
int* int_variable() const {
ASSERT(type_ == TYPE_INT);
return reinterpret_cast<int*>(valptr_);
}
static bool EqualNames(const char* a, const char* b) {
for (int i = 0; NormalizeChar(a[i]) == NormalizeChar(b[i]); i++) {
if (a[i] == '\0') {
return true;
double* float_variable() const {
ASSERT(type_ == TYPE_FLOAT);
return reinterpret_cast<double*>(valptr_);
}
const char** string_variable() const {
ASSERT(type_ == TYPE_STRING);
return reinterpret_cast<const char**>(valptr_);
}
bool bool_default() const {
ASSERT(type_ == TYPE_BOOL);
return *reinterpret_cast<const bool*>(defptr_);
}
int int_default() const {
ASSERT(type_ == TYPE_INT);
return *reinterpret_cast<const int*>(defptr_);
}
double float_default() const {
ASSERT(type_ == TYPE_FLOAT);
return *reinterpret_cast<const double*>(defptr_);
}
const char* string_default() const {
ASSERT(type_ == TYPE_STRING);
return *reinterpret_cast<const char* const *>(defptr_);
}
// Compare this flag's current value against the default.
bool IsDefault() const {
switch (type_) {
case TYPE_BOOL:
return *bool_variable() == bool_default();
case TYPE_INT:
return *int_variable() == int_default();
case TYPE_FLOAT:
return *float_variable() == float_default();
case TYPE_STRING:
const char* str1 = *string_variable();
const char* str2 = string_default();
if (str2 == NULL) return str1 == NULL;
if (str1 == NULL) return str2 == NULL;
return strcmp(str1, str2) == 0;
}
return true; // NOTREACHED
}
// Set a flag back to it's default value.
void Reset() {
switch (type_) {
case TYPE_BOOL:
*bool_variable() = bool_default();
break;
case TYPE_INT:
*int_variable() = int_default();
break;
case TYPE_FLOAT:
*float_variable() = float_default();
break;
case TYPE_STRING:
*string_variable() = string_default();
break;
}
}
return false;
}
};
Flag flags[] = {
#define FLAG_MODE_META
#include "flags.defs"
};
const size_t num_flags = sizeof(flags) / sizeof(*flags);
} // namespace
// -----------------------------------------------------------------------------
// Implementation of Flag
Flag::Flag(const char* file, const char* name, const char* comment,
Type type, void* variable, FlagValue default_) {
file_ = file;
name_ = NormalizeName(name);
comment_ = comment;
type_ = type;
variable_ = reinterpret_cast<FlagValue*>(variable);
this->default_ = default_;
FlagList::Register(this);
}
void Flag::SetToDefault() {
// Note that we cannot simply do '*variable_ = default_;' since
// flag variables are not really of type FlagValue and thus may
// be smaller! The FlagValue union is simply 'overlayed' on top
// of a flag variable for convenient access. Since union members
// are guarantee to be aligned at the beginning, this works.
switch (type_) {
case Flag::BOOL:
variable_->b = default_.b;
return;
case Flag::INT:
variable_->i = default_.i;
return;
case Flag::FLOAT:
variable_->f = default_.f;
return;
case Flag::STRING:
variable_->s = default_.s;
return;
}
UNREACHABLE();
}
bool Flag::IsDefault() const {
switch (type_) {
case Flag::BOOL:
return variable_->b == default_.b;
case Flag::INT:
return variable_->i == default_.i;
case Flag::FLOAT:
return variable_->f == default_.f;
case Flag::STRING:
if (variable_->s && default_.s) {
return strcmp(variable_->s, default_.s) == 0;
} else {
return variable_->s == default_.s;
}
}
UNREACHABLE();
return false;
}
static const char* Type2String(Flag::Type type) {
static const char* Type2String(Flag::FlagType type) {
switch (type) {
case Flag::BOOL: return "bool";
case Flag::INT: return "int";
case Flag::FLOAT: return "float";
case Flag::STRING: return "string";
case Flag::TYPE_BOOL: return "bool";
case Flag::TYPE_INT: return "int";
case Flag::TYPE_FLOAT: return "float";
case Flag::TYPE_STRING: return "string";
}
UNREACHABLE();
return NULL;
}
static char* ToString(Flag::Type type, FlagValue* variable) {
static char* ToString(Flag* flag) {
Vector<char> value;
switch (type) {
case Flag::BOOL:
switch (flag->type()) {
case Flag::TYPE_BOOL:
value = Vector<char>::New(6);
OS::SNPrintF(value, "%s", (variable->b ? "true" : "false"));
OS::SNPrintF(value, "%s", (*flag->bool_variable() ? "true" : "false"));
break;
case Flag::INT:
case Flag::TYPE_INT:
value = Vector<char>::New(12);
OS::SNPrintF(value, "%d", variable->i);
OS::SNPrintF(value, "%d", *flag->int_variable());
break;
case Flag::FLOAT:
case Flag::TYPE_FLOAT:
value = Vector<char>::New(20);
OS::SNPrintF(value, "%f", variable->f);
OS::SNPrintF(value, "%f", *flag->float_variable());
break;
case Flag::STRING:
if (variable->s) {
int length = strlen(variable->s) + 1;
case Flag::TYPE_STRING:
const char* str = *flag->string_variable();
if (str) {
int length = strlen(str) + 1;
value = Vector<char>::New(length);
OS::SNPrintF(value, "%s", variable->s);
OS::SNPrintF(value, "%s", str);
} else {
value = Vector<char>::New(5);
OS::SNPrintF(value, "NULL");
@ -164,42 +194,14 @@ static char* ToString(Flag::Type type, FlagValue* variable) {
}
static void PrintFlagValue(Flag::Type type, FlagValue* variable) {
char* value = ToString(type, variable);
printf("%s", value);
DeleteArray(value);
}
char* Flag::StringValue() const {
return ToString(type_, variable_);
}
void Flag::Print(bool print_current_value) {
printf(" --%s (%s) type: %s default: ", name_, comment_,
Type2String(type_));
PrintFlagValue(type_, &default_);
if (print_current_value) {
printf(" current value: ");
PrintFlagValue(type_, variable_);
}
printf("\n");
}
// -----------------------------------------------------------------------------
// Implementation of FlagList
Flag* FlagList::list_ = NULL;
// static
List<char *>* FlagList::argv() {
List<char *>* args = new List<char*>(8);
for (Flag* f = list_; f != NULL; f = f->next()) {
for (size_t i = 0; i < num_flags; ++i) {
Flag* f = &flags[i];
if (!f->IsDefault()) {
Vector<char> cmdline_flag;
if (f->type() != Flag::BOOL || *(f->bool_variable())) {
if (f->type() != Flag::TYPE_BOOL || *(f->bool_variable())) {
int length = strlen(f->name()) + 2 + 1;
cmdline_flag = Vector<char>::New(length);
OS::SNPrintF(cmdline_flag, "--%s", f->name());
@ -209,45 +211,26 @@ List<char *>* FlagList::argv() {
OS::SNPrintF(cmdline_flag, "--no%s", f->name());
}
args->Add(cmdline_flag.start());
if (f->type() != Flag::BOOL) {
args->Add(f->StringValue());
if (f->type() != Flag::TYPE_BOOL) {
args->Add(ToString(f));
}
}
}
return args;
}
void FlagList::Print(const char* file, bool print_current_value) {
// Since flag registration is likely by file (= C++ file),
// we don't need to sort by file and still get grouped output.
const char* current = NULL;
for (Flag* f = list_; f != NULL; f = f->next()) {
if (file == NULL || file == f->file()) {
if (current != f->file()) {
printf("Flags from %s:\n", f->file());
current = f->file();
}
f->Print(print_current_value);
}
}
}
Flag* FlagList::Lookup(const char* name) {
Flag* f = list_;
while (f != NULL && !EqualNames(name, f->name()))
f = f->next();
return f;
}
void FlagList::SplitArgument(const char* arg,
char* buffer,
int buffer_size,
const char** name,
const char** value,
bool* is_bool) {
// Helper function to parse flags: Takes an argument arg and splits it into
// a flag name and flag value (or NULL if they are missing). is_bool is set
// if the arg started with "-no" or "--no". The buffer may be used to NUL-
// terminate the name, it must be large enough to hold any possible name.
static void SplitArgument(const char* arg,
char* buffer,
int buffer_size,
const char** name,
const char** value,
bool* is_bool) {
*name = NULL;
*value = NULL;
*is_bool = false;
@ -282,6 +265,31 @@ void FlagList::SplitArgument(const char* arg,
}
inline char NormalizeChar(char ch) {
return ch == '_' ? '-' : ch;
}
static bool EqualNames(const char* a, const char* b) {
for (int i = 0; NormalizeChar(a[i]) == NormalizeChar(b[i]); i++) {
if (a[i] == '\0') {
return true;
}
}
return false;
}
static Flag* FindFlag(const char* name) {
for (size_t i = 0; i < num_flags; ++i) {
if (EqualNames(name, flags[i].name()))
return &flags[i];
}
return NULL;
}
// static
int FlagList::SetFlagsFromCommandLine(int* argc,
char** argv,
bool remove_flags) {
@ -299,7 +307,7 @@ int FlagList::SetFlagsFromCommandLine(int* argc,
if (name != NULL) {
// lookup the flag
Flag* flag = Lookup(name);
Flag* flag = FindFlag(name);
if (flag == NULL) {
if (remove_flags) {
// We don't recognize this flag but since we're removing
@ -314,7 +322,7 @@ int FlagList::SetFlagsFromCommandLine(int* argc,
}
// if we still need a flag value, use the next argument if available
if (flag->type() != Flag::BOOL && value == NULL) {
if (flag->type() != Flag::TYPE_BOOL && value == NULL) {
if (i < *argc) {
value = argv[i++];
} else {
@ -327,23 +335,23 @@ int FlagList::SetFlagsFromCommandLine(int* argc,
// set the flag
char* endp = const_cast<char*>(""); // *endp is only read
switch (flag->type()) {
case Flag::BOOL:
case Flag::TYPE_BOOL:
*flag->bool_variable() = !is_bool;
break;
case Flag::INT:
case Flag::TYPE_INT:
*flag->int_variable() = strtol(value, &endp, 10); // NOLINT
break;
case Flag::FLOAT:
case Flag::TYPE_FLOAT:
*flag->float_variable() = strtod(value, &endp);
break;
case Flag::STRING:
case Flag::TYPE_STRING:
*flag->string_variable() = value;
break;
}
// handle errors
if ((flag->type() == Flag::BOOL && value != NULL) ||
(flag->type() != Flag::BOOL && is_bool) ||
if ((flag->type() == Flag::TYPE_BOOL && value != NULL) ||
(flag->type() != Flag::TYPE_BOOL && is_bool) ||
*endp != '\0') {
fprintf(stderr, "Error: illegal value for flag %s of type %s\n",
arg, Type2String(flag->type()));
@ -384,6 +392,7 @@ static char* SkipBlackSpace(char* p) {
}
// static
int FlagList::SetFlagsFromString(const char* str, int len) {
// make a 0-terminated copy of str
char* copy0 = NewArray<char>(len + 1);
@ -427,12 +436,23 @@ int FlagList::SetFlagsFromString(const char* str, int len) {
}
void FlagList::Register(Flag* flag) {
ASSERT(flag != NULL && strlen(flag->name()) > 0);
if (Lookup(flag->name()) != NULL)
V8_Fatal(flag->file(), 0, "flag %s declared twice", flag->name());
flag->next_ = list_;
list_ = flag;
// static
void FlagList::ResetAllFlags() {
for (size_t i = 0; i < num_flags; ++i) {
flags[i].Reset();
}
}
// static
void FlagList::PrintHelp() {
for (size_t i = 0; i < num_flags; ++i) {
Flag* f = &flags[i];
char* value = ToString(f);
printf(" --%s (%s) type: %s default: %s\n",
f->name(), f->comment(), Type2String(f->type()), value);
DeleteArray(value);
}
}
} } // namespace v8::internal

318
src/flags.defs Executable file
View File

@ -0,0 +1,318 @@
// Copyright 2008 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// This file defines all of the flags. It is separated into different section,
// for Debug, Release, Logging and Profiling, etc. To add a new flag, find the
// correct section, and use one of the DEFINE_ macros, without a trailing ';'.
//
// This include does not have a guard, because it is a template-style include,
// which can be included multiple times in different modes. It expects to have
// a mode defined before it's included. The modes are FLAG_MODE_... below:
// We want to declare the names of the variables for the header file. Normally
// this will just be an extern declaration, but for a readonly flag we let the
// compiler make better optimizations by giving it the value.
#if defined(FLAG_MODE_DECLARE)
#define FLAG_FULL(ftype, ctype, nam, def, cmt) \
extern ctype FLAG_##nam;
#define FLAG_READONLY(ftype, ctype, nam, def, cmt) \
static ctype const FLAG_##nam = def;
// We want to supply the actual storage and value for the flag variable in the
// .cc file. We only do this for writable flags.
#elif defined(FLAG_MODE_DEFINE)
#define FLAG_FULL(ftype, ctype, nam, def, cmt) \
ctype FLAG_##nam = def;
#define FLAG_READONLY(ftype, ctype, nam, def, cmt)
// We need to define all of our default values so that the Flag structure can
// access them by pointer. These are just used internally inside of one .cc,
// for MODE_META, so there is no impact on the flags interface.
#elif defined(FLAG_MODE_DEFINE_DEFAULTS)
#define FLAG_FULL(ftype, ctype, nam, def, cmt) \
static ctype const FLAGDEFAULT_##nam = def;
#define FLAG_READONLY(ftype, ctype, nam, def, cmt)
// We want to write entries into our meta data table, for internal parsing and
// printing / etc in the flag parser code. We only do this for writable flags.
#elif defined(FLAG_MODE_META)
#define FLAG_FULL(ftype, ctype, nam, def, cmt) \
{ Flag::TYPE_##ftype, #nam, &FLAG_##nam, &FLAGDEFAULT_##nam, cmt },
#define FLAG_READONLY(ftype, ctype, nam, def, cmt)
#else
#error No mode supplied when including flags.defs
#endif
#define DEFINE_bool(nam, def, cmt) FLAG(BOOL, bool, nam, def, cmt)
#define DEFINE_int(nam, def, cmt) FLAG(INT, int, 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)
//
// Flags in all modes.
//
#define FLAG FLAG_FULL
// assembler-ia32.cc / assembler-arm.cc
DEFINE_bool(debug_code, false,
"generate extra code (comments, assertions) for debugging")
DEFINE_bool(emit_branch_hints, false, "emit branch hints")
DEFINE_bool(push_pop_elimination, true,
"eliminate redundant push/pops in assembly code")
DEFINE_bool(print_push_pop_elimination, false,
"print elimination of redundant push/pops in assembly code")
DEFINE_bool(eliminate_jumps, true, "eliminate jumps to jumps in assembly code")
DEFINE_bool(print_jump_elimination, false,
"print elimination of jumps to jumps in assembly code")
// bootstrapper.cc
DEFINE_string(expose_natives_as, NULL, "expose natives in global object")
DEFINE_string(expose_debug_as, NULL, "expose debug in global object")
DEFINE_string(natives_file, NULL, "alternative natives file")
DEFINE_bool(expose_gc, false, "expose gc extension")
// builtins-ia32.cc
DEFINE_bool(inline_new, true, "use fast inline allocation")
// checks.cc
DEFINE_bool(stack_trace_on_abort, true,
"print a stack trace if an assertion failure occurs")
// codegen-ia32.cc / codegen-arm.cc
DEFINE_bool(trace, false, "trace function calls")
DEFINE_bool(defer_negation, true, "defer negation operation")
DEFINE_bool(check_stack, true,
"check stack for overflow, interrupt, breakpoint")
// codegen.cc
DEFINE_bool(lazy, true, "use lazy compilation")
DEFINE_bool(debug_info, true, "add debug information to compiled functions")
// compiler.cc
DEFINE_bool(strict, false, "strict error checking")
DEFINE_int(min_preparse_length, 1024,
"Minimum length for automatic enable preparsing")
// debug.cc
DEFINE_bool(remote_debugging, false, "enable remote debugging")
DEFINE_bool(trace_debug_json, false, "trace debugging JSON request/response")
// execution.cc
DEFINE_bool(call_regexp, false, "allow calls to RegExp objects")
// frames.cc
DEFINE_int(max_stack_trace_source_length, 300,
"maximum length of function source code printed in a stack trace.")
// heap.cc
DEFINE_int(new_space_size, 0, "size of (each semispace in) the new generation")
DEFINE_int(old_space_size, 0, "size of the old generation")
DEFINE_bool(gc_global, false, "always perform global GCs")
DEFINE_int(gc_interval, -1, "garbage collect after <n> allocations")
DEFINE_bool(trace_gc, false,
"print one trace line following each garbage collection")
// ic.cc
DEFINE_bool(use_ic, true, "use inline caching")
// macro-assembler-ia32.cc
DEFINE_bool(native_code_counters, false,
"generate extra code for manipulating stats counters")
// mark-compact.cc
DEFINE_bool(always_compact, false, "Perform compaction on every full GC")
DEFINE_bool(never_compact, false,
"Never perform compaction on full GC - testing only")
DEFINE_bool(cleanup_ics_at_gc, true,
"Flush inline caches prior to mark compact collection.")
DEFINE_bool(cleanup_caches_in_maps_at_gc, true,
"Flush code caches in maps during mark compact cycle.")
// mksnapshot.cc
DEFINE_bool(h, false, "print this message")
// parser.cc
DEFINE_bool(allow_natives_syntax, false, "allow natives syntax")
// simulator-arm.cc
DEFINE_bool(trace_sim, false, "trace simulator execution")
DEFINE_int(stop_sim_at, 0, "Simulator stop after x number of instructions")
// top.cc
DEFINE_bool(trace_exception, false,
"print stack trace when throwing exceptions")
DEFINE_bool(preallocate_message_memory, false,
"preallocate some memory to build stack traces.")
// usage-analyzer.cc
DEFINE_bool(usage_computation, true, "compute variable usage counts")
// v8.cc
DEFINE_bool(preemption, false,
"activate a 100ms timer that switches between V8 threads")
// Testing flags test/cctest/test-{flags,api,serialization}.cc
DEFINE_bool(testing_bool_flag, true, "testing_bool_flag")
DEFINE_int(testing_int_flag, 13, "testing_int_flag")
DEFINE_float(testing_float_flag, 2.5, "float-flag")
DEFINE_string(testing_string_flag, "Hello, world!", "string-flag")
DEFINE_int(testing_prng_seed, 42, "Seed used for threading test randomness")
#ifdef WIN32
DEFINE_string(testing_serialization_file, "C:\\Windows\\Temp\\serdes",
"file in which to testing_serialize heap")
#else
DEFINE_string(testing_serialization_file, "/tmp/serdes",
"file in which to serialize heap")
#endif
//
// Debug only flags
//
#undef FLAG
#ifdef DEBUG
#define FLAG FLAG_FULL
#else
#define FLAG FLAG_READONLY
#endif
// checks.cc
DEFINE_bool(enable_slow_asserts, false,
"enable asserts that are slow to execute")
// code-stubs.cc
DEFINE_bool(print_code_stubs, false, "print code stubs")
// codegen-ia32.cc / codegen-arm.cc
DEFINE_bool(trace_codegen, false,
"print name of functions for which code is generated")
DEFINE_bool(print_builtin_code, false, "print generated code for builtins")
DEFINE_bool(print_source, false, "pretty print source code")
DEFINE_bool(print_builtin_source, false,
"pretty print source code for builtins")
DEFINE_bool(print_ast, false, "print source AST")
DEFINE_bool(print_builtin_ast, false, "print source AST for builtins")
DEFINE_bool(trace_calls, false, "trace calls")
DEFINE_bool(trace_builtin_calls, false, "trace builtins calls")
DEFINE_string(stop_at, "", "function name where to insert a breakpoint")
// compiler.cc
DEFINE_bool(print_builtin_scopes, false, "print scopes for builtins")
DEFINE_bool(print_scopes, false, "print scopes")
// contexts.cc
DEFINE_bool(trace_contexts, false, "trace contexts operations")
// heap.cc
DEFINE_bool(gc_greedy, false, "perform GC prior to some allocations")
DEFINE_bool(gc_verbose, false, "print stuff during garbage collection")
DEFINE_bool(heap_stats, false, "report heap statistics before and after GC")
DEFINE_bool(code_stats, false, "report code statistics after GC")
DEFINE_bool(verify_heap, false, "verify heap pointers before and after GC")
DEFINE_bool(print_handles, false, "report handles after GC")
DEFINE_bool(print_global_handles, false, "report global handles after GC")
DEFINE_bool(print_rset, false, "print remembered sets before GC")
// ic.cc
DEFINE_bool(trace_ic, false, "trace inline cache state transitions")
// objects.cc
DEFINE_bool(trace_normalization,
false,
"prints when objects are turned into dictionaries.")
// runtime.cc
DEFINE_bool(trace_lazy, false, "trace lazy compilation")
// serialize.cc
DEFINE_bool(debug_serialization, false,
"write debug information into the snapshot.")
// spaces.cc
DEFINE_bool(collect_heap_spill_statistics, false,
"report heap spill statistics along with heap_stats "
"(requires heap_stats)")
//
// Logging and profiling only flags
//
#undef FLAG
#ifdef ENABLE_LOGGING_AND_PROFILING
#define FLAG FLAG_FULL
#else
#define FLAG FLAG_READONLY
#endif
// log.cc
DEFINE_bool(log, false,
"Minimal logging (no API, code, GC, suspect, or handles samples).")
DEFINE_bool(log_all, false, "Log all events to the log file.")
DEFINE_bool(log_api, false, "Log API events to the log file.")
DEFINE_bool(log_code, false,
"Log code events to the log file without profiling.")
DEFINE_bool(log_gc, false,
"Log heap samples on garbage collection for the hp2ps tool.")
DEFINE_bool(log_handles, false, "Log global handle events.")
DEFINE_bool(log_state_changes, false, "Log state changes.")
DEFINE_bool(log_suspect, false, "Log suspect operations.")
DEFINE_bool(prof, false,
"Log statistical profiling information (implies --log-code).")
DEFINE_bool(log_regexp, false, "Log regular expression execution.")
DEFINE_bool(sliding_state_window, false,
"Update sliding state window counters.")
DEFINE_string(logfile, "v8.log", "Specify the name of the log file.")
//
// Disassembler only flags
//
#undef FLAG
#ifdef ENABLE_DISASSEMBLER
#define FLAG FLAG_FULL
#else
#define FLAG FLAG_READONLY
#endif
// codegen-ia32.cc / codegen-arm.cc
DEFINE_bool(print_code, false, "print generated code")
// Cleanup...
#undef FLAG_FULL
#undef FLAG_READONLY
#undef FLAG
#undef DEFINE_bool
#undef DEFINE_int
#undef DEFINE_string
#undef FLAG_MODE_DECLARE
#undef FLAG_MODE_DEFINE
#undef FLAG_MODE_DEFINE_DEFAULTS
#undef FLAG_MODE_META

View File

@ -27,143 +27,17 @@
#ifndef V8_FLAGS_H_
#define V8_FLAGS_H_
#include "checks.h"
namespace v8 { namespace internal {
// Internal use only.
union FlagValue {
static FlagValue New_BOOL(bool b) {
FlagValue v;
v.b = b;
return v;
}
static FlagValue New_INT(int i) {
FlagValue v;
v.i = i;
return v;
}
static FlagValue New_FLOAT(float f) {
FlagValue v;
v.f = f;
return v;
}
static FlagValue New_STRING(const char* s) {
FlagValue v;
v.s = s;
return v;
}
bool b;
int i;
double f;
const char* s;
};
// Each flag can be accessed programmatically via a Flag object.
class Flag {
public:
enum Type { BOOL, INT, FLOAT, STRING };
// Internal use only.
Flag(const char* file, const char* name, const char* comment,
Type type, void* variable, FlagValue default_);
// General flag information
const char* file() const { return file_; }
const char* name() const { return name_; }
const char* comment() const { return comment_; }
// Flag type
Type type() const { return type_; }
// Flag variables
inline bool* bool_variable() const;
inline int* int_variable() const;
inline double* float_variable() const;
inline const char** string_variable() const;
// Default values
inline bool bool_default() const;
inline int int_default() const;
inline double float_default() const;
inline const char* string_default() const;
// Resets a flag to its default value
void SetToDefault();
// True if a flag is set to its default value
bool IsDefault() const;
// Iteration support
Flag* next() const { return next_; }
// Prints flag information. The current flag value is only printed
// if print_current_value is set.
void Print(bool print_current_value);
// Returns the string formatted value of the flag. The caller is responsible
// for disposing the string.
char* StringValue() const;
private:
const char* file_;
const char* name_;
const char* comment_;
Type type_;
FlagValue* variable_;
FlagValue default_;
Flag* next_;
friend class FlagList; // accesses next_
};
// Internal use only.
#define DEFINE_FLAG(type, c_type, name, default, comment) \
/* define and initialize the flag */ \
c_type FLAG_##name = (default); \
/* register the flag */ \
static v8::internal::Flag Flag_##name(__FILE__, \
#name, \
(comment), \
v8::internal::Flag::type, \
&FLAG_##name, \
v8::internal::FlagValue::New_##type(default))
// Internal use only.
#define DECLARE_FLAG(c_type, name) \
/* declare the external flag */ \
extern c_type FLAG_##name
// Use the following macros to define a new flag:
#define DEFINE_bool(name, default, comment) \
DEFINE_FLAG(BOOL, bool, name, default, comment)
#define DEFINE_int(name, default, comment) \
DEFINE_FLAG(INT, int, name, default, comment)
#define DEFINE_float(name, default, comment) \
DEFINE_FLAG(FLOAT, double, name, default, comment)
#define DEFINE_string(name, default, comment) \
DEFINE_FLAG(STRING, const char*, name, default, comment)
// Use the following macros to declare a flag defined elsewhere:
#define DECLARE_bool(name) DECLARE_FLAG(bool, name)
#define DECLARE_int(name) DECLARE_FLAG(int, name)
#define DECLARE_float(name) DECLARE_FLAG(double, name)
#define DECLARE_string(name) DECLARE_FLAG(const char*, name)
// Declare all of our flags.
#define FLAG_MODE_DECLARE
#include "flags.defs"
// The global list of all flags.
class FlagList {
public:
// The NULL-terminated list of all flags. Traverse with Flag::next().
static Flag* list() { return list_; }
// The list of all flags with a value different from the default
// and their values. The format of the list is like the format of the
// argv array passed to the main function, e.g.
@ -172,25 +46,6 @@ class FlagList {
// The caller is responsible for disposing the list.
static List<char *>* argv();
// If file != NULL, prints information for all flags defined in file;
// otherwise prints information for all flags in all files. The current
// flag value is only printed if print_current_value is set.
static void Print(const char* file, bool print_current_value);
// Lookup a flag by name. Returns the matching flag or NULL.
static Flag* Lookup(const char* name);
// Helper function to parse flags: Takes an argument arg and splits it into
// a flag name and flag value (or NULL if they are missing). is_bool is set
// if the arg started with "-no" or "--no". The buffer may be used to NUL-
// terminate the name, it must be large enough to hold any possible name.
static void SplitArgument(const char* arg,
char* buffer,
int buffer_size,
const char** name,
const char** value,
bool* is_bool);
// Set the flag values by parsing the command line. If remove_flags is
// set, the flags and associated values are removed from (argc,
// argv). Returns 0 if no error occurred. Otherwise, returns the argv
@ -211,12 +66,11 @@ class FlagList {
// and then calls SetFlagsFromCommandLine() and returns its result.
static int SetFlagsFromString(const char* str, int len);
// Registers a new flag. Called during program initialization. Not
// thread-safe.
static void Register(Flag* flag);
// Reset all flags to their default value.
static void ResetAllFlags();
private:
static Flag* list_;
// Print help to stdout with flags, types, and default values.
static void PrintHelp();
};
} } // namespace v8::internal

View File

@ -35,14 +35,6 @@
namespace v8 { namespace internal {
DEFINE_int(max_stack_trace_source_length, 300,
"maximum length of function source code printed in a stack trace.");
// -------------------------------------------------------------------------
// Iterator that supports traversing the stack handlers of a
// particular frame. Needs to know the top of the handler chain.
class StackHandlerIterator BASE_EMBEDDED {

View File

@ -39,12 +39,6 @@
namespace v8 { namespace internal {
DECLARE_bool(allow_natives_syntax);
#ifdef DEBUG
DECLARE_bool(gc_greedy);
#endif
#define CALL_GC(RESULT) \
{ \
Failure* __failure__ = Failure::cast(RESULT); \

View File

@ -33,12 +33,6 @@
namespace v8 { namespace internal {
#ifdef DEBUG
DECLARE_bool(gc_greedy);
DECLARE_int(gc_interval);
#endif
int Heap::MaxHeapObjectSize() {
return Page::kMaxHeapObjectSize;
}

View File

@ -43,31 +43,6 @@
namespace v8 { namespace internal {
#ifdef DEBUG
DEFINE_bool(gc_greedy, false, "perform GC prior to some allocations");
DEFINE_bool(gc_verbose, false, "print stuff during garbage collection");
DEFINE_bool(heap_stats, false, "report heap statistics before and after GC");
DEFINE_bool(code_stats, false, "report code statistics after GC");
DEFINE_bool(verify_heap, false, "verify heap pointers before and after GC");
DEFINE_bool(print_handles, false, "report handles after GC");
DEFINE_bool(print_global_handles, false, "report global handles after GC");
DEFINE_bool(print_rset, false, "print remembered sets before GC");
#endif
DEFINE_int(new_space_size, 0, "size of (each semispace in) the new generation");
DEFINE_int(old_space_size, 0, "size of the old generation");
DEFINE_bool(gc_global, false, "always perform global GCs");
DEFINE_int(gc_interval, -1, "garbage collect after <n> allocations");
DEFINE_bool(trace_gc, false,
"print one trace line following each garbage collection");
#ifdef ENABLE_LOGGING_AND_PROFILING
DECLARE_bool(log_gc);
#endif
#define ROOT_ALLOCATION(type, name) type* Heap::name##_;
ROOT_LIST(ROOT_ALLOCATION)
#undef ROOT_ALLOCATION

View File

@ -34,10 +34,6 @@
namespace v8 { namespace internal {
DECLARE_bool(debug_code);
// ----------------------------------------------------------------------------
// Static IC stub generators.
//

View File

@ -37,13 +37,6 @@
namespace v8 { namespace internal {
#ifdef DEBUG
DEFINE_bool(trace_ic, false, "trace inline cache state transitions");
#endif
DEFINE_bool(use_ic, true, "use inline caching");
DECLARE_bool(strict);
#ifdef DEBUG
static char TransitionMarkFromState(IC::State state) {
switch (state) {

View File

@ -36,30 +36,6 @@ namespace v8 { namespace internal {
#ifdef ENABLE_LOGGING_AND_PROFILING
//
// Command line flags used by Logger.
//
DEFINE_bool(log, false,
"Minimal logging (no API, code, GC, suspect, or handles samples).");
DEFINE_bool(log_all, false, "Log all events to the log file.");
DEFINE_bool(log_api, false, "Log API events to the log file.");
DEFINE_bool(log_code, false,
"Log code events to the log file without profiling.");
DEFINE_bool(log_gc, false,
"Log heap samples on garbage collection for the hp2ps tool.");
DEFINE_bool(log_handles, false, "Log global handle events.");
DEFINE_bool(log_state_changes, false, "Log state changes.");
DEFINE_bool(log_suspect, false, "Log suspect operations.");
DEFINE_bool(prof, false,
"Log statistical profiling information (implies --log-code).");
DEFINE_bool(log_regexp, false,
"Log regular expression execution.");
DEFINE_bool(sliding_state_window, false,
"Update sliding state window counters.");
DEFINE_string(logfile, "v8.log", "Specify the name of the log file.");
//
// Sliding state window. Updates counters to keep track of the last
// window of kBufferSize states. This is useful to track where we

View File

@ -34,10 +34,6 @@
namespace v8 { namespace internal {
DECLARE_bool(debug_code);
DECLARE_bool(optimize_locals);
// Give alias names to registers
Register cp = { 8 }; // JavaScript context pointer
Register pp = { 10 }; // parameter pointer

View File

@ -35,11 +35,6 @@
namespace v8 { namespace internal {
DECLARE_bool(debug_code);
DEFINE_bool(native_code_counters, false,
"generate extra code for manipulating stats counters");
MacroAssembler::MacroAssembler(void* buffer, int size)
: Assembler(buffer, size),
unresolved_(0),

View File

@ -42,21 +42,8 @@ namespace v8 { namespace internal {
// TODO(1240833): Fix the heap verification code and turn this into a real
// flag.
static const bool FLAG_verify_global_gc = false;
DECLARE_bool(gc_verbose);
#endif // DEBUG
DEFINE_bool(always_compact, false, "Perform compaction on every full GC");
DEFINE_bool(never_compact, false,
"Never perform compaction on full GC - testing only");
DEFINE_bool(cleanup_ics_at_gc, true,
"Flush inline caches prior to mark compact collection.");
DEFINE_bool(cleanup_caches_in_maps_at_gc, true,
"Flush code caches in maps during mark compact cycle.");
DECLARE_bool(gc_global);
// ----------------------------------------------------------------------------
// MarkCompactCollector

View File

@ -38,14 +38,6 @@
#include "platform.h"
#include "serialize.h"
DEFINE_bool(h, false, "print this message");
namespace v8 { namespace internal {
#ifdef ENABLE_LOGGING_AND_PROFILING
DECLARE_bool(log_code);
#endif
} }
// use explicit namespace to avoid clashing with types in namespace v8
namespace i = v8::internal;
using namespace v8;

View File

@ -43,12 +43,6 @@
namespace v8 { namespace internal {
#ifdef DEBUG
DEFINE_bool(trace_normalization,
false,
"prints when objects are turned into dictionaries.");
#endif
// Getters and setters are stored in a fixed array property. These are
// constants for their indices.
const int kGetterIndex = 0;

View File

@ -37,10 +37,6 @@
namespace v8 { namespace internal {
DECLARE_bool(lazy);
DEFINE_bool(allow_natives_syntax, false, "allow natives syntax");
class ParserFactory;
class ParserLog;
class TemporaryScope;

View File

@ -2723,11 +2723,6 @@ static Object* Runtime_NewObject(Arguments args) {
}
#ifdef DEBUG
DEFINE_bool(trace_lazy, false, "trace lazy compilation");
#endif
static Object* Runtime_LazyCompile(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);

View File

@ -826,8 +826,6 @@ void Scope::AllocateNonParameterLocal(Variable* var) {
}
DECLARE_bool(usage_computation);
void Scope::AllocateNonParameterLocals() {
// Each variable occurs exactly once in the locals_ list; all
// variables that have no rewrite yet are non-parameter locals.

View File

@ -41,12 +41,6 @@
namespace v8 { namespace internal {
#ifdef DEBUG
DEFINE_bool(debug_serialization, false,
"write debug information into the snapshot.");
#endif
// Encoding: a RelativeAddress must be able to fit in a pointer:
// it is encoded as an Address with (from MS to LS bits):
// 27 bits identifying a word in the space, in one of three formats:
@ -1021,12 +1015,6 @@ void Serializer::PutHeader() {
}
#ifdef ENABLE_LOGGING_AND_PROFILING
DECLARE_bool(log_code);
DECLARE_string(logfile);
#endif
void Serializer::PutLog() {
#ifdef ENABLE_LOGGING_AND_PROFILING
if (FLAG_log_code) {
@ -1301,10 +1289,6 @@ void Deserializer::VisitRuntimeEntry(RelocInfo* rinfo) {
}
DECLARE_bool(use_ic);
DECLARE_bool(debug_code);
DECLARE_bool(lazy);
void Deserializer::GetFlags() {
reader_.ExpectC('F');
int argc = reader_.GetInt() + 1;

View File

@ -45,9 +45,6 @@ using ::v8::internal::ReadLine;
using ::v8::internal::DeleteArray;
DEFINE_bool(trace_sim, false, "trace simulator execution");
// The Debugger class is used by the simulator while debugging simulated ARM
// code.
class Debugger {
@ -1393,9 +1390,6 @@ void Simulator::InstructionDecode(Instr* instr) {
}
DEFINE_int(stop_sim_at, 0, "Simulator stop after x number of instructions");
//
void Simulator::execute() {
// Get the PC to simulate. Cannot use the accessor here as we need the

View File

@ -33,17 +33,6 @@
namespace v8 { namespace internal {
#ifdef DEBUG
DECLARE_bool(heap_stats);
DEFINE_bool(collect_heap_spill_statistics, false,
"report heap spill statistics along with heap_stats "
"(requires heap_stats)");
#endif
#ifdef ENABLE_LOGGING_AND_PROFILING
DECLARE_bool(log_gc);
#endif
// For contiguous spaces, top should be in the space (or at the end) and limit
// should be the end of the space.
#define ASSERT_SEMISPACE_ALLOCATION_INFO(info, space) \

View File

@ -912,7 +912,6 @@ Object* StubCompiler::CompileCallDebugPrepareStepIn(Code::Flags flags) {
}
DECLARE_bool(print_code_stubs);
Object* StubCompiler::GetCodeWithFlags(Code::Flags flags) {
CodeDesc desc;
masm_.GetCode(&desc);

View File

@ -36,11 +36,6 @@
namespace v8 { namespace internal {
DEFINE_bool(trace_exception, false,
"print stack trace when throwing exceptions");
DEFINE_bool(preallocate_message_memory, false,
"preallocate some memory to build stack traces.");
ThreadLocalTop Top::thread_local_;
Mutex* Top::break_access_ = OS::CreateMutex();
StackFrame::Id Top::break_frame_id_;

View File

@ -33,8 +33,6 @@
namespace v8 { namespace internal {
DEFINE_bool(usage_computation, true, "compute variable usage counts");
// Weight boundaries
static const int MinWeight = 1;
static const int MaxWeight = 1000000;

View File

@ -34,9 +34,6 @@
namespace v8 { namespace internal {
DEFINE_bool(preemption, false,
"activate a 100ms timer that switches between V8 threads");
bool V8::has_been_setup_ = false;
bool V8::has_been_disposed_ = false;

View File

@ -53,7 +53,7 @@
#include "checks.h"
#include "allocation.h"
#include "utils.h"
#include "flags-inl.h"
#include "flags.h"
// Objects & heap
#include "objects.h"

View File

@ -4480,15 +4480,11 @@ void ApiTestFuzzer::Run() {
}
DECLARE_int(prng_seed);
DEFINE_int(prng_seed, 42, "Seed used for threading test randomness");
static unsigned linear_congruential_generator;
void ApiTestFuzzer::Setup(PartOfTest part) {
linear_congruential_generator = FLAG_prng_seed;
linear_congruential_generator = i::FLAG_testing_prng_seed;
fuzzing_ = true;
int start = (part == FIRST_PART) ? 0 : (RegisterThreadedTest::count() >> 1);
int end = (part == FIRST_PART)

View File

@ -54,12 +54,6 @@ using ::v8::internal::StepOut; // From StepAction enum
// Size of temp buffer for formatting small strings.
#define SMALL_STRING_BUFFER_SIZE 80
#ifdef DEBUG
namespace v8 { namespace internal {
DECLARE_bool(verify_heap);
} }
#endif
// --- A d d i t i o n a l C h e c k H e l p e r s

View File

@ -32,61 +32,54 @@
using namespace v8::internal;
DEFINE_bool(bool_flag, true, "bool_flag");
DEFINE_int(int_flag, 13, "int_flag");
DEFINE_float(float_flag, 2.5, "float-flag");
DEFINE_string(string_flag, "Hello, world!", "string-flag");
// This test must be executed first!
TEST(Default) {
CHECK(FLAG_bool_flag);
CHECK_EQ(13, FLAG_int_flag);
CHECK_EQ(2.5, FLAG_float_flag);
CHECK_EQ(0, strcmp(FLAG_string_flag, "Hello, world!"));
CHECK(FLAG_testing_bool_flag);
CHECK_EQ(13, FLAG_testing_int_flag);
CHECK_EQ(2.5, FLAG_testing_float_flag);
CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "Hello, world!"));
}
static void SetFlagsToDefault() {
for (Flag* f = FlagList::list(); f != NULL; f = f->next()) {
f->SetToDefault();
}
FlagList::ResetAllFlags();
TestDefault();
}
TEST(Flags1) {
FlagList::Print(__FILE__, false);
FlagList::Print(NULL, true);
FlagList::PrintHelp();
}
TEST(Flags2) {
SetFlagsToDefault();
int argc = 7;
const char* argv[] = { "Test2", "-nobool-flag", "notaflag", "--int_flag=77",
"-float_flag=.25", "--string_flag", "no way!" };
const char* argv[] = { "Test2", "-notesting-bool-flag", "notaflag",
"--testing_int_flag=77", "-testing_float_flag=.25",
"--testing_string_flag", "no way!" };
CHECK_EQ(0, FlagList::SetFlagsFromCommandLine(&argc,
const_cast<char **>(argv),
false));
CHECK_EQ(7, argc);
CHECK(!FLAG_bool_flag);
CHECK_EQ(77, FLAG_int_flag);
CHECK_EQ(.25, FLAG_float_flag);
CHECK_EQ(0, strcmp(FLAG_string_flag, "no way!"));
CHECK(!FLAG_testing_bool_flag);
CHECK_EQ(77, FLAG_testing_int_flag);
CHECK_EQ(.25, FLAG_testing_float_flag);
CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "no way!"));
}
TEST(Flags2b) {
SetFlagsToDefault();
const char* str =
" -nobool-flag notaflag --int_flag=77 -float_flag=.25 "
"--string_flag no_way! ";
" -notesting-bool-flag notaflag --testing_int_flag=77 "
"-testing_float_flag=.25 "
"--testing_string_flag no_way! ";
CHECK_EQ(0, FlagList::SetFlagsFromString(str, strlen(str)));
CHECK(!FLAG_bool_flag);
CHECK_EQ(77, FLAG_int_flag);
CHECK_EQ(.25, FLAG_float_flag);
CHECK_EQ(0, strcmp(FLAG_string_flag, "no_way!"));
CHECK(!FLAG_testing_bool_flag);
CHECK_EQ(77, FLAG_testing_int_flag);
CHECK_EQ(.25, FLAG_testing_float_flag);
CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "no_way!"));
}
@ -94,36 +87,38 @@ TEST(Flags3) {
SetFlagsToDefault();
int argc = 8;
const char* argv[] =
{ "Test3", "--bool_flag", "notaflag", "--int_flag", "-666",
"--float_flag", "-12E10", "-string-flag=foo-bar" };
{ "Test3", "--testing_bool_flag", "notaflag",
"--testing_int_flag", "-666",
"--testing_float_flag", "-12E10", "-testing-string-flag=foo-bar" };
CHECK_EQ(0, FlagList::SetFlagsFromCommandLine(&argc,
const_cast<char **>(argv),
true));
CHECK_EQ(2, argc);
CHECK(FLAG_bool_flag);
CHECK_EQ(-666, FLAG_int_flag);
CHECK_EQ(-12E10, FLAG_float_flag);
CHECK_EQ(0, strcmp(FLAG_string_flag, "foo-bar"));
CHECK(FLAG_testing_bool_flag);
CHECK_EQ(-666, FLAG_testing_int_flag);
CHECK_EQ(-12E10, FLAG_testing_float_flag);
CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "foo-bar"));
}
TEST(Flags3b) {
SetFlagsToDefault();
const char* str =
"--bool_flag notaflag --int_flag -666 --float_flag -12E10 "
"-string-flag=foo-bar";
"--testing_bool_flag notaflag --testing_int_flag -666 "
"--testing_float_flag -12E10 "
"-testing-string-flag=foo-bar";
CHECK_EQ(0, FlagList::SetFlagsFromString(str, strlen(str)));
CHECK(FLAG_bool_flag);
CHECK_EQ(-666, FLAG_int_flag);
CHECK_EQ(-12E10, FLAG_float_flag);
CHECK_EQ(0, strcmp(FLAG_string_flag, "foo-bar"));
CHECK(FLAG_testing_bool_flag);
CHECK_EQ(-666, FLAG_testing_int_flag);
CHECK_EQ(-12E10, FLAG_testing_float_flag);
CHECK_EQ(0, strcmp(FLAG_testing_string_flag, "foo-bar"));
}
TEST(Flags4) {
SetFlagsToDefault();
int argc = 3;
const char* argv[] = { "Test4", "--bool_flag", "--foo" };
const char* argv[] = { "Test4", "--testing_bool_flag", "--foo" };
CHECK_EQ(0, FlagList::SetFlagsFromCommandLine(&argc,
const_cast<char **>(argv),
true));
@ -133,7 +128,7 @@ TEST(Flags4) {
TEST(Flags4b) {
SetFlagsToDefault();
const char* str = "--bool_flag --foo";
const char* str = "--testing_bool_flag --foo";
CHECK_EQ(2, FlagList::SetFlagsFromString(str, strlen(str)));
}
@ -141,7 +136,7 @@ TEST(Flags4b) {
TEST(Flags5) {
SetFlagsToDefault();
int argc = 2;
const char* argv[] = { "Test5", "--int_flag=\"foobar\"" };
const char* argv[] = { "Test5", "--testing_int_flag=\"foobar\"" };
CHECK_EQ(1, FlagList::SetFlagsFromCommandLine(&argc,
const_cast<char **>(argv),
true));
@ -151,7 +146,7 @@ TEST(Flags5) {
TEST(Flags5b) {
SetFlagsToDefault();
const char* str = " --int_flag=\"foobar\"";
const char* str = " --testing_int_flag=\"foobar\"";
CHECK_EQ(1, FlagList::SetFlagsFromString(str, strlen(str)));
}
@ -159,7 +154,8 @@ TEST(Flags5b) {
TEST(Flags6) {
SetFlagsToDefault();
int argc = 4;
const char* argv[] = { "Test5", "--int-flag", "0", "--float_flag" };
const char* argv[] = { "Test5", "--testing-int-flag", "0",
"--testing_float_flag" };
CHECK_EQ(3, FlagList::SetFlagsFromCommandLine(&argc,
const_cast<char **>(argv),
true));
@ -169,6 +165,6 @@ TEST(Flags6) {
TEST(Flags6b) {
SetFlagsToDefault();
const char* str = " --int-flag 0 --float_flag ";
const char* str = " --testing-int-flag 0 --testing_float_flag ";
CHECK_EQ(3, FlagList::SetFlagsFromString(str, strlen(str)));
}

View File

@ -34,11 +34,6 @@
#include "top.h"
#include "cctest.h"
namespace v8 { namespace internal {
DECLARE_bool(gc_global);
DECLARE_bool(always_compact);
} }
using namespace v8::internal;
static v8::Persistent<v8::Context> env;

View File

@ -40,21 +40,8 @@
#include "snapshot.h"
#include "cctest.h"
namespace v8 { namespace internal {
#ifdef WIN32
DEFINE_string(serialization_file, "C:\\Windows\\Temp\\serdes",
"file in which to serialize heap");
#else
DEFINE_string(serialization_file, "/tmp/serdes",
"file in which to serialize heap");
#endif
DECLARE_bool(debug_serialization);
}} // namespace v8::internal
using namespace v8::internal;
static int local_counters[256];
static int counter_count = 0;
static std::map<std::wstring, int> counter_table;
@ -174,7 +161,7 @@ static void Serialize() {
v8::Persistent<v8::Context> env = v8::Context::New(&extensions);
env->Enter();
Snapshot::WriteToFile(FLAG_serialization_file);
Snapshot::WriteToFile(FLAG_testing_serialization_file);
}
@ -218,7 +205,7 @@ static void Deserialize() {
#ifdef DEBUG
FLAG_debug_serialization = true;
#endif
CHECK(Snapshot::Initialize(FLAG_serialization_file));
CHECK(Snapshot::Initialize(FLAG_testing_serialization_file));
}

View File

@ -224,7 +224,6 @@
897FF1310E719B8F00D62E90 /* execution.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = execution.h; sourceTree = "<group>"; };
897FF1320E719B8F00D62E90 /* factory.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = factory.cc; sourceTree = "<group>"; };
897FF1330E719B8F00D62E90 /* factory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = factory.h; sourceTree = "<group>"; };
897FF1340E719B8F00D62E90 /* flags-inl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "flags-inl.h"; sourceTree = "<group>"; };
897FF1350E719B8F00D62E90 /* flags.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = flags.cc; sourceTree = "<group>"; };
897FF1360E719B8F00D62E90 /* flags.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = flags.h; sourceTree = "<group>"; };
897FF1370E719B8F00D62E90 /* frames-arm.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "frames-arm.cc"; sourceTree = "<group>"; };
@ -486,7 +485,6 @@
897FF1310E719B8F00D62E90 /* execution.h */,
897FF1320E719B8F00D62E90 /* factory.cc */,
897FF1330E719B8F00D62E90 /* factory.h */,
897FF1340E719B8F00D62E90 /* flags-inl.h */,
897FF1350E719B8F00D62E90 /* flags.cc */,
897FF1360E719B8F00D62E90 /* flags.h */,
897FF1370E719B8F00D62E90 /* frames-arm.cc */,