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

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

Issue 2302643002: Split the AST representation of class properties from object properties (Closed)
Patch Set: rebase Created 4 years, 3 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-literal-reindexer.cc ('k') | src/ast/ast-traversal-visitor.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-numbering.h" 5 #include "src/ast/ast-numbering.h"
6 6
7 #include "src/ast/ast.h" 7 #include "src/ast/ast.h"
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 21 matching lines...) Expand all
32 AST_NODE_LIST(DEFINE_VISIT) 32 AST_NODE_LIST(DEFINE_VISIT)
33 #undef DEFINE_VISIT 33 #undef DEFINE_VISIT
34 34
35 void VisitVariableProxyReference(VariableProxy* node); 35 void VisitVariableProxyReference(VariableProxy* node);
36 void VisitPropertyReference(Property* node); 36 void VisitPropertyReference(Property* node);
37 void VisitReference(Expression* expr); 37 void VisitReference(Expression* expr);
38 38
39 void VisitStatements(ZoneList<Statement*>* statements); 39 void VisitStatements(ZoneList<Statement*>* statements);
40 void VisitDeclarations(ZoneList<Declaration*>* declarations); 40 void VisitDeclarations(ZoneList<Declaration*>* declarations);
41 void VisitArguments(ZoneList<Expression*>* arguments); 41 void VisitArguments(ZoneList<Expression*>* arguments);
42 void VisitObjectLiteralProperty(ObjectLiteralProperty* property); 42 void VisitLiteralProperty(LiteralProperty* property);
43 43
44 int ReserveIdRange(int n) { 44 int ReserveIdRange(int n) {
45 int tmp = next_id_; 45 int tmp = next_id_;
46 next_id_ += n; 46 next_id_ += n;
47 return tmp; 47 return tmp;
48 } 48 }
49 49
50 void IncrementNodeCount() { properties_.add_node_count(1); } 50 void IncrementNodeCount() { properties_.add_node_count(1); }
51 void DisableSelfOptimization() { 51 void DisableSelfOptimization() {
52 properties_.flags() |= AstProperties::kDontSelfOptimize; 52 properties_.flags() |= AstProperties::kDontSelfOptimize;
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 void AstNumberingVisitor::VisitClassLiteral(ClassLiteral* node) { 457 void AstNumberingVisitor::VisitClassLiteral(ClassLiteral* node) {
458 IncrementNodeCount(); 458 IncrementNodeCount();
459 DisableCrankshaft(kClassLiteral); 459 DisableCrankshaft(kClassLiteral);
460 node->set_base_id(ReserveIdRange(node->num_ids())); 460 node->set_base_id(ReserveIdRange(node->num_ids()));
461 if (node->extends()) Visit(node->extends()); 461 if (node->extends()) Visit(node->extends());
462 if (node->constructor()) Visit(node->constructor()); 462 if (node->constructor()) Visit(node->constructor());
463 if (node->class_variable_proxy()) { 463 if (node->class_variable_proxy()) {
464 VisitVariableProxy(node->class_variable_proxy()); 464 VisitVariableProxy(node->class_variable_proxy());
465 } 465 }
466 for (int i = 0; i < node->properties()->length(); i++) { 466 for (int i = 0; i < node->properties()->length(); i++) {
467 VisitObjectLiteralProperty(node->properties()->at(i)); 467 VisitLiteralProperty(node->properties()->at(i));
468 } 468 }
469 ReserveFeedbackSlots(node); 469 ReserveFeedbackSlots(node);
470 } 470 }
471 471
472 472
473 void AstNumberingVisitor::VisitObjectLiteral(ObjectLiteral* node) { 473 void AstNumberingVisitor::VisitObjectLiteral(ObjectLiteral* node) {
474 IncrementNodeCount(); 474 IncrementNodeCount();
475 node->set_base_id(ReserveIdRange(node->num_ids())); 475 node->set_base_id(ReserveIdRange(node->num_ids()));
476 for (int i = 0; i < node->properties()->length(); i++) { 476 for (int i = 0; i < node->properties()->length(); i++) {
477 VisitObjectLiteralProperty(node->properties()->at(i)); 477 VisitLiteralProperty(node->properties()->at(i));
478 } 478 }
479 node->BuildConstantProperties(isolate_); 479 node->BuildConstantProperties(isolate_);
480 // Mark all computed expressions that are bound to a key that 480 // Mark all computed expressions that are bound to a key that
481 // is shadowed by a later occurrence of the same key. For the 481 // is shadowed by a later occurrence of the same key. For the
482 // marked expressions, no store code will be is emitted. 482 // marked expressions, no store code will be is emitted.
483 node->CalculateEmitStore(zone_); 483 node->CalculateEmitStore(zone_);
484 ReserveFeedbackSlots(node); 484 ReserveFeedbackSlots(node);
485 } 485 }
486 486
487 487 void AstNumberingVisitor::VisitLiteralProperty(LiteralProperty* node) {
488 void AstNumberingVisitor::VisitObjectLiteralProperty(
489 ObjectLiteralProperty* node) {
490 if (node->is_computed_name()) DisableCrankshaft(kComputedPropertyName); 488 if (node->is_computed_name()) DisableCrankshaft(kComputedPropertyName);
491 Visit(node->key()); 489 Visit(node->key());
492 Visit(node->value()); 490 Visit(node->value());
493 } 491 }
494 492
495
496 void AstNumberingVisitor::VisitArrayLiteral(ArrayLiteral* node) { 493 void AstNumberingVisitor::VisitArrayLiteral(ArrayLiteral* node) {
497 IncrementNodeCount(); 494 IncrementNodeCount();
498 node->set_base_id(ReserveIdRange(node->num_ids())); 495 node->set_base_id(ReserveIdRange(node->num_ids()));
499 for (int i = 0; i < node->values()->length(); i++) { 496 for (int i = 0; i < node->values()->length(); i++) {
500 Visit(node->values()->at(i)); 497 Visit(node->values()->at(i));
501 } 498 }
502 node->BuildConstantElements(isolate_); 499 node->BuildConstantElements(isolate_);
503 ReserveFeedbackSlots(node); 500 ReserveFeedbackSlots(node);
504 } 501 }
505 502
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 } 587 }
591 588
592 589
593 bool AstNumbering::Renumber(Isolate* isolate, Zone* zone, 590 bool AstNumbering::Renumber(Isolate* isolate, Zone* zone,
594 FunctionLiteral* function) { 591 FunctionLiteral* function) {
595 AstNumberingVisitor visitor(isolate, zone); 592 AstNumberingVisitor visitor(isolate, zone);
596 return visitor.Renumber(function); 593 return visitor.Renumber(function);
597 } 594 }
598 } // namespace internal 595 } // namespace internal
599 } // namespace v8 596 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast-literal-reindexer.cc ('k') | src/ast/ast-traversal-visitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698