Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: src/ast/ast.cc

Issue 2646333002: [parser] Delete has_seen_proto in ObjectLiteral. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ast/ast.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/ast/ast.h" 5 #include "src/ast/ast.h"
6 6
7 #include <cmath> // For isfinite. 7 #include <cmath> // For isfinite.
8 8
9 #include "src/ast/compile-time-value.h" 9 #include "src/ast/compile-time-value.h"
10 #include "src/ast/prettyprinter.h" 10 #include "src/ast/prettyprinter.h"
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 513
514 int position = 0; 514 int position = 0;
515 // Accumulate the value in local variables and store it at the end. 515 // Accumulate the value in local variables and store it at the end.
516 bool is_simple = true; 516 bool is_simple = true;
517 int depth_acc = 1; 517 int depth_acc = 1;
518 uint32_t max_element_index = 0; 518 uint32_t max_element_index = 0;
519 uint32_t elements = 0; 519 uint32_t elements = 0;
520 for (int i = 0; i < properties()->length(); i++) { 520 for (int i = 0; i < properties()->length(); i++) {
521 ObjectLiteral::Property* property = properties()->at(i); 521 ObjectLiteral::Property* property = properties()->at(i);
522 if (!IsBoilerplateProperty(property)) { 522 if (!IsBoilerplateProperty(property)) {
523 DCHECK(has_seen_proto());
524 is_simple = false; 523 is_simple = false;
525 continue; 524 continue;
526 } 525 }
527 526
528 if (static_cast<uint32_t>(position) == boilerplate_properties_ * 2) { 527 if (static_cast<uint32_t>(position) == boilerplate_properties_ * 2) {
529 DCHECK(property->is_computed_name()); 528 DCHECK(property->is_computed_name());
530 is_simple = false; 529 is_simple = false;
531 break; 530 break;
532 } 531 }
533 DCHECK(!property->is_computed_name()); 532 DCHECK(!property->is_computed_name());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 bit_field_ = HasElementsField::update(bit_field_, elements > 0); 576 bit_field_ = HasElementsField::update(bit_field_, elements > 0);
578 577
579 set_is_simple(is_simple); 578 set_is_simple(is_simple);
580 set_depth(depth_acc); 579 set_depth(depth_acc);
581 } 580 }
582 581
583 void ObjectLiteral::BuildConstantProperties(Isolate* isolate) { 582 void ObjectLiteral::BuildConstantProperties(Isolate* isolate) {
584 if (!constant_properties_.is_null()) return; 583 if (!constant_properties_.is_null()) return;
585 584
586 int index_keys = 0; 585 int index_keys = 0;
586 bool has_seen_proto = false;
587 for (int i = 0; i < properties()->length(); i++) { 587 for (int i = 0; i < properties()->length(); i++) {
588 ObjectLiteral::Property* property = properties()->at(i); 588 ObjectLiteral::Property* property = properties()->at(i);
589 if (!IsBoilerplateProperty(property) || property->is_computed_name()) { 589 if (!IsBoilerplateProperty(property)) {
590 has_seen_proto = true;
591 continue;
592 }
593 if (property->is_computed_name()) {
590 continue; 594 continue;
591 } 595 }
592 596
593 Handle<Object> key = property->key()->AsLiteral()->value(); 597 Handle<Object> key = property->key()->AsLiteral()->value();
594 598
595 uint32_t element_index = 0; 599 uint32_t element_index = 0;
596 if (key->ToArrayIndex(&element_index)) { 600 if (key->ToArrayIndex(&element_index)) {
597 index_keys++; 601 index_keys++;
598 } 602 }
599 } 603 }
600 604
601 Handle<BoilerplateDescription> constant_properties = 605 Handle<BoilerplateDescription> constant_properties =
602 isolate->factory()->NewBoilerplateDescription( 606 isolate->factory()->NewBoilerplateDescription(
603 boilerplate_properties_, properties()->length() - index_keys, 607 boilerplate_properties_, properties()->length() - index_keys,
604 has_seen_proto()); 608 has_seen_proto);
605 609
606 int position = 0; 610 int position = 0;
607 for (int i = 0; i < properties()->length(); i++) { 611 for (int i = 0; i < properties()->length(); i++) {
608 ObjectLiteral::Property* property = properties()->at(i); 612 ObjectLiteral::Property* property = properties()->at(i);
609 if (!IsBoilerplateProperty(property)) { 613 if (!IsBoilerplateProperty(property)) {
610 continue; 614 continue;
611 } 615 }
612 616
613 if (static_cast<uint32_t>(position) == boilerplate_properties_ * 2) { 617 if (static_cast<uint32_t>(position) == boilerplate_properties_ * 2) {
614 DCHECK(property->is_computed_name()); 618 DCHECK(property->is_computed_name());
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 // static 1058 // static
1055 bool Literal::Match(void* literal1, void* literal2) { 1059 bool Literal::Match(void* literal1, void* literal2) {
1056 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); 1060 const AstValue* x = static_cast<Literal*>(literal1)->raw_value();
1057 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); 1061 const AstValue* y = static_cast<Literal*>(literal2)->raw_value();
1058 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || 1062 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) ||
1059 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); 1063 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber());
1060 } 1064 }
1061 1065
1062 } // namespace internal 1066 } // namespace internal
1063 } // namespace v8 1067 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698