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

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

Issue 2266493002: Used a BitField to improve packing of AstNode and subclasses (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Merge branch 'master' into ast-packing 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 | « no previous file | src/ast/ast.cc » ('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 #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-types.h" 8 #include "src/ast/ast-types.h"
9 #include "src/ast/ast-value-factory.h" 9 #include "src/ast/ast-value-factory.h"
10 #include "src/ast/modules.h" 10 #include "src/ast/modules.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 186
187 class AstNode: public ZoneObject { 187 class AstNode: public ZoneObject {
188 public: 188 public:
189 #define DECLARE_TYPE_ENUM(type) k##type, 189 #define DECLARE_TYPE_ENUM(type) k##type,
190 enum NodeType : uint8_t { AST_NODE_LIST(DECLARE_TYPE_ENUM) }; 190 enum NodeType : uint8_t { AST_NODE_LIST(DECLARE_TYPE_ENUM) };
191 #undef DECLARE_TYPE_ENUM 191 #undef DECLARE_TYPE_ENUM
192 192
193 void* operator new(size_t size, Zone* zone) { return zone->New(size); } 193 void* operator new(size_t size, Zone* zone) { return zone->New(size); }
194 194
195 NodeType node_type() const { return node_type_; } 195 NodeType node_type() const { return NodeTypeField::decode(bit_field_); }
196 int position() const { return position_; } 196 int position() const { return position_; }
197 197
198 #ifdef DEBUG 198 #ifdef DEBUG
199 void Print(Isolate* isolate); 199 void Print(Isolate* isolate);
200 #endif // DEBUG 200 #endif // DEBUG
201 201
202 // Type testing & conversion functions overridden by concrete subclasses. 202 // Type testing & conversion functions overridden by concrete subclasses.
203 #define DECLARE_NODE_FUNCTIONS(type) \ 203 #define DECLARE_NODE_FUNCTIONS(type) \
204 V8_INLINE bool Is##type() const; \ 204 V8_INLINE bool Is##type() const; \
205 V8_INLINE type* As##type(); \ 205 V8_INLINE type* As##type(); \
206 V8_INLINE const type* As##type() const; 206 V8_INLINE const type* As##type() const;
207 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 207 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
208 #undef DECLARE_NODE_FUNCTIONS 208 #undef DECLARE_NODE_FUNCTIONS
209 209
210 BreakableStatement* AsBreakableStatement(); 210 BreakableStatement* AsBreakableStatement();
211 IterationStatement* AsIterationStatement(); 211 IterationStatement* AsIterationStatement();
212 MaterializedLiteral* AsMaterializedLiteral(); 212 MaterializedLiteral* AsMaterializedLiteral();
213 213
214 protected:
215 AstNode(int position, NodeType type)
216 : position_(position), node_type_(type) {}
217
218 private: 214 private:
219 // Hidden to prevent accidental usage. It would have to load the 215 // Hidden to prevent accidental usage. It would have to load the
220 // current zone from the TLS. 216 // current zone from the TLS.
221 void* operator new(size_t size); 217 void* operator new(size_t size);
222 218
223 int position_; 219 int position_;
224 NodeType node_type_; 220 class NodeTypeField : public BitField<NodeType, 0, 6> {};
225 // Ends with NodeType which is uint8_t sized. Deriving classes in turn begin 221
226 // sub-int32_t-sized fields for optimum packing efficiency. 222 protected:
223 uint32_t bit_field_;
224 static const uint8_t kNextBitFieldIndex = NodeTypeField::kNext;
225
226 AstNode(int position, NodeType type)
227 : position_(position), bit_field_(NodeTypeField::encode(type)) {}
227 }; 228 };
228 229
229 230
230 class Statement : public AstNode { 231 class Statement : public AstNode {
231 public: 232 public:
232 bool IsEmpty() { return AsEmptyStatement() != NULL; } 233 bool IsEmpty() { return AsEmptyStatement() != NULL; }
233 bool IsJump() const; 234 bool IsJump() const;
234 235
235 protected: 236 protected:
236 Statement(int position, NodeType type) : AstNode(position, type) {} 237 Statement(int position, NodeType type) : AstNode(position, type) {}
238
239 static const uint8_t kNextBitFieldIndex = AstNode::kNextBitFieldIndex;
237 }; 240 };
238 241
239 242
240 class SmallMapList final { 243 class SmallMapList final {
241 public: 244 public:
242 SmallMapList() {} 245 SmallMapList() {}
243 SmallMapList(int capacity, Zone* zone) : list_(capacity, zone) {} 246 SmallMapList(int capacity, Zone* zone) : list_(capacity, zone) {}
244 247
245 void Reserve(int capacity, Zone* zone) { list_.Reserve(capacity, zone); } 248 void Reserve(int capacity, Zone* zone) { list_.Reserve(capacity, zone); }
246 void Clear() { list_.Clear(); } 249 void Clear() { list_.Clear(); }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 SmallMapList* GetReceiverTypes(); 345 SmallMapList* GetReceiverTypes();
343 KeyedAccessStoreMode GetStoreMode() const; 346 KeyedAccessStoreMode GetStoreMode() const;
344 IcCheckType GetKeyType() const; 347 IcCheckType GetKeyType() const;
345 bool IsMonomorphic() const; 348 bool IsMonomorphic() const;
346 349
347 void set_base_id(int id) { base_id_ = id; } 350 void set_base_id(int id) { base_id_ = id; }
348 static int num_ids() { return parent_num_ids() + 2; } 351 static int num_ids() { return parent_num_ids() + 2; }
349 BailoutId id() const { return BailoutId(local_id(0)); } 352 BailoutId id() const { return BailoutId(local_id(0)); }
350 TypeFeedbackId test_id() const { return TypeFeedbackId(local_id(1)); } 353 TypeFeedbackId test_id() const { return TypeFeedbackId(local_id(1)); }
351 354
355 private:
356 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
357
358 int base_id_;
359 class ToBooleanTypesField
360 : public BitField<uint16_t, AstNode::kNextBitFieldIndex, 9> {};
361
352 protected: 362 protected:
353 Expression(int pos, NodeType type) 363 Expression(int pos, NodeType type)
354 : AstNode(pos, type), 364 : AstNode(pos, type), base_id_(BailoutId::None().ToInt()) {
355 bit_field_(0), 365 bit_field_ = ToBooleanTypesField::update(bit_field_, 0);
356 base_id_(BailoutId::None().ToInt()) {} 366 }
357 367
358 static int parent_num_ids() { return 0; } 368 static int parent_num_ids() { return 0; }
359 void set_to_boolean_types(uint16_t types) { 369 void set_to_boolean_types(uint16_t types) {
360 bit_field_ = ToBooleanTypesField::update(bit_field_, types); 370 bit_field_ = ToBooleanTypesField::update(bit_field_, types);
361 } 371 }
362 int base_id() const { 372 int base_id() const {
363 DCHECK(!BailoutId(base_id_).IsNone()); 373 DCHECK(!BailoutId(base_id_).IsNone());
364 return base_id_; 374 return base_id_;
365 } 375 }
366 376
367 private: 377 static const uint8_t kNextBitFieldIndex = ToBooleanTypesField::kNext;
368 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
369
370 uint16_t bit_field_;
371 int base_id_;
372 class ToBooleanTypesField : public BitField16<uint16_t, 0, 9> {};
373 }; 378 };
374 379
375 380
376 class BreakableStatement : public Statement { 381 class BreakableStatement : public Statement {
377 public: 382 public:
378 enum BreakableType { 383 enum BreakableType {
379 TARGET_FOR_ANONYMOUS, 384 TARGET_FOR_ANONYMOUS,
380 TARGET_FOR_NAMED_ONLY 385 TARGET_FOR_NAMED_ONLY
381 }; 386 };
382 387
383 // The labels associated with this statement. May be NULL; 388 // The labels associated with this statement. May be NULL;
384 // if it is != NULL, guaranteed to contain at least one entry. 389 // if it is != NULL, guaranteed to contain at least one entry.
385 ZoneList<const AstRawString*>* labels() const { return labels_; } 390 ZoneList<const AstRawString*>* labels() const { return labels_; }
386 391
387 // Code generation 392 // Code generation
388 Label* break_target() { return &break_target_; } 393 Label* break_target() { return &break_target_; }
389 394
390 // Testers. 395 // Testers.
391 bool is_target_for_anonymous() const { 396 bool is_target_for_anonymous() const {
392 return breakable_type_ == TARGET_FOR_ANONYMOUS; 397 return BreakableTypeField::decode(bit_field_) == TARGET_FOR_ANONYMOUS;
393 } 398 }
394 399
395 void set_base_id(int id) { base_id_ = id; } 400 void set_base_id(int id) { base_id_ = id; }
396 static int num_ids() { return parent_num_ids() + 2; } 401 static int num_ids() { return parent_num_ids() + 2; }
397 BailoutId EntryId() const { return BailoutId(local_id(0)); } 402 BailoutId EntryId() const { return BailoutId(local_id(0)); }
398 BailoutId ExitId() const { return BailoutId(local_id(1)); } 403 BailoutId ExitId() const { return BailoutId(local_id(1)); }
399 404
405 private:
406 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
407
408 BreakableType breakableType() const {
409 return BreakableTypeField::decode(bit_field_);
410 }
411
412 int base_id_;
413 Label break_target_;
414 ZoneList<const AstRawString*>* labels_;
415
416 class BreakableTypeField
417 : public BitField<BreakableType, Statement::kNextBitFieldIndex, 1> {};
418
400 protected: 419 protected:
401 BreakableStatement(ZoneList<const AstRawString*>* labels, 420 BreakableStatement(ZoneList<const AstRawString*>* labels,
402 BreakableType breakable_type, int position, NodeType type) 421 BreakableType breakable_type, int position, NodeType type)
403 : Statement(position, type), 422 : Statement(position, type),
404 breakable_type_(breakable_type),
405 base_id_(BailoutId::None().ToInt()), 423 base_id_(BailoutId::None().ToInt()),
406 labels_(labels) { 424 labels_(labels) {
407 DCHECK(labels == NULL || labels->length() > 0); 425 DCHECK(labels == NULL || labels->length() > 0);
426 bit_field_ |= BreakableTypeField::encode(breakable_type);
408 } 427 }
409 static int parent_num_ids() { return 0; } 428 static int parent_num_ids() { return 0; }
410 429
411 int base_id() const { 430 int base_id() const {
412 DCHECK(!BailoutId(base_id_).IsNone()); 431 DCHECK(!BailoutId(base_id_).IsNone());
413 return base_id_; 432 return base_id_;
414 } 433 }
415 434
416 private: 435 static const uint8_t kNextBitFieldIndex = BreakableTypeField::kNext;
417 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
418
419 BreakableType breakable_type_;
420 int base_id_;
421 Label break_target_;
422 ZoneList<const AstRawString*>* labels_;
423 }; 436 };
424 437
425 438
426 class Block final : public BreakableStatement { 439 class Block final : public BreakableStatement {
427 public: 440 public:
428 ZoneList<Statement*>* statements() { return &statements_; } 441 ZoneList<Statement*>* statements() { return &statements_; }
429 bool ignore_completion_value() const { return ignore_completion_value_; } 442 bool ignore_completion_value() const {
443 return IgnoreCompletionField::decode(bit_field_);
444 }
430 445
431 static int num_ids() { return parent_num_ids() + 1; } 446 static int num_ids() { return parent_num_ids() + 1; }
432 BailoutId DeclsId() const { return BailoutId(local_id(0)); } 447 BailoutId DeclsId() const { return BailoutId(local_id(0)); }
433 448
434 bool IsJump() const { 449 bool IsJump() const {
435 return !statements_.is_empty() && statements_.last()->IsJump() 450 return !statements_.is_empty() && statements_.last()->IsJump()
436 && labels() == NULL; // Good enough as an approximation... 451 && labels() == NULL; // Good enough as an approximation...
437 } 452 }
438 453
439 Scope* scope() const { return scope_; } 454 Scope* scope() const { return scope_; }
440 void set_scope(Scope* scope) { scope_ = scope; } 455 void set_scope(Scope* scope) { scope_ = scope; }
441 456
442 private: 457 private:
443 friend class AstNodeFactory; 458 friend class AstNodeFactory;
444 459
445 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, 460 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity,
446 bool ignore_completion_value, int pos) 461 bool ignore_completion_value, int pos)
447 : BreakableStatement(labels, TARGET_FOR_NAMED_ONLY, pos, kBlock), 462 : BreakableStatement(labels, TARGET_FOR_NAMED_ONLY, pos, kBlock),
448 statements_(capacity, zone), 463 statements_(capacity, zone),
449 ignore_completion_value_(ignore_completion_value), 464 scope_(NULL) {
450 scope_(NULL) {} 465 bit_field_ |= IgnoreCompletionField::encode(ignore_completion_value);
466 }
451 static int parent_num_ids() { return BreakableStatement::num_ids(); } 467 static int parent_num_ids() { return BreakableStatement::num_ids(); }
452 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 468 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
453 469
454 ZoneList<Statement*> statements_; 470 ZoneList<Statement*> statements_;
455 bool ignore_completion_value_;
456 Scope* scope_; 471 Scope* scope_;
472
473 class IgnoreCompletionField
474 : public BitField<bool, BreakableStatement::kNextBitFieldIndex, 1> {};
475
476 protected:
477 static const uint8_t kNextBitFieldIndex = IgnoreCompletionField::kNext;
457 }; 478 };
458 479
459 480
460 class DoExpression final : public Expression { 481 class DoExpression final : public Expression {
461 public: 482 public:
462 Block* block() { return block_; } 483 Block* block() { return block_; }
463 void set_block(Block* b) { block_ = b; } 484 void set_block(Block* b) { block_ = b; }
464 VariableProxy* result() { return result_; } 485 VariableProxy* result() { return result_; }
465 void set_result(VariableProxy* v) { result_ = v; } 486 void set_result(VariableProxy* v) { result_ = v; }
466 FunctionLiteral* represented_function() { return represented_function_; } 487 FunctionLiteral* represented_function() { return represented_function_; }
467 void set_represented_function(FunctionLiteral* f) { 488 void set_represented_function(FunctionLiteral* f) {
468 represented_function_ = f; 489 represented_function_ = f;
469 } 490 }
470 bool IsAnonymousFunctionDefinition() const; 491 bool IsAnonymousFunctionDefinition() const;
471 492
493 protected:
494 static const uint8_t kNextBitFieldIndex = Expression::kNextBitFieldIndex;
495
472 private: 496 private:
473 friend class AstNodeFactory; 497 friend class AstNodeFactory;
474 498
475 DoExpression(Block* block, VariableProxy* result, int pos) 499 DoExpression(Block* block, VariableProxy* result, int pos)
476 : Expression(pos, kDoExpression), 500 : Expression(pos, kDoExpression),
477 block_(block), 501 block_(block),
478 result_(result), 502 result_(result),
479 represented_function_(nullptr) { 503 represented_function_(nullptr) {
480 DCHECK_NOT_NULL(block_); 504 DCHECK_NOT_NULL(block_);
481 DCHECK_NOT_NULL(result_); 505 DCHECK_NOT_NULL(result_);
482 } 506 }
483 static int parent_num_ids() { return Expression::num_ids(); } 507 static int parent_num_ids() { return Expression::num_ids(); }
484 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 508 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
485 509
486 Block* block_; 510 Block* block_;
487 VariableProxy* result_; 511 VariableProxy* result_;
488 FunctionLiteral* represented_function_; 512 FunctionLiteral* represented_function_;
489 }; 513 };
490 514
491 515
492 class Declaration : public AstNode { 516 class Declaration : public AstNode {
493 public: 517 public:
494 VariableProxy* proxy() const { return proxy_; } 518 VariableProxy* proxy() const { return proxy_; }
495 Scope* scope() const { return scope_; } 519 Scope* scope() const { return scope_; }
496 520
497 protected: 521 protected:
498 Declaration(VariableProxy* proxy, Scope* scope, int pos, NodeType type) 522 Declaration(VariableProxy* proxy, Scope* scope, int pos, NodeType type)
499 : AstNode(pos, type), proxy_(proxy), scope_(scope) {} 523 : AstNode(pos, type), proxy_(proxy), scope_(scope) {}
500 524
525 static const uint8_t kNextBitFieldIndex = AstNode::kNextBitFieldIndex;
526
501 private: 527 private:
502 VariableProxy* proxy_; 528 VariableProxy* proxy_;
503 529
504 // Nested scope from which the declaration originated. 530 // Nested scope from which the declaration originated.
505 Scope* scope_; 531 Scope* scope_;
506 }; 532 };
507 533
508 534
509 class VariableDeclaration final : public Declaration { 535 class VariableDeclaration final : public Declaration {
510 private: 536 private:
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 protected: 580 protected:
555 IterationStatement(ZoneList<const AstRawString*>* labels, int pos, 581 IterationStatement(ZoneList<const AstRawString*>* labels, int pos,
556 NodeType type) 582 NodeType type)
557 : BreakableStatement(labels, TARGET_FOR_ANONYMOUS, pos, type), 583 : BreakableStatement(labels, TARGET_FOR_ANONYMOUS, pos, type),
558 body_(NULL), 584 body_(NULL),
559 yield_count_(0), 585 yield_count_(0),
560 first_yield_id_(0) {} 586 first_yield_id_(0) {}
561 static int parent_num_ids() { return BreakableStatement::num_ids(); } 587 static int parent_num_ids() { return BreakableStatement::num_ids(); }
562 void Initialize(Statement* body) { body_ = body; } 588 void Initialize(Statement* body) { body_ = body; }
563 589
590 static const uint8_t kNextBitFieldIndex =
591 BreakableStatement::kNextBitFieldIndex;
592
564 private: 593 private:
565 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 594 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
566 595
567 Statement* body_; 596 Statement* body_;
568 Label continue_target_; 597 Label continue_target_;
569 int yield_count_; 598 int yield_count_;
570 int first_yield_id_; 599 int first_yield_id_;
571 }; 600 };
572 601
573 602
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 // Type feedback information. 737 // Type feedback information.
709 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 738 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
710 FeedbackVectorSlotCache* cache); 739 FeedbackVectorSlotCache* cache);
711 FeedbackVectorSlot EachFeedbackSlot() const { return each_slot_; } 740 FeedbackVectorSlot EachFeedbackSlot() const { return each_slot_; }
712 FeedbackVectorSlot ForInFeedbackSlot() { 741 FeedbackVectorSlot ForInFeedbackSlot() {
713 DCHECK(!for_in_feedback_slot_.IsInvalid()); 742 DCHECK(!for_in_feedback_slot_.IsInvalid());
714 return for_in_feedback_slot_; 743 return for_in_feedback_slot_;
715 } 744 }
716 745
717 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; 746 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN };
718 ForInType for_in_type() const { return for_in_type_; } 747 ForInType for_in_type() const { return ForInTypeField::decode(bit_field_); }
719 void set_for_in_type(ForInType type) { for_in_type_ = type; } 748 void set_for_in_type(ForInType type) {
749 bit_field_ = ForInTypeField::update(bit_field_, type);
750 }
720 751
721 static int num_ids() { return parent_num_ids() + 7; } 752 static int num_ids() { return parent_num_ids() + 7; }
722 BailoutId BodyId() const { return BailoutId(local_id(0)); } 753 BailoutId BodyId() const { return BailoutId(local_id(0)); }
723 BailoutId EnumId() const { return BailoutId(local_id(1)); } 754 BailoutId EnumId() const { return BailoutId(local_id(1)); }
724 BailoutId ToObjectId() const { return BailoutId(local_id(2)); } 755 BailoutId ToObjectId() const { return BailoutId(local_id(2)); }
725 BailoutId PrepareId() const { return BailoutId(local_id(3)); } 756 BailoutId PrepareId() const { return BailoutId(local_id(3)); }
726 BailoutId FilterId() const { return BailoutId(local_id(4)); } 757 BailoutId FilterId() const { return BailoutId(local_id(4)); }
727 BailoutId AssignmentId() const { return BailoutId(local_id(5)); } 758 BailoutId AssignmentId() const { return BailoutId(local_id(5)); }
728 BailoutId IncrementId() const { return BailoutId(local_id(6)); } 759 BailoutId IncrementId() const { return BailoutId(local_id(6)); }
729 BailoutId ContinueId() const { return EntryId(); } 760 BailoutId ContinueId() const { return EntryId(); }
730 BailoutId StackCheckId() const { return BodyId(); } 761 BailoutId StackCheckId() const { return BodyId(); }
731 762
732 private: 763 private:
733 friend class AstNodeFactory; 764 friend class AstNodeFactory;
734 765
735 ForInStatement(ZoneList<const AstRawString*>* labels, int pos) 766 ForInStatement(ZoneList<const AstRawString*>* labels, int pos)
736 : ForEachStatement(labels, pos, kForInStatement), 767 : ForEachStatement(labels, pos, kForInStatement),
737 each_(nullptr), 768 each_(nullptr),
738 subject_(nullptr), 769 subject_(nullptr) {
739 for_in_type_(SLOW_FOR_IN) {} 770 bit_field_ = ForInTypeField::update(bit_field_, SLOW_FOR_IN);
771 }
772
740 static int parent_num_ids() { return ForEachStatement::num_ids(); } 773 static int parent_num_ids() { return ForEachStatement::num_ids(); }
741 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 774 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
742 775
743 Expression* each_; 776 Expression* each_;
744 Expression* subject_; 777 Expression* subject_;
745 ForInType for_in_type_;
746 FeedbackVectorSlot each_slot_; 778 FeedbackVectorSlot each_slot_;
747 FeedbackVectorSlot for_in_feedback_slot_; 779 FeedbackVectorSlot for_in_feedback_slot_;
780
781 class ForInTypeField
782 : public BitField<ForInType, ForEachStatement::kNextBitFieldIndex, 1> {};
783
784 protected:
785 static const uint8_t kNextBitFieldIndex = ForInTypeField::kNext;
748 }; 786 };
749 787
750 788
751 class ForOfStatement final : public ForEachStatement { 789 class ForOfStatement final : public ForEachStatement {
752 public: 790 public:
753 void Initialize(Statement* body, Variable* iterator, 791 void Initialize(Statement* body, Variable* iterator,
754 Expression* assign_iterator, Expression* next_result, 792 Expression* assign_iterator, Expression* next_result,
755 Expression* result_done, Expression* assign_each) { 793 Expression* result_done, Expression* assign_each) {
756 ForEachStatement::Initialize(body); 794 ForEachStatement::Initialize(body);
757 iterator_ = iterator; 795 iterator_ = iterator;
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 class MaterializedLiteral : public Expression { 1284 class MaterializedLiteral : public Expression {
1247 public: 1285 public:
1248 int literal_index() { return literal_index_; } 1286 int literal_index() { return literal_index_; }
1249 1287
1250 int depth() const { 1288 int depth() const {
1251 // only callable after initialization. 1289 // only callable after initialization.
1252 DCHECK(depth_ >= 1); 1290 DCHECK(depth_ >= 1);
1253 return depth_; 1291 return depth_;
1254 } 1292 }
1255 1293
1294 private:
1295 int depth_ : 31;
1296 int literal_index_;
1297
1298 friend class AstLiteralReindexer;
1299
1300 class IsSimpleField
1301 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {};
1302
1256 protected: 1303 protected:
1257 MaterializedLiteral(int literal_index, int pos, NodeType type) 1304 MaterializedLiteral(int literal_index, int pos, NodeType type)
1258 : Expression(pos, type), 1305 : Expression(pos, type), depth_(0), literal_index_(literal_index) {
1259 is_simple_(false), 1306 bit_field_ |= IsSimpleField::encode(false);
1260 depth_(0), 1307 }
1261 literal_index_(literal_index) {}
1262 1308
1263 // A materialized literal is simple if the values consist of only 1309 // A materialized literal is simple if the values consist of only
1264 // constants and simple object and array literals. 1310 // constants and simple object and array literals.
1265 bool is_simple() const { return is_simple_; } 1311 bool is_simple() const { return IsSimpleField::decode(bit_field_); }
1266 void set_is_simple(bool is_simple) { is_simple_ = is_simple; } 1312 void set_is_simple(bool is_simple) {
1313 bit_field_ = IsSimpleField::update(bit_field_, is_simple);
1314 }
1267 friend class CompileTimeValue; 1315 friend class CompileTimeValue;
1268 1316
1269 void set_depth(int depth) { 1317 void set_depth(int depth) {
1270 DCHECK_LE(1, depth); 1318 DCHECK_LE(1, depth);
1271 depth_ = depth; 1319 depth_ = depth;
1272 } 1320 }
1273 1321
1274 // Populate the constant properties/elements fixed array. 1322 // Populate the constant properties/elements fixed array.
1275 void BuildConstants(Isolate* isolate); 1323 void BuildConstants(Isolate* isolate);
1276 friend class ArrayLiteral; 1324 friend class ArrayLiteral;
1277 friend class ObjectLiteral; 1325 friend class ObjectLiteral;
1278 1326
1279 // If the expression is a literal, return the literal value; 1327 // If the expression is a literal, return the literal value;
1280 // if the expression is a materialized literal and is simple return a 1328 // if the expression is a materialized literal and is simple return a
1281 // compile time value as encoded by CompileTimeValue::GetValue(). 1329 // compile time value as encoded by CompileTimeValue::GetValue().
1282 // Otherwise, return undefined literal as the placeholder 1330 // Otherwise, return undefined literal as the placeholder
1283 // in the object literal boilerplate. 1331 // in the object literal boilerplate.
1284 Handle<Object> GetBoilerplateValue(Expression* expression, Isolate* isolate); 1332 Handle<Object> GetBoilerplateValue(Expression* expression, Isolate* isolate);
1285 1333
1286 private: 1334 static const uint8_t kNextBitFieldIndex = IsSimpleField::kNext;
1287 bool is_simple_ : 1;
1288 int depth_ : 31;
1289 int literal_index_;
1290
1291 friend class AstLiteralReindexer;
1292 }; 1335 };
1293 1336
1294 // Common supertype for ObjectLiteralProperty and ClassLiteralProperty 1337 // Common supertype for ObjectLiteralProperty and ClassLiteralProperty
1295 class LiteralProperty : public ZoneObject { 1338 class LiteralProperty : public ZoneObject {
1296 public: 1339 public:
1297 Expression* key() const { return key_; } 1340 Expression* key() const { return key_; }
1298 Expression* value() const { return value_; } 1341 Expression* value() const { return value_; }
1299 void set_key(Expression* e) { key_ = e; } 1342 void set_key(Expression* e) { key_ = e; }
1300 void set_value(Expression* e) { value_ = e; } 1343 void set_value(Expression* e) { value_ = e; }
1301 1344
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 // for minimizing the work when constructing it at runtime. 1411 // for minimizing the work when constructing it at runtime.
1369 class ObjectLiteral final : public MaterializedLiteral { 1412 class ObjectLiteral final : public MaterializedLiteral {
1370 public: 1413 public:
1371 typedef ObjectLiteralProperty Property; 1414 typedef ObjectLiteralProperty Property;
1372 1415
1373 Handle<FixedArray> constant_properties() const { 1416 Handle<FixedArray> constant_properties() const {
1374 return constant_properties_; 1417 return constant_properties_;
1375 } 1418 }
1376 int properties_count() const { return boilerplate_properties_; } 1419 int properties_count() const { return boilerplate_properties_; }
1377 ZoneList<Property*>* properties() const { return properties_; } 1420 ZoneList<Property*>* properties() const { return properties_; }
1378 bool fast_elements() const { return fast_elements_; } 1421 bool fast_elements() const { return FastElementsField::decode(bit_field_); }
1379 bool may_store_doubles() const { return may_store_doubles_; } 1422 bool may_store_doubles() const {
1380 bool has_elements() const { return has_elements_; } 1423 return MayStoreDoublesField::decode(bit_field_);
1424 }
1425 bool has_elements() const { return HasElementsField::decode(bit_field_); }
1381 bool has_shallow_properties() const { 1426 bool has_shallow_properties() const {
1382 return depth() == 1 && !has_elements() && !may_store_doubles(); 1427 return depth() == 1 && !has_elements() && !may_store_doubles();
1383 } 1428 }
1384 1429
1385 // Decide if a property should be in the object boilerplate. 1430 // Decide if a property should be in the object boilerplate.
1386 static bool IsBoilerplateProperty(Property* property); 1431 static bool IsBoilerplateProperty(Property* property);
1387 1432
1388 // Populate the constant properties fixed array. 1433 // Populate the constant properties fixed array.
1389 void BuildConstantProperties(Isolate* isolate); 1434 void BuildConstantProperties(Isolate* isolate);
1390 1435
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 1485 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
1441 FeedbackVectorSlotCache* cache); 1486 FeedbackVectorSlotCache* cache);
1442 1487
1443 private: 1488 private:
1444 friend class AstNodeFactory; 1489 friend class AstNodeFactory;
1445 1490
1446 ObjectLiteral(ZoneList<Property*>* properties, int literal_index, 1491 ObjectLiteral(ZoneList<Property*>* properties, int literal_index,
1447 uint32_t boilerplate_properties, int pos) 1492 uint32_t boilerplate_properties, int pos)
1448 : MaterializedLiteral(literal_index, pos, kObjectLiteral), 1493 : MaterializedLiteral(literal_index, pos, kObjectLiteral),
1449 boilerplate_properties_(boilerplate_properties), 1494 boilerplate_properties_(boilerplate_properties),
1450 fast_elements_(false), 1495 properties_(properties) {
1451 has_elements_(false), 1496 bit_field_ |= FastElementsField::encode(false) |
1452 may_store_doubles_(false), 1497 HasElementsField::encode(false) |
1453 properties_(properties) {} 1498 MayStoreDoublesField::encode(false);
1499 }
1454 1500
1455 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } 1501 static int parent_num_ids() { return MaterializedLiteral::num_ids(); }
1456 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 1502 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1457 1503
1458 uint32_t boilerplate_properties_ : 29; 1504 uint32_t boilerplate_properties_;
1459 bool fast_elements_ : 1;
1460 bool has_elements_ : 1;
1461 bool may_store_doubles_ : 1;
1462 FeedbackVectorSlot slot_; 1505 FeedbackVectorSlot slot_;
1463 Handle<FixedArray> constant_properties_; 1506 Handle<FixedArray> constant_properties_;
1464 ZoneList<Property*>* properties_; 1507 ZoneList<Property*>* properties_;
1508
1509 class FastElementsField
1510 : public BitField<bool, MaterializedLiteral::kNextBitFieldIndex, 1> {};
1511 class HasElementsField : public BitField<bool, FastElementsField::kNext, 1> {
1512 };
1513 class MayStoreDoublesField
1514 : public BitField<bool, HasElementsField::kNext, 1> {};
1515
1516 protected:
1517 static const uint8_t kNextBitFieldIndex = MayStoreDoublesField::kNext;
1465 }; 1518 };
1466 1519
1467 1520
1468 // A map from property names to getter/setter pairs allocated in the zone. 1521 // A map from property names to getter/setter pairs allocated in the zone.
1469 class AccessorTable 1522 class AccessorTable
1470 : public base::TemplateHashMap<Literal, ObjectLiteral::Accessors, 1523 : public base::TemplateHashMap<Literal, ObjectLiteral::Accessors,
1471 ZoneAllocationPolicy> { 1524 ZoneAllocationPolicy> {
1472 public: 1525 public:
1473 explicit AccessorTable(Zone* zone) 1526 explicit AccessorTable(Zone* zone)
1474 : base::TemplateHashMap<Literal, ObjectLiteral::Accessors, 1527 : base::TemplateHashMap<Literal, ObjectLiteral::Accessors,
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 friend class AstNodeFactory; 1699 friend class AstNodeFactory;
1647 1700
1648 VariableProxy(Variable* var, int start_position, int end_position); 1701 VariableProxy(Variable* var, int start_position, int end_position);
1649 VariableProxy(const AstRawString* name, VariableKind variable_kind, 1702 VariableProxy(const AstRawString* name, VariableKind variable_kind,
1650 int start_position, int end_position); 1703 int start_position, int end_position);
1651 explicit VariableProxy(const VariableProxy* copy_from); 1704 explicit VariableProxy(const VariableProxy* copy_from);
1652 1705
1653 static int parent_num_ids() { return Expression::num_ids(); } 1706 static int parent_num_ids() { return Expression::num_ids(); }
1654 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 1707 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1655 1708
1656 class IsThisField : public BitField8<bool, 0, 1> {}; 1709 class IsThisField : public BitField<bool, Expression::kNextBitFieldIndex, 1> {
1657 class IsAssignedField : public BitField8<bool, 1, 1> {}; 1710 };
1658 class IsResolvedField : public BitField8<bool, 2, 1> {}; 1711 class IsAssignedField : public BitField<bool, IsThisField::kNext, 1> {};
1659 class IsNewTargetField : public BitField8<bool, 3, 1> {}; 1712 class IsResolvedField : public BitField<bool, IsAssignedField::kNext, 1> {};
1713 class IsNewTargetField : public BitField<bool, IsResolvedField::kNext, 1> {};
1660 1714
1661 uint8_t bit_field_;
1662 // Position is stored in the AstNode superclass, but VariableProxy needs to 1715 // Position is stored in the AstNode superclass, but VariableProxy needs to
1663 // know its end position too (for error messages). It cannot be inferred from 1716 // know its end position too (for error messages). It cannot be inferred from
1664 // the variable name length because it can contain escapes. 1717 // the variable name length because it can contain escapes.
1665 int end_position_; 1718 int end_position_;
1666 FeedbackVectorSlot variable_feedback_slot_; 1719 FeedbackVectorSlot variable_feedback_slot_;
1667 union { 1720 union {
1668 const AstRawString* raw_name_; // if !is_resolved_ 1721 const AstRawString* raw_name_; // if !is_resolved_
1669 Variable* var_; // if is_resolved_ 1722 Variable* var_; // if is_resolved_
1670 }; 1723 };
1671 VariableProxy* next_unresolved_; 1724 VariableProxy* next_unresolved_;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 bool super_access = property->IsSuperAccess(); 1801 bool super_access = property->IsSuperAccess();
1749 return (property->key()->IsPropertyName()) 1802 return (property->key()->IsPropertyName())
1750 ? (super_access ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY) 1803 ? (super_access ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY)
1751 : (super_access ? KEYED_SUPER_PROPERTY : KEYED_PROPERTY); 1804 : (super_access ? KEYED_SUPER_PROPERTY : KEYED_PROPERTY);
1752 } 1805 }
1753 1806
1754 private: 1807 private:
1755 friend class AstNodeFactory; 1808 friend class AstNodeFactory;
1756 1809
1757 Property(Expression* obj, Expression* key, int pos) 1810 Property(Expression* obj, Expression* key, int pos)
1758 : Expression(pos, kProperty), 1811 : Expression(pos, kProperty), obj_(obj), key_(key) {
1759 bit_field_(IsForCallField::encode(false) | 1812 bit_field_ |= IsForCallField::encode(false) |
1760 IsStringAccessField::encode(false) | 1813 IsStringAccessField::encode(false) |
1761 InlineCacheStateField::encode(UNINITIALIZED)), 1814 InlineCacheStateField::encode(UNINITIALIZED);
1762 obj_(obj), 1815 }
1763 key_(key) {}
1764 1816
1765 static int parent_num_ids() { return Expression::num_ids(); } 1817 static int parent_num_ids() { return Expression::num_ids(); }
1766 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 1818 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1767 1819
1768 class IsForCallField : public BitField8<bool, 0, 1> {}; 1820 class IsForCallField
1769 class IsStringAccessField : public BitField8<bool, 1, 1> {}; 1821 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {};
1770 class KeyTypeField : public BitField8<IcCheckType, 2, 1> {}; 1822 class IsStringAccessField : public BitField<bool, IsForCallField::kNext, 1> {
1771 class InlineCacheStateField : public BitField8<InlineCacheState, 3, 4> {}; 1823 };
1824 class KeyTypeField
1825 : public BitField<IcCheckType, IsStringAccessField::kNext, 1> {};
1826 class InlineCacheStateField
1827 : public BitField<InlineCacheState, KeyTypeField::kNext, 4> {};
1772 1828
1773 uint8_t bit_field_;
1774 FeedbackVectorSlot property_feedback_slot_; 1829 FeedbackVectorSlot property_feedback_slot_;
1775 Expression* obj_; 1830 Expression* obj_;
1776 Expression* key_; 1831 Expression* key_;
1777 SmallMapList receiver_types_; 1832 SmallMapList receiver_types_;
1778 }; 1833 };
1779 1834
1780 1835
1781 class Call final : public Expression { 1836 class Call final : public Expression {
1782 public: 1837 public:
1783 Expression* expression() const { return expression_; } 1838 Expression* expression() const { return expression_; }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 // Used to assert that the FullCodeGenerator records the return site. 1924 // Used to assert that the FullCodeGenerator records the return site.
1870 bool return_is_recorded_; 1925 bool return_is_recorded_;
1871 #endif 1926 #endif
1872 1927
1873 private: 1928 private:
1874 friend class AstNodeFactory; 1929 friend class AstNodeFactory;
1875 1930
1876 Call(Expression* expression, ZoneList<Expression*>* arguments, int pos, 1931 Call(Expression* expression, ZoneList<Expression*>* arguments, int pos,
1877 PossiblyEval possibly_eval) 1932 PossiblyEval possibly_eval)
1878 : Expression(pos, kCall), 1933 : Expression(pos, kCall),
1879 bit_field_(
1880 IsUninitializedField::encode(false) |
1881 IsPossiblyEvalField::encode(possibly_eval == IS_POSSIBLY_EVAL)),
1882 expression_(expression), 1934 expression_(expression),
1883 arguments_(arguments) { 1935 arguments_(arguments) {
1936 bit_field_ |=
1937 IsUninitializedField::encode(false) |
1938 IsPossiblyEvalField::encode(possibly_eval == IS_POSSIBLY_EVAL);
1939
1884 if (expression->IsProperty()) { 1940 if (expression->IsProperty()) {
1885 expression->AsProperty()->mark_for_call(); 1941 expression->AsProperty()->mark_for_call();
1886 } 1942 }
1887 } 1943 }
1888 1944
1889 static int parent_num_ids() { return Expression::num_ids(); } 1945 static int parent_num_ids() { return Expression::num_ids(); }
1890 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 1946 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1891 1947
1892 class IsUninitializedField : public BitField8<bool, 0, 1> {}; 1948 class IsUninitializedField
1893 class IsTailField : public BitField8<bool, 1, 1> {}; 1949 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {};
1894 class IsPossiblyEvalField : public BitField8<bool, 2, 1> {}; 1950 class IsTailField : public BitField<bool, IsUninitializedField::kNext, 1> {};
1951 class IsPossiblyEvalField : public BitField<bool, IsTailField::kNext, 1> {};
1895 1952
1896 uint8_t bit_field_;
1897 FeedbackVectorSlot ic_slot_; 1953 FeedbackVectorSlot ic_slot_;
1898 FeedbackVectorSlot stub_slot_; 1954 FeedbackVectorSlot stub_slot_;
1899 Expression* expression_; 1955 Expression* expression_;
1900 ZoneList<Expression*>* arguments_; 1956 ZoneList<Expression*>* arguments_;
1901 Handle<JSFunction> target_; 1957 Handle<JSFunction> target_;
1902 Handle<AllocationSite> allocation_site_; 1958 Handle<AllocationSite> allocation_site_;
1903 }; 1959 };
1904 1960
1905 1961
1906 class CallNew final : public Expression { 1962 class CallNew final : public Expression {
1907 public: 1963 public:
1908 Expression* expression() const { return expression_; } 1964 Expression* expression() const { return expression_; }
1909 ZoneList<Expression*>* arguments() const { return arguments_; } 1965 ZoneList<Expression*>* arguments() const { return arguments_; }
1910 1966
1911 void set_expression(Expression* e) { expression_ = e; } 1967 void set_expression(Expression* e) { expression_ = e; }
1912 1968
1913 // Type feedback information. 1969 // Type feedback information.
1914 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 1970 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
1915 FeedbackVectorSlotCache* cache) { 1971 FeedbackVectorSlotCache* cache) {
1916 // CallNew stores feedback in the exact same way as Call. We can 1972 // CallNew stores feedback in the exact same way as Call. We can
1917 // piggyback on the type feedback infrastructure for calls. 1973 // piggyback on the type feedback infrastructure for calls.
1918 callnew_feedback_slot_ = spec->AddCallICSlot(); 1974 callnew_feedback_slot_ = spec->AddCallICSlot();
1919 } 1975 }
1920 1976
1921 FeedbackVectorSlot CallNewFeedbackSlot() { 1977 FeedbackVectorSlot CallNewFeedbackSlot() {
1922 DCHECK(!callnew_feedback_slot_.IsInvalid()); 1978 DCHECK(!callnew_feedback_slot_.IsInvalid());
1923 return callnew_feedback_slot_; 1979 return callnew_feedback_slot_;
1924 } 1980 }
1925 1981
1926 bool IsMonomorphic() const { return is_monomorphic_; } 1982 bool IsMonomorphic() const { return IsMonomorphicField::decode(bit_field_); }
1927 Handle<JSFunction> target() const { return target_; } 1983 Handle<JSFunction> target() const { return target_; }
1928 Handle<AllocationSite> allocation_site() const { 1984 Handle<AllocationSite> allocation_site() const {
1929 return allocation_site_; 1985 return allocation_site_;
1930 } 1986 }
1931 1987
1932 static int num_ids() { return parent_num_ids() + 1; } 1988 static int num_ids() { return parent_num_ids() + 1; }
1933 static int feedback_slots() { return 1; } 1989 static int feedback_slots() { return 1; }
1934 BailoutId ReturnId() const { return BailoutId(local_id(0)); } 1990 BailoutId ReturnId() const { return BailoutId(local_id(0)); }
1935 1991
1936 void set_allocation_site(Handle<AllocationSite> site) { 1992 void set_allocation_site(Handle<AllocationSite> site) {
1937 allocation_site_ = site; 1993 allocation_site_ = site;
1938 } 1994 }
1939 void set_is_monomorphic(bool monomorphic) { is_monomorphic_ = monomorphic; } 1995 void set_is_monomorphic(bool monomorphic) {
1996 bit_field_ = IsMonomorphicField::update(bit_field_, monomorphic);
1997 }
1940 void set_target(Handle<JSFunction> target) { target_ = target; } 1998 void set_target(Handle<JSFunction> target) { target_ = target; }
1941 void SetKnownGlobalTarget(Handle<JSFunction> target) { 1999 void SetKnownGlobalTarget(Handle<JSFunction> target) {
1942 target_ = target; 2000 target_ = target;
1943 is_monomorphic_ = true; 2001 set_is_monomorphic(true);
1944 } 2002 }
1945 2003
1946 private: 2004 private:
1947 friend class AstNodeFactory; 2005 friend class AstNodeFactory;
1948 2006
1949 CallNew(Expression* expression, ZoneList<Expression*>* arguments, int pos) 2007 CallNew(Expression* expression, ZoneList<Expression*>* arguments, int pos)
1950 : Expression(pos, kCallNew), 2008 : Expression(pos, kCallNew),
1951 is_monomorphic_(false),
1952 expression_(expression), 2009 expression_(expression),
1953 arguments_(arguments) {} 2010 arguments_(arguments) {
2011 bit_field_ |= IsMonomorphicField::encode(false);
2012 }
1954 2013
1955 static int parent_num_ids() { return Expression::num_ids(); } 2014 static int parent_num_ids() { return Expression::num_ids(); }
1956 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2015 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1957 2016
1958 bool is_monomorphic_;
1959 FeedbackVectorSlot callnew_feedback_slot_; 2017 FeedbackVectorSlot callnew_feedback_slot_;
1960 Expression* expression_; 2018 Expression* expression_;
1961 ZoneList<Expression*>* arguments_; 2019 ZoneList<Expression*>* arguments_;
1962 Handle<JSFunction> target_; 2020 Handle<JSFunction> target_;
1963 Handle<AllocationSite> allocation_site_; 2021 Handle<AllocationSite> allocation_site_;
2022
2023 class IsMonomorphicField
2024 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {};
1964 }; 2025 };
1965 2026
1966 2027
1967 // The CallRuntime class does not represent any official JavaScript 2028 // The CallRuntime class does not represent any official JavaScript
1968 // language construct. Instead it is used to call a C or JS function 2029 // language construct. Instead it is used to call a C or JS function
1969 // with a set of arguments. This is used from the builtins that are 2030 // with a set of arguments. This is used from the builtins that are
1970 // implemented in JavaScript (see "v8natives.js"). 2031 // implemented in JavaScript (see "v8natives.js").
1971 class CallRuntime final : public Expression { 2032 class CallRuntime final : public Expression {
1972 public: 2033 public:
1973 ZoneList<Expression*>* arguments() const { return arguments_; } 2034 ZoneList<Expression*>* arguments() const { return arguments_; }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2011 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2072 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2012 2073
2013 int context_index_; 2074 int context_index_;
2014 const Runtime::Function* function_; 2075 const Runtime::Function* function_;
2015 ZoneList<Expression*>* arguments_; 2076 ZoneList<Expression*>* arguments_;
2016 }; 2077 };
2017 2078
2018 2079
2019 class UnaryOperation final : public Expression { 2080 class UnaryOperation final : public Expression {
2020 public: 2081 public:
2021 Token::Value op() const { return op_; } 2082 Token::Value op() const { return OperatorField::decode(bit_field_); }
2022 Expression* expression() const { return expression_; } 2083 Expression* expression() const { return expression_; }
2023 void set_expression(Expression* e) { expression_ = e; } 2084 void set_expression(Expression* e) { expression_ = e; }
2024 2085
2025 // For unary not (Token::NOT), the AST ids where true and false will 2086 // For unary not (Token::NOT), the AST ids where true and false will
2026 // actually be materialized, respectively. 2087 // actually be materialized, respectively.
2027 static int num_ids() { return parent_num_ids() + 2; } 2088 static int num_ids() { return parent_num_ids() + 2; }
2028 BailoutId MaterializeTrueId() const { return BailoutId(local_id(0)); } 2089 BailoutId MaterializeTrueId() const { return BailoutId(local_id(0)); }
2029 BailoutId MaterializeFalseId() const { return BailoutId(local_id(1)); } 2090 BailoutId MaterializeFalseId() const { return BailoutId(local_id(1)); }
2030 2091
2031 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); 2092 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle);
2032 2093
2033 private: 2094 private:
2034 friend class AstNodeFactory; 2095 friend class AstNodeFactory;
2035 2096
2036 UnaryOperation(Token::Value op, Expression* expression, int pos) 2097 UnaryOperation(Token::Value op, Expression* expression, int pos)
2037 : Expression(pos, kUnaryOperation), op_(op), expression_(expression) { 2098 : Expression(pos, kUnaryOperation), expression_(expression) {
2099 bit_field_ |= OperatorField::encode(op);
2038 DCHECK(Token::IsUnaryOp(op)); 2100 DCHECK(Token::IsUnaryOp(op));
2039 } 2101 }
2040 2102
2041 static int parent_num_ids() { return Expression::num_ids(); } 2103 static int parent_num_ids() { return Expression::num_ids(); }
2042 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2104 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2043 2105
2044 Token::Value op_;
2045 Expression* expression_; 2106 Expression* expression_;
2107
2108 class OperatorField
2109 : public BitField<Token::Value, Expression::kNextBitFieldIndex, 7> {};
2046 }; 2110 };
2047 2111
2048 2112
2049 class BinaryOperation final : public Expression { 2113 class BinaryOperation final : public Expression {
2050 public: 2114 public:
2051 Token::Value op() const { return static_cast<Token::Value>(op_); } 2115 Token::Value op() const { return OperatorField::decode(bit_field_); }
2052 Expression* left() const { return left_; } 2116 Expression* left() const { return left_; }
2053 void set_left(Expression* e) { left_ = e; } 2117 void set_left(Expression* e) { left_ = e; }
2054 Expression* right() const { return right_; } 2118 Expression* right() const { return right_; }
2055 void set_right(Expression* e) { right_ = e; } 2119 void set_right(Expression* e) { right_ = e; }
2056 Handle<AllocationSite> allocation_site() const { return allocation_site_; } 2120 Handle<AllocationSite> allocation_site() const { return allocation_site_; }
2057 void set_allocation_site(Handle<AllocationSite> allocation_site) { 2121 void set_allocation_site(Handle<AllocationSite> allocation_site) {
2058 allocation_site_ = allocation_site; 2122 allocation_site_ = allocation_site;
2059 } 2123 }
2060 2124
2061 void MarkTail() { 2125 void MarkTail() {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 if (arg.IsJust()) fixed_right_arg_value_ = arg.FromJust(); 2159 if (arg.IsJust()) fixed_right_arg_value_ = arg.FromJust();
2096 } 2160 }
2097 2161
2098 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); 2162 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle);
2099 2163
2100 private: 2164 private:
2101 friend class AstNodeFactory; 2165 friend class AstNodeFactory;
2102 2166
2103 BinaryOperation(Token::Value op, Expression* left, Expression* right, int pos) 2167 BinaryOperation(Token::Value op, Expression* left, Expression* right, int pos)
2104 : Expression(pos, kBinaryOperation), 2168 : Expression(pos, kBinaryOperation),
2105 op_(static_cast<byte>(op)),
2106 has_fixed_right_arg_(false), 2169 has_fixed_right_arg_(false),
2107 fixed_right_arg_value_(0), 2170 fixed_right_arg_value_(0),
2108 left_(left), 2171 left_(left),
2109 right_(right) { 2172 right_(right) {
2173 bit_field_ |= OperatorField::encode(op);
2110 DCHECK(Token::IsBinaryOp(op)); 2174 DCHECK(Token::IsBinaryOp(op));
2111 } 2175 }
2112 2176
2113 static int parent_num_ids() { return Expression::num_ids(); } 2177 static int parent_num_ids() { return Expression::num_ids(); }
2114 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2178 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2115 2179
2116 const byte op_; // actually Token::Value
2117 // TODO(rossberg): the fixed arg should probably be represented as a Constant 2180 // TODO(rossberg): the fixed arg should probably be represented as a Constant
2118 // type for the RHS. Currenty it's actually a Maybe<int> 2181 // type for the RHS. Currenty it's actually a Maybe<int>
2119 bool has_fixed_right_arg_; 2182 bool has_fixed_right_arg_;
2120 int fixed_right_arg_value_; 2183 int fixed_right_arg_value_;
2121 Expression* left_; 2184 Expression* left_;
2122 Expression* right_; 2185 Expression* right_;
2123 Handle<AllocationSite> allocation_site_; 2186 Handle<AllocationSite> allocation_site_;
2124 FeedbackVectorSlot type_feedback_slot_; 2187 FeedbackVectorSlot type_feedback_slot_;
2188
2189 class OperatorField
2190 : public BitField<Token::Value, Expression::kNextBitFieldIndex, 7> {};
2125 }; 2191 };
2126 2192
2127 2193
2128 class CountOperation final : public Expression { 2194 class CountOperation final : public Expression {
2129 public: 2195 public:
2130 bool is_prefix() const { return IsPrefixField::decode(bit_field_); } 2196 bool is_prefix() const { return IsPrefixField::decode(bit_field_); }
2131 bool is_postfix() const { return !is_prefix(); } 2197 bool is_postfix() const { return !is_prefix(); }
2132 2198
2133 Token::Value op() const { return TokenField::decode(bit_field_); } 2199 Token::Value op() const { return TokenField::decode(bit_field_); }
2134 Token::Value binary_op() { 2200 Token::Value binary_op() {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2169 } 2235 }
2170 2236
2171 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 2237 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
2172 FeedbackVectorSlotCache* cache); 2238 FeedbackVectorSlotCache* cache);
2173 FeedbackVectorSlot CountSlot() const { return slot_; } 2239 FeedbackVectorSlot CountSlot() const { return slot_; }
2174 2240
2175 private: 2241 private:
2176 friend class AstNodeFactory; 2242 friend class AstNodeFactory;
2177 2243
2178 CountOperation(Token::Value op, bool is_prefix, Expression* expr, int pos) 2244 CountOperation(Token::Value op, bool is_prefix, Expression* expr, int pos)
2179 : Expression(pos, kCountOperation), 2245 : Expression(pos, kCountOperation), type_(NULL), expression_(expr) {
2180 bit_field_( 2246 bit_field_ |=
2181 IsPrefixField::encode(is_prefix) | KeyTypeField::encode(ELEMENT) | 2247 IsPrefixField::encode(is_prefix) | KeyTypeField::encode(ELEMENT) |
2182 StoreModeField::encode(STANDARD_STORE) | TokenField::encode(op)), 2248 StoreModeField::encode(STANDARD_STORE) | TokenField::encode(op);
2183 type_(NULL), 2249 }
2184 expression_(expr) {}
2185 2250
2186 static int parent_num_ids() { return Expression::num_ids(); } 2251 static int parent_num_ids() { return Expression::num_ids(); }
2187 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2252 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2188 2253
2189 class IsPrefixField : public BitField16<bool, 0, 1> {}; 2254 class IsPrefixField
2190 class KeyTypeField : public BitField16<IcCheckType, 1, 1> {}; 2255 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {};
2191 class StoreModeField : public BitField16<KeyedAccessStoreMode, 2, 3> {}; 2256 class KeyTypeField : public BitField<IcCheckType, IsPrefixField::kNext, 1> {};
2192 class TokenField : public BitField16<Token::Value, 5, 8> {}; 2257 class StoreModeField
2258 : public BitField<KeyedAccessStoreMode, KeyTypeField::kNext, 3> {};
2259 class TokenField : public BitField<Token::Value, StoreModeField::kNext, 7> {};
2193 2260
2194 // Starts with 16-bit field, which should get packed together with
2195 // Expression's trailing 16-bit field.
2196 uint16_t bit_field_;
2197 FeedbackVectorSlot slot_; 2261 FeedbackVectorSlot slot_;
2198 FeedbackVectorSlot binary_operation_slot_; 2262 FeedbackVectorSlot binary_operation_slot_;
2199 AstType* type_; 2263 AstType* type_;
2200 Expression* expression_; 2264 Expression* expression_;
2201 SmallMapList receiver_types_; 2265 SmallMapList receiver_types_;
2202 }; 2266 };
2203 2267
2204 2268
2205 class CompareOperation final : public Expression { 2269 class CompareOperation final : public Expression {
2206 public: 2270 public:
2207 Token::Value op() const { return op_; } 2271 Token::Value op() const { return OperatorField::decode(bit_field_); }
2208 Expression* left() const { return left_; } 2272 Expression* left() const { return left_; }
2209 Expression* right() const { return right_; } 2273 Expression* right() const { return right_; }
2210 2274
2211 void set_left(Expression* e) { left_ = e; } 2275 void set_left(Expression* e) { left_ = e; }
2212 void set_right(Expression* e) { right_ = e; } 2276 void set_right(Expression* e) { right_ = e; }
2213 2277
2214 // Type feedback information. 2278 // Type feedback information.
2215 static int num_ids() { return parent_num_ids() + 1; } 2279 static int num_ids() { return parent_num_ids() + 1; }
2216 TypeFeedbackId CompareOperationFeedbackId() const { 2280 TypeFeedbackId CompareOperationFeedbackId() const {
2217 return TypeFeedbackId(local_id(0)); 2281 return TypeFeedbackId(local_id(0));
(...skipping 15 matching lines...) Expand all
2233 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); 2297 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check);
2234 bool IsLiteralCompareUndefined(Expression** expr); 2298 bool IsLiteralCompareUndefined(Expression** expr);
2235 bool IsLiteralCompareNull(Expression** expr); 2299 bool IsLiteralCompareNull(Expression** expr);
2236 2300
2237 private: 2301 private:
2238 friend class AstNodeFactory; 2302 friend class AstNodeFactory;
2239 2303
2240 CompareOperation(Token::Value op, Expression* left, Expression* right, 2304 CompareOperation(Token::Value op, Expression* left, Expression* right,
2241 int pos) 2305 int pos)
2242 : Expression(pos, kCompareOperation), 2306 : Expression(pos, kCompareOperation),
2243 op_(op),
2244 left_(left), 2307 left_(left),
2245 right_(right), 2308 right_(right),
2246 combined_type_(AstType::None()) { 2309 combined_type_(AstType::None()) {
2310 bit_field_ |= OperatorField::encode(op);
2247 DCHECK(Token::IsCompareOp(op)); 2311 DCHECK(Token::IsCompareOp(op));
2248 } 2312 }
2249 2313
2250 static int parent_num_ids() { return Expression::num_ids(); } 2314 static int parent_num_ids() { return Expression::num_ids(); }
2251 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2315 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2252 2316
2253 Token::Value op_;
2254 Expression* left_; 2317 Expression* left_;
2255 Expression* right_; 2318 Expression* right_;
2256 2319
2257 AstType* combined_type_; 2320 AstType* combined_type_;
2258 FeedbackVectorSlot type_feedback_slot_; 2321 FeedbackVectorSlot type_feedback_slot_;
2322 class OperatorField
2323 : public BitField<Token::Value, Expression::kNextBitFieldIndex, 7> {};
2259 }; 2324 };
2260 2325
2261 2326
2262 class Spread final : public Expression { 2327 class Spread final : public Expression {
2263 public: 2328 public:
2264 Expression* expression() const { return expression_; } 2329 Expression* expression() const { return expression_; }
2265 void set_expression(Expression* e) { expression_ = e; } 2330 void set_expression(Expression* e) { expression_ = e; }
2266 2331
2267 int expression_position() const { return expr_pos_; } 2332 int expression_position() const { return expr_pos_; }
2268 2333
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
2372 FeedbackVectorSlot AssignmentSlot() const { return slot_; } 2437 FeedbackVectorSlot AssignmentSlot() const { return slot_; }
2373 2438
2374 private: 2439 private:
2375 friend class AstNodeFactory; 2440 friend class AstNodeFactory;
2376 2441
2377 Assignment(Token::Value op, Expression* target, Expression* value, int pos); 2442 Assignment(Token::Value op, Expression* target, Expression* value, int pos);
2378 2443
2379 static int parent_num_ids() { return Expression::num_ids(); } 2444 static int parent_num_ids() { return Expression::num_ids(); }
2380 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2445 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2381 2446
2382 class IsUninitializedField : public BitField16<bool, 0, 1> {}; 2447 class IsUninitializedField
2448 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {};
2383 class KeyTypeField 2449 class KeyTypeField
2384 : public BitField16<IcCheckType, IsUninitializedField::kNext, 1> {}; 2450 : public BitField<IcCheckType, IsUninitializedField::kNext, 1> {};
2385 class StoreModeField 2451 class StoreModeField
2386 : public BitField16<KeyedAccessStoreMode, KeyTypeField::kNext, 3> {}; 2452 : public BitField<KeyedAccessStoreMode, KeyTypeField::kNext, 3> {};
2387 class TokenField : public BitField16<Token::Value, StoreModeField::kNext, 8> { 2453 class TokenField : public BitField<Token::Value, StoreModeField::kNext, 7> {};
2388 };
2389 2454
2390 // Starts with 16-bit field, which should get packed together with
2391 // Expression's trailing 16-bit field.
2392 uint16_t bit_field_;
2393 FeedbackVectorSlot slot_; 2455 FeedbackVectorSlot slot_;
2394 Expression* target_; 2456 Expression* target_;
2395 Expression* value_; 2457 Expression* value_;
2396 BinaryOperation* binary_operation_; 2458 BinaryOperation* binary_operation_;
2397 SmallMapList receiver_types_; 2459 SmallMapList receiver_types_;
2398 }; 2460 };
2399 2461
2400 2462
2401 // The RewritableExpression class is a wrapper for AST nodes that wait 2463 // The RewritableExpression class is a wrapper for AST nodes that wait
2402 // for some potential rewriting. However, even if such nodes are indeed 2464 // for some potential rewriting. However, even if such nodes are indeed
2403 // rewritten, the RewritableExpression wrapper nodes will survive in the 2465 // rewritten, the RewritableExpression wrapper nodes will survive in the
2404 // final AST and should be just ignored, i.e., they should be treated as 2466 // final AST and should be just ignored, i.e., they should be treated as
2405 // equivalent to the wrapped nodes. For this reason and to simplify later 2467 // equivalent to the wrapped nodes. For this reason and to simplify later
2406 // phases, RewritableExpressions are considered as exceptions of AST nodes 2468 // phases, RewritableExpressions are considered as exceptions of AST nodes
2407 // in the following sense: 2469 // in the following sense:
2408 // 2470 //
2409 // 1. IsRewritableExpression and AsRewritableExpression behave as usual. 2471 // 1. IsRewritableExpression and AsRewritableExpression behave as usual.
2410 // 2. All other Is* and As* methods are practically delegated to the 2472 // 2. All other Is* and As* methods are practically delegated to the
2411 // wrapped node, i.e. IsArrayLiteral() will return true iff the 2473 // wrapped node, i.e. IsArrayLiteral() will return true iff the
2412 // wrapped node is an array literal. 2474 // wrapped node is an array literal.
2413 // 2475 //
2414 // Furthermore, an invariant that should be respected is that the wrapped 2476 // Furthermore, an invariant that should be respected is that the wrapped
2415 // node is not a RewritableExpression. 2477 // node is not a RewritableExpression.
2416 class RewritableExpression final : public Expression { 2478 class RewritableExpression final : public Expression {
2417 public: 2479 public:
2418 Expression* expression() const { return expr_; } 2480 Expression* expression() const { return expr_; }
2419 bool is_rewritten() const { return is_rewritten_; } 2481 bool is_rewritten() const { return IsRewrittenField::decode(bit_field_); }
2420 2482
2421 void Rewrite(Expression* new_expression) { 2483 void Rewrite(Expression* new_expression) {
2422 DCHECK(!is_rewritten()); 2484 DCHECK(!is_rewritten());
2423 DCHECK_NOT_NULL(new_expression); 2485 DCHECK_NOT_NULL(new_expression);
2424 DCHECK(!new_expression->IsRewritableExpression()); 2486 DCHECK(!new_expression->IsRewritableExpression());
2425 expr_ = new_expression; 2487 expr_ = new_expression;
2426 is_rewritten_ = true; 2488 bit_field_ = IsRewrittenField::update(bit_field_, true);
2427 } 2489 }
2428 2490
2429 static int num_ids() { return parent_num_ids(); } 2491 static int num_ids() { return parent_num_ids(); }
2430 2492
2431 private: 2493 private:
2432 friend class AstNodeFactory; 2494 friend class AstNodeFactory;
2433 2495
2434 explicit RewritableExpression(Expression* expression) 2496 explicit RewritableExpression(Expression* expression)
2435 : Expression(expression->position(), kRewritableExpression), 2497 : Expression(expression->position(), kRewritableExpression),
2436 is_rewritten_(false),
2437 expr_(expression) { 2498 expr_(expression) {
2499 bit_field_ |= IsRewrittenField::encode(false);
2438 DCHECK(!expression->IsRewritableExpression()); 2500 DCHECK(!expression->IsRewritableExpression());
2439 } 2501 }
2440 2502
2441 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2503 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2442 2504
2443 bool is_rewritten_;
2444 Expression* expr_; 2505 Expression* expr_;
2506
2507 class IsRewrittenField
2508 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {};
2445 }; 2509 };
2446 2510
2447 // Our Yield is different from the JS yield in that it "returns" its argument as 2511 // Our Yield is different from the JS yield in that it "returns" its argument as
2448 // is, without wrapping it in an iterator result object. Such wrapping, if 2512 // is, without wrapping it in an iterator result object. Such wrapping, if
2449 // desired, must be done beforehand (see the parser). 2513 // desired, must be done beforehand (see the parser).
2450 class Yield final : public Expression { 2514 class Yield final : public Expression {
2451 public: 2515 public:
2452 enum OnException { kOnExceptionThrow, kOnExceptionRethrow }; 2516 enum OnException { kOnExceptionThrow, kOnExceptionRethrow };
2453 2517
2454 Expression* generator_object() const { return generator_object_; } 2518 Expression* generator_object() const { return generator_object_; }
2455 Expression* expression() const { return expression_; } 2519 Expression* expression() const { return expression_; }
2520 OnException on_exception() const {
2521 return OnExceptionField::decode(bit_field_);
2522 }
2456 bool rethrow_on_exception() const { 2523 bool rethrow_on_exception() const {
2457 return on_exception_ == kOnExceptionRethrow; 2524 return on_exception() == kOnExceptionRethrow;
2458 } 2525 }
2459 int yield_id() const { return yield_id_; } 2526 int yield_id() const { return yield_id_; }
2460 2527
2461 void set_generator_object(Expression* e) { generator_object_ = e; } 2528 void set_generator_object(Expression* e) { generator_object_ = e; }
2462 void set_expression(Expression* e) { expression_ = e; } 2529 void set_expression(Expression* e) { expression_ = e; }
2463 void set_yield_id(int yield_id) { yield_id_ = yield_id; } 2530 void set_yield_id(int yield_id) { yield_id_ = yield_id; }
2464 2531
2465 private: 2532 private:
2466 friend class AstNodeFactory; 2533 friend class AstNodeFactory;
2467 2534
2468 Yield(Expression* generator_object, Expression* expression, int pos, 2535 Yield(Expression* generator_object, Expression* expression, int pos,
2469 OnException on_exception) 2536 OnException on_exception)
2470 : Expression(pos, kYield), 2537 : Expression(pos, kYield),
2471 on_exception_(on_exception),
2472 yield_id_(-1), 2538 yield_id_(-1),
2473 generator_object_(generator_object), 2539 generator_object_(generator_object),
2474 expression_(expression) {} 2540 expression_(expression) {
2541 bit_field_ |= OnExceptionField::encode(on_exception);
2542 }
2475 2543
2476 OnException on_exception_;
2477 int yield_id_; 2544 int yield_id_;
2478 Expression* generator_object_; 2545 Expression* generator_object_;
2479 Expression* expression_; 2546 Expression* expression_;
2547
2548 class OnExceptionField
2549 : public BitField<OnException, Expression::kNextBitFieldIndex, 1> {};
2480 }; 2550 };
2481 2551
2482 2552
2483 class Throw final : public Expression { 2553 class Throw final : public Expression {
2484 public: 2554 public:
2485 Expression* exception() const { return exception_; } 2555 Expression* exception() const { return exception_; }
2486 void set_exception(Expression* e) { exception_ = e; } 2556 void set_exception(Expression* e) { exception_ = e; }
2487 2557
2488 private: 2558 private:
2489 friend class AstNodeFactory; 2559 friend class AstNodeFactory;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2563 raw_inferred_name_ = NULL; 2633 raw_inferred_name_ = NULL;
2564 } 2634 }
2565 2635
2566 void set_raw_inferred_name(const AstString* raw_inferred_name) { 2636 void set_raw_inferred_name(const AstString* raw_inferred_name) {
2567 DCHECK(raw_inferred_name != NULL); 2637 DCHECK(raw_inferred_name != NULL);
2568 raw_inferred_name_ = raw_inferred_name; 2638 raw_inferred_name_ = raw_inferred_name;
2569 DCHECK(inferred_name_.is_null()); 2639 DCHECK(inferred_name_.is_null());
2570 inferred_name_ = Handle<String>(); 2640 inferred_name_ = Handle<String>();
2571 } 2641 }
2572 2642
2573 bool pretenure() const { return Pretenure::decode(bitfield_); } 2643 bool pretenure() const { return Pretenure::decode(bit_field_); }
2574 void set_pretenure() { bitfield_ = Pretenure::update(bitfield_, true); } 2644 void set_pretenure() { bit_field_ = Pretenure::update(bit_field_, true); }
2575 2645
2576 bool has_duplicate_parameters() const { 2646 bool has_duplicate_parameters() const {
2577 return HasDuplicateParameters::decode(bitfield_); 2647 return HasDuplicateParameters::decode(bit_field_);
2578 } 2648 }
2579 2649
2580 bool is_function() const { return IsFunction::decode(bitfield_); } 2650 bool is_function() const { return IsFunction::decode(bit_field_); }
2581 2651
2582 // This is used as a heuristic on when to eagerly compile a function 2652 // This is used as a heuristic on when to eagerly compile a function
2583 // literal. We consider the following constructs as hints that the 2653 // literal. We consider the following constructs as hints that the
2584 // function will be called immediately: 2654 // function will be called immediately:
2585 // - (function() { ... })(); 2655 // - (function() { ... })();
2586 // - var x = function() { ... }(); 2656 // - var x = function() { ... }();
2587 bool should_eager_compile() const { 2657 bool should_eager_compile() const {
2588 return ShouldEagerCompile::decode(bitfield_); 2658 return ShouldEagerCompile::decode(bit_field_);
2589 } 2659 }
2590 void set_should_eager_compile() { 2660 void set_should_eager_compile() {
2591 bitfield_ = ShouldEagerCompile::update(bitfield_, true); 2661 bit_field_ = ShouldEagerCompile::update(bit_field_, true);
2592 } 2662 }
2593 2663
2594 // A hint that we expect this function to be called (exactly) once, 2664 // A hint that we expect this function to be called (exactly) once,
2595 // i.e. we suspect it's an initialization function. 2665 // i.e. we suspect it's an initialization function.
2596 bool should_be_used_once_hint() const { 2666 bool should_be_used_once_hint() const {
2597 return ShouldBeUsedOnceHint::decode(bitfield_); 2667 return ShouldNotBeUsedOnceHintField::decode(bit_field_);
2598 } 2668 }
2599 void set_should_be_used_once_hint() { 2669 void set_should_be_used_once_hint() {
2600 bitfield_ = ShouldBeUsedOnceHint::update(bitfield_, true); 2670 bit_field_ = ShouldNotBeUsedOnceHintField::update(bit_field_, true);
2601 } 2671 }
2602 2672
2603 FunctionType function_type() const { 2673 FunctionType function_type() const {
2604 return FunctionTypeBits::decode(bitfield_); 2674 return FunctionTypeBits::decode(bit_field_);
2605 } 2675 }
2606 FunctionKind kind() const { return FunctionKindBits::decode(bitfield_); } 2676 FunctionKind kind() const { return FunctionKindBits::decode(bit_field_); }
2607 2677
2608 int ast_node_count() { return ast_properties_.node_count(); } 2678 int ast_node_count() { return ast_properties_.node_count(); }
2609 AstProperties::Flags flags() const { return ast_properties_.flags(); } 2679 AstProperties::Flags flags() const { return ast_properties_.flags(); }
2610 void set_ast_properties(AstProperties* ast_properties) { 2680 void set_ast_properties(AstProperties* ast_properties) {
2611 ast_properties_ = *ast_properties; 2681 ast_properties_ = *ast_properties;
2612 } 2682 }
2613 const FeedbackVectorSpec* feedback_vector_spec() const { 2683 const FeedbackVectorSpec* feedback_vector_spec() const {
2614 return ast_properties_.get_spec(); 2684 return ast_properties_.get_spec();
2615 } 2685 }
2616 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } 2686 bool dont_optimize() { return dont_optimize_reason() != kNoReason; }
2617 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } 2687 BailoutReason dont_optimize_reason() {
2688 return DontOptimizeReasonField::decode(bit_field_2_);
2689 }
2618 void set_dont_optimize_reason(BailoutReason reason) { 2690 void set_dont_optimize_reason(BailoutReason reason) {
2619 dont_optimize_reason_ = reason; 2691 bit_field_2_ = DontOptimizeReasonField::update(bit_field_2_, reason);
2620 } 2692 }
2621 2693
2622 bool IsAnonymousFunctionDefinition() const { 2694 bool IsAnonymousFunctionDefinition() const {
2623 return is_anonymous_expression(); 2695 return is_anonymous_expression();
2624 } 2696 }
2625 2697
2626 int yield_count() { return yield_count_; } 2698 int yield_count() { return yield_count_; }
2627 void set_yield_count(int yield_count) { yield_count_ = yield_count; } 2699 void set_yield_count(int yield_count) { yield_count_ = yield_count; }
2628 2700
2629 bool requires_class_field_init() { 2701 bool requires_class_field_init() {
2630 return RequiresClassFieldInit::decode(bitfield_); 2702 return RequiresClassFieldInit::decode(bit_field_);
2631 } 2703 }
2632 void set_requires_class_field_init(bool requires_class_field_init) { 2704 void set_requires_class_field_init(bool requires_class_field_init) {
2633 bitfield_ = 2705 bit_field_ =
2634 RequiresClassFieldInit::update(bitfield_, requires_class_field_init); 2706 RequiresClassFieldInit::update(bit_field_, requires_class_field_init);
2635 } 2707 }
2636 bool is_class_field_initializer() { 2708 bool is_class_field_initializer() {
2637 return IsClassFieldInitializer::decode(bitfield_); 2709 return IsClassFieldInitializer::decode(bit_field_2_);
2638 } 2710 }
2639 void set_is_class_field_initializer(bool is_class_field_initializer) { 2711 void set_is_class_field_initializer(bool is_class_field_initializer) {
2640 bitfield_ = 2712 bit_field_ = IsClassFieldInitializer::update(bit_field_2_,
2641 IsClassFieldInitializer::update(bitfield_, is_class_field_initializer); 2713 is_class_field_initializer);
2642 } 2714 }
2643 2715
2644 private: 2716 private:
2645 friend class AstNodeFactory; 2717 friend class AstNodeFactory;
2646 2718
2647 FunctionLiteral(Zone* zone, const AstString* name, 2719 FunctionLiteral(Zone* zone, const AstString* name,
2648 AstValueFactory* ast_value_factory, DeclarationScope* scope, 2720 AstValueFactory* ast_value_factory, DeclarationScope* scope,
2649 ZoneList<Statement*>* body, int materialized_literal_count, 2721 ZoneList<Statement*>* body, int materialized_literal_count,
2650 int expected_property_count, int parameter_count, 2722 int expected_property_count, int parameter_count,
2651 FunctionType function_type, 2723 FunctionType function_type,
2652 ParameterFlag has_duplicate_parameters, 2724 ParameterFlag has_duplicate_parameters,
2653 EagerCompileHint eager_compile_hint, FunctionKind kind, 2725 EagerCompileHint eager_compile_hint, FunctionKind kind,
2654 int position, bool is_function) 2726 int position, bool is_function)
2655 : Expression(position, kFunctionLiteral), 2727 : Expression(position, kFunctionLiteral),
2656 dont_optimize_reason_(kNoReason),
2657 materialized_literal_count_(materialized_literal_count), 2728 materialized_literal_count_(materialized_literal_count),
2658 expected_property_count_(expected_property_count), 2729 expected_property_count_(expected_property_count),
2659 parameter_count_(parameter_count), 2730 parameter_count_(parameter_count),
2660 function_token_position_(kNoSourcePosition), 2731 function_token_position_(kNoSourcePosition),
2661 yield_count_(0), 2732 yield_count_(0),
2662 raw_name_(name), 2733 raw_name_(name),
2663 scope_(scope), 2734 scope_(scope),
2664 body_(body), 2735 body_(body),
2665 raw_inferred_name_(ast_value_factory->empty_string()), 2736 raw_inferred_name_(ast_value_factory->empty_string()),
2666 ast_properties_(zone) { 2737 ast_properties_(zone) {
2667 bitfield_ = 2738 bit_field_ |=
2668 FunctionTypeBits::encode(function_type) | Pretenure::encode(false) | 2739 FunctionTypeBits::encode(function_type) | Pretenure::encode(false) |
2669 HasDuplicateParameters::encode(has_duplicate_parameters == 2740 HasDuplicateParameters::encode(has_duplicate_parameters ==
2670 kHasDuplicateParameters) | 2741 kHasDuplicateParameters) |
2671 IsFunction::encode(is_function) | 2742 IsFunction::encode(is_function) |
2672 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) | 2743 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) |
2673 RequiresClassFieldInit::encode(false) | 2744 FunctionKindBits::encode(kind) | RequiresClassFieldInit::encode(false) |
2674 IsClassFieldInitializer::encode(false) | 2745 ShouldNotBeUsedOnceHintField::encode(false);
2675 FunctionKindBits::encode(kind) | ShouldBeUsedOnceHint::encode(false); 2746
2747 bit_field_2_ = DontOptimizeReasonField::encode(kNoReason) |
2748 IsClassFieldInitializer::encode(false);
2749
2676 DCHECK(IsValidFunctionKind(kind)); 2750 DCHECK(IsValidFunctionKind(kind));
2677 } 2751 }
2678 2752
2679 class FunctionTypeBits : public BitField<FunctionType, 0, 2> {}; 2753 class FunctionTypeBits
2680 class Pretenure : public BitField<bool, 2, 1> {}; 2754 : public BitField<FunctionType, Expression::kNextBitFieldIndex, 2> {};
2681 class HasDuplicateParameters : public BitField<bool, 3, 1> {}; 2755 class Pretenure : public BitField<bool, FunctionTypeBits::kNext, 1> {};
2682 class IsFunction : public BitField<bool, 4, 1> {}; 2756 class HasDuplicateParameters : public BitField<bool, Pretenure::kNext, 1> {};
2683 class ShouldEagerCompile : public BitField<bool, 5, 1> {}; 2757 class IsFunction : public BitField<bool, HasDuplicateParameters::kNext, 1> {};
2684 class ShouldBeUsedOnceHint : public BitField<bool, 6, 1> {}; 2758 class ShouldEagerCompile : public BitField<bool, IsFunction::kNext, 1> {};
2685 class RequiresClassFieldInit : public BitField<bool, 7, 1> {}; 2759 class FunctionKindBits
2686 class IsClassFieldInitializer : public BitField<bool, 8, 1> {}; 2760 : public BitField<FunctionKind, ShouldEagerCompile::kNext, 9> {};
2687 class FunctionKindBits : public BitField<FunctionKind, 9, 9> {}; 2761 class ShouldNotBeUsedOnceHintField
2762 : public BitField<bool, FunctionKindBits::kNext, 1> {};
2763 class RequiresClassFieldInit
2764 : public BitField<bool, ShouldNotBeUsedOnceHintField::kNext, 1> {};
2688 2765
2689 uint32_t bitfield_; 2766 uint32_t bit_field_2_;
2690 2767
2691 BailoutReason dont_optimize_reason_; 2768 class IsClassFieldInitializer : public BitField<bool, 0, 1> {};
2769 class DontOptimizeReasonField
2770 : public BitField<BailoutReason, IsClassFieldInitializer::kNext, 8> {};
2692 2771
2693 int materialized_literal_count_; 2772 int materialized_literal_count_;
2694 int expected_property_count_; 2773 int expected_property_count_;
2695 int parameter_count_; 2774 int parameter_count_;
2696 int function_token_position_; 2775 int function_token_position_;
2697 int yield_count_; 2776 int yield_count_;
2698 2777
2699 const AstString* raw_name_; 2778 const AstString* raw_name_;
2700 DeclarationScope* scope_; 2779 DeclarationScope* scope_;
2701 ZoneList<Statement*>* body_; 2780 ZoneList<Statement*>* body_;
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
3535 : NULL; \ 3614 : NULL; \
3536 } 3615 }
3537 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3616 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3538 #undef DECLARE_NODE_FUNCTIONS 3617 #undef DECLARE_NODE_FUNCTIONS
3539 3618
3540 3619
3541 } // namespace internal 3620 } // namespace internal
3542 } // namespace v8 3621 } // namespace v8
3543 3622
3544 #endif // V8_AST_AST_H_ 3623 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698