Skip to content

Commit ac73189

Browse files
Remove a redundant field in the FunctionLiteral class. The boolean
contains_array_literal_ implies materialized_literal_count_ > 0, and we appear not to need to know about array literals specifically. Review URL: http://codereview.chromium.org/272043 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3055 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
1 parent 4ddc771 commit ac73189

File tree

7 files changed

+6
-39
lines changed

7 files changed

+6
-39
lines changed

src/ast.h

-4
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,6 @@ class FunctionLiteral: public Expression {
12541254
Scope* scope,
12551255
ZoneList<Statement*>* body,
12561256
int materialized_literal_count,
1257-
bool contains_array_literal,
12581257
int expected_property_count,
12591258
bool has_only_this_property_assignments,
12601259
bool has_only_simple_this_property_assignments,
@@ -1267,7 +1266,6 @@ class FunctionLiteral: public Expression {
12671266
scope_(scope),
12681267
body_(body),
12691268
materialized_literal_count_(materialized_literal_count),
1270-
contains_array_literal_(contains_array_literal),
12711269
expected_property_count_(expected_property_count),
12721270
has_only_this_property_assignments_(has_only_this_property_assignments),
12731271
has_only_simple_this_property_assignments_(
@@ -1300,7 +1298,6 @@ class FunctionLiteral: public Expression {
13001298
bool is_expression() const { return is_expression_; }
13011299

13021300
int materialized_literal_count() { return materialized_literal_count_; }
1303-
bool contains_array_literal() { return contains_array_literal_; }
13041301
int expected_property_count() { return expected_property_count_; }
13051302
bool has_only_this_property_assignments() {
13061303
return has_only_this_property_assignments_;
@@ -1335,7 +1332,6 @@ class FunctionLiteral: public Expression {
13351332
Scope* scope_;
13361333
ZoneList<Statement*>* body_;
13371334
int materialized_literal_count_;
1338-
bool contains_array_literal_;
13391335
int expected_property_count_;
13401336
bool has_only_this_property_assignments_;
13411337
bool has_only_simple_this_property_assignments_;

src/codegen.cc

-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ Handle<JSFunction> CodeGenerator::BuildBoilerplate(FunctionLiteral* node) {
322322
Handle<JSFunction> function =
323323
Factory::NewFunctionBoilerplate(node->name(),
324324
node->materialized_literal_count(),
325-
node->contains_array_literal(),
326325
code);
327326
CodeGenerator::SetFunctionInfo(function, node, false, script_);
328327

src/compiler.cc

-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ static Handle<JSFunction> MakeFunction(bool is_global,
197197
Handle<JSFunction> fun =
198198
Factory::NewFunctionBoilerplate(lit->name(),
199199
lit->materialized_literal_count(),
200-
lit->contains_array_literal(),
201200
code);
202201

203202
ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position());

src/factory.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -477,15 +477,14 @@ Handle<JSFunction> Factory::NewFunction(Handle<String> name,
477477

478478
Handle<JSFunction> Factory::NewFunctionBoilerplate(Handle<String> name,
479479
int number_of_literals,
480-
bool contains_array_literal,
481480
Handle<Code> code) {
482481
Handle<JSFunction> function = NewFunctionBoilerplate(name);
483482
function->set_code(*code);
484483
int literals_array_size = number_of_literals;
485484
// If the function contains object, regexp or array literals,
486485
// allocate extra space for a literals array prefix containing the
487486
// object, regexp and array constructor functions.
488-
if (number_of_literals > 0 || contains_array_literal) {
487+
if (number_of_literals > 0) {
489488
literals_array_size += JSFunction::kLiteralsPrefixSize;
490489
}
491490
Handle<FixedArray> literals =

src/factory.h

-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ class Factory : public AllStatic {
264264

265265
static Handle<JSFunction> NewFunctionBoilerplate(Handle<String> name,
266266
int number_of_literals,
267-
bool contains_array_literal,
268267
Handle<Code> code);
269268

270269
static Handle<JSFunction> NewFunctionBoilerplate(Handle<String> name);

src/parser.cc

+4-21
Original file line numberDiff line numberDiff line change
@@ -675,9 +675,6 @@ class TemporaryScope BASE_EMBEDDED {
675675
}
676676
int materialized_literal_count() { return materialized_literal_count_; }
677677

678-
void set_contains_array_literal() { contains_array_literal_ = true; }
679-
bool contains_array_literal() { return contains_array_literal_; }
680-
681678
void SetThisPropertyAssignmentInfo(
682679
bool only_this_property_assignments,
683680
bool only_simple_this_property_assignments,
@@ -700,17 +697,11 @@ class TemporaryScope BASE_EMBEDDED {
700697
void AddProperty() { expected_property_count_++; }
701698
int expected_property_count() { return expected_property_count_; }
702699
private:
703-
// Captures the number of nodes that need materialization in the
704-
// function. regexp literals, and boilerplate for object literals.
700+
// Captures the number of literals that need materialization in the
701+
// function. Includes regexp literals, and boilerplate for object
702+
// and array literals.
705703
int materialized_literal_count_;
706704

707-
// Captures whether or not the function contains array literals. If
708-
// the function contains array literals, we have to allocate space
709-
// for the array constructor in the literals array of the function.
710-
// This array constructor is used when creating the actual array
711-
// literals.
712-
bool contains_array_literal_;
713-
714705
// Properties count estimation.
715706
int expected_property_count_;
716707

@@ -728,7 +719,6 @@ class TemporaryScope BASE_EMBEDDED {
728719

729720
TemporaryScope::TemporaryScope(Parser* parser)
730721
: materialized_literal_count_(0),
731-
contains_array_literal_(false),
732722
expected_property_count_(0),
733723
only_this_property_assignments_(false),
734724
only_simple_this_property_assignments_(false),
@@ -1236,7 +1226,6 @@ FunctionLiteral* Parser::ParseProgram(Handle<String> source,
12361226
top_scope_,
12371227
body.elements(),
12381228
temp_scope.materialized_literal_count(),
1239-
temp_scope.contains_array_literal(),
12401229
temp_scope.expected_property_count(),
12411230
temp_scope.only_this_property_assignments(),
12421231
temp_scope.only_simple_this_property_assignments(),
@@ -1903,7 +1892,7 @@ Statement* Parser::ParseNativeDeclaration(bool* ok) {
19031892
const int literals = fun->NumberOfLiterals();
19041893
Handle<Code> code = Handle<Code>(fun->shared()->code());
19051894
Handle<JSFunction> boilerplate =
1906-
Factory::NewFunctionBoilerplate(name, literals, false, code);
1895+
Factory::NewFunctionBoilerplate(name, literals, code);
19071896

19081897
// Copy the function data to the boilerplate. Used by
19091898
// builtins.cc:HandleApiCall to perform argument type checks and to
@@ -3306,7 +3295,6 @@ Expression* Parser::ParseArrayLiteral(bool* ok) {
33063295
Expect(Token::RBRACK, CHECK_OK);
33073296

33083297
// Update the scope information before the pre-parsing bailout.
3309-
temp_scope_->set_contains_array_literal();
33103298
int literal_index = temp_scope_->NextMaterializedLiteralIndex();
33113299

33123300
if (is_pre_parsing_) return NULL;
@@ -3636,7 +3624,6 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> var_name,
36363624

36373625
int materialized_literal_count;
36383626
int expected_property_count;
3639-
bool contains_array_literal;
36403627
bool only_this_property_assignments;
36413628
bool only_simple_this_property_assignments;
36423629
Handle<FixedArray> this_property_assignments;
@@ -3650,12 +3637,10 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> var_name,
36503637
only_this_property_assignments = false;
36513638
only_simple_this_property_assignments = false;
36523639
this_property_assignments = Factory::empty_fixed_array();
3653-
contains_array_literal = entry.contains_array_literal();
36543640
} else {
36553641
ParseSourceElements(&body, Token::RBRACE, CHECK_OK);
36563642
materialized_literal_count = temp_scope.materialized_literal_count();
36573643
expected_property_count = temp_scope.expected_property_count();
3658-
contains_array_literal = temp_scope.contains_array_literal();
36593644
only_this_property_assignments =
36603645
temp_scope.only_this_property_assignments();
36613646
only_simple_this_property_assignments =
@@ -3671,15 +3656,13 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> var_name,
36713656
entry.set_end_pos(end_pos);
36723657
entry.set_literal_count(materialized_literal_count);
36733658
entry.set_property_count(expected_property_count);
3674-
entry.set_contains_array_literal(contains_array_literal);
36753659
}
36763660

36773661
FunctionLiteral* function_literal =
36783662
NEW(FunctionLiteral(name,
36793663
top_scope_,
36803664
body.elements(),
36813665
materialized_literal_count,
3682-
contains_array_literal,
36833666
expected_property_count,
36843667
only_this_property_assignments,
36853668
only_simple_this_property_assignments,

src/parser.h

+1-9
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,16 @@ class FunctionEntry BASE_EMBEDDED {
7070
int property_count() { return backing_[kPropertyCountOffset]; }
7171
void set_property_count(int value) { backing_[kPropertyCountOffset] = value; }
7272

73-
bool contains_array_literal() {
74-
return backing_[kContainsArrayLiteralOffset] != 0;
75-
}
76-
void set_contains_array_literal(bool value) {
77-
backing_[kContainsArrayLiteralOffset] = value ? 1 : 0;
78-
}
79-
8073
bool is_valid() { return backing_.length() > 0; }
8174

82-
static const int kSize = 5;
75+
static const int kSize = 4;
8376

8477
private:
8578
Vector<unsigned> backing_;
8679
static const int kStartPosOffset = 0;
8780
static const int kEndPosOffset = 1;
8881
static const int kLiteralCountOffset = 2;
8982
static const int kPropertyCountOffset = 3;
90-
static const int kContainsArrayLiteralOffset = 4;
9183
};
9284

9385

0 commit comments

Comments
 (0)