| Index: src/parser.cc
|
| ===================================================================
|
| --- src/parser.cc (revision 3271)
|
| +++ src/parser.cc (working copy)
|
| @@ -676,17 +676,12 @@
|
| int materialized_literal_count() { return materialized_literal_count_; }
|
|
|
| void SetThisPropertyAssignmentInfo(
|
| - bool only_this_property_assignments,
|
| bool only_simple_this_property_assignments,
|
| Handle<FixedArray> this_property_assignments) {
|
| - only_this_property_assignments_ = only_this_property_assignments;
|
| only_simple_this_property_assignments_ =
|
| only_simple_this_property_assignments;
|
| this_property_assignments_ = this_property_assignments;
|
| }
|
| - bool only_this_property_assignments() {
|
| - return only_this_property_assignments_;
|
| - }
|
| bool only_simple_this_property_assignments() {
|
| return only_simple_this_property_assignments_;
|
| }
|
| @@ -705,7 +700,6 @@
|
| // Properties count estimation.
|
| int expected_property_count_;
|
|
|
| - bool only_this_property_assignments_;
|
| bool only_simple_this_property_assignments_;
|
| Handle<FixedArray> this_property_assignments_;
|
|
|
| @@ -720,7 +714,6 @@
|
| TemporaryScope::TemporaryScope(Parser* parser)
|
| : materialized_literal_count_(0),
|
| expected_property_count_(0),
|
| - only_this_property_assignments_(false),
|
| only_simple_this_property_assignments_(false),
|
| this_property_assignments_(Factory::empty_fixed_array()),
|
| parser_(parser),
|
| @@ -1227,7 +1220,6 @@
|
| body.elements(),
|
| temp_scope.materialized_literal_count(),
|
| temp_scope.expected_property_count(),
|
| - temp_scope.only_this_property_assignments(),
|
| temp_scope.only_simple_this_property_assignments(),
|
| temp_scope.this_property_assignments(),
|
| 0,
|
| @@ -1441,16 +1433,15 @@
|
| class ThisNamedPropertyAssigmentFinder : public ParserFinder {
|
| public:
|
| ThisNamedPropertyAssigmentFinder()
|
| - : only_this_property_assignments_(true),
|
| - only_simple_this_property_assignments_(true),
|
| + : only_simple_this_property_assignments_(true),
|
| names_(NULL),
|
| assigned_arguments_(NULL),
|
| assigned_constants_(NULL) {}
|
|
|
| void Update(Scope* scope, Statement* stat) {
|
| - // Bail out if function already has non this property assignment
|
| - // statements.
|
| - if (!only_this_property_assignments_) {
|
| + // Bail out if function already has property assignment that are
|
| + // not simple this property assignments.
|
| + if (!only_simple_this_property_assignments_) {
|
| return;
|
| }
|
|
|
| @@ -1459,16 +1450,10 @@
|
| if (IsThisPropertyAssignment(assignment)) {
|
| HandleThisPropertyAssignment(scope, assignment);
|
| } else {
|
| - only_this_property_assignments_ = false;
|
| only_simple_this_property_assignments_ = false;
|
| }
|
| }
|
|
|
| - // Returns whether only statements of the form this.x = ...; was encountered.
|
| - bool only_this_property_assignments() {
|
| - return only_this_property_assignments_;
|
| - }
|
| -
|
| // Returns whether only statements of the form this.x = y; where y is either a
|
| // constant or a function argument was encountered.
|
| bool only_simple_this_property_assignments() {
|
| @@ -1524,28 +1509,24 @@
|
| // Constant assigned.
|
| Literal* literal = assignment->value()->AsLiteral();
|
| AssignmentFromConstant(key, literal->handle());
|
| + return;
|
| } else if (assignment->value()->AsVariableProxy() != NULL) {
|
| // Variable assigned.
|
| Handle<String> name =
|
| assignment->value()->AsVariableProxy()->name();
|
| // Check whether the variable assigned matches an argument name.
|
| - int index = -1;
|
| for (int i = 0; i < scope->num_parameters(); i++) {
|
| if (*scope->parameter(i)->name() == *name) {
|
| // Assigned from function argument.
|
| - index = i;
|
| - break;
|
| + AssignmentFromParameter(key, i);
|
| + return;
|
| }
|
| }
|
| - if (index != -1) {
|
| - AssignmentFromParameter(key, index);
|
| - } else {
|
| - AssignmentFromSomethingElse(key);
|
| - }
|
| - } else {
|
| - AssignmentFromSomethingElse(key);
|
| }
|
| }
|
| + // It is not a simple "this.x = value;" assignment with a constant
|
| + // or parameter value.
|
| + AssignmentFromSomethingElse();
|
| }
|
|
|
| void AssignmentFromParameter(Handle<String> name, int index) {
|
| @@ -1562,12 +1543,7 @@
|
| assigned_constants_->Add(value);
|
| }
|
|
|
| - void AssignmentFromSomethingElse(Handle<String> name) {
|
| - EnsureAllocation();
|
| - names_->Add(name);
|
| - assigned_arguments_->Add(-1);
|
| - assigned_constants_->Add(Factory::undefined_value());
|
| -
|
| + void AssignmentFromSomethingElse() {
|
| // The this assignment is not a simple one.
|
| only_simple_this_property_assignments_ = false;
|
| }
|
| @@ -1582,7 +1558,6 @@
|
| }
|
| }
|
|
|
| - bool only_this_property_assignments_;
|
| bool only_simple_this_property_assignments_;
|
| ZoneStringList* names_;
|
| ZoneList<int>* assigned_arguments_;
|
| @@ -1623,11 +1598,11 @@
|
|
|
| // Propagate the collected information on this property assignments.
|
| if (top_scope_->is_function_scope()) {
|
| - if (this_property_assignment_finder.only_this_property_assignments()) {
|
| + bool only_simple_this_property_assignments =
|
| + this_property_assignment_finder.only_simple_this_property_assignments();
|
| + if (only_simple_this_property_assignments) {
|
| temp_scope_->SetThisPropertyAssignmentInfo(
|
| - this_property_assignment_finder.only_this_property_assignments(),
|
| - this_property_assignment_finder.
|
| - only_simple_this_property_assignments(),
|
| + only_simple_this_property_assignments,
|
| this_property_assignment_finder.GetThisPropertyAssignments());
|
| }
|
| }
|
| @@ -3624,7 +3599,6 @@
|
|
|
| int materialized_literal_count;
|
| int expected_property_count;
|
| - bool only_this_property_assignments;
|
| bool only_simple_this_property_assignments;
|
| Handle<FixedArray> this_property_assignments;
|
| if (is_lazily_compiled && pre_data() != NULL) {
|
| @@ -3634,15 +3608,12 @@
|
| scanner_.SeekForward(end_pos);
|
| materialized_literal_count = entry.literal_count();
|
| expected_property_count = entry.property_count();
|
| - only_this_property_assignments = false;
|
| only_simple_this_property_assignments = false;
|
| this_property_assignments = Factory::empty_fixed_array();
|
| } else {
|
| ParseSourceElements(&body, Token::RBRACE, CHECK_OK);
|
| materialized_literal_count = temp_scope.materialized_literal_count();
|
| expected_property_count = temp_scope.expected_property_count();
|
| - only_this_property_assignments =
|
| - temp_scope.only_this_property_assignments();
|
| only_simple_this_property_assignments =
|
| temp_scope.only_simple_this_property_assignments();
|
| this_property_assignments = temp_scope.this_property_assignments();
|
| @@ -3664,7 +3635,6 @@
|
| body.elements(),
|
| materialized_literal_count,
|
| expected_property_count,
|
| - only_this_property_assignments,
|
| only_simple_this_property_assignments,
|
| this_property_assignments,
|
| num_parameters,
|
|
|