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

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

Issue 2126233002: Devirtualize AstNode and subclasses, except for visiting-related methods. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: And call again Created 4 years, 5 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 | « no previous file | src/ast/ast.cc » ('j') | src/ast/ast.cc » ('J')
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 #ifndef V8_AST_AST_H_ 5 #ifndef V8_AST_AST_H_
6 #define V8_AST_AST_H_ 6 #define V8_AST_AST_H_
7 7
8 #include "src/ast/ast-value-factory.h" 8 #include "src/ast/ast-value-factory.h"
9 #include "src/ast/modules.h" 9 #include "src/ast/modules.h"
10 #include "src/ast/variables.h" 10 #include "src/ast/variables.h"
(...skipping 24 matching lines...) Expand all
35 35
36 // ---------------------------------------------------------------------------- 36 // ----------------------------------------------------------------------------
37 // Nodes of the abstract syntax tree. Only concrete classes are 37 // Nodes of the abstract syntax tree. Only concrete classes are
38 // enumerated here. 38 // enumerated here.
39 39
40 #define DECLARATION_NODE_LIST(V) \ 40 #define DECLARATION_NODE_LIST(V) \
41 V(VariableDeclaration) \ 41 V(VariableDeclaration) \
42 V(FunctionDeclaration) \ 42 V(FunctionDeclaration) \
43 V(ImportDeclaration) 43 V(ImportDeclaration)
44 44
45 #define ITERATION_NODE_LIST(V) \
46 V(DoWhileStatement) \
47 V(WhileStatement) \
48 V(ForStatement) \
49 V(ForInStatement) \
50 V(ForOfStatement)
51
52 #define BREAKABLE_NODE_LIST(V) \
53 V(Block) \
54 V(SwitchStatement)
55
45 #define STATEMENT_NODE_LIST(V) \ 56 #define STATEMENT_NODE_LIST(V) \
46 V(Block) \ 57 ITERATION_NODE_LIST(V) \
58 BREAKABLE_NODE_LIST(V) \
47 V(ExpressionStatement) \ 59 V(ExpressionStatement) \
48 V(EmptyStatement) \ 60 V(EmptyStatement) \
49 V(SloppyBlockFunctionStatement) \ 61 V(SloppyBlockFunctionStatement) \
50 V(IfStatement) \ 62 V(IfStatement) \
51 V(ContinueStatement) \ 63 V(ContinueStatement) \
52 V(BreakStatement) \ 64 V(BreakStatement) \
53 V(ReturnStatement) \ 65 V(ReturnStatement) \
54 V(WithStatement) \ 66 V(WithStatement) \
55 V(SwitchStatement) \
56 V(DoWhileStatement) \
57 V(WhileStatement) \
58 V(ForStatement) \
59 V(ForInStatement) \
60 V(ForOfStatement) \
61 V(TryCatchStatement) \ 67 V(TryCatchStatement) \
62 V(TryFinallyStatement) \ 68 V(TryFinallyStatement) \
63 V(DebuggerStatement) 69 V(DebuggerStatement)
64 70
71 #define LITERAL_NODE_LIST(V) \
72 V(RegExpLiteral) \
73 V(ObjectLiteral) \
74 V(ArrayLiteral)
75
76 #define PROPERTY_NODE_LIST(V) \
77 V(Assignment) \
78 V(CountOperation) \
79 V(Property)
80
81 #define CALL_NODE_LIST(V) \
82 V(Call) \
83 V(CallNew)
84
65 #define EXPRESSION_NODE_LIST(V) \ 85 #define EXPRESSION_NODE_LIST(V) \
86 LITERAL_NODE_LIST(V) \
87 PROPERTY_NODE_LIST(V) \
88 CALL_NODE_LIST(V) \
66 V(FunctionLiteral) \ 89 V(FunctionLiteral) \
67 V(ClassLiteral) \ 90 V(ClassLiteral) \
68 V(NativeFunctionLiteral) \ 91 V(NativeFunctionLiteral) \
69 V(Conditional) \ 92 V(Conditional) \
70 V(VariableProxy) \ 93 V(VariableProxy) \
71 V(Literal) \ 94 V(Literal) \
72 V(RegExpLiteral) \
73 V(ObjectLiteral) \
74 V(ArrayLiteral) \
75 V(Assignment) \
76 V(Yield) \ 95 V(Yield) \
77 V(Throw) \ 96 V(Throw) \
78 V(Property) \
79 V(Call) \
80 V(CallNew) \
81 V(CallRuntime) \ 97 V(CallRuntime) \
82 V(UnaryOperation) \ 98 V(UnaryOperation) \
83 V(CountOperation) \
84 V(BinaryOperation) \ 99 V(BinaryOperation) \
85 V(CompareOperation) \ 100 V(CompareOperation) \
86 V(Spread) \ 101 V(Spread) \
87 V(ThisFunction) \ 102 V(ThisFunction) \
88 V(SuperPropertyReference) \ 103 V(SuperPropertyReference) \
89 V(SuperCallReference) \ 104 V(SuperCallReference) \
90 V(CaseClause) \ 105 V(CaseClause) \
91 V(EmptyParentheses) \ 106 V(EmptyParentheses) \
92 V(DoExpression) \ 107 V(DoExpression) \
93 V(RewritableExpression) 108 V(RewritableExpression)
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 #endif // DEBUG 217 #endif // DEBUG
203 218
204 // Type testing & conversion functions overridden by concrete subclasses. 219 // Type testing & conversion functions overridden by concrete subclasses.
205 #define DECLARE_NODE_FUNCTIONS(type) \ 220 #define DECLARE_NODE_FUNCTIONS(type) \
206 V8_INLINE bool Is##type() const; \ 221 V8_INLINE bool Is##type() const; \
207 V8_INLINE type* As##type(); \ 222 V8_INLINE type* As##type(); \
208 V8_INLINE const type* As##type() const; 223 V8_INLINE const type* As##type() const;
209 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 224 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
210 #undef DECLARE_NODE_FUNCTIONS 225 #undef DECLARE_NODE_FUNCTIONS
211 226
212 virtual BreakableStatement* AsBreakableStatement() { return NULL; } 227 BreakableStatement* AsBreakableStatement();
213 virtual IterationStatement* AsIterationStatement() { return NULL; } 228 IterationStatement* AsIterationStatement();
214 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } 229 MaterializedLiteral* AsMaterializedLiteral();
215 230
216 private: 231 private:
217 // Hidden to prevent accidental usage. It would have to load the 232 // Hidden to prevent accidental usage. It would have to load the
218 // current zone from the TLS. 233 // current zone from the TLS.
219 void* operator new(size_t size); 234 void* operator new(size_t size);
220 235
221 friend class CaseClause; // Generates AST IDs. 236 friend class CaseClause; // Generates AST IDs.
222 237
223 int position_; 238 int position_;
224 }; 239 };
225 240
226 241
227 class Statement : public AstNode { 242 class Statement : public AstNode {
228 public: 243 public:
229 explicit Statement(Zone* zone, int position) : AstNode(position) {} 244 explicit Statement(Zone* zone, int position) : AstNode(position) {}
230 245
231 bool IsEmpty() { return AsEmptyStatement() != NULL; } 246 bool IsEmpty() { return AsEmptyStatement() != NULL; }
232 virtual bool IsJump() const { return false; } 247 bool IsJump() const;
233 }; 248 };
234 249
235 250
236 class SmallMapList final { 251 class SmallMapList final {
237 public: 252 public:
238 SmallMapList() {} 253 SmallMapList() {}
239 SmallMapList(int capacity, Zone* zone) : list_(capacity, zone) {} 254 SmallMapList(int capacity, Zone* zone) : list_(capacity, zone) {}
240 255
241 void Reserve(int capacity, Zone* zone) { list_.Reserve(capacity, zone); } 256 void Reserve(int capacity, Zone* zone) { list_.Reserve(capacity, zone); }
242 void Clear() { list_.Clear(); } 257 void Clear() { list_.Clear(); }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 kUninitialized, 303 kUninitialized,
289 // Evaluated for its side effects. 304 // Evaluated for its side effects.
290 kEffect, 305 kEffect,
291 // Evaluated for its value (and side effects). 306 // Evaluated for its value (and side effects).
292 kValue, 307 kValue,
293 // Evaluated for control flow (and side effects). 308 // Evaluated for control flow (and side effects).
294 kTest 309 kTest
295 }; 310 };
296 311
297 // Mark this expression as being in tail position. 312 // Mark this expression as being in tail position.
298 virtual void MarkTail() {} 313 void MarkTail();
299 314
300 // True iff the expression is a valid reference expression. 315 // True iff the expression is a valid reference expression.
301 virtual bool IsValidReferenceExpression() const { return false; } 316 bool IsValidReferenceExpression() const;
302 317
303 // Helpers for ToBoolean conversion. 318 // Helpers for ToBoolean conversion.
304 virtual bool ToBooleanIsTrue() const { return false; } 319 bool ToBooleanIsTrue() const;
305 virtual bool ToBooleanIsFalse() const { return false; } 320 bool ToBooleanIsFalse() const;
306 321
307 // Symbols that cannot be parsed as array indices are considered property 322 // Symbols that cannot be parsed as array indices are considered property
308 // names. We do not treat symbols that can be array indexes as property 323 // names. We do not treat symbols that can be array indexes as property
309 // names because [] for string objects is handled only by keyed ICs. 324 // names because [] for string objects is handled only by keyed ICs.
310 virtual bool IsPropertyName() const { return false; } 325 bool IsPropertyName() const;
311 326
312 // True iff the expression is a class or function expression without 327 // True iff the expression is a class or function expression without
313 // a syntactic name. 328 // a syntactic name.
314 virtual bool IsAnonymousFunctionDefinition() const { return false; } 329 bool IsAnonymousFunctionDefinition() const;
315 330
316 // True iff the expression is a literal represented as a smi. 331 // True iff the expression is a literal represented as a smi.
317 bool IsSmiLiteral() const; 332 bool IsSmiLiteral() const;
318 333
319 // True iff the expression is a string literal. 334 // True iff the expression is a string literal.
320 bool IsStringLiteral() const; 335 bool IsStringLiteral() const;
321 336
322 // True iff the expression is the null literal. 337 // True iff the expression is the null literal.
323 bool IsNullLiteral() const; 338 bool IsNullLiteral() const;
324 339
325 // True if we can prove that the expression is the undefined literal. Note 340 // True if we can prove that the expression is the undefined literal. Note
326 // that this also checks for loads of the global "undefined" variable. 341 // that this also checks for loads of the global "undefined" variable.
327 bool IsUndefinedLiteral() const; 342 bool IsUndefinedLiteral() const;
328 343
329 // True iff the expression is a valid target for an assignment. 344 // True iff the expression is a valid target for an assignment.
330 bool IsValidReferenceExpressionOrThis() const; 345 bool IsValidReferenceExpressionOrThis() const;
331 346
332 // Type feedback information for assignments and properties.
333 virtual bool IsMonomorphic() {
334 UNREACHABLE();
335 return false;
336 }
337 virtual SmallMapList* GetReceiverTypes() {
338 UNREACHABLE();
339 return NULL;
340 }
341 virtual KeyedAccessStoreMode GetStoreMode() const {
342 UNREACHABLE();
343 return STANDARD_STORE;
344 }
345 virtual IcCheckType GetKeyType() const {
346 UNREACHABLE();
347 return ELEMENT;
348 }
349
350 // TODO(rossberg): this should move to its own AST node eventually. 347 // TODO(rossberg): this should move to its own AST node eventually.
351 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); 348 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle);
352 uint16_t to_boolean_types() const { 349 uint16_t to_boolean_types() const {
353 return ToBooleanTypesField::decode(bit_field_); 350 return ToBooleanTypesField::decode(bit_field_);
354 } 351 }
355 352
353 SmallMapList* GetReceiverTypes();
354 KeyedAccessStoreMode GetStoreMode() const;
355 IcCheckType GetKeyType() const;
356 bool IsMonomorphic() const;
357
356 void set_base_id(int id) { base_id_ = id; } 358 void set_base_id(int id) { base_id_ = id; }
357 static int num_ids() { return parent_num_ids() + 2; } 359 static int num_ids() { return parent_num_ids() + 2; }
358 BailoutId id() const { return BailoutId(local_id(0)); } 360 BailoutId id() const { return BailoutId(local_id(0)); }
359 TypeFeedbackId test_id() const { return TypeFeedbackId(local_id(1)); } 361 TypeFeedbackId test_id() const { return TypeFeedbackId(local_id(1)); }
360 362
361 protected: 363 protected:
362 Expression(Zone* zone, int pos) 364 Expression(Zone* zone, int pos)
363 : AstNode(pos), 365 : AstNode(pos),
364 base_id_(BailoutId::None().ToInt()), 366 base_id_(BailoutId::None().ToInt()),
365 bit_field_(0) {} 367 bit_field_(0) {}
(...skipping 22 matching lines...) Expand all
388 public: 390 public:
389 enum BreakableType { 391 enum BreakableType {
390 TARGET_FOR_ANONYMOUS, 392 TARGET_FOR_ANONYMOUS,
391 TARGET_FOR_NAMED_ONLY 393 TARGET_FOR_NAMED_ONLY
392 }; 394 };
393 395
394 // The labels associated with this statement. May be NULL; 396 // The labels associated with this statement. May be NULL;
395 // if it is != NULL, guaranteed to contain at least one entry. 397 // if it is != NULL, guaranteed to contain at least one entry.
396 ZoneList<const AstRawString*>* labels() const { return labels_; } 398 ZoneList<const AstRawString*>* labels() const { return labels_; }
397 399
398 // Type testing & conversion.
399 BreakableStatement* AsBreakableStatement() final { return this; }
400
401 // Code generation 400 // Code generation
402 Label* break_target() { return &break_target_; } 401 Label* break_target() { return &break_target_; }
403 402
404 // Testers. 403 // Testers.
405 bool is_target_for_anonymous() const { 404 bool is_target_for_anonymous() const {
406 return breakable_type_ == TARGET_FOR_ANONYMOUS; 405 return breakable_type_ == TARGET_FOR_ANONYMOUS;
407 } 406 }
408 407
409 void set_base_id(int id) { base_id_ = id; } 408 void set_base_id(int id) { base_id_ = id; }
410 static int num_ids() { return parent_num_ids() + 2; } 409 static int num_ids() { return parent_num_ids() + 2; }
(...skipping 29 matching lines...) Expand all
440 class Block final : public BreakableStatement { 439 class Block final : public BreakableStatement {
441 public: 440 public:
442 DECLARE_NODE_TYPE(Block) 441 DECLARE_NODE_TYPE(Block)
443 442
444 ZoneList<Statement*>* statements() { return &statements_; } 443 ZoneList<Statement*>* statements() { return &statements_; }
445 bool ignore_completion_value() const { return ignore_completion_value_; } 444 bool ignore_completion_value() const { return ignore_completion_value_; }
446 445
447 static int num_ids() { return parent_num_ids() + 1; } 446 static int num_ids() { return parent_num_ids() + 1; }
448 BailoutId DeclsId() const { return BailoutId(local_id(0)); } 447 BailoutId DeclsId() const { return BailoutId(local_id(0)); }
449 448
450 bool IsJump() const override { 449 bool IsJump() const {
451 return !statements_.is_empty() && statements_.last()->IsJump() 450 return !statements_.is_empty() && statements_.last()->IsJump()
452 && labels() == NULL; // Good enough as an approximation... 451 && labels() == NULL; // Good enough as an approximation...
453 } 452 }
454 453
455 Scope* scope() const { return scope_; } 454 Scope* scope() const { return scope_; }
456 void set_scope(Scope* scope) { scope_ = scope; } 455 void set_scope(Scope* scope) { scope_ = scope; }
457 456
458 protected: 457 protected:
459 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, 458 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity,
460 bool ignore_completion_value, int pos) 459 bool ignore_completion_value, int pos)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 Block* block_; 495 Block* block_;
497 VariableProxy* result_; 496 VariableProxy* result_;
498 }; 497 };
499 498
500 499
501 class Declaration : public AstNode { 500 class Declaration : public AstNode {
502 public: 501 public:
503 VariableProxy* proxy() const { return proxy_; } 502 VariableProxy* proxy() const { return proxy_; }
504 VariableMode mode() const { return mode_; } 503 VariableMode mode() const { return mode_; }
505 Scope* scope() const { return scope_; } 504 Scope* scope() const { return scope_; }
506 virtual InitializationFlag initialization() const = 0; 505 InitializationFlag initialization() const;
507 506
508 protected: 507 protected:
509 Declaration(Zone* zone, VariableProxy* proxy, VariableMode mode, Scope* scope, 508 Declaration(Zone* zone, VariableProxy* proxy, VariableMode mode, Scope* scope,
510 int pos) 509 int pos)
511 : AstNode(pos), mode_(mode), proxy_(proxy), scope_(scope) { 510 : AstNode(pos), mode_(mode), proxy_(proxy), scope_(scope) {
512 DCHECK(IsDeclaredVariableMode(mode)); 511 DCHECK(IsDeclaredVariableMode(mode));
513 } 512 }
514 513
515 private: 514 private:
516 VariableMode mode_; 515 VariableMode mode_;
517 VariableProxy* proxy_; 516 VariableProxy* proxy_;
518 517
519 // Nested scope from which the declaration originated. 518 // Nested scope from which the declaration originated.
520 Scope* scope_; 519 Scope* scope_;
521 }; 520 };
522 521
523 522
524 class VariableDeclaration final : public Declaration { 523 class VariableDeclaration final : public Declaration {
525 public: 524 public:
526 DECLARE_NODE_TYPE(VariableDeclaration) 525 DECLARE_NODE_TYPE(VariableDeclaration)
527 526
528 InitializationFlag initialization() const override { 527 InitializationFlag initialization() const {
529 return mode() == VAR ? kCreatedInitialized : kNeedsInitialization; 528 return mode() == VAR ? kCreatedInitialized : kNeedsInitialization;
530 } 529 }
531 530
532 protected: 531 protected:
533 VariableDeclaration(Zone* zone, VariableProxy* proxy, VariableMode mode, 532 VariableDeclaration(Zone* zone, VariableProxy* proxy, VariableMode mode,
534 Scope* scope, int pos) 533 Scope* scope, int pos)
535 : Declaration(zone, proxy, mode, scope, pos) {} 534 : Declaration(zone, proxy, mode, scope, pos) {}
536 }; 535 };
537 536
538 537
539 class FunctionDeclaration final : public Declaration { 538 class FunctionDeclaration final : public Declaration {
540 public: 539 public:
541 DECLARE_NODE_TYPE(FunctionDeclaration) 540 DECLARE_NODE_TYPE(FunctionDeclaration)
542 541
543 FunctionLiteral* fun() const { return fun_; } 542 FunctionLiteral* fun() const { return fun_; }
544 void set_fun(FunctionLiteral* f) { fun_ = f; } 543 void set_fun(FunctionLiteral* f) { fun_ = f; }
545 InitializationFlag initialization() const override { 544 InitializationFlag initialization() const { return kCreatedInitialized; }
546 return kCreatedInitialized;
547 }
548 545
549 protected: 546 protected:
550 FunctionDeclaration(Zone* zone, 547 FunctionDeclaration(Zone* zone,
551 VariableProxy* proxy, 548 VariableProxy* proxy,
552 VariableMode mode, 549 VariableMode mode,
553 FunctionLiteral* fun, 550 FunctionLiteral* fun,
554 Scope* scope, 551 Scope* scope,
555 int pos) 552 int pos)
556 : Declaration(zone, proxy, mode, scope, pos), 553 : Declaration(zone, proxy, mode, scope, pos),
557 fun_(fun) { 554 fun_(fun) {
558 DCHECK(mode == VAR || mode == LET || mode == CONST); 555 DCHECK(mode == VAR || mode == LET || mode == CONST);
559 DCHECK(fun != NULL); 556 DCHECK(fun != NULL);
560 } 557 }
561 558
562 private: 559 private:
563 FunctionLiteral* fun_; 560 FunctionLiteral* fun_;
564 }; 561 };
565 562
566 563
567 class ImportDeclaration final : public Declaration { 564 class ImportDeclaration final : public Declaration {
568 public: 565 public:
569 DECLARE_NODE_TYPE(ImportDeclaration) 566 DECLARE_NODE_TYPE(ImportDeclaration)
570 567
571 const AstRawString* import_name() const { return import_name_; } 568 const AstRawString* import_name() const { return import_name_; }
572 const AstRawString* module_specifier() const { return module_specifier_; } 569 const AstRawString* module_specifier() const { return module_specifier_; }
573 void set_module_specifier(const AstRawString* module_specifier) { 570 void set_module_specifier(const AstRawString* module_specifier) {
574 DCHECK(module_specifier_ == NULL); 571 DCHECK(module_specifier_ == NULL);
575 module_specifier_ = module_specifier; 572 module_specifier_ = module_specifier;
576 } 573 }
577 InitializationFlag initialization() const override { 574 InitializationFlag initialization() const { return kNeedsInitialization; }
578 return kNeedsInitialization;
579 }
580 575
581 protected: 576 protected:
582 ImportDeclaration(Zone* zone, VariableProxy* proxy, 577 ImportDeclaration(Zone* zone, VariableProxy* proxy,
583 const AstRawString* import_name, 578 const AstRawString* import_name,
584 const AstRawString* module_specifier, Scope* scope, int pos) 579 const AstRawString* module_specifier, Scope* scope, int pos)
585 : Declaration(zone, proxy, CONST, scope, pos), 580 : Declaration(zone, proxy, CONST, scope, pos),
586 import_name_(import_name), 581 import_name_(import_name),
587 module_specifier_(module_specifier) {} 582 module_specifier_(module_specifier) {}
588 583
589 private: 584 private:
(...skipping 14 matching lines...) Expand all
604 : AstNode(pos), descriptor_(descriptor), body_(body) {} 599 : AstNode(pos), descriptor_(descriptor), body_(body) {}
605 600
606 private: 601 private:
607 ModuleDescriptor* descriptor_; 602 ModuleDescriptor* descriptor_;
608 Block* body_; 603 Block* body_;
609 }; 604 };
610 605
611 606
612 class IterationStatement : public BreakableStatement { 607 class IterationStatement : public BreakableStatement {
613 public: 608 public:
614 // Type testing & conversion.
615 IterationStatement* AsIterationStatement() final { return this; }
616
617 Statement* body() const { return body_; } 609 Statement* body() const { return body_; }
618 void set_body(Statement* s) { body_ = s; } 610 void set_body(Statement* s) { body_ = s; }
619 611
620 int yield_count() const { return yield_count_; } 612 int yield_count() const { return yield_count_; }
621 int first_yield_id() const { return first_yield_id_; } 613 int first_yield_id() const { return first_yield_id_; }
622 void set_yield_count(int yield_count) { yield_count_ = yield_count; } 614 void set_yield_count(int yield_count) { yield_count_ = yield_count; }
623 void set_first_yield_id(int first_yield_id) { 615 void set_first_yield_id(int first_yield_id) {
624 first_yield_id_ = first_yield_id; 616 first_yield_id_ = first_yield_id;
625 } 617 }
626 618
627 static int num_ids() { return parent_num_ids() + 1; } 619 static int num_ids() { return parent_num_ids() + 1; }
628 BailoutId OsrEntryId() const { return BailoutId(local_id(0)); } 620 BailoutId OsrEntryId() const { return BailoutId(local_id(0)); }
629 virtual BailoutId ContinueId() const = 0;
630 virtual BailoutId StackCheckId() const = 0;
631 621
632 // Code generation 622 // Code generation
633 Label* continue_target() { return &continue_target_; } 623 Label* continue_target() { return &continue_target_; }
634 624
635 protected: 625 protected:
636 IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) 626 IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
637 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), 627 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos),
638 body_(NULL), 628 body_(NULL),
639 yield_count_(0), 629 yield_count_(0),
640 first_yield_id_(0) {} 630 first_yield_id_(0) {}
(...skipping 16 matching lines...) Expand all
657 647
658 void Initialize(Expression* cond, Statement* body) { 648 void Initialize(Expression* cond, Statement* body) {
659 IterationStatement::Initialize(body); 649 IterationStatement::Initialize(body);
660 cond_ = cond; 650 cond_ = cond;
661 } 651 }
662 652
663 Expression* cond() const { return cond_; } 653 Expression* cond() const { return cond_; }
664 void set_cond(Expression* e) { cond_ = e; } 654 void set_cond(Expression* e) { cond_ = e; }
665 655
666 static int num_ids() { return parent_num_ids() + 2; } 656 static int num_ids() { return parent_num_ids() + 2; }
667 BailoutId ContinueId() const override { return BailoutId(local_id(0)); } 657 BailoutId ContinueId() const { return BailoutId(local_id(0)); }
668 BailoutId StackCheckId() const override { return BackEdgeId(); } 658 BailoutId StackCheckId() const { return BackEdgeId(); }
669 BailoutId BackEdgeId() const { return BailoutId(local_id(1)); } 659 BailoutId BackEdgeId() const { return BailoutId(local_id(1)); }
670 660
671 protected: 661 protected:
672 DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) 662 DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
673 : IterationStatement(zone, labels, pos), cond_(NULL) {} 663 : IterationStatement(zone, labels, pos), cond_(NULL) {}
674 static int parent_num_ids() { return IterationStatement::num_ids(); } 664 static int parent_num_ids() { return IterationStatement::num_ids(); }
675 665
676 private: 666 private:
677 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 667 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
678 668
679 Expression* cond_; 669 Expression* cond_;
680 }; 670 };
681 671
682 672
683 class WhileStatement final : public IterationStatement { 673 class WhileStatement final : public IterationStatement {
684 public: 674 public:
685 DECLARE_NODE_TYPE(WhileStatement) 675 DECLARE_NODE_TYPE(WhileStatement)
686 676
687 void Initialize(Expression* cond, Statement* body) { 677 void Initialize(Expression* cond, Statement* body) {
688 IterationStatement::Initialize(body); 678 IterationStatement::Initialize(body);
689 cond_ = cond; 679 cond_ = cond;
690 } 680 }
691 681
692 Expression* cond() const { return cond_; } 682 Expression* cond() const { return cond_; }
693 void set_cond(Expression* e) { cond_ = e; } 683 void set_cond(Expression* e) { cond_ = e; }
694 684
695 static int num_ids() { return parent_num_ids() + 1; } 685 static int num_ids() { return parent_num_ids() + 1; }
696 BailoutId ContinueId() const override { return EntryId(); } 686 BailoutId ContinueId() const { return EntryId(); }
697 BailoutId StackCheckId() const override { return BodyId(); } 687 BailoutId StackCheckId() const { return BodyId(); }
698 BailoutId BodyId() const { return BailoutId(local_id(0)); } 688 BailoutId BodyId() const { return BailoutId(local_id(0)); }
699 689
700 protected: 690 protected:
701 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) 691 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
702 : IterationStatement(zone, labels, pos), cond_(NULL) {} 692 : IterationStatement(zone, labels, pos), cond_(NULL) {}
703 static int parent_num_ids() { return IterationStatement::num_ids(); } 693 static int parent_num_ids() { return IterationStatement::num_ids(); }
704 694
705 private: 695 private:
706 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 696 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
707 697
(...skipping 17 matching lines...) Expand all
725 715
726 Statement* init() const { return init_; } 716 Statement* init() const { return init_; }
727 Expression* cond() const { return cond_; } 717 Expression* cond() const { return cond_; }
728 Statement* next() const { return next_; } 718 Statement* next() const { return next_; }
729 719
730 void set_init(Statement* s) { init_ = s; } 720 void set_init(Statement* s) { init_ = s; }
731 void set_cond(Expression* e) { cond_ = e; } 721 void set_cond(Expression* e) { cond_ = e; }
732 void set_next(Statement* s) { next_ = s; } 722 void set_next(Statement* s) { next_ = s; }
733 723
734 static int num_ids() { return parent_num_ids() + 2; } 724 static int num_ids() { return parent_num_ids() + 2; }
735 BailoutId ContinueId() const override { return BailoutId(local_id(0)); } 725 BailoutId ContinueId() const { return BailoutId(local_id(0)); }
736 BailoutId StackCheckId() const override { return BodyId(); } 726 BailoutId StackCheckId() const { return BodyId(); }
737 BailoutId BodyId() const { return BailoutId(local_id(1)); } 727 BailoutId BodyId() const { return BailoutId(local_id(1)); }
738 728
739 protected: 729 protected:
740 ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) 730 ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
741 : IterationStatement(zone, labels, pos), 731 : IterationStatement(zone, labels, pos),
742 init_(NULL), 732 init_(NULL),
743 cond_(NULL), 733 cond_(NULL),
744 next_(NULL) {} 734 next_(NULL) {}
745 static int parent_num_ids() { return IterationStatement::num_ids(); } 735 static int parent_num_ids() { return IterationStatement::num_ids(); }
746 736
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 ForInType for_in_type() const { return for_in_type_; } 795 ForInType for_in_type() const { return for_in_type_; }
806 void set_for_in_type(ForInType type) { for_in_type_ = type; } 796 void set_for_in_type(ForInType type) { for_in_type_ = type; }
807 797
808 static int num_ids() { return parent_num_ids() + 6; } 798 static int num_ids() { return parent_num_ids() + 6; }
809 BailoutId BodyId() const { return BailoutId(local_id(0)); } 799 BailoutId BodyId() const { return BailoutId(local_id(0)); }
810 BailoutId EnumId() const { return BailoutId(local_id(1)); } 800 BailoutId EnumId() const { return BailoutId(local_id(1)); }
811 BailoutId ToObjectId() const { return BailoutId(local_id(2)); } 801 BailoutId ToObjectId() const { return BailoutId(local_id(2)); }
812 BailoutId PrepareId() const { return BailoutId(local_id(3)); } 802 BailoutId PrepareId() const { return BailoutId(local_id(3)); }
813 BailoutId FilterId() const { return BailoutId(local_id(4)); } 803 BailoutId FilterId() const { return BailoutId(local_id(4)); }
814 BailoutId AssignmentId() const { return BailoutId(local_id(5)); } 804 BailoutId AssignmentId() const { return BailoutId(local_id(5)); }
815 BailoutId ContinueId() const override { return EntryId(); } 805 BailoutId ContinueId() const { return EntryId(); }
816 BailoutId StackCheckId() const override { return BodyId(); } 806 BailoutId StackCheckId() const { return BodyId(); }
817 807
818 protected: 808 protected:
819 ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) 809 ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
820 : ForEachStatement(zone, labels, pos), 810 : ForEachStatement(zone, labels, pos),
821 each_(nullptr), 811 each_(nullptr),
822 subject_(nullptr), 812 subject_(nullptr),
823 for_in_type_(SLOW_FOR_IN) {} 813 for_in_type_(SLOW_FOR_IN) {}
824 static int parent_num_ids() { return ForEachStatement::num_ids(); } 814 static int parent_num_ids() { return ForEachStatement::num_ids(); }
825 815
826 private: 816 private:
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 // each = result.value 861 // each = result.value
872 Expression* assign_each() const { 862 Expression* assign_each() const {
873 return assign_each_; 863 return assign_each_;
874 } 864 }
875 865
876 void set_assign_iterator(Expression* e) { assign_iterator_ = e; } 866 void set_assign_iterator(Expression* e) { assign_iterator_ = e; }
877 void set_next_result(Expression* e) { next_result_ = e; } 867 void set_next_result(Expression* e) { next_result_ = e; }
878 void set_result_done(Expression* e) { result_done_ = e; } 868 void set_result_done(Expression* e) { result_done_ = e; }
879 void set_assign_each(Expression* e) { assign_each_ = e; } 869 void set_assign_each(Expression* e) { assign_each_ = e; }
880 870
881 BailoutId ContinueId() const override { return EntryId(); } 871 BailoutId ContinueId() const { return EntryId(); }
882 BailoutId StackCheckId() const override { return BackEdgeId(); } 872 BailoutId StackCheckId() const { return BackEdgeId(); }
883 873
884 static int num_ids() { return parent_num_ids() + 1; } 874 static int num_ids() { return parent_num_ids() + 1; }
885 BailoutId BackEdgeId() const { return BailoutId(local_id(0)); } 875 BailoutId BackEdgeId() const { return BailoutId(local_id(0)); }
886 876
887 protected: 877 protected:
888 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) 878 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
889 : ForEachStatement(zone, labels, pos), 879 : ForEachStatement(zone, labels, pos),
890 iterator_(NULL), 880 iterator_(NULL),
891 assign_iterator_(NULL), 881 assign_iterator_(NULL),
892 next_result_(NULL), 882 next_result_(NULL),
(...skipping 11 matching lines...) Expand all
904 Expression* assign_each_; 894 Expression* assign_each_;
905 }; 895 };
906 896
907 897
908 class ExpressionStatement final : public Statement { 898 class ExpressionStatement final : public Statement {
909 public: 899 public:
910 DECLARE_NODE_TYPE(ExpressionStatement) 900 DECLARE_NODE_TYPE(ExpressionStatement)
911 901
912 void set_expression(Expression* e) { expression_ = e; } 902 void set_expression(Expression* e) { expression_ = e; }
913 Expression* expression() const { return expression_; } 903 Expression* expression() const { return expression_; }
914 bool IsJump() const override { return expression_->IsThrow(); } 904 bool IsJump() const { return expression_->IsThrow(); }
915 905
916 protected: 906 protected:
917 ExpressionStatement(Zone* zone, Expression* expression, int pos) 907 ExpressionStatement(Zone* zone, Expression* expression, int pos)
918 : Statement(zone, pos), expression_(expression) { } 908 : Statement(zone, pos), expression_(expression) { }
919 909
920 private: 910 private:
921 Expression* expression_; 911 Expression* expression_;
922 }; 912 };
923 913
924 914
925 class JumpStatement : public Statement { 915 class JumpStatement : public Statement {
926 public: 916 public:
927 bool IsJump() const final { return true; } 917 bool IsJump() const { return true; }
928 918
929 protected: 919 protected:
930 explicit JumpStatement(Zone* zone, int pos) : Statement(zone, pos) {} 920 explicit JumpStatement(Zone* zone, int pos) : Statement(zone, pos) {}
931 }; 921 };
932 922
933 923
934 class ContinueStatement final : public JumpStatement { 924 class ContinueStatement final : public JumpStatement {
935 public: 925 public:
936 DECLARE_NODE_TYPE(ContinueStatement) 926 DECLARE_NODE_TYPE(ContinueStatement)
937 927
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } 1082 bool HasElseStatement() const { return !else_statement()->IsEmpty(); }
1093 1083
1094 Expression* condition() const { return condition_; } 1084 Expression* condition() const { return condition_; }
1095 Statement* then_statement() const { return then_statement_; } 1085 Statement* then_statement() const { return then_statement_; }
1096 Statement* else_statement() const { return else_statement_; } 1086 Statement* else_statement() const { return else_statement_; }
1097 1087
1098 void set_condition(Expression* e) { condition_ = e; } 1088 void set_condition(Expression* e) { condition_ = e; }
1099 void set_then_statement(Statement* s) { then_statement_ = s; } 1089 void set_then_statement(Statement* s) { then_statement_ = s; }
1100 void set_else_statement(Statement* s) { else_statement_ = s; } 1090 void set_else_statement(Statement* s) { else_statement_ = s; }
1101 1091
1102 bool IsJump() const override { 1092 bool IsJump() const {
1103 return HasThenStatement() && then_statement()->IsJump() 1093 return HasThenStatement() && then_statement()->IsJump()
1104 && HasElseStatement() && else_statement()->IsJump(); 1094 && HasElseStatement() && else_statement()->IsJump();
1105 } 1095 }
1106 1096
1107 void set_base_id(int id) { base_id_ = id; } 1097 void set_base_id(int id) { base_id_ = id; }
1108 static int num_ids() { return parent_num_ids() + 3; } 1098 static int num_ids() { return parent_num_ids() + 3; }
1109 BailoutId IfId() const { return BailoutId(local_id(0)); } 1099 BailoutId IfId() const { return BailoutId(local_id(0)); }
1110 BailoutId ThenId() const { return BailoutId(local_id(1)); } 1100 BailoutId ThenId() const { return BailoutId(local_id(1)); }
1111 BailoutId ElseId() const { return BailoutId(local_id(2)); } 1101 BailoutId ElseId() const { return BailoutId(local_id(2)); }
1112 1102
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 1249
1260 Statement* statement_; 1250 Statement* statement_;
1261 Scope* const scope_; 1251 Scope* const scope_;
1262 }; 1252 };
1263 1253
1264 1254
1265 class Literal final : public Expression { 1255 class Literal final : public Expression {
1266 public: 1256 public:
1267 DECLARE_NODE_TYPE(Literal) 1257 DECLARE_NODE_TYPE(Literal)
1268 1258
1269 bool IsPropertyName() const override { return value_->IsPropertyName(); } 1259 bool IsPropertyName() const { return value_->IsPropertyName(); }
1270 1260
1271 Handle<String> AsPropertyName() { 1261 Handle<String> AsPropertyName() {
1272 DCHECK(IsPropertyName()); 1262 DCHECK(IsPropertyName());
1273 return Handle<String>::cast(value()); 1263 return Handle<String>::cast(value());
1274 } 1264 }
1275 1265
1276 const AstRawString* AsRawPropertyName() { 1266 const AstRawString* AsRawPropertyName() {
1277 DCHECK(IsPropertyName()); 1267 DCHECK(IsPropertyName());
1278 return value_->AsString(); 1268 return value_->AsString();
1279 } 1269 }
1280 1270
1281 bool ToBooleanIsTrue() const override { return value()->BooleanValue(); } 1271 bool ToBooleanIsTrue() const { return value()->BooleanValue(); }
1282 bool ToBooleanIsFalse() const override { return !value()->BooleanValue(); } 1272 bool ToBooleanIsFalse() const { return !value()->BooleanValue(); }
1283 1273
1284 Handle<Object> value() const { return value_->value(); } 1274 Handle<Object> value() const { return value_->value(); }
1285 const AstValue* raw_value() const { return value_; } 1275 const AstValue* raw_value() const { return value_; }
1286 1276
1287 // Support for using Literal as a HashMap key. NOTE: Currently, this works 1277 // Support for using Literal as a HashMap key. NOTE: Currently, this works
1288 // only for string and number literals! 1278 // only for string and number literals!
1289 uint32_t Hash(); 1279 uint32_t Hash();
1290 static bool Match(void* literal1, void* literal2); 1280 static bool Match(void* literal1, void* literal2);
1291 1281
1292 static int num_ids() { return parent_num_ids() + 1; } 1282 static int num_ids() { return parent_num_ids() + 1; }
(...skipping 11 matching lines...) Expand all
1304 1294
1305 const AstValue* value_; 1295 const AstValue* value_;
1306 }; 1296 };
1307 1297
1308 1298
1309 class AstLiteralReindexer; 1299 class AstLiteralReindexer;
1310 1300
1311 // Base class for literals that needs space in the corresponding JSFunction. 1301 // Base class for literals that needs space in the corresponding JSFunction.
1312 class MaterializedLiteral : public Expression { 1302 class MaterializedLiteral : public Expression {
1313 public: 1303 public:
1314 MaterializedLiteral* AsMaterializedLiteral() final { return this; }
1315
1316 int literal_index() { return literal_index_; } 1304 int literal_index() { return literal_index_; }
1317 1305
1318 int depth() const { 1306 int depth() const {
1319 // only callable after initialization. 1307 // only callable after initialization.
1320 DCHECK(depth_ >= 1); 1308 DCHECK(depth_ >= 1);
1321 return depth_; 1309 return depth_;
1322 } 1310 }
1323 1311
1324 protected: 1312 protected:
1325 MaterializedLiteral(Zone* zone, int literal_index, int pos) 1313 MaterializedLiteral(Zone* zone, int literal_index, int pos)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 }; 1362 };
1375 1363
1376 Expression* key() { return key_; } 1364 Expression* key() { return key_; }
1377 Expression* value() { return value_; } 1365 Expression* value() { return value_; }
1378 Kind kind() { return kind_; } 1366 Kind kind() { return kind_; }
1379 1367
1380 void set_key(Expression* e) { key_ = e; } 1368 void set_key(Expression* e) { key_ = e; }
1381 void set_value(Expression* e) { value_ = e; } 1369 void set_value(Expression* e) { value_ = e; }
1382 1370
1383 // Type feedback information. 1371 // Type feedback information.
1384 bool IsMonomorphic() { return !receiver_type_.is_null(); }
Igor Sheludko 2016/07/14 14:02:33 Why is it disappeared?
1385 Handle<Map> GetReceiverType() { return receiver_type_; } 1372 Handle<Map> GetReceiverType() { return receiver_type_; }
1386 1373
1387 bool IsCompileTimeValue(); 1374 bool IsCompileTimeValue();
1388 1375
1389 void set_emit_store(bool emit_store); 1376 void set_emit_store(bool emit_store);
1390 bool emit_store(); 1377 bool emit_store();
1391 1378
1392 bool is_static() const { return is_static_; } 1379 bool is_static() const { return is_static_; }
1393 bool is_computed_name() const { return is_computed_name_; } 1380 bool is_computed_name() const { return is_computed_name_; }
1394 1381
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 ZoneList<Expression*>* values_; 1632 ZoneList<Expression*>* values_;
1646 int first_spread_index_; 1633 int first_spread_index_;
1647 FeedbackVectorSlot literal_slot_; 1634 FeedbackVectorSlot literal_slot_;
1648 }; 1635 };
1649 1636
1650 1637
1651 class VariableProxy final : public Expression { 1638 class VariableProxy final : public Expression {
1652 public: 1639 public:
1653 DECLARE_NODE_TYPE(VariableProxy) 1640 DECLARE_NODE_TYPE(VariableProxy)
1654 1641
1655 bool IsValidReferenceExpression() const override { 1642 bool IsValidReferenceExpression() const {
1656 return !is_this() && !is_new_target(); 1643 return !is_this() && !is_new_target();
1657 } 1644 }
1658 1645
1659 bool IsArguments() const { return is_resolved() && var()->is_arguments(); } 1646 bool IsArguments() const { return is_resolved() && var()->is_arguments(); }
1660 1647
1661 Handle<String> name() const { return raw_name()->string(); } 1648 Handle<String> name() const { return raw_name()->string(); }
1662 const AstRawString* raw_name() const { 1649 const AstRawString* raw_name() const {
1663 return is_resolved() ? var_->raw_name() : raw_name_; 1650 return is_resolved() ? var_->raw_name() : raw_name_;
1664 } 1651 }
1665 1652
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 KEYED_PROPERTY, 1732 KEYED_PROPERTY,
1746 NAMED_SUPER_PROPERTY, 1733 NAMED_SUPER_PROPERTY,
1747 KEYED_SUPER_PROPERTY 1734 KEYED_SUPER_PROPERTY
1748 }; 1735 };
1749 1736
1750 1737
1751 class Property final : public Expression { 1738 class Property final : public Expression {
1752 public: 1739 public:
1753 DECLARE_NODE_TYPE(Property) 1740 DECLARE_NODE_TYPE(Property)
1754 1741
1755 bool IsValidReferenceExpression() const override { return true; } 1742 bool IsValidReferenceExpression() const { return true; }
1756 1743
1757 Expression* obj() const { return obj_; } 1744 Expression* obj() const { return obj_; }
1758 Expression* key() const { return key_; } 1745 Expression* key() const { return key_; }
1759 1746
1760 void set_obj(Expression* e) { obj_ = e; } 1747 void set_obj(Expression* e) { obj_ = e; }
1761 void set_key(Expression* e) { key_ = e; } 1748 void set_key(Expression* e) { key_ = e; }
1762 1749
1763 static int num_ids() { return parent_num_ids() + 1; } 1750 static int num_ids() { return parent_num_ids() + 1; }
1764 BailoutId LoadId() const { return BailoutId(local_id(0)); } 1751 BailoutId LoadId() const { return BailoutId(local_id(0)); }
1765 1752
1766 bool IsStringAccess() const { 1753 bool IsStringAccess() const {
1767 return IsStringAccessField::decode(bit_field_); 1754 return IsStringAccessField::decode(bit_field_);
1768 } 1755 }
1769 1756
1770 // Type feedback information. 1757 // Type feedback information.
1771 bool IsMonomorphic() override { return receiver_types_.length() == 1; } 1758 bool IsMonomorphic() const { return receiver_types_.length() == 1; }
1772 SmallMapList* GetReceiverTypes() override { return &receiver_types_; } 1759 SmallMapList* GetReceiverTypes() { return &receiver_types_; }
1773 KeyedAccessStoreMode GetStoreMode() const override { return STANDARD_STORE; } 1760 KeyedAccessStoreMode GetStoreMode() const { return STANDARD_STORE; }
1774 IcCheckType GetKeyType() const override { 1761 IcCheckType GetKeyType() const { return KeyTypeField::decode(bit_field_); }
1775 return KeyTypeField::decode(bit_field_);
1776 }
1777 bool IsUninitialized() const { 1762 bool IsUninitialized() const {
1778 return !is_for_call() && HasNoTypeInformation(); 1763 return !is_for_call() && HasNoTypeInformation();
1779 } 1764 }
1780 bool HasNoTypeInformation() const { 1765 bool HasNoTypeInformation() const {
1781 return GetInlineCacheState() == UNINITIALIZED; 1766 return GetInlineCacheState() == UNINITIALIZED;
1782 } 1767 }
1783 InlineCacheState GetInlineCacheState() const { 1768 InlineCacheState GetInlineCacheState() const {
1784 return InlineCacheStateField::decode(bit_field_); 1769 return InlineCacheStateField::decode(bit_field_);
1785 } 1770 }
1786 void set_is_string_access(bool b) { 1771 void set_is_string_access(bool b) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 void set_expression(Expression* e) { expression_ = e; } 1839 void set_expression(Expression* e) { expression_ = e; }
1855 1840
1856 // Type feedback information. 1841 // Type feedback information.
1857 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 1842 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
1858 FeedbackVectorSlotCache* cache); 1843 FeedbackVectorSlotCache* cache);
1859 1844
1860 FeedbackVectorSlot CallFeedbackSlot() const { return stub_slot_; } 1845 FeedbackVectorSlot CallFeedbackSlot() const { return stub_slot_; }
1861 1846
1862 FeedbackVectorSlot CallFeedbackICSlot() const { return ic_slot_; } 1847 FeedbackVectorSlot CallFeedbackICSlot() const { return ic_slot_; }
1863 1848
1864 SmallMapList* GetReceiverTypes() override { 1849 SmallMapList* GetReceiverTypes() const {
1865 if (expression()->IsProperty()) { 1850 if (expression()->IsProperty()) {
1866 return expression()->AsProperty()->GetReceiverTypes(); 1851 return expression()->AsProperty()->GetReceiverTypes();
1867 } 1852 }
1868 return NULL; 1853 return nullptr;
1869 } 1854 }
1870 1855
1871 bool IsMonomorphic() override { 1856 bool IsMonomorphic() const {
1872 if (expression()->IsProperty()) { 1857 if (expression()->IsProperty()) {
1873 return expression()->AsProperty()->IsMonomorphic(); 1858 return expression()->AsProperty()->IsMonomorphic();
1874 } 1859 }
1875 return !target_.is_null(); 1860 return !target_.is_null();
1876 } 1861 }
1877 1862
1878 bool global_call() const { 1863 bool global_call() const {
1879 VariableProxy* proxy = expression_->AsVariableProxy(); 1864 VariableProxy* proxy = expression_->AsVariableProxy();
1880 return proxy != NULL && proxy->var()->IsUnallocatedOrGlobalSlot(); 1865 return proxy != NULL && proxy->var()->IsUnallocatedOrGlobalSlot();
1881 } 1866 }
(...skipping 25 matching lines...) Expand all
1907 return IsUninitializedField::decode(bit_field_); 1892 return IsUninitializedField::decode(bit_field_);
1908 } 1893 }
1909 void set_is_uninitialized(bool b) { 1894 void set_is_uninitialized(bool b) {
1910 bit_field_ = IsUninitializedField::update(bit_field_, b); 1895 bit_field_ = IsUninitializedField::update(bit_field_, b);
1911 } 1896 }
1912 1897
1913 TailCallMode tail_call_mode() const { 1898 TailCallMode tail_call_mode() const {
1914 return IsTailField::decode(bit_field_) ? TailCallMode::kAllow 1899 return IsTailField::decode(bit_field_) ? TailCallMode::kAllow
1915 : TailCallMode::kDisallow; 1900 : TailCallMode::kDisallow;
1916 } 1901 }
1917 void MarkTail() override { 1902 void MarkTail() { bit_field_ = IsTailField::update(bit_field_, true); }
1918 bit_field_ = IsTailField::update(bit_field_, true);
1919 }
1920 1903
1921 enum CallType { 1904 enum CallType {
1922 POSSIBLY_EVAL_CALL, 1905 POSSIBLY_EVAL_CALL,
1923 GLOBAL_CALL, 1906 GLOBAL_CALL,
1924 LOOKUP_SLOT_CALL, 1907 LOOKUP_SLOT_CALL,
1925 NAMED_PROPERTY_CALL, 1908 NAMED_PROPERTY_CALL,
1926 KEYED_PROPERTY_CALL, 1909 KEYED_PROPERTY_CALL,
1927 NAMED_SUPER_PROPERTY_CALL, 1910 NAMED_SUPER_PROPERTY_CALL,
1928 KEYED_SUPER_PROPERTY_CALL, 1911 KEYED_SUPER_PROPERTY_CALL,
1929 SUPER_CALL, 1912 SUPER_CALL,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1984 // Construct calls have two slots, one right after the other. 1967 // Construct calls have two slots, one right after the other.
1985 // The second slot stores the call count for monomorphic calls. 1968 // The second slot stores the call count for monomorphic calls.
1986 spec->AddGeneralSlot(); 1969 spec->AddGeneralSlot();
1987 } 1970 }
1988 1971
1989 FeedbackVectorSlot CallNewFeedbackSlot() { 1972 FeedbackVectorSlot CallNewFeedbackSlot() {
1990 DCHECK(!callnew_feedback_slot_.IsInvalid()); 1973 DCHECK(!callnew_feedback_slot_.IsInvalid());
1991 return callnew_feedback_slot_; 1974 return callnew_feedback_slot_;
1992 } 1975 }
1993 1976
1994 bool IsMonomorphic() override { return is_monomorphic_; } 1977 bool IsMonomorphic() const { return is_monomorphic_; }
1995 Handle<JSFunction> target() const { return target_; } 1978 Handle<JSFunction> target() const { return target_; }
1996 Handle<AllocationSite> allocation_site() const { 1979 Handle<AllocationSite> allocation_site() const {
1997 return allocation_site_; 1980 return allocation_site_;
1998 } 1981 }
1999 1982
2000 static int num_ids() { return parent_num_ids() + 1; } 1983 static int num_ids() { return parent_num_ids() + 1; }
2001 static int feedback_slots() { return 1; } 1984 static int feedback_slots() { return 1; }
2002 BailoutId ReturnId() const { return BailoutId(local_id(0)); } 1985 BailoutId ReturnId() const { return BailoutId(local_id(0)); }
2003 1986
2004 void set_allocation_site(Handle<AllocationSite> site) { 1987 void set_allocation_site(Handle<AllocationSite> site) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
2090 Token::Value op() const { return op_; } 2073 Token::Value op() const { return op_; }
2091 Expression* expression() const { return expression_; } 2074 Expression* expression() const { return expression_; }
2092 void set_expression(Expression* e) { expression_ = e; } 2075 void set_expression(Expression* e) { expression_ = e; }
2093 2076
2094 // For unary not (Token::NOT), the AST ids where true and false will 2077 // For unary not (Token::NOT), the AST ids where true and false will
2095 // actually be materialized, respectively. 2078 // actually be materialized, respectively.
2096 static int num_ids() { return parent_num_ids() + 2; } 2079 static int num_ids() { return parent_num_ids() + 2; }
2097 BailoutId MaterializeTrueId() const { return BailoutId(local_id(0)); } 2080 BailoutId MaterializeTrueId() const { return BailoutId(local_id(0)); }
2098 BailoutId MaterializeFalseId() const { return BailoutId(local_id(1)); } 2081 BailoutId MaterializeFalseId() const { return BailoutId(local_id(1)); }
2099 2082
2100 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) override; 2083 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle);
2101 2084
2102 protected: 2085 protected:
2103 UnaryOperation(Zone* zone, Token::Value op, Expression* expression, int pos) 2086 UnaryOperation(Zone* zone, Token::Value op, Expression* expression, int pos)
2104 : Expression(zone, pos), op_(op), expression_(expression) { 2087 : Expression(zone, pos), op_(op), expression_(expression) {
2105 DCHECK(Token::IsUnaryOp(op)); 2088 DCHECK(Token::IsUnaryOp(op));
2106 } 2089 }
2107 static int parent_num_ids() { return Expression::num_ids(); } 2090 static int parent_num_ids() { return Expression::num_ids(); }
2108 2091
2109 private: 2092 private:
2110 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2093 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
(...skipping 10 matching lines...) Expand all
2121 Token::Value op() const { return static_cast<Token::Value>(op_); } 2104 Token::Value op() const { return static_cast<Token::Value>(op_); }
2122 Expression* left() const { return left_; } 2105 Expression* left() const { return left_; }
2123 void set_left(Expression* e) { left_ = e; } 2106 void set_left(Expression* e) { left_ = e; }
2124 Expression* right() const { return right_; } 2107 Expression* right() const { return right_; }
2125 void set_right(Expression* e) { right_ = e; } 2108 void set_right(Expression* e) { right_ = e; }
2126 Handle<AllocationSite> allocation_site() const { return allocation_site_; } 2109 Handle<AllocationSite> allocation_site() const { return allocation_site_; }
2127 void set_allocation_site(Handle<AllocationSite> allocation_site) { 2110 void set_allocation_site(Handle<AllocationSite> allocation_site) {
2128 allocation_site_ = allocation_site; 2111 allocation_site_ = allocation_site;
2129 } 2112 }
2130 2113
2131 void MarkTail() override { 2114 void MarkTail() {
2132 switch (op()) { 2115 switch (op()) {
2133 case Token::COMMA: 2116 case Token::COMMA:
2134 case Token::AND: 2117 case Token::AND:
2135 case Token::OR: 2118 case Token::OR:
2136 right_->MarkTail(); 2119 right_->MarkTail();
2137 default: 2120 default:
2138 break; 2121 break;
2139 } 2122 }
2140 } 2123 }
2141 2124
2142 // The short-circuit logical operations need an AST ID for their 2125 // The short-circuit logical operations need an AST ID for their
2143 // right-hand subexpression. 2126 // right-hand subexpression.
2144 static int num_ids() { return parent_num_ids() + 2; } 2127 static int num_ids() { return parent_num_ids() + 2; }
2145 BailoutId RightId() const { return BailoutId(local_id(0)); } 2128 BailoutId RightId() const { return BailoutId(local_id(0)); }
2146 2129
2147 TypeFeedbackId BinaryOperationFeedbackId() const { 2130 TypeFeedbackId BinaryOperationFeedbackId() const {
2148 return TypeFeedbackId(local_id(1)); 2131 return TypeFeedbackId(local_id(1));
2149 } 2132 }
2150 Maybe<int> fixed_right_arg() const { 2133 Maybe<int> fixed_right_arg() const {
2151 return has_fixed_right_arg_ ? Just(fixed_right_arg_value_) : Nothing<int>(); 2134 return has_fixed_right_arg_ ? Just(fixed_right_arg_value_) : Nothing<int>();
2152 } 2135 }
2153 void set_fixed_right_arg(Maybe<int> arg) { 2136 void set_fixed_right_arg(Maybe<int> arg) {
2154 has_fixed_right_arg_ = arg.IsJust(); 2137 has_fixed_right_arg_ = arg.IsJust();
2155 if (arg.IsJust()) fixed_right_arg_value_ = arg.FromJust(); 2138 if (arg.IsJust()) fixed_right_arg_value_ = arg.FromJust();
2156 } 2139 }
2157 2140
2158 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) override; 2141 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle);
2159 2142
2160 protected: 2143 protected:
2161 BinaryOperation(Zone* zone, Token::Value op, Expression* left, 2144 BinaryOperation(Zone* zone, Token::Value op, Expression* left,
2162 Expression* right, int pos) 2145 Expression* right, int pos)
2163 : Expression(zone, pos), 2146 : Expression(zone, pos),
2164 op_(static_cast<byte>(op)), 2147 op_(static_cast<byte>(op)),
2165 has_fixed_right_arg_(false), 2148 has_fixed_right_arg_(false),
2166 fixed_right_arg_value_(0), 2149 fixed_right_arg_value_(0),
2167 left_(left), 2150 left_(left),
2168 right_(right) { 2151 right_(right) {
(...skipping 23 matching lines...) Expand all
2192 bool is_postfix() const { return !is_prefix(); } 2175 bool is_postfix() const { return !is_prefix(); }
2193 2176
2194 Token::Value op() const { return TokenField::decode(bit_field_); } 2177 Token::Value op() const { return TokenField::decode(bit_field_); }
2195 Token::Value binary_op() { 2178 Token::Value binary_op() {
2196 return (op() == Token::INC) ? Token::ADD : Token::SUB; 2179 return (op() == Token::INC) ? Token::ADD : Token::SUB;
2197 } 2180 }
2198 2181
2199 Expression* expression() const { return expression_; } 2182 Expression* expression() const { return expression_; }
2200 void set_expression(Expression* e) { expression_ = e; } 2183 void set_expression(Expression* e) { expression_ = e; }
2201 2184
2202 bool IsMonomorphic() override { return receiver_types_.length() == 1; } 2185 bool IsMonomorphic() const { return receiver_types_.length() == 1; }
2203 SmallMapList* GetReceiverTypes() override { return &receiver_types_; } 2186 SmallMapList* GetReceiverTypes() { return &receiver_types_; }
2204 IcCheckType GetKeyType() const override { 2187 IcCheckType GetKeyType() const { return KeyTypeField::decode(bit_field_); }
2205 return KeyTypeField::decode(bit_field_); 2188 KeyedAccessStoreMode GetStoreMode() const {
2206 }
2207 KeyedAccessStoreMode GetStoreMode() const override {
2208 return StoreModeField::decode(bit_field_); 2189 return StoreModeField::decode(bit_field_);
2209 } 2190 }
2210 Type* type() const { return type_; } 2191 Type* type() const { return type_; }
2211 void set_key_type(IcCheckType type) { 2192 void set_key_type(IcCheckType type) {
2212 bit_field_ = KeyTypeField::update(bit_field_, type); 2193 bit_field_ = KeyTypeField::update(bit_field_, type);
2213 } 2194 }
2214 void set_store_mode(KeyedAccessStoreMode mode) { 2195 void set_store_mode(KeyedAccessStoreMode mode) {
2215 bit_field_ = StoreModeField::update(bit_field_, mode); 2196 bit_field_ = StoreModeField::update(bit_field_, mode);
2216 } 2197 }
2217 void set_type(Type* type) { type_ = type; } 2198 void set_type(Type* type) { type_ = type; }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2335 DECLARE_NODE_TYPE(Conditional) 2316 DECLARE_NODE_TYPE(Conditional)
2336 2317
2337 Expression* condition() const { return condition_; } 2318 Expression* condition() const { return condition_; }
2338 Expression* then_expression() const { return then_expression_; } 2319 Expression* then_expression() const { return then_expression_; }
2339 Expression* else_expression() const { return else_expression_; } 2320 Expression* else_expression() const { return else_expression_; }
2340 2321
2341 void set_condition(Expression* e) { condition_ = e; } 2322 void set_condition(Expression* e) { condition_ = e; }
2342 void set_then_expression(Expression* e) { then_expression_ = e; } 2323 void set_then_expression(Expression* e) { then_expression_ = e; }
2343 void set_else_expression(Expression* e) { else_expression_ = e; } 2324 void set_else_expression(Expression* e) { else_expression_ = e; }
2344 2325
2345 void MarkTail() override { 2326 void MarkTail() {
2346 then_expression_->MarkTail(); 2327 then_expression_->MarkTail();
2347 else_expression_->MarkTail(); 2328 else_expression_->MarkTail();
2348 } 2329 }
2349 2330
2350 static int num_ids() { return parent_num_ids() + 2; } 2331 static int num_ids() { return parent_num_ids() + 2; }
2351 BailoutId ThenId() const { return BailoutId(local_id(0)); } 2332 BailoutId ThenId() const { return BailoutId(local_id(0)); }
2352 BailoutId ElseId() const { return BailoutId(local_id(1)); } 2333 BailoutId ElseId() const { return BailoutId(local_id(1)); }
2353 2334
2354 protected: 2335 protected:
2355 Conditional(Zone* zone, Expression* condition, Expression* then_expression, 2336 Conditional(Zone* zone, Expression* condition, Expression* then_expression,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2387 BinaryOperation* binary_operation() const { return binary_operation_; } 2368 BinaryOperation* binary_operation() const { return binary_operation_; }
2388 2369
2389 // This check relies on the definition order of token in token.h. 2370 // This check relies on the definition order of token in token.h.
2390 bool is_compound() const { return op() > Token::ASSIGN; } 2371 bool is_compound() const { return op() > Token::ASSIGN; }
2391 2372
2392 static int num_ids() { return parent_num_ids() + 2; } 2373 static int num_ids() { return parent_num_ids() + 2; }
2393 BailoutId AssignmentId() const { return BailoutId(local_id(0)); } 2374 BailoutId AssignmentId() const { return BailoutId(local_id(0)); }
2394 2375
2395 // Type feedback information. 2376 // Type feedback information.
2396 TypeFeedbackId AssignmentFeedbackId() { return TypeFeedbackId(local_id(1)); } 2377 TypeFeedbackId AssignmentFeedbackId() { return TypeFeedbackId(local_id(1)); }
2397 bool IsMonomorphic() override { return receiver_types_.length() == 1; }
2398 bool IsUninitialized() const { 2378 bool IsUninitialized() const {
2399 return IsUninitializedField::decode(bit_field_); 2379 return IsUninitializedField::decode(bit_field_);
2400 } 2380 }
2401 bool HasNoTypeInformation() { 2381 bool HasNoTypeInformation() {
2402 return IsUninitializedField::decode(bit_field_); 2382 return IsUninitializedField::decode(bit_field_);
2403 } 2383 }
2404 SmallMapList* GetReceiverTypes() override { return &receiver_types_; } 2384 bool IsMonomorphic() const { return receiver_types_.length() == 1; }
2405 IcCheckType GetKeyType() const override { 2385 SmallMapList* GetReceiverTypes() { return &receiver_types_; }
2406 return KeyTypeField::decode(bit_field_); 2386 IcCheckType GetKeyType() const { return KeyTypeField::decode(bit_field_); }
2407 } 2387 KeyedAccessStoreMode GetStoreMode() const {
2408 KeyedAccessStoreMode GetStoreMode() const override {
2409 return StoreModeField::decode(bit_field_); 2388 return StoreModeField::decode(bit_field_);
2410 } 2389 }
2411 void set_is_uninitialized(bool b) { 2390 void set_is_uninitialized(bool b) {
2412 bit_field_ = IsUninitializedField::update(bit_field_, b); 2391 bit_field_ = IsUninitializedField::update(bit_field_, b);
2413 } 2392 }
2414 void set_key_type(IcCheckType key_type) { 2393 void set_key_type(IcCheckType key_type) {
2415 bit_field_ = KeyTypeField::update(bit_field_, key_type); 2394 bit_field_ = KeyTypeField::update(bit_field_, key_type);
2416 } 2395 }
2417 void set_store_mode(KeyedAccessStoreMode mode) { 2396 void set_store_mode(KeyedAccessStoreMode mode) {
2418 bit_field_ = StoreModeField::update(bit_field_, mode); 2397 bit_field_ = StoreModeField::update(bit_field_, mode);
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
2661 } 2640 }
2662 const FeedbackVectorSpec* feedback_vector_spec() const { 2641 const FeedbackVectorSpec* feedback_vector_spec() const {
2663 return ast_properties_.get_spec(); 2642 return ast_properties_.get_spec();
2664 } 2643 }
2665 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } 2644 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; }
2666 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } 2645 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; }
2667 void set_dont_optimize_reason(BailoutReason reason) { 2646 void set_dont_optimize_reason(BailoutReason reason) {
2668 dont_optimize_reason_ = reason; 2647 dont_optimize_reason_ = reason;
2669 } 2648 }
2670 2649
2671 bool IsAnonymousFunctionDefinition() const final { 2650 bool IsAnonymousFunctionDefinition() const {
2672 return is_anonymous_expression(); 2651 return is_anonymous_expression();
2673 } 2652 }
2674 2653
2675 int yield_count() { return yield_count_; } 2654 int yield_count() { return yield_count_; }
2676 void set_yield_count(int yield_count) { yield_count_ = yield_count; } 2655 void set_yield_count(int yield_count) { yield_count_ = yield_count; }
2677 2656
2678 protected: 2657 protected:
2679 FunctionLiteral(Zone* zone, const AstString* name, 2658 FunctionLiteral(Zone* zone, const AstString* name,
2680 AstValueFactory* ast_value_factory, Scope* scope, 2659 AstValueFactory* ast_value_factory, Scope* scope,
2681 ZoneList<Statement*>* body, int materialized_literal_count, 2660 ZoneList<Statement*>* body, int materialized_literal_count,
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2770 FeedbackVectorSlotCache* cache); 2749 FeedbackVectorSlotCache* cache);
2771 2750
2772 bool NeedsProxySlot() const { 2751 bool NeedsProxySlot() const {
2773 return class_variable_proxy() != nullptr && 2752 return class_variable_proxy() != nullptr &&
2774 class_variable_proxy()->var()->IsUnallocated(); 2753 class_variable_proxy()->var()->IsUnallocated();
2775 } 2754 }
2776 2755
2777 FeedbackVectorSlot PrototypeSlot() const { return prototype_slot_; } 2756 FeedbackVectorSlot PrototypeSlot() const { return prototype_slot_; }
2778 FeedbackVectorSlot ProxySlot() const { return proxy_slot_; } 2757 FeedbackVectorSlot ProxySlot() const { return proxy_slot_; }
2779 2758
2780 bool IsAnonymousFunctionDefinition() const final { 2759 bool IsAnonymousFunctionDefinition() const {
2781 return constructor()->raw_name()->length() == 0; 2760 return constructor()->raw_name()->length() == 0;
2782 } 2761 }
2783 2762
2784 protected: 2763 protected:
2785 ClassLiteral(Zone* zone, Scope* scope, VariableProxy* class_variable_proxy, 2764 ClassLiteral(Zone* zone, Scope* scope, VariableProxy* class_variable_proxy,
2786 Expression* extends, FunctionLiteral* constructor, 2765 Expression* extends, FunctionLiteral* constructor,
2787 ZoneList<Property*>* properties, int start_position, 2766 ZoneList<Property*>* properties, int start_position,
2788 int end_position) 2767 int end_position)
2789 : Expression(zone, start_position), 2768 : Expression(zone, start_position),
2790 scope_(scope), 2769 scope_(scope),
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
3547 : NULL; \ 3526 : NULL; \
3548 } 3527 }
3549 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3528 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3550 #undef DECLARE_NODE_FUNCTIONS 3529 #undef DECLARE_NODE_FUNCTIONS
3551 3530
3552 3531
3553 } // namespace internal 3532 } // namespace internal
3554 } // namespace v8 3533 } // namespace v8
3555 3534
3556 #endif // V8_AST_AST_H_ 3535 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/ast.cc » ('j') | src/ast/ast.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698