Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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, 7> {}; |
|
Toon Verwaest
2016/08/31 17:23:30
Isn't 6 enough? I'd make it 8 or 6 :) Probably 6 i
| |
| 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 Loading... | |
| 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 { return ignore_completion_value_; } |
| 430 | 443 |
| 431 static int num_ids() { return parent_num_ids() + 1; } | 444 static int num_ids() { return parent_num_ids() + 1; } |
| 432 BailoutId DeclsId() const { return BailoutId(local_id(0)); } | 445 BailoutId DeclsId() const { return BailoutId(local_id(0)); } |
| 433 | 446 |
| 434 bool IsJump() const { | 447 bool IsJump() const { |
| 435 return !statements_.is_empty() && statements_.last()->IsJump() | 448 return !statements_.is_empty() && statements_.last()->IsJump() |
| 436 && labels() == NULL; // Good enough as an approximation... | 449 && labels() == NULL; // Good enough as an approximation... |
| 437 } | 450 } |
| 438 | 451 |
| 439 Scope* scope() const { return scope_; } | 452 Scope* scope() const { return scope_; } |
| 440 void set_scope(Scope* scope) { scope_ = scope; } | 453 void set_scope(Scope* scope) { scope_ = scope; } |
| 441 | 454 |
| 442 private: | 455 private: |
| 443 friend class AstNodeFactory; | 456 friend class AstNodeFactory; |
| 444 | 457 |
| 445 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, | 458 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, |
| 446 bool ignore_completion_value, int pos) | 459 bool ignore_completion_value, int pos) |
| 447 : BreakableStatement(labels, TARGET_FOR_NAMED_ONLY, pos, kBlock), | 460 : BreakableStatement(labels, TARGET_FOR_NAMED_ONLY, pos, kBlock), |
| 448 statements_(capacity, zone), | 461 statements_(capacity, zone), |
| 449 ignore_completion_value_(ignore_completion_value), | 462 scope_(NULL) { |
| 450 scope_(NULL) {} | 463 bit_field_ |= IgnoreCompletionField::encode(ignore_completion_value); |
| 464 } | |
| 451 static int parent_num_ids() { return BreakableStatement::num_ids(); } | 465 static int parent_num_ids() { return BreakableStatement::num_ids(); } |
| 452 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 466 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 453 | 467 |
| 454 ZoneList<Statement*> statements_; | 468 ZoneList<Statement*> statements_; |
| 455 bool ignore_completion_value_; | 469 bool ignore_completion_value_; |
| 456 Scope* scope_; | 470 Scope* scope_; |
| 471 | |
| 472 class IgnoreCompletionField | |
| 473 : public BitField<bool, BreakableStatement::kNextBitFieldIndex, 1> {}; | |
| 474 | |
| 475 protected: | |
| 476 static const uint8_t kNextBitFieldIndex = IgnoreCompletionField::kNext; | |
| 457 }; | 477 }; |
| 458 | 478 |
| 459 | 479 |
| 460 class DoExpression final : public Expression { | 480 class DoExpression final : public Expression { |
| 461 public: | 481 public: |
| 462 Block* block() { return block_; } | 482 Block* block() { return block_; } |
| 463 void set_block(Block* b) { block_ = b; } | 483 void set_block(Block* b) { block_ = b; } |
| 464 VariableProxy* result() { return result_; } | 484 VariableProxy* result() { return result_; } |
| 465 void set_result(VariableProxy* v) { result_ = v; } | 485 void set_result(VariableProxy* v) { result_ = v; } |
| 466 FunctionLiteral* represented_function() { return represented_function_; } | 486 FunctionLiteral* represented_function() { return represented_function_; } |
| 467 void set_represented_function(FunctionLiteral* f) { | 487 void set_represented_function(FunctionLiteral* f) { |
| 468 represented_function_ = f; | 488 represented_function_ = f; |
| 469 } | 489 } |
| 470 bool IsAnonymousFunctionDefinition() const; | 490 bool IsAnonymousFunctionDefinition() const; |
| 471 | 491 |
| 492 protected: | |
| 493 static const uint8_t kNextBitFieldIndex = Expression::kNextBitFieldIndex; | |
| 494 | |
| 472 private: | 495 private: |
| 473 friend class AstNodeFactory; | 496 friend class AstNodeFactory; |
| 474 | 497 |
| 475 DoExpression(Block* block, VariableProxy* result, int pos) | 498 DoExpression(Block* block, VariableProxy* result, int pos) |
| 476 : Expression(pos, kDoExpression), | 499 : Expression(pos, kDoExpression), |
| 477 block_(block), | 500 block_(block), |
| 478 result_(result), | 501 result_(result), |
| 479 represented_function_(nullptr) { | 502 represented_function_(nullptr) { |
| 480 DCHECK_NOT_NULL(block_); | 503 DCHECK_NOT_NULL(block_); |
| 481 DCHECK_NOT_NULL(result_); | 504 DCHECK_NOT_NULL(result_); |
| 482 } | 505 } |
| 483 static int parent_num_ids() { return Expression::num_ids(); } | 506 static int parent_num_ids() { return Expression::num_ids(); } |
| 484 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 507 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 485 | 508 |
| 486 Block* block_; | 509 Block* block_; |
| 487 VariableProxy* result_; | 510 VariableProxy* result_; |
| 488 FunctionLiteral* represented_function_; | 511 FunctionLiteral* represented_function_; |
| 489 }; | 512 }; |
| 490 | 513 |
| 491 | 514 |
| 492 class Declaration : public AstNode { | 515 class Declaration : public AstNode { |
| 493 public: | 516 public: |
| 494 VariableProxy* proxy() const { return proxy_; } | 517 VariableProxy* proxy() const { return proxy_; } |
| 495 Scope* scope() const { return scope_; } | 518 Scope* scope() const { return scope_; } |
| 496 | 519 |
| 497 protected: | 520 protected: |
| 498 Declaration(VariableProxy* proxy, Scope* scope, int pos, NodeType type) | 521 Declaration(VariableProxy* proxy, Scope* scope, int pos, NodeType type) |
| 499 : AstNode(pos, type), proxy_(proxy), scope_(scope) {} | 522 : AstNode(pos, type), proxy_(proxy), scope_(scope) {} |
| 500 | 523 |
| 524 static const uint8_t kNextBitFieldIndex = AstNode::kNextBitFieldIndex; | |
| 525 | |
| 501 private: | 526 private: |
| 502 VariableProxy* proxy_; | 527 VariableProxy* proxy_; |
| 503 | 528 |
| 504 // Nested scope from which the declaration originated. | 529 // Nested scope from which the declaration originated. |
| 505 Scope* scope_; | 530 Scope* scope_; |
| 506 }; | 531 }; |
| 507 | 532 |
| 508 | 533 |
| 509 class VariableDeclaration final : public Declaration { | 534 class VariableDeclaration final : public Declaration { |
| 510 private: | 535 private: |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 554 protected: | 579 protected: |
| 555 IterationStatement(ZoneList<const AstRawString*>* labels, int pos, | 580 IterationStatement(ZoneList<const AstRawString*>* labels, int pos, |
| 556 NodeType type) | 581 NodeType type) |
| 557 : BreakableStatement(labels, TARGET_FOR_ANONYMOUS, pos, type), | 582 : BreakableStatement(labels, TARGET_FOR_ANONYMOUS, pos, type), |
| 558 body_(NULL), | 583 body_(NULL), |
| 559 yield_count_(0), | 584 yield_count_(0), |
| 560 first_yield_id_(0) {} | 585 first_yield_id_(0) {} |
| 561 static int parent_num_ids() { return BreakableStatement::num_ids(); } | 586 static int parent_num_ids() { return BreakableStatement::num_ids(); } |
| 562 void Initialize(Statement* body) { body_ = body; } | 587 void Initialize(Statement* body) { body_ = body; } |
| 563 | 588 |
| 589 static const uint8_t kNextBitFieldIndex = | |
| 590 BreakableStatement::kNextBitFieldIndex; | |
| 591 | |
| 564 private: | 592 private: |
| 565 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 593 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 566 | 594 |
| 567 Statement* body_; | 595 Statement* body_; |
| 568 Label continue_target_; | 596 Label continue_target_; |
| 569 int yield_count_; | 597 int yield_count_; |
| 570 int first_yield_id_; | 598 int first_yield_id_; |
| 571 }; | 599 }; |
| 572 | 600 |
| 573 | 601 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 708 // Type feedback information. | 736 // Type feedback information. |
| 709 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 737 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
| 710 FeedbackVectorSlotCache* cache); | 738 FeedbackVectorSlotCache* cache); |
| 711 FeedbackVectorSlot EachFeedbackSlot() const { return each_slot_; } | 739 FeedbackVectorSlot EachFeedbackSlot() const { return each_slot_; } |
| 712 FeedbackVectorSlot ForInFeedbackSlot() { | 740 FeedbackVectorSlot ForInFeedbackSlot() { |
| 713 DCHECK(!for_in_feedback_slot_.IsInvalid()); | 741 DCHECK(!for_in_feedback_slot_.IsInvalid()); |
| 714 return for_in_feedback_slot_; | 742 return for_in_feedback_slot_; |
| 715 } | 743 } |
| 716 | 744 |
| 717 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; | 745 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; |
| 718 ForInType for_in_type() const { return for_in_type_; } | 746 ForInType for_in_type() const { return ForInTypeField::decode(bit_field_); } |
| 719 void set_for_in_type(ForInType type) { for_in_type_ = type; } | 747 void set_for_in_type(ForInType type) { |
| 748 bit_field_ = ForInTypeField::update(bit_field_, type); | |
| 749 } | |
| 720 | 750 |
| 721 static int num_ids() { return parent_num_ids() + 7; } | 751 static int num_ids() { return parent_num_ids() + 7; } |
| 722 BailoutId BodyId() const { return BailoutId(local_id(0)); } | 752 BailoutId BodyId() const { return BailoutId(local_id(0)); } |
| 723 BailoutId EnumId() const { return BailoutId(local_id(1)); } | 753 BailoutId EnumId() const { return BailoutId(local_id(1)); } |
| 724 BailoutId ToObjectId() const { return BailoutId(local_id(2)); } | 754 BailoutId ToObjectId() const { return BailoutId(local_id(2)); } |
| 725 BailoutId PrepareId() const { return BailoutId(local_id(3)); } | 755 BailoutId PrepareId() const { return BailoutId(local_id(3)); } |
| 726 BailoutId FilterId() const { return BailoutId(local_id(4)); } | 756 BailoutId FilterId() const { return BailoutId(local_id(4)); } |
| 727 BailoutId AssignmentId() const { return BailoutId(local_id(5)); } | 757 BailoutId AssignmentId() const { return BailoutId(local_id(5)); } |
| 728 BailoutId IncrementId() const { return BailoutId(local_id(6)); } | 758 BailoutId IncrementId() const { return BailoutId(local_id(6)); } |
| 729 BailoutId ContinueId() const { return EntryId(); } | 759 BailoutId ContinueId() const { return EntryId(); } |
| 730 BailoutId StackCheckId() const { return BodyId(); } | 760 BailoutId StackCheckId() const { return BodyId(); } |
| 731 | 761 |
| 732 private: | 762 private: |
| 733 friend class AstNodeFactory; | 763 friend class AstNodeFactory; |
| 734 | 764 |
| 735 ForInStatement(ZoneList<const AstRawString*>* labels, int pos) | 765 ForInStatement(ZoneList<const AstRawString*>* labels, int pos) |
| 736 : ForEachStatement(labels, pos, kForInStatement), | 766 : ForEachStatement(labels, pos, kForInStatement), |
| 737 each_(nullptr), | 767 each_(nullptr), |
| 738 subject_(nullptr), | 768 subject_(nullptr) { |
| 739 for_in_type_(SLOW_FOR_IN) {} | 769 bit_field_ = ForInTypeField::update(bit_field_, SLOW_FOR_IN); |
| 770 } | |
| 771 | |
| 740 static int parent_num_ids() { return ForEachStatement::num_ids(); } | 772 static int parent_num_ids() { return ForEachStatement::num_ids(); } |
| 741 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 773 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 742 | 774 |
| 743 Expression* each_; | 775 Expression* each_; |
| 744 Expression* subject_; | 776 Expression* subject_; |
| 745 ForInType for_in_type_; | |
| 746 FeedbackVectorSlot each_slot_; | 777 FeedbackVectorSlot each_slot_; |
| 747 FeedbackVectorSlot for_in_feedback_slot_; | 778 FeedbackVectorSlot for_in_feedback_slot_; |
| 779 | |
| 780 class ForInTypeField | |
| 781 : public BitField<ForInType, ForEachStatement::kNextBitFieldIndex, 1> {}; | |
| 782 | |
| 783 protected: | |
| 784 static const uint8_t kNextBitFieldIndex = ForInTypeField::kNext; | |
| 748 }; | 785 }; |
| 749 | 786 |
| 750 | 787 |
| 751 class ForOfStatement final : public ForEachStatement { | 788 class ForOfStatement final : public ForEachStatement { |
| 752 public: | 789 public: |
| 753 void Initialize(Statement* body, Variable* iterator, | 790 void Initialize(Statement* body, Variable* iterator, |
| 754 Expression* assign_iterator, Expression* next_result, | 791 Expression* assign_iterator, Expression* next_result, |
| 755 Expression* result_done, Expression* assign_each) { | 792 Expression* result_done, Expression* assign_each) { |
| 756 ForEachStatement::Initialize(body); | 793 ForEachStatement::Initialize(body); |
| 757 iterator_ = iterator; | 794 iterator_ = iterator; |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1246 class MaterializedLiteral : public Expression { | 1283 class MaterializedLiteral : public Expression { |
| 1247 public: | 1284 public: |
| 1248 int literal_index() { return literal_index_; } | 1285 int literal_index() { return literal_index_; } |
| 1249 | 1286 |
| 1250 int depth() const { | 1287 int depth() const { |
| 1251 // only callable after initialization. | 1288 // only callable after initialization. |
| 1252 DCHECK(depth_ >= 1); | 1289 DCHECK(depth_ >= 1); |
| 1253 return depth_; | 1290 return depth_; |
| 1254 } | 1291 } |
| 1255 | 1292 |
| 1293 private: | |
| 1294 int depth_ : 31; | |
| 1295 int literal_index_; | |
| 1296 | |
| 1297 friend class AstLiteralReindexer; | |
| 1298 | |
| 1299 class IsSimpleField | |
| 1300 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; | |
| 1301 | |
| 1256 protected: | 1302 protected: |
| 1257 MaterializedLiteral(int literal_index, int pos, NodeType type) | 1303 MaterializedLiteral(int literal_index, int pos, NodeType type) |
| 1258 : Expression(pos, type), | 1304 : Expression(pos, type), depth_(0), literal_index_(literal_index) { |
| 1259 is_simple_(false), | 1305 bit_field_ |= IsSimpleField::encode(false); |
| 1260 depth_(0), | 1306 } |
| 1261 literal_index_(literal_index) {} | |
| 1262 | 1307 |
| 1263 // A materialized literal is simple if the values consist of only | 1308 // A materialized literal is simple if the values consist of only |
| 1264 // constants and simple object and array literals. | 1309 // constants and simple object and array literals. |
| 1265 bool is_simple() const { return is_simple_; } | 1310 bool is_simple() const { return IsSimpleField::decode(bit_field_); } |
| 1266 void set_is_simple(bool is_simple) { is_simple_ = is_simple; } | 1311 void set_is_simple(bool is_simple) { |
| 1312 bit_field_ = IsSimpleField::update(bit_field_, is_simple); | |
| 1313 } | |
| 1267 friend class CompileTimeValue; | 1314 friend class CompileTimeValue; |
| 1268 | 1315 |
| 1269 void set_depth(int depth) { | 1316 void set_depth(int depth) { |
| 1270 DCHECK_LE(1, depth); | 1317 DCHECK_LE(1, depth); |
| 1271 depth_ = depth; | 1318 depth_ = depth; |
| 1272 } | 1319 } |
| 1273 | 1320 |
| 1274 // Populate the constant properties/elements fixed array. | 1321 // Populate the constant properties/elements fixed array. |
| 1275 void BuildConstants(Isolate* isolate); | 1322 void BuildConstants(Isolate* isolate); |
| 1276 friend class ArrayLiteral; | 1323 friend class ArrayLiteral; |
| 1277 friend class ObjectLiteral; | 1324 friend class ObjectLiteral; |
| 1278 | 1325 |
| 1279 // If the expression is a literal, return the literal value; | 1326 // If the expression is a literal, return the literal value; |
| 1280 // if the expression is a materialized literal and is simple return a | 1327 // if the expression is a materialized literal and is simple return a |
| 1281 // compile time value as encoded by CompileTimeValue::GetValue(). | 1328 // compile time value as encoded by CompileTimeValue::GetValue(). |
| 1282 // Otherwise, return undefined literal as the placeholder | 1329 // Otherwise, return undefined literal as the placeholder |
| 1283 // in the object literal boilerplate. | 1330 // in the object literal boilerplate. |
| 1284 Handle<Object> GetBoilerplateValue(Expression* expression, Isolate* isolate); | 1331 Handle<Object> GetBoilerplateValue(Expression* expression, Isolate* isolate); |
| 1285 | 1332 |
| 1286 private: | 1333 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 }; | 1334 }; |
| 1293 | 1335 |
| 1294 | 1336 |
| 1295 // Property is used for passing information | 1337 // Property is used for passing information |
| 1296 // about an object literal's properties from the parser | 1338 // about an object literal's properties from the parser |
| 1297 // to the code generator. | 1339 // to the code generator. |
| 1298 class ObjectLiteralProperty final : public ZoneObject { | 1340 class ObjectLiteralProperty final : public ZoneObject { |
| 1299 public: | 1341 public: |
| 1300 enum Kind : uint8_t { | 1342 enum Kind : uint8_t { |
| 1301 CONSTANT, // Property with constant value (compile time). | 1343 CONSTANT, // Property with constant value (compile time). |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1362 // for minimizing the work when constructing it at runtime. | 1404 // for minimizing the work when constructing it at runtime. |
| 1363 class ObjectLiteral final : public MaterializedLiteral { | 1405 class ObjectLiteral final : public MaterializedLiteral { |
| 1364 public: | 1406 public: |
| 1365 typedef ObjectLiteralProperty Property; | 1407 typedef ObjectLiteralProperty Property; |
| 1366 | 1408 |
| 1367 Handle<FixedArray> constant_properties() const { | 1409 Handle<FixedArray> constant_properties() const { |
| 1368 return constant_properties_; | 1410 return constant_properties_; |
| 1369 } | 1411 } |
| 1370 int properties_count() const { return boilerplate_properties_; } | 1412 int properties_count() const { return boilerplate_properties_; } |
| 1371 ZoneList<Property*>* properties() const { return properties_; } | 1413 ZoneList<Property*>* properties() const { return properties_; } |
| 1372 bool fast_elements() const { return fast_elements_; } | 1414 bool fast_elements() const { return FastElementsField::decode(bit_field_); } |
| 1373 bool may_store_doubles() const { return may_store_doubles_; } | 1415 bool may_store_doubles() const { |
| 1374 bool has_elements() const { return has_elements_; } | 1416 return MayStoreDoublesField::decode(bit_field_); |
| 1417 } | |
| 1418 bool has_elements() const { return HasElementsField::decode(bit_field_); } | |
| 1375 bool has_shallow_properties() const { | 1419 bool has_shallow_properties() const { |
| 1376 return depth() == 1 && !has_elements() && !may_store_doubles(); | 1420 return depth() == 1 && !has_elements() && !may_store_doubles(); |
| 1377 } | 1421 } |
| 1378 | 1422 |
| 1379 // Decide if a property should be in the object boilerplate. | 1423 // Decide if a property should be in the object boilerplate. |
| 1380 static bool IsBoilerplateProperty(Property* property); | 1424 static bool IsBoilerplateProperty(Property* property); |
| 1381 | 1425 |
| 1382 // Populate the constant properties fixed array. | 1426 // Populate the constant properties fixed array. |
| 1383 void BuildConstantProperties(Isolate* isolate); | 1427 void BuildConstantProperties(Isolate* isolate); |
| 1384 | 1428 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1434 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 1478 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
| 1435 FeedbackVectorSlotCache* cache); | 1479 FeedbackVectorSlotCache* cache); |
| 1436 | 1480 |
| 1437 private: | 1481 private: |
| 1438 friend class AstNodeFactory; | 1482 friend class AstNodeFactory; |
| 1439 | 1483 |
| 1440 ObjectLiteral(ZoneList<Property*>* properties, int literal_index, | 1484 ObjectLiteral(ZoneList<Property*>* properties, int literal_index, |
| 1441 uint32_t boilerplate_properties, int pos) | 1485 uint32_t boilerplate_properties, int pos) |
| 1442 : MaterializedLiteral(literal_index, pos, kObjectLiteral), | 1486 : MaterializedLiteral(literal_index, pos, kObjectLiteral), |
| 1443 boilerplate_properties_(boilerplate_properties), | 1487 boilerplate_properties_(boilerplate_properties), |
| 1444 fast_elements_(false), | 1488 properties_(properties) { |
| 1445 has_elements_(false), | 1489 bit_field_ |= FastElementsField::encode(false) | |
| 1446 may_store_doubles_(false), | 1490 HasElementsField::encode(false) | |
| 1447 properties_(properties) {} | 1491 MayStoreDoublesField::encode(false); |
| 1492 } | |
| 1448 | 1493 |
| 1449 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } | 1494 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } |
| 1450 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1495 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 1451 | 1496 |
| 1452 uint32_t boilerplate_properties_ : 29; | 1497 uint32_t boilerplate_properties_; |
| 1453 bool fast_elements_ : 1; | |
| 1454 bool has_elements_ : 1; | |
| 1455 bool may_store_doubles_ : 1; | |
| 1456 FeedbackVectorSlot slot_; | 1498 FeedbackVectorSlot slot_; |
| 1457 Handle<FixedArray> constant_properties_; | 1499 Handle<FixedArray> constant_properties_; |
| 1458 ZoneList<Property*>* properties_; | 1500 ZoneList<Property*>* properties_; |
| 1501 | |
| 1502 class FastElementsField | |
| 1503 : public BitField<bool, MaterializedLiteral::kNextBitFieldIndex, 1> {}; | |
| 1504 class HasElementsField : public BitField<bool, FastElementsField::kNext, 1> { | |
| 1505 }; | |
| 1506 class MayStoreDoublesField | |
| 1507 : public BitField<bool, HasElementsField::kNext, 1> {}; | |
| 1508 | |
| 1509 protected: | |
| 1510 static const uint8_t kNextBitFieldIndex = MayStoreDoublesField::kNext; | |
| 1459 }; | 1511 }; |
| 1460 | 1512 |
| 1461 | 1513 |
| 1462 // A map from property names to getter/setter pairs allocated in the zone. | 1514 // A map from property names to getter/setter pairs allocated in the zone. |
| 1463 class AccessorTable | 1515 class AccessorTable |
| 1464 : public base::TemplateHashMap<Literal, ObjectLiteral::Accessors, | 1516 : public base::TemplateHashMap<Literal, ObjectLiteral::Accessors, |
| 1465 ZoneAllocationPolicy> { | 1517 ZoneAllocationPolicy> { |
| 1466 public: | 1518 public: |
| 1467 explicit AccessorTable(Zone* zone) | 1519 explicit AccessorTable(Zone* zone) |
| 1468 : base::TemplateHashMap<Literal, ObjectLiteral::Accessors, | 1520 : base::TemplateHashMap<Literal, ObjectLiteral::Accessors, |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1640 friend class AstNodeFactory; | 1692 friend class AstNodeFactory; |
| 1641 | 1693 |
| 1642 VariableProxy(Variable* var, int start_position, int end_position); | 1694 VariableProxy(Variable* var, int start_position, int end_position); |
| 1643 VariableProxy(const AstRawString* name, Variable::Kind variable_kind, | 1695 VariableProxy(const AstRawString* name, Variable::Kind variable_kind, |
| 1644 int start_position, int end_position); | 1696 int start_position, int end_position); |
| 1645 explicit VariableProxy(const VariableProxy* copy_from); | 1697 explicit VariableProxy(const VariableProxy* copy_from); |
| 1646 | 1698 |
| 1647 static int parent_num_ids() { return Expression::num_ids(); } | 1699 static int parent_num_ids() { return Expression::num_ids(); } |
| 1648 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1700 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 1649 | 1701 |
| 1650 class IsThisField : public BitField8<bool, 0, 1> {}; | 1702 class IsThisField : public BitField<bool, Expression::kNextBitFieldIndex, 1> { |
| 1651 class IsAssignedField : public BitField8<bool, 1, 1> {}; | 1703 }; |
| 1652 class IsResolvedField : public BitField8<bool, 2, 1> {}; | 1704 class IsAssignedField : public BitField<bool, IsThisField::kNext, 1> {}; |
| 1653 class IsNewTargetField : public BitField8<bool, 3, 1> {}; | 1705 class IsResolvedField : public BitField<bool, IsAssignedField::kNext, 1> {}; |
| 1706 class IsNewTargetField : public BitField<bool, IsResolvedField::kNext, 1> {}; | |
| 1654 | 1707 |
| 1655 uint8_t bit_field_; | |
| 1656 // Position is stored in the AstNode superclass, but VariableProxy needs to | 1708 // Position is stored in the AstNode superclass, but VariableProxy needs to |
| 1657 // know its end position too (for error messages). It cannot be inferred from | 1709 // know its end position too (for error messages). It cannot be inferred from |
| 1658 // the variable name length because it can contain escapes. | 1710 // the variable name length because it can contain escapes. |
| 1659 int end_position_; | 1711 int end_position_; |
| 1660 FeedbackVectorSlot variable_feedback_slot_; | 1712 FeedbackVectorSlot variable_feedback_slot_; |
| 1661 union { | 1713 union { |
| 1662 const AstRawString* raw_name_; // if !is_resolved_ | 1714 const AstRawString* raw_name_; // if !is_resolved_ |
| 1663 Variable* var_; // if is_resolved_ | 1715 Variable* var_; // if is_resolved_ |
| 1664 }; | 1716 }; |
| 1665 VariableProxy* next_unresolved_; | 1717 VariableProxy* next_unresolved_; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1742 bool super_access = property->IsSuperAccess(); | 1794 bool super_access = property->IsSuperAccess(); |
| 1743 return (property->key()->IsPropertyName()) | 1795 return (property->key()->IsPropertyName()) |
| 1744 ? (super_access ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY) | 1796 ? (super_access ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY) |
| 1745 : (super_access ? KEYED_SUPER_PROPERTY : KEYED_PROPERTY); | 1797 : (super_access ? KEYED_SUPER_PROPERTY : KEYED_PROPERTY); |
| 1746 } | 1798 } |
| 1747 | 1799 |
| 1748 private: | 1800 private: |
| 1749 friend class AstNodeFactory; | 1801 friend class AstNodeFactory; |
| 1750 | 1802 |
| 1751 Property(Expression* obj, Expression* key, int pos) | 1803 Property(Expression* obj, Expression* key, int pos) |
| 1752 : Expression(pos, kProperty), | 1804 : Expression(pos, kProperty), obj_(obj), key_(key) { |
| 1753 bit_field_(IsForCallField::encode(false) | | 1805 bit_field_ |= IsForCallField::encode(false) | |
| 1754 IsStringAccessField::encode(false) | | 1806 IsStringAccessField::encode(false) | |
| 1755 InlineCacheStateField::encode(UNINITIALIZED)), | 1807 InlineCacheStateField::encode(UNINITIALIZED); |
| 1756 obj_(obj), | 1808 } |
| 1757 key_(key) {} | |
| 1758 | 1809 |
| 1759 static int parent_num_ids() { return Expression::num_ids(); } | 1810 static int parent_num_ids() { return Expression::num_ids(); } |
| 1760 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1811 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 1761 | 1812 |
| 1762 class IsForCallField : public BitField8<bool, 0, 1> {}; | 1813 class IsForCallField |
| 1763 class IsStringAccessField : public BitField8<bool, 1, 1> {}; | 1814 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; |
| 1764 class KeyTypeField : public BitField8<IcCheckType, 2, 1> {}; | 1815 class IsStringAccessField : public BitField<bool, IsForCallField::kNext, 1> { |
| 1765 class InlineCacheStateField : public BitField8<InlineCacheState, 3, 4> {}; | 1816 }; |
| 1817 class KeyTypeField | |
| 1818 : public BitField<IcCheckType, IsStringAccessField::kNext, 1> {}; | |
| 1819 class InlineCacheStateField | |
| 1820 : public BitField<InlineCacheState, KeyTypeField::kNext, 4> {}; | |
| 1766 | 1821 |
| 1767 uint8_t bit_field_; | |
| 1768 FeedbackVectorSlot property_feedback_slot_; | 1822 FeedbackVectorSlot property_feedback_slot_; |
| 1769 Expression* obj_; | 1823 Expression* obj_; |
| 1770 Expression* key_; | 1824 Expression* key_; |
| 1771 SmallMapList receiver_types_; | 1825 SmallMapList receiver_types_; |
| 1772 }; | 1826 }; |
| 1773 | 1827 |
| 1774 | 1828 |
| 1775 class Call final : public Expression { | 1829 class Call final : public Expression { |
| 1776 public: | 1830 public: |
| 1777 Expression* expression() const { return expression_; } | 1831 Expression* expression() const { return expression_; } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1863 // Used to assert that the FullCodeGenerator records the return site. | 1917 // Used to assert that the FullCodeGenerator records the return site. |
| 1864 bool return_is_recorded_; | 1918 bool return_is_recorded_; |
| 1865 #endif | 1919 #endif |
| 1866 | 1920 |
| 1867 private: | 1921 private: |
| 1868 friend class AstNodeFactory; | 1922 friend class AstNodeFactory; |
| 1869 | 1923 |
| 1870 Call(Expression* expression, ZoneList<Expression*>* arguments, int pos, | 1924 Call(Expression* expression, ZoneList<Expression*>* arguments, int pos, |
| 1871 PossiblyEval possibly_eval) | 1925 PossiblyEval possibly_eval) |
| 1872 : Expression(pos, kCall), | 1926 : Expression(pos, kCall), |
| 1873 bit_field_( | |
| 1874 IsUninitializedField::encode(false) | | |
| 1875 IsPossiblyEvalField::encode(possibly_eval == IS_POSSIBLY_EVAL)), | |
| 1876 expression_(expression), | 1927 expression_(expression), |
| 1877 arguments_(arguments) { | 1928 arguments_(arguments) { |
| 1929 bit_field_ |= | |
| 1930 IsUninitializedField::encode(false) | | |
| 1931 IsPossiblyEvalField::encode(possibly_eval == IS_POSSIBLY_EVAL); | |
| 1932 | |
| 1878 if (expression->IsProperty()) { | 1933 if (expression->IsProperty()) { |
| 1879 expression->AsProperty()->mark_for_call(); | 1934 expression->AsProperty()->mark_for_call(); |
| 1880 } | 1935 } |
| 1881 } | 1936 } |
| 1882 | 1937 |
| 1883 static int parent_num_ids() { return Expression::num_ids(); } | 1938 static int parent_num_ids() { return Expression::num_ids(); } |
| 1884 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1939 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 1885 | 1940 |
| 1886 class IsUninitializedField : public BitField8<bool, 0, 1> {}; | 1941 class IsUninitializedField |
| 1887 class IsTailField : public BitField8<bool, 1, 1> {}; | 1942 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; |
| 1888 class IsPossiblyEvalField : public BitField8<bool, 2, 1> {}; | 1943 class IsTailField : public BitField<bool, IsUninitializedField::kNext, 1> {}; |
| 1944 class IsPossiblyEvalField : public BitField<bool, IsTailField::kNext, 1> {}; | |
| 1889 | 1945 |
| 1890 uint8_t bit_field_; | |
| 1891 FeedbackVectorSlot ic_slot_; | 1946 FeedbackVectorSlot ic_slot_; |
| 1892 FeedbackVectorSlot stub_slot_; | 1947 FeedbackVectorSlot stub_slot_; |
| 1893 Expression* expression_; | 1948 Expression* expression_; |
| 1894 ZoneList<Expression*>* arguments_; | 1949 ZoneList<Expression*>* arguments_; |
| 1895 Handle<JSFunction> target_; | 1950 Handle<JSFunction> target_; |
| 1896 Handle<AllocationSite> allocation_site_; | 1951 Handle<AllocationSite> allocation_site_; |
| 1897 }; | 1952 }; |
| 1898 | 1953 |
| 1899 | 1954 |
| 1900 class CallNew final : public Expression { | 1955 class CallNew final : public Expression { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1911 // Construct calls have two slots, one right after the other. | 1966 // Construct calls have two slots, one right after the other. |
| 1912 // The second slot stores the call count for monomorphic calls. | 1967 // The second slot stores the call count for monomorphic calls. |
| 1913 spec->AddGeneralSlot(); | 1968 spec->AddGeneralSlot(); |
| 1914 } | 1969 } |
| 1915 | 1970 |
| 1916 FeedbackVectorSlot CallNewFeedbackSlot() { | 1971 FeedbackVectorSlot CallNewFeedbackSlot() { |
| 1917 DCHECK(!callnew_feedback_slot_.IsInvalid()); | 1972 DCHECK(!callnew_feedback_slot_.IsInvalid()); |
| 1918 return callnew_feedback_slot_; | 1973 return callnew_feedback_slot_; |
| 1919 } | 1974 } |
| 1920 | 1975 |
| 1921 bool IsMonomorphic() const { return is_monomorphic_; } | 1976 bool IsMonomorphic() const { return IsMonomorphicField::decode(bit_field_); } |
| 1922 Handle<JSFunction> target() const { return target_; } | 1977 Handle<JSFunction> target() const { return target_; } |
| 1923 Handle<AllocationSite> allocation_site() const { | 1978 Handle<AllocationSite> allocation_site() const { |
| 1924 return allocation_site_; | 1979 return allocation_site_; |
| 1925 } | 1980 } |
| 1926 | 1981 |
| 1927 static int num_ids() { return parent_num_ids() + 1; } | 1982 static int num_ids() { return parent_num_ids() + 1; } |
| 1928 static int feedback_slots() { return 1; } | 1983 static int feedback_slots() { return 1; } |
| 1929 BailoutId ReturnId() const { return BailoutId(local_id(0)); } | 1984 BailoutId ReturnId() const { return BailoutId(local_id(0)); } |
| 1930 | 1985 |
| 1931 void set_allocation_site(Handle<AllocationSite> site) { | 1986 void set_allocation_site(Handle<AllocationSite> site) { |
| 1932 allocation_site_ = site; | 1987 allocation_site_ = site; |
| 1933 } | 1988 } |
| 1934 void set_is_monomorphic(bool monomorphic) { is_monomorphic_ = monomorphic; } | 1989 void set_is_monomorphic(bool monomorphic) { |
| 1990 bit_field_ = IsMonomorphicField::update(bit_field_, monomorphic); | |
| 1991 } | |
| 1935 void set_target(Handle<JSFunction> target) { target_ = target; } | 1992 void set_target(Handle<JSFunction> target) { target_ = target; } |
| 1936 void SetKnownGlobalTarget(Handle<JSFunction> target) { | 1993 void SetKnownGlobalTarget(Handle<JSFunction> target) { |
| 1937 target_ = target; | 1994 target_ = target; |
| 1938 is_monomorphic_ = true; | 1995 set_is_monomorphic(true); |
| 1939 } | 1996 } |
| 1940 | 1997 |
| 1941 private: | 1998 private: |
| 1942 friend class AstNodeFactory; | 1999 friend class AstNodeFactory; |
| 1943 | 2000 |
| 1944 CallNew(Expression* expression, ZoneList<Expression*>* arguments, int pos) | 2001 CallNew(Expression* expression, ZoneList<Expression*>* arguments, int pos) |
| 1945 : Expression(pos, kCallNew), | 2002 : Expression(pos, kCallNew), |
| 1946 is_monomorphic_(false), | |
| 1947 expression_(expression), | 2003 expression_(expression), |
| 1948 arguments_(arguments) {} | 2004 arguments_(arguments) { |
| 2005 bit_field_ |= IsMonomorphicField::encode(false); | |
| 2006 } | |
| 1949 | 2007 |
| 1950 static int parent_num_ids() { return Expression::num_ids(); } | 2008 static int parent_num_ids() { return Expression::num_ids(); } |
| 1951 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2009 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 1952 | 2010 |
| 1953 bool is_monomorphic_; | |
| 1954 FeedbackVectorSlot callnew_feedback_slot_; | 2011 FeedbackVectorSlot callnew_feedback_slot_; |
| 1955 Expression* expression_; | 2012 Expression* expression_; |
| 1956 ZoneList<Expression*>* arguments_; | 2013 ZoneList<Expression*>* arguments_; |
| 1957 Handle<JSFunction> target_; | 2014 Handle<JSFunction> target_; |
| 1958 Handle<AllocationSite> allocation_site_; | 2015 Handle<AllocationSite> allocation_site_; |
| 2016 | |
| 2017 class IsMonomorphicField | |
| 2018 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; | |
| 1959 }; | 2019 }; |
| 1960 | 2020 |
| 1961 | 2021 |
| 1962 // The CallRuntime class does not represent any official JavaScript | 2022 // The CallRuntime class does not represent any official JavaScript |
| 1963 // language construct. Instead it is used to call a C or JS function | 2023 // language construct. Instead it is used to call a C or JS function |
| 1964 // with a set of arguments. This is used from the builtins that are | 2024 // with a set of arguments. This is used from the builtins that are |
| 1965 // implemented in JavaScript (see "v8natives.js"). | 2025 // implemented in JavaScript (see "v8natives.js"). |
| 1966 class CallRuntime final : public Expression { | 2026 class CallRuntime final : public Expression { |
| 1967 public: | 2027 public: |
| 1968 ZoneList<Expression*>* arguments() const { return arguments_; } | 2028 ZoneList<Expression*>* arguments() const { return arguments_; } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2002 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2062 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 2003 | 2063 |
| 2004 int context_index_; | 2064 int context_index_; |
| 2005 const Runtime::Function* function_; | 2065 const Runtime::Function* function_; |
| 2006 ZoneList<Expression*>* arguments_; | 2066 ZoneList<Expression*>* arguments_; |
| 2007 }; | 2067 }; |
| 2008 | 2068 |
| 2009 | 2069 |
| 2010 class UnaryOperation final : public Expression { | 2070 class UnaryOperation final : public Expression { |
| 2011 public: | 2071 public: |
| 2012 Token::Value op() const { return op_; } | 2072 Token::Value op() const { return OperatorField::decode(bit_field_); } |
| 2013 Expression* expression() const { return expression_; } | 2073 Expression* expression() const { return expression_; } |
| 2014 void set_expression(Expression* e) { expression_ = e; } | 2074 void set_expression(Expression* e) { expression_ = e; } |
| 2015 | 2075 |
| 2016 // For unary not (Token::NOT), the AST ids where true and false will | 2076 // For unary not (Token::NOT), the AST ids where true and false will |
| 2017 // actually be materialized, respectively. | 2077 // actually be materialized, respectively. |
| 2018 static int num_ids() { return parent_num_ids() + 2; } | 2078 static int num_ids() { return parent_num_ids() + 2; } |
| 2019 BailoutId MaterializeTrueId() const { return BailoutId(local_id(0)); } | 2079 BailoutId MaterializeTrueId() const { return BailoutId(local_id(0)); } |
| 2020 BailoutId MaterializeFalseId() const { return BailoutId(local_id(1)); } | 2080 BailoutId MaterializeFalseId() const { return BailoutId(local_id(1)); } |
| 2021 | 2081 |
| 2022 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); | 2082 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); |
| 2023 | 2083 |
| 2024 private: | 2084 private: |
| 2025 friend class AstNodeFactory; | 2085 friend class AstNodeFactory; |
| 2026 | 2086 |
| 2027 UnaryOperation(Token::Value op, Expression* expression, int pos) | 2087 UnaryOperation(Token::Value op, Expression* expression, int pos) |
| 2028 : Expression(pos, kUnaryOperation), op_(op), expression_(expression) { | 2088 : Expression(pos, kUnaryOperation), expression_(expression) { |
| 2089 bit_field_ |= OperatorField::encode(op); | |
| 2029 DCHECK(Token::IsUnaryOp(op)); | 2090 DCHECK(Token::IsUnaryOp(op)); |
| 2030 } | 2091 } |
| 2031 | 2092 |
| 2032 static int parent_num_ids() { return Expression::num_ids(); } | 2093 static int parent_num_ids() { return Expression::num_ids(); } |
| 2033 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2094 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 2034 | 2095 |
| 2035 Token::Value op_; | |
| 2036 Expression* expression_; | 2096 Expression* expression_; |
| 2097 | |
| 2098 class OperatorField | |
| 2099 : public BitField<Token::Value, Expression::kNextBitFieldIndex, 7> {}; | |
| 2037 }; | 2100 }; |
| 2038 | 2101 |
| 2039 | 2102 |
| 2040 class BinaryOperation final : public Expression { | 2103 class BinaryOperation final : public Expression { |
| 2041 public: | 2104 public: |
| 2042 Token::Value op() const { return static_cast<Token::Value>(op_); } | 2105 Token::Value op() const { return OperatorField::decode(bit_field_); } |
| 2043 Expression* left() const { return left_; } | 2106 Expression* left() const { return left_; } |
| 2044 void set_left(Expression* e) { left_ = e; } | 2107 void set_left(Expression* e) { left_ = e; } |
| 2045 Expression* right() const { return right_; } | 2108 Expression* right() const { return right_; } |
| 2046 void set_right(Expression* e) { right_ = e; } | 2109 void set_right(Expression* e) { right_ = e; } |
| 2047 Handle<AllocationSite> allocation_site() const { return allocation_site_; } | 2110 Handle<AllocationSite> allocation_site() const { return allocation_site_; } |
| 2048 void set_allocation_site(Handle<AllocationSite> allocation_site) { | 2111 void set_allocation_site(Handle<AllocationSite> allocation_site) { |
| 2049 allocation_site_ = allocation_site; | 2112 allocation_site_ = allocation_site; |
| 2050 } | 2113 } |
| 2051 | 2114 |
| 2052 void MarkTail() { | 2115 void MarkTail() { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2086 if (arg.IsJust()) fixed_right_arg_value_ = arg.FromJust(); | 2149 if (arg.IsJust()) fixed_right_arg_value_ = arg.FromJust(); |
| 2087 } | 2150 } |
| 2088 | 2151 |
| 2089 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); | 2152 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); |
| 2090 | 2153 |
| 2091 private: | 2154 private: |
| 2092 friend class AstNodeFactory; | 2155 friend class AstNodeFactory; |
| 2093 | 2156 |
| 2094 BinaryOperation(Token::Value op, Expression* left, Expression* right, int pos) | 2157 BinaryOperation(Token::Value op, Expression* left, Expression* right, int pos) |
| 2095 : Expression(pos, kBinaryOperation), | 2158 : Expression(pos, kBinaryOperation), |
| 2096 op_(static_cast<byte>(op)), | |
| 2097 has_fixed_right_arg_(false), | 2159 has_fixed_right_arg_(false), |
| 2098 fixed_right_arg_value_(0), | 2160 fixed_right_arg_value_(0), |
| 2099 left_(left), | 2161 left_(left), |
| 2100 right_(right) { | 2162 right_(right) { |
| 2163 bit_field_ |= OperatorField::encode(op); | |
| 2101 DCHECK(Token::IsBinaryOp(op)); | 2164 DCHECK(Token::IsBinaryOp(op)); |
| 2102 } | 2165 } |
| 2103 | 2166 |
| 2104 static int parent_num_ids() { return Expression::num_ids(); } | 2167 static int parent_num_ids() { return Expression::num_ids(); } |
| 2105 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2168 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 2106 | 2169 |
| 2107 const byte op_; // actually Token::Value | |
| 2108 // TODO(rossberg): the fixed arg should probably be represented as a Constant | 2170 // TODO(rossberg): the fixed arg should probably be represented as a Constant |
| 2109 // type for the RHS. Currenty it's actually a Maybe<int> | 2171 // type for the RHS. Currenty it's actually a Maybe<int> |
| 2110 bool has_fixed_right_arg_; | 2172 bool has_fixed_right_arg_; |
| 2111 int fixed_right_arg_value_; | 2173 int fixed_right_arg_value_; |
| 2112 Expression* left_; | 2174 Expression* left_; |
| 2113 Expression* right_; | 2175 Expression* right_; |
| 2114 Handle<AllocationSite> allocation_site_; | 2176 Handle<AllocationSite> allocation_site_; |
| 2115 FeedbackVectorSlot type_feedback_slot_; | 2177 FeedbackVectorSlot type_feedback_slot_; |
| 2178 | |
| 2179 class OperatorField | |
| 2180 : public BitField<Token::Value, Expression::kNextBitFieldIndex, 7> {}; | |
| 2116 }; | 2181 }; |
| 2117 | 2182 |
| 2118 | 2183 |
| 2119 class CountOperation final : public Expression { | 2184 class CountOperation final : public Expression { |
| 2120 public: | 2185 public: |
| 2121 bool is_prefix() const { return IsPrefixField::decode(bit_field_); } | 2186 bool is_prefix() const { return IsPrefixField::decode(bit_field_); } |
| 2122 bool is_postfix() const { return !is_prefix(); } | 2187 bool is_postfix() const { return !is_prefix(); } |
| 2123 | 2188 |
| 2124 Token::Value op() const { return TokenField::decode(bit_field_); } | 2189 Token::Value op() const { return TokenField::decode(bit_field_); } |
| 2125 Token::Value binary_op() { | 2190 Token::Value binary_op() { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2160 } | 2225 } |
| 2161 | 2226 |
| 2162 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 2227 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
| 2163 FeedbackVectorSlotCache* cache); | 2228 FeedbackVectorSlotCache* cache); |
| 2164 FeedbackVectorSlot CountSlot() const { return slot_; } | 2229 FeedbackVectorSlot CountSlot() const { return slot_; } |
| 2165 | 2230 |
| 2166 private: | 2231 private: |
| 2167 friend class AstNodeFactory; | 2232 friend class AstNodeFactory; |
| 2168 | 2233 |
| 2169 CountOperation(Token::Value op, bool is_prefix, Expression* expr, int pos) | 2234 CountOperation(Token::Value op, bool is_prefix, Expression* expr, int pos) |
| 2170 : Expression(pos, kCountOperation), | 2235 : Expression(pos, kCountOperation), type_(NULL), expression_(expr) { |
| 2171 bit_field_( | 2236 bit_field_ |= |
| 2172 IsPrefixField::encode(is_prefix) | KeyTypeField::encode(ELEMENT) | | 2237 IsPrefixField::encode(is_prefix) | KeyTypeField::encode(ELEMENT) | |
| 2173 StoreModeField::encode(STANDARD_STORE) | TokenField::encode(op)), | 2238 StoreModeField::encode(STANDARD_STORE) | TokenField::encode(op); |
| 2174 type_(NULL), | 2239 } |
| 2175 expression_(expr) {} | |
| 2176 | 2240 |
| 2177 static int parent_num_ids() { return Expression::num_ids(); } | 2241 static int parent_num_ids() { return Expression::num_ids(); } |
| 2178 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2242 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 2179 | 2243 |
| 2180 class IsPrefixField : public BitField16<bool, 0, 1> {}; | 2244 class IsPrefixField |
| 2181 class KeyTypeField : public BitField16<IcCheckType, 1, 1> {}; | 2245 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; |
| 2182 class StoreModeField : public BitField16<KeyedAccessStoreMode, 2, 3> {}; | 2246 class KeyTypeField : public BitField<IcCheckType, IsPrefixField::kNext, 1> {}; |
| 2183 class TokenField : public BitField16<Token::Value, 5, 8> {}; | 2247 class StoreModeField |
| 2248 : public BitField<KeyedAccessStoreMode, KeyTypeField::kNext, 3> {}; | |
| 2249 class TokenField : public BitField<Token::Value, StoreModeField::kNext, 7> {}; | |
| 2184 | 2250 |
| 2185 // Starts with 16-bit field, which should get packed together with | |
| 2186 // Expression's trailing 16-bit field. | |
| 2187 uint16_t bit_field_; | |
| 2188 FeedbackVectorSlot slot_; | 2251 FeedbackVectorSlot slot_; |
| 2189 FeedbackVectorSlot binary_operation_slot_; | 2252 FeedbackVectorSlot binary_operation_slot_; |
| 2190 Type* type_; | 2253 Type* type_; |
| 2191 Expression* expression_; | 2254 Expression* expression_; |
| 2192 SmallMapList receiver_types_; | 2255 SmallMapList receiver_types_; |
| 2193 }; | 2256 }; |
| 2194 | 2257 |
| 2195 | 2258 |
| 2196 class CompareOperation final : public Expression { | 2259 class CompareOperation final : public Expression { |
| 2197 public: | 2260 public: |
| 2198 Token::Value op() const { return op_; } | 2261 Token::Value op() const { return OperatorField::decode(bit_field_); } |
| 2199 Expression* left() const { return left_; } | 2262 Expression* left() const { return left_; } |
| 2200 Expression* right() const { return right_; } | 2263 Expression* right() const { return right_; } |
| 2201 | 2264 |
| 2202 void set_left(Expression* e) { left_ = e; } | 2265 void set_left(Expression* e) { left_ = e; } |
| 2203 void set_right(Expression* e) { right_ = e; } | 2266 void set_right(Expression* e) { right_ = e; } |
| 2204 | 2267 |
| 2205 // Type feedback information. | 2268 // Type feedback information. |
| 2206 static int num_ids() { return parent_num_ids() + 1; } | 2269 static int num_ids() { return parent_num_ids() + 1; } |
| 2207 TypeFeedbackId CompareOperationFeedbackId() const { | 2270 TypeFeedbackId CompareOperationFeedbackId() const { |
| 2208 return TypeFeedbackId(local_id(0)); | 2271 return TypeFeedbackId(local_id(0)); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 2224 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); | 2287 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); |
| 2225 bool IsLiteralCompareUndefined(Expression** expr); | 2288 bool IsLiteralCompareUndefined(Expression** expr); |
| 2226 bool IsLiteralCompareNull(Expression** expr); | 2289 bool IsLiteralCompareNull(Expression** expr); |
| 2227 | 2290 |
| 2228 private: | 2291 private: |
| 2229 friend class AstNodeFactory; | 2292 friend class AstNodeFactory; |
| 2230 | 2293 |
| 2231 CompareOperation(Token::Value op, Expression* left, Expression* right, | 2294 CompareOperation(Token::Value op, Expression* left, Expression* right, |
| 2232 int pos) | 2295 int pos) |
| 2233 : Expression(pos, kCompareOperation), | 2296 : Expression(pos, kCompareOperation), |
| 2234 op_(op), | |
| 2235 left_(left), | 2297 left_(left), |
| 2236 right_(right), | 2298 right_(right), |
| 2237 combined_type_(Type::None()) { | 2299 combined_type_(Type::None()) { |
| 2300 bit_field_ |= OperatorField::encode(op); | |
| 2238 DCHECK(Token::IsCompareOp(op)); | 2301 DCHECK(Token::IsCompareOp(op)); |
| 2239 } | 2302 } |
| 2240 | 2303 |
| 2241 static int parent_num_ids() { return Expression::num_ids(); } | 2304 static int parent_num_ids() { return Expression::num_ids(); } |
| 2242 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2305 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 2243 | 2306 |
| 2244 Token::Value op_; | |
| 2245 Expression* left_; | 2307 Expression* left_; |
| 2246 Expression* right_; | 2308 Expression* right_; |
| 2247 | 2309 |
| 2248 Type* combined_type_; | 2310 Type* combined_type_; |
| 2249 FeedbackVectorSlot type_feedback_slot_; | 2311 FeedbackVectorSlot type_feedback_slot_; |
| 2312 class OperatorField | |
| 2313 : public BitField<Token::Value, Expression::kNextBitFieldIndex, 7> {}; | |
| 2250 }; | 2314 }; |
| 2251 | 2315 |
| 2252 | 2316 |
| 2253 class Spread final : public Expression { | 2317 class Spread final : public Expression { |
| 2254 public: | 2318 public: |
| 2255 Expression* expression() const { return expression_; } | 2319 Expression* expression() const { return expression_; } |
| 2256 void set_expression(Expression* e) { expression_ = e; } | 2320 void set_expression(Expression* e) { expression_ = e; } |
| 2257 | 2321 |
| 2258 int expression_position() const { return expr_pos_; } | 2322 int expression_position() const { return expr_pos_; } |
| 2259 | 2323 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2363 FeedbackVectorSlot AssignmentSlot() const { return slot_; } | 2427 FeedbackVectorSlot AssignmentSlot() const { return slot_; } |
| 2364 | 2428 |
| 2365 private: | 2429 private: |
| 2366 friend class AstNodeFactory; | 2430 friend class AstNodeFactory; |
| 2367 | 2431 |
| 2368 Assignment(Token::Value op, Expression* target, Expression* value, int pos); | 2432 Assignment(Token::Value op, Expression* target, Expression* value, int pos); |
| 2369 | 2433 |
| 2370 static int parent_num_ids() { return Expression::num_ids(); } | 2434 static int parent_num_ids() { return Expression::num_ids(); } |
| 2371 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2435 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 2372 | 2436 |
| 2373 class IsUninitializedField : public BitField16<bool, 0, 1> {}; | 2437 class IsUninitializedField |
| 2438 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; | |
| 2374 class KeyTypeField | 2439 class KeyTypeField |
| 2375 : public BitField16<IcCheckType, IsUninitializedField::kNext, 1> {}; | 2440 : public BitField<IcCheckType, IsUninitializedField::kNext, 1> {}; |
| 2376 class StoreModeField | 2441 class StoreModeField |
| 2377 : public BitField16<KeyedAccessStoreMode, KeyTypeField::kNext, 3> {}; | 2442 : public BitField<KeyedAccessStoreMode, KeyTypeField::kNext, 3> {}; |
| 2378 class TokenField : public BitField16<Token::Value, StoreModeField::kNext, 8> { | 2443 class TokenField : public BitField<Token::Value, StoreModeField::kNext, 7> {}; |
| 2379 }; | |
| 2380 | 2444 |
| 2381 // Starts with 16-bit field, which should get packed together with | |
| 2382 // Expression's trailing 16-bit field. | |
| 2383 uint16_t bit_field_; | |
| 2384 FeedbackVectorSlot slot_; | 2445 FeedbackVectorSlot slot_; |
| 2385 Expression* target_; | 2446 Expression* target_; |
| 2386 Expression* value_; | 2447 Expression* value_; |
| 2387 BinaryOperation* binary_operation_; | 2448 BinaryOperation* binary_operation_; |
| 2388 SmallMapList receiver_types_; | 2449 SmallMapList receiver_types_; |
| 2389 }; | 2450 }; |
| 2390 | 2451 |
| 2391 | 2452 |
| 2392 // The RewritableExpression class is a wrapper for AST nodes that wait | 2453 // The RewritableExpression class is a wrapper for AST nodes that wait |
| 2393 // for some potential rewriting. However, even if such nodes are indeed | 2454 // for some potential rewriting. However, even if such nodes are indeed |
| 2394 // rewritten, the RewritableExpression wrapper nodes will survive in the | 2455 // rewritten, the RewritableExpression wrapper nodes will survive in the |
| 2395 // final AST and should be just ignored, i.e., they should be treated as | 2456 // final AST and should be just ignored, i.e., they should be treated as |
| 2396 // equivalent to the wrapped nodes. For this reason and to simplify later | 2457 // equivalent to the wrapped nodes. For this reason and to simplify later |
| 2397 // phases, RewritableExpressions are considered as exceptions of AST nodes | 2458 // phases, RewritableExpressions are considered as exceptions of AST nodes |
| 2398 // in the following sense: | 2459 // in the following sense: |
| 2399 // | 2460 // |
| 2400 // 1. IsRewritableExpression and AsRewritableExpression behave as usual. | 2461 // 1. IsRewritableExpression and AsRewritableExpression behave as usual. |
| 2401 // 2. All other Is* and As* methods are practically delegated to the | 2462 // 2. All other Is* and As* methods are practically delegated to the |
| 2402 // wrapped node, i.e. IsArrayLiteral() will return true iff the | 2463 // wrapped node, i.e. IsArrayLiteral() will return true iff the |
| 2403 // wrapped node is an array literal. | 2464 // wrapped node is an array literal. |
| 2404 // | 2465 // |
| 2405 // Furthermore, an invariant that should be respected is that the wrapped | 2466 // Furthermore, an invariant that should be respected is that the wrapped |
| 2406 // node is not a RewritableExpression. | 2467 // node is not a RewritableExpression. |
| 2407 class RewritableExpression final : public Expression { | 2468 class RewritableExpression final : public Expression { |
| 2408 public: | 2469 public: |
| 2409 Expression* expression() const { return expr_; } | 2470 Expression* expression() const { return expr_; } |
| 2410 bool is_rewritten() const { return is_rewritten_; } | 2471 bool is_rewritten() const { return IsRewrittenField::decode(bit_field_); } |
| 2411 | 2472 |
| 2412 void Rewrite(Expression* new_expression) { | 2473 void Rewrite(Expression* new_expression) { |
| 2413 DCHECK(!is_rewritten()); | 2474 DCHECK(!is_rewritten()); |
| 2414 DCHECK_NOT_NULL(new_expression); | 2475 DCHECK_NOT_NULL(new_expression); |
| 2415 DCHECK(!new_expression->IsRewritableExpression()); | 2476 DCHECK(!new_expression->IsRewritableExpression()); |
| 2416 expr_ = new_expression; | 2477 expr_ = new_expression; |
| 2417 is_rewritten_ = true; | 2478 bit_field_ = IsRewrittenField::update(bit_field_, true); |
| 2418 } | 2479 } |
| 2419 | 2480 |
| 2420 static int num_ids() { return parent_num_ids(); } | 2481 static int num_ids() { return parent_num_ids(); } |
| 2421 | 2482 |
| 2422 private: | 2483 private: |
| 2423 friend class AstNodeFactory; | 2484 friend class AstNodeFactory; |
| 2424 | 2485 |
| 2425 explicit RewritableExpression(Expression* expression) | 2486 explicit RewritableExpression(Expression* expression) |
| 2426 : Expression(expression->position(), kRewritableExpression), | 2487 : Expression(expression->position(), kRewritableExpression), |
| 2427 is_rewritten_(false), | |
| 2428 expr_(expression) { | 2488 expr_(expression) { |
| 2489 bit_field_ |= IsRewrittenField::encode(false); | |
| 2429 DCHECK(!expression->IsRewritableExpression()); | 2490 DCHECK(!expression->IsRewritableExpression()); |
| 2430 } | 2491 } |
| 2431 | 2492 |
| 2432 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2493 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 2433 | 2494 |
| 2434 bool is_rewritten_; | |
| 2435 Expression* expr_; | 2495 Expression* expr_; |
| 2496 | |
| 2497 class IsRewrittenField | |
| 2498 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; | |
| 2436 }; | 2499 }; |
| 2437 | 2500 |
| 2438 // Our Yield is different from the JS yield in that it "returns" its argument as | 2501 // Our Yield is different from the JS yield in that it "returns" its argument as |
| 2439 // is, without wrapping it in an iterator result object. Such wrapping, if | 2502 // is, without wrapping it in an iterator result object. Such wrapping, if |
| 2440 // desired, must be done beforehand (see the parser). | 2503 // desired, must be done beforehand (see the parser). |
| 2441 class Yield final : public Expression { | 2504 class Yield final : public Expression { |
| 2442 public: | 2505 public: |
| 2443 enum OnException { kOnExceptionThrow, kOnExceptionRethrow }; | 2506 enum OnException { kOnExceptionThrow, kOnExceptionRethrow }; |
| 2444 | 2507 |
| 2445 Expression* generator_object() const { return generator_object_; } | 2508 Expression* generator_object() const { return generator_object_; } |
| 2446 Expression* expression() const { return expression_; } | 2509 Expression* expression() const { return expression_; } |
| 2510 OnException on_exception() const { | |
| 2511 return OnExceptionField::decode(bit_field_); | |
| 2512 } | |
| 2447 bool rethrow_on_exception() const { | 2513 bool rethrow_on_exception() const { |
| 2448 return on_exception_ == kOnExceptionRethrow; | 2514 return on_exception() == kOnExceptionRethrow; |
| 2449 } | 2515 } |
| 2450 int yield_id() const { return yield_id_; } | 2516 int yield_id() const { return yield_id_; } |
| 2451 | 2517 |
| 2452 void set_generator_object(Expression* e) { generator_object_ = e; } | 2518 void set_generator_object(Expression* e) { generator_object_ = e; } |
| 2453 void set_expression(Expression* e) { expression_ = e; } | 2519 void set_expression(Expression* e) { expression_ = e; } |
| 2454 void set_yield_id(int yield_id) { yield_id_ = yield_id; } | 2520 void set_yield_id(int yield_id) { yield_id_ = yield_id; } |
| 2455 | 2521 |
| 2456 private: | 2522 private: |
| 2457 friend class AstNodeFactory; | 2523 friend class AstNodeFactory; |
| 2458 | 2524 |
| 2459 Yield(Expression* generator_object, Expression* expression, int pos, | 2525 Yield(Expression* generator_object, Expression* expression, int pos, |
| 2460 OnException on_exception) | 2526 OnException on_exception) |
| 2461 : Expression(pos, kYield), | 2527 : Expression(pos, kYield), |
| 2462 on_exception_(on_exception), | |
| 2463 yield_id_(-1), | 2528 yield_id_(-1), |
| 2464 generator_object_(generator_object), | 2529 generator_object_(generator_object), |
| 2465 expression_(expression) {} | 2530 expression_(expression) { |
| 2531 bit_field_ |= OnExceptionField::encode(on_exception); | |
| 2532 } | |
| 2466 | 2533 |
| 2467 OnException on_exception_; | |
| 2468 int yield_id_; | 2534 int yield_id_; |
| 2469 Expression* generator_object_; | 2535 Expression* generator_object_; |
| 2470 Expression* expression_; | 2536 Expression* expression_; |
| 2537 | |
| 2538 class OnExceptionField | |
| 2539 : public BitField<OnException, Expression::kNextBitFieldIndex, 1> {}; | |
| 2471 }; | 2540 }; |
| 2472 | 2541 |
| 2473 | 2542 |
| 2474 class Throw final : public Expression { | 2543 class Throw final : public Expression { |
| 2475 public: | 2544 public: |
| 2476 Expression* exception() const { return exception_; } | 2545 Expression* exception() const { return exception_; } |
| 2477 void set_exception(Expression* e) { exception_ = e; } | 2546 void set_exception(Expression* e) { exception_ = e; } |
| 2478 | 2547 |
| 2479 private: | 2548 private: |
| 2480 friend class AstNodeFactory; | 2549 friend class AstNodeFactory; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2554 raw_inferred_name_ = NULL; | 2623 raw_inferred_name_ = NULL; |
| 2555 } | 2624 } |
| 2556 | 2625 |
| 2557 void set_raw_inferred_name(const AstString* raw_inferred_name) { | 2626 void set_raw_inferred_name(const AstString* raw_inferred_name) { |
| 2558 DCHECK(raw_inferred_name != NULL); | 2627 DCHECK(raw_inferred_name != NULL); |
| 2559 raw_inferred_name_ = raw_inferred_name; | 2628 raw_inferred_name_ = raw_inferred_name; |
| 2560 DCHECK(inferred_name_.is_null()); | 2629 DCHECK(inferred_name_.is_null()); |
| 2561 inferred_name_ = Handle<String>(); | 2630 inferred_name_ = Handle<String>(); |
| 2562 } | 2631 } |
| 2563 | 2632 |
| 2564 bool pretenure() const { return Pretenure::decode(bitfield_); } | 2633 bool pretenure() const { return Pretenure::decode(bit_field_); } |
| 2565 void set_pretenure() { bitfield_ = Pretenure::update(bitfield_, true); } | 2634 void set_pretenure() { bit_field_ = Pretenure::update(bit_field_, true); } |
| 2566 | 2635 |
| 2567 bool has_duplicate_parameters() const { | 2636 bool has_duplicate_parameters() const { |
| 2568 return HasDuplicateParameters::decode(bitfield_); | 2637 return HasDuplicateParameters::decode(bit_field_); |
| 2569 } | 2638 } |
| 2570 | 2639 |
| 2571 bool is_function() const { return IsFunction::decode(bitfield_); } | 2640 bool is_function() const { return IsFunction::decode(bit_field_); } |
| 2572 | 2641 |
| 2573 // This is used as a heuristic on when to eagerly compile a function | 2642 // This is used as a heuristic on when to eagerly compile a function |
| 2574 // literal. We consider the following constructs as hints that the | 2643 // literal. We consider the following constructs as hints that the |
| 2575 // function will be called immediately: | 2644 // function will be called immediately: |
| 2576 // - (function() { ... })(); | 2645 // - (function() { ... })(); |
| 2577 // - var x = function() { ... }(); | 2646 // - var x = function() { ... }(); |
| 2578 bool should_eager_compile() const { | 2647 bool should_eager_compile() const { |
| 2579 return ShouldEagerCompile::decode(bitfield_); | 2648 return ShouldEagerCompile::decode(bit_field_); |
| 2580 } | 2649 } |
| 2581 void set_should_eager_compile() { | 2650 void set_should_eager_compile() { |
| 2582 bitfield_ = ShouldEagerCompile::update(bitfield_, true); | 2651 bit_field_ = ShouldEagerCompile::update(bit_field_, true); |
| 2583 } | 2652 } |
| 2584 | 2653 |
| 2585 // A hint that we expect this function to be called (exactly) once, | 2654 // A hint that we expect this function to be called (exactly) once, |
| 2586 // i.e. we suspect it's an initialization function. | 2655 // i.e. we suspect it's an initialization function. |
| 2587 bool should_be_used_once_hint() const { | 2656 bool should_be_used_once_hint() const { return should_be_used_once_hint_; } |
| 2588 return ShouldBeUsedOnceHint::decode(bitfield_); | 2657 void set_should_be_used_once_hint() { should_be_used_once_hint_ = true; } |
| 2589 } | |
| 2590 void set_should_be_used_once_hint() { | |
| 2591 bitfield_ = ShouldBeUsedOnceHint::update(bitfield_, true); | |
| 2592 } | |
| 2593 | 2658 |
| 2594 FunctionType function_type() const { | 2659 FunctionType function_type() const { |
| 2595 return FunctionTypeBits::decode(bitfield_); | 2660 return FunctionTypeBits::decode(bit_field_); |
| 2596 } | 2661 } |
| 2597 FunctionKind kind() const { return FunctionKindBits::decode(bitfield_); } | 2662 FunctionKind kind() const { return FunctionKindBits::decode(bit_field_); } |
| 2598 | 2663 |
| 2599 int ast_node_count() { return ast_properties_.node_count(); } | 2664 int ast_node_count() { return ast_properties_.node_count(); } |
| 2600 AstProperties::Flags flags() const { return ast_properties_.flags(); } | 2665 AstProperties::Flags flags() const { return ast_properties_.flags(); } |
| 2601 void set_ast_properties(AstProperties* ast_properties) { | 2666 void set_ast_properties(AstProperties* ast_properties) { |
| 2602 ast_properties_ = *ast_properties; | 2667 ast_properties_ = *ast_properties; |
| 2603 } | 2668 } |
| 2604 const FeedbackVectorSpec* feedback_vector_spec() const { | 2669 const FeedbackVectorSpec* feedback_vector_spec() const { |
| 2605 return ast_properties_.get_spec(); | 2670 return ast_properties_.get_spec(); |
| 2606 } | 2671 } |
| 2607 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } | 2672 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 2623 FunctionLiteral(Zone* zone, const AstString* name, | 2688 FunctionLiteral(Zone* zone, const AstString* name, |
| 2624 AstValueFactory* ast_value_factory, DeclarationScope* scope, | 2689 AstValueFactory* ast_value_factory, DeclarationScope* scope, |
| 2625 ZoneList<Statement*>* body, int materialized_literal_count, | 2690 ZoneList<Statement*>* body, int materialized_literal_count, |
| 2626 int expected_property_count, int parameter_count, | 2691 int expected_property_count, int parameter_count, |
| 2627 FunctionType function_type, | 2692 FunctionType function_type, |
| 2628 ParameterFlag has_duplicate_parameters, | 2693 ParameterFlag has_duplicate_parameters, |
| 2629 EagerCompileHint eager_compile_hint, FunctionKind kind, | 2694 EagerCompileHint eager_compile_hint, FunctionKind kind, |
| 2630 int position, bool is_function) | 2695 int position, bool is_function) |
| 2631 : Expression(position, kFunctionLiteral), | 2696 : Expression(position, kFunctionLiteral), |
| 2632 dont_optimize_reason_(kNoReason), | 2697 dont_optimize_reason_(kNoReason), |
| 2698 should_be_used_once_hint_(false), | |
| 2633 materialized_literal_count_(materialized_literal_count), | 2699 materialized_literal_count_(materialized_literal_count), |
| 2634 expected_property_count_(expected_property_count), | 2700 expected_property_count_(expected_property_count), |
| 2635 parameter_count_(parameter_count), | 2701 parameter_count_(parameter_count), |
| 2636 function_token_position_(kNoSourcePosition), | 2702 function_token_position_(kNoSourcePosition), |
| 2637 yield_count_(0), | 2703 yield_count_(0), |
| 2638 raw_name_(name), | 2704 raw_name_(name), |
| 2639 scope_(scope), | 2705 scope_(scope), |
| 2640 body_(body), | 2706 body_(body), |
| 2641 raw_inferred_name_(ast_value_factory->empty_string()), | 2707 raw_inferred_name_(ast_value_factory->empty_string()), |
| 2642 ast_properties_(zone) { | 2708 ast_properties_(zone) { |
| 2643 bitfield_ = | 2709 bit_field_ |= |
| 2644 FunctionTypeBits::encode(function_type) | Pretenure::encode(false) | | 2710 FunctionTypeBits::encode(function_type) | Pretenure::encode(false) | |
| 2645 HasDuplicateParameters::encode(has_duplicate_parameters == | 2711 HasDuplicateParameters::encode(has_duplicate_parameters == |
| 2646 kHasDuplicateParameters) | | 2712 kHasDuplicateParameters) | |
| 2647 IsFunction::encode(is_function) | | 2713 IsFunction::encode(is_function) | |
| 2648 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) | | 2714 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) | |
| 2649 FunctionKindBits::encode(kind) | ShouldBeUsedOnceHint::encode(false); | 2715 FunctionKindBits::encode(kind); |
| 2650 DCHECK(IsValidFunctionKind(kind)); | 2716 DCHECK(IsValidFunctionKind(kind)); |
| 2651 } | 2717 } |
| 2652 | 2718 |
| 2653 class FunctionTypeBits : public BitField16<FunctionType, 0, 2> {}; | 2719 class FunctionTypeBits |
| 2654 class Pretenure : public BitField16<bool, 2, 1> {}; | 2720 : public BitField<FunctionType, Expression::kNextBitFieldIndex, 2> {}; |
| 2655 class HasDuplicateParameters : public BitField16<bool, 3, 1> {}; | 2721 class Pretenure : public BitField<bool, FunctionTypeBits::kNext, 1> {}; |
| 2656 class IsFunction : public BitField16<bool, 4, 1> {}; | 2722 class HasDuplicateParameters : public BitField<bool, Pretenure::kNext, 1> {}; |
| 2657 class ShouldEagerCompile : public BitField16<bool, 5, 1> {}; | 2723 class IsFunction : public BitField<bool, HasDuplicateParameters::kNext, 1> {}; |
| 2658 class ShouldBeUsedOnceHint : public BitField16<bool, 6, 1> {}; | 2724 class ShouldEagerCompile : public BitField<bool, IsFunction::kNext, 1> {}; |
| 2659 class FunctionKindBits : public BitField16<FunctionKind, 7, 9> {}; | 2725 class FunctionKindBits |
| 2660 | 2726 : public BitField<FunctionKind, ShouldEagerCompile::kNext, 9> {}; |
| 2661 // Start with 16-bit field, which should get packed together | |
| 2662 // with Expression's trailing 16-bit field. | |
| 2663 uint16_t bitfield_; | |
| 2664 | 2727 |
| 2665 BailoutReason dont_optimize_reason_; | 2728 BailoutReason dont_optimize_reason_; |
| 2729 bool should_be_used_once_hint_ : 1; | |
| 2666 | 2730 |
| 2667 int materialized_literal_count_; | 2731 int materialized_literal_count_; |
| 2668 int expected_property_count_; | 2732 int expected_property_count_; |
| 2669 int parameter_count_; | 2733 int parameter_count_; |
| 2670 int function_token_position_; | 2734 int function_token_position_; |
| 2671 int yield_count_; | 2735 int yield_count_; |
| 2672 | 2736 |
| 2673 const AstString* raw_name_; | 2737 const AstString* raw_name_; |
| 2674 DeclarationScope* scope_; | 2738 DeclarationScope* scope_; |
| 2675 ZoneList<Statement*>* body_; | 2739 ZoneList<Statement*>* body_; |
| (...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3464 : NULL; \ | 3528 : NULL; \ |
| 3465 } | 3529 } |
| 3466 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3530 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
| 3467 #undef DECLARE_NODE_FUNCTIONS | 3531 #undef DECLARE_NODE_FUNCTIONS |
| 3468 | 3532 |
| 3469 | 3533 |
| 3470 } // namespace internal | 3534 } // namespace internal |
| 3471 } // namespace v8 | 3535 } // namespace v8 |
| 3472 | 3536 |
| 3473 #endif // V8_AST_AST_H_ | 3537 #endif // V8_AST_AST_H_ |
| OLD | NEW |