Commit 37a2e324 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Unify kMaxArguments with number of bits used to encode it.

Increase the number of bits by 1 by making Flags unsigned.

BUG=chromium:211741

Review URL: https://chromiumcodereview.appspot.com/12886008

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13964 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent e2cd7aa4
......@@ -3869,8 +3869,9 @@ Code::Flags Code::ComputeFlags(Kind kind,
StubType type,
int argc,
InlineCacheHolderFlag holder) {
ASSERT(argc <= Code::kMaxArguments);
// Compute the bit mask.
int bits = KindField::encode(kind)
unsigned int bits = KindField::encode(kind)
| ICStateField::encode(ic_state)
| TypeField::encode(type)
| ExtraICStateField::encode(extra_ic_state)
......
......@@ -4302,8 +4302,8 @@ class Code: public HeapObject {
// FLAGS_MIN_VALUE and FLAGS_MAX_VALUE are specified to ensure that
// enumeration type has correct value range (see Issue 830 for more details).
enum Flags {
FLAGS_MIN_VALUE = kMinInt,
FLAGS_MAX_VALUE = kMaxInt
FLAGS_MIN_VALUE = 0,
FLAGS_MAX_VALUE = kMaxUInt32
};
#define CODE_KIND_LIST(V) \
......@@ -4784,6 +4784,9 @@ class Code: public HeapObject {
// Signed field cannot be encoded using the BitField class.
static const int kArgumentsCountShift = 17;
static const int kArgumentsCountMask = ~((1 << kArgumentsCountShift) - 1);
static const int kArgumentsBits =
PlatformSmiTagging::kSmiValueSize - Code::kArgumentsCountShift + 1;
static const int kMaxArguments = (1 << kArgumentsBits) - 1;
// This constant should be encodable in an ARM instruction.
static const int kFlagsNotUsedInLookup =
......
......@@ -4201,7 +4201,7 @@ ZoneList<Expression*>* Parser::ParseArguments(bool* ok) {
while (!done) {
Expression* argument = ParseAssignmentExpression(true, CHECK_OK);
result->Add(argument, zone());
if (result->length() > kMaxNumFunctionParameters) {
if (result->length() > Code::kMaxArguments) {
ReportMessageAt(scanner().location(), "too_many_arguments",
Vector<const char*>::empty());
*ok = false;
......@@ -4378,7 +4378,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name,
top_scope_->DeclareParameter(param_name, VAR);
num_parameters++;
if (num_parameters > kMaxNumFunctionParameters) {
if (num_parameters > Code::kMaxArguments) {
ReportMessageAt(scanner().location(), "too_many_parameters",
Vector<const char*>::empty());
*ok = false;
......
......@@ -448,11 +448,6 @@ class Parser {
Vector<Handle<String> > args);
private:
// Limit on number of function parameters is chosen arbitrarily.
// Code::Flags uses only the low 17 bits of num-parameters to
// construct a hashable id, so if more than 2^17 are allowed, this
// should be checked.
static const int kMaxNumFunctionParameters = 32766;
static const int kMaxNumFunctionLocals = 131071; // 2^17-1
enum Mode {
......
......@@ -593,7 +593,7 @@ Handle<Code> StubCache::ComputeCallConstant(int argc,
Handle<Code> code =
compiler.CompileCallConstant(object, holder, name, check, function);
code->set_check_type(check);
ASSERT_EQ(flags, code->flags());
ASSERT(flags == code->flags());
PROFILE(isolate_,
CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), *code, *name));
GDBJIT(AddCode(GDBJITInterface::CALL_IC, *name, *code));
......@@ -633,7 +633,7 @@ Handle<Code> StubCache::ComputeCallField(int argc,
Handle<Code> code =
compiler.CompileCallField(Handle<JSObject>::cast(object),
holder, index, name);
ASSERT_EQ(flags, code->flags());
ASSERT(flags == code->flags());
PROFILE(isolate_,
CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), *code, *name));
GDBJIT(AddCode(GDBJITInterface::CALL_IC, *name, *code));
......@@ -672,7 +672,7 @@ Handle<Code> StubCache::ComputeCallInterceptor(int argc,
Handle<Code> code =
compiler.CompileCallInterceptor(Handle<JSObject>::cast(object),
holder, name);
ASSERT_EQ(flags, code->flags());
ASSERT(flags == code->flags());
PROFILE(isolate(),
CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), *code, *name));
GDBJIT(AddCode(GDBJITInterface::CALL_IC, *name, *code));
......@@ -702,7 +702,7 @@ Handle<Code> StubCache::ComputeCallGlobal(int argc,
CallStubCompiler compiler(isolate(), argc, kind, extra_state, cache_holder);
Handle<Code> code =
compiler.CompileCallGlobal(receiver, holder, cell, function, name);
ASSERT_EQ(flags, code->flags());
ASSERT(flags == code->flags());
PROFILE(isolate(),
CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), *code, *name));
GDBJIT(AddCode(GDBJITInterface::CALL_IC, *name, *code));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment