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

Side by Side Diff: src/ast.h

Issue 24076007: Unify handling of position info in AST, part 1 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/ast.cc » ('j') | src/parser.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 enum NodeType { 199 enum NodeType {
200 AST_NODE_LIST(DECLARE_TYPE_ENUM) 200 AST_NODE_LIST(DECLARE_TYPE_ENUM)
201 kInvalid = -1 201 kInvalid = -1
202 }; 202 };
203 #undef DECLARE_TYPE_ENUM 203 #undef DECLARE_TYPE_ENUM
204 204
205 void* operator new(size_t size, Zone* zone) { 205 void* operator new(size_t size, Zone* zone) {
206 return zone->New(static_cast<int>(size)); 206 return zone->New(static_cast<int>(size));
207 } 207 }
208 208
209 AstNode() {} 209 explicit AstNode(int position): position_(position) {}
210
211 virtual ~AstNode() {} 210 virtual ~AstNode() {}
212 211
213 virtual void Accept(AstVisitor* v) = 0; 212 virtual void Accept(AstVisitor* v) = 0;
214 virtual NodeType node_type() const = 0; 213 virtual NodeType node_type() const = 0;
214 int position() const { return position_; }
215 215
216 // Type testing & conversion functions overridden by concrete subclasses. 216 // Type testing & conversion functions overridden by concrete subclasses.
217 #define DECLARE_NODE_FUNCTIONS(type) \ 217 #define DECLARE_NODE_FUNCTIONS(type) \
218 bool Is##type() { return node_type() == AstNode::k##type; } \ 218 bool Is##type() { return node_type() == AstNode::k##type; } \
219 type* As##type() { return Is##type() ? reinterpret_cast<type*>(this) : NULL; } 219 type* As##type() { return Is##type() ? reinterpret_cast<type*>(this) : NULL; }
220 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 220 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
221 #undef DECLARE_NODE_FUNCTIONS 221 #undef DECLARE_NODE_FUNCTIONS
222 222
223 virtual TargetCollector* AsTargetCollector() { return NULL; } 223 virtual TargetCollector* AsTargetCollector() { return NULL; }
224 virtual BreakableStatement* AsBreakableStatement() { return NULL; } 224 virtual BreakableStatement* AsBreakableStatement() { return NULL; }
(...skipping 16 matching lines...) Expand all
241 return TypeFeedbackId(id.ToInt()); 241 return TypeFeedbackId(id.ToInt());
242 } 242 }
243 243
244 244
245 private: 245 private:
246 // Hidden to prevent accidental usage. It would have to load the 246 // Hidden to prevent accidental usage. It would have to load the
247 // current zone from the TLS. 247 // current zone from the TLS.
248 void* operator new(size_t size); 248 void* operator new(size_t size);
249 249
250 friend class CaseClause; // Generates AST IDs. 250 friend class CaseClause; // Generates AST IDs.
251
252 int position_;
251 }; 253 };
252 254
253 255
254 class Statement : public AstNode { 256 class Statement : public AstNode {
255 public: 257 public:
256 Statement() : statement_pos_(RelocInfo::kNoPosition) {} 258 // TODO(rossberg)
259 explicit Statement(int position) : AstNode(position) {}
257 260
258 bool IsEmpty() { return AsEmptyStatement() != NULL; } 261 bool IsEmpty() { return AsEmptyStatement() != NULL; }
259 virtual bool IsJump() const { return false; } 262 virtual bool IsJump() const { return false; }
260
261 void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; }
262 int statement_pos() const { return statement_pos_; }
263
264 private:
265 int statement_pos_;
266 }; 263 };
267 264
268 265
269 class SmallMapList V8_FINAL { 266 class SmallMapList V8_FINAL {
270 public: 267 public:
271 SmallMapList() {} 268 SmallMapList() {}
272 SmallMapList(int capacity, Zone* zone) : list_(capacity, zone) {} 269 SmallMapList(int capacity, Zone* zone) : list_(capacity, zone) {}
273 270
274 void Reserve(int capacity, Zone* zone) { list_.Reserve(capacity, zone); } 271 void Reserve(int capacity, Zone* zone) { list_.Reserve(capacity, zone); }
275 void Clear() { list_.Clear(); } 272 void Clear() { list_.Clear(); }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // code generation. 319 // code generation.
323 kUninitialized, 320 kUninitialized,
324 // Evaluated for its side effects. 321 // Evaluated for its side effects.
325 kEffect, 322 kEffect,
326 // Evaluated for its value (and side effects). 323 // Evaluated for its value (and side effects).
327 kValue, 324 kValue,
328 // Evaluated for control flow (and side effects). 325 // Evaluated for control flow (and side effects).
329 kTest 326 kTest
330 }; 327 };
331 328
332 virtual int position() const {
333 UNREACHABLE();
334 return 0;
335 }
336
337 virtual bool IsValidLeftHandSide() { return false; } 329 virtual bool IsValidLeftHandSide() { return false; }
338 330
339 // Helpers for ToBoolean conversion. 331 // Helpers for ToBoolean conversion.
340 virtual bool ToBooleanIsTrue() { return false; } 332 virtual bool ToBooleanIsTrue() { return false; }
341 virtual bool ToBooleanIsFalse() { return false; } 333 virtual bool ToBooleanIsFalse() { return false; }
342 334
343 // Symbols that cannot be parsed as array indices are considered property 335 // Symbols that cannot be parsed as array indices are considered property
344 // names. We do not treat symbols that can be array indexes as property 336 // names. We do not treat symbols that can be array indexes as property
345 // names because [] for string objects is handled only by keyed ICs. 337 // names because [] for string objects is handled only by keyed ICs.
346 virtual bool IsPropertyName() { return false; } 338 virtual bool IsPropertyName() { return false; }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 } 372 }
381 373
382 // TODO(rossberg): this should move to its own AST node eventually. 374 // TODO(rossberg): this should move to its own AST node eventually.
383 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); 375 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle);
384 byte to_boolean_types() const { return to_boolean_types_; } 376 byte to_boolean_types() const { return to_boolean_types_; }
385 377
386 BailoutId id() const { return id_; } 378 BailoutId id() const { return id_; }
387 TypeFeedbackId test_id() const { return test_id_; } 379 TypeFeedbackId test_id() const { return test_id_; }
388 380
389 protected: 381 protected:
390 explicit Expression(Isolate* isolate) 382 Expression(Isolate* isolate, int pos)
391 : bounds_(Bounds::Unbounded(isolate)), 383 : AstNode(pos),
384 bounds_(Bounds::Unbounded(isolate)),
392 id_(GetNextId(isolate)), 385 id_(GetNextId(isolate)),
393 test_id_(GetNextId(isolate)) {} 386 test_id_(GetNextId(isolate)) {}
394 void set_to_boolean_types(byte types) { to_boolean_types_ = types; } 387 void set_to_boolean_types(byte types) { to_boolean_types_ = types; }
395 388
396 private: 389 private:
397 Bounds bounds_; 390 Bounds bounds_;
398 byte to_boolean_types_; 391 byte to_boolean_types_;
399 392
400 const BailoutId id_; 393 const BailoutId id_;
401 const TypeFeedbackId test_id_; 394 const TypeFeedbackId test_id_;
(...skipping 22 matching lines...) Expand all
424 // Testers. 417 // Testers.
425 bool is_target_for_anonymous() const { 418 bool is_target_for_anonymous() const {
426 return breakable_type_ == TARGET_FOR_ANONYMOUS; 419 return breakable_type_ == TARGET_FOR_ANONYMOUS;
427 } 420 }
428 421
429 BailoutId EntryId() const { return entry_id_; } 422 BailoutId EntryId() const { return entry_id_; }
430 BailoutId ExitId() const { return exit_id_; } 423 BailoutId ExitId() const { return exit_id_; }
431 424
432 protected: 425 protected:
433 BreakableStatement( 426 BreakableStatement(
434 Isolate* isolate, ZoneStringList* labels, BreakableType breakable_type) 427 Isolate* isolate, ZoneStringList* labels,
435 : labels_(labels), 428 BreakableType breakable_type, int position)
429 : Statement(position),
430 labels_(labels),
436 breakable_type_(breakable_type), 431 breakable_type_(breakable_type),
437 entry_id_(GetNextId(isolate)), 432 entry_id_(GetNextId(isolate)),
438 exit_id_(GetNextId(isolate)) { 433 exit_id_(GetNextId(isolate)) {
439 ASSERT(labels == NULL || labels->length() > 0); 434 ASSERT(labels == NULL || labels->length() > 0);
440 } 435 }
441 436
442 437
443 private: 438 private:
444 ZoneStringList* labels_; 439 ZoneStringList* labels_;
445 BreakableType breakable_type_; 440 BreakableType breakable_type_;
(...skipping 20 matching lines...) Expand all
466 } 461 }
467 462
468 Scope* scope() const { return scope_; } 463 Scope* scope() const { return scope_; }
469 void set_scope(Scope* scope) { scope_ = scope; } 464 void set_scope(Scope* scope) { scope_ = scope; }
470 465
471 protected: 466 protected:
472 Block(Isolate* isolate, 467 Block(Isolate* isolate,
473 ZoneStringList* labels, 468 ZoneStringList* labels,
474 int capacity, 469 int capacity,
475 bool is_initializer_block, 470 bool is_initializer_block,
471 int pos,
476 Zone* zone) 472 Zone* zone)
477 : BreakableStatement(isolate, labels, TARGET_FOR_NAMED_ONLY), 473 : BreakableStatement(isolate, labels, TARGET_FOR_NAMED_ONLY, pos),
478 statements_(capacity, zone), 474 statements_(capacity, zone),
479 is_initializer_block_(is_initializer_block), 475 is_initializer_block_(is_initializer_block),
480 scope_(NULL) { 476 scope_(NULL) {
481 } 477 }
482 478
483 private: 479 private:
484 ZoneList<Statement*> statements_; 480 ZoneList<Statement*> statements_;
485 bool is_initializer_block_; 481 bool is_initializer_block_;
486 Scope* scope_; 482 Scope* scope_;
487 }; 483 };
488 484
489 485
490 class Declaration : public AstNode { 486 class Declaration : public AstNode {
491 public: 487 public:
492 VariableProxy* proxy() const { return proxy_; } 488 VariableProxy* proxy() const { return proxy_; }
493 VariableMode mode() const { return mode_; } 489 VariableMode mode() const { return mode_; }
494 Scope* scope() const { return scope_; } 490 Scope* scope() const { return scope_; }
495 virtual InitializationFlag initialization() const = 0; 491 virtual InitializationFlag initialization() const = 0;
496 virtual bool IsInlineable() const; 492 virtual bool IsInlineable() const;
497 493
498 protected: 494 protected:
499 Declaration(VariableProxy* proxy, 495 Declaration(VariableProxy* proxy,
500 VariableMode mode, 496 VariableMode mode,
501 Scope* scope) 497 Scope* scope,
502 : proxy_(proxy), 498 int pos)
499 : AstNode(pos),
500 proxy_(proxy),
503 mode_(mode), 501 mode_(mode),
504 scope_(scope) { 502 scope_(scope) {
505 ASSERT(IsDeclaredVariableMode(mode)); 503 ASSERT(IsDeclaredVariableMode(mode));
506 } 504 }
507 505
508 private: 506 private:
509 VariableProxy* proxy_; 507 VariableProxy* proxy_;
510 VariableMode mode_; 508 VariableMode mode_;
511 509
512 // Nested scope from which the declaration originated. 510 // Nested scope from which the declaration originated.
513 Scope* scope_; 511 Scope* scope_;
514 }; 512 };
515 513
516 514
517 class VariableDeclaration V8_FINAL : public Declaration { 515 class VariableDeclaration V8_FINAL : public Declaration {
518 public: 516 public:
519 DECLARE_NODE_TYPE(VariableDeclaration) 517 DECLARE_NODE_TYPE(VariableDeclaration)
520 518
521 virtual InitializationFlag initialization() const V8_OVERRIDE { 519 virtual InitializationFlag initialization() const V8_OVERRIDE {
522 return mode() == VAR ? kCreatedInitialized : kNeedsInitialization; 520 return mode() == VAR ? kCreatedInitialized : kNeedsInitialization;
523 } 521 }
524 522
525 protected: 523 protected:
526 VariableDeclaration(VariableProxy* proxy, 524 VariableDeclaration(VariableProxy* proxy,
527 VariableMode mode, 525 VariableMode mode,
528 Scope* scope) 526 Scope* scope,
529 : Declaration(proxy, mode, scope) { 527 int pos)
528 : Declaration(proxy, mode, scope, pos) {
530 } 529 }
531 }; 530 };
532 531
533 532
534 class FunctionDeclaration V8_FINAL : public Declaration { 533 class FunctionDeclaration V8_FINAL : public Declaration {
535 public: 534 public:
536 DECLARE_NODE_TYPE(FunctionDeclaration) 535 DECLARE_NODE_TYPE(FunctionDeclaration)
537 536
538 FunctionLiteral* fun() const { return fun_; } 537 FunctionLiteral* fun() const { return fun_; }
539 virtual InitializationFlag initialization() const V8_OVERRIDE { 538 virtual InitializationFlag initialization() const V8_OVERRIDE {
540 return kCreatedInitialized; 539 return kCreatedInitialized;
541 } 540 }
542 virtual bool IsInlineable() const V8_OVERRIDE; 541 virtual bool IsInlineable() const V8_OVERRIDE;
543 542
544 protected: 543 protected:
545 FunctionDeclaration(VariableProxy* proxy, 544 FunctionDeclaration(VariableProxy* proxy,
546 VariableMode mode, 545 VariableMode mode,
547 FunctionLiteral* fun, 546 FunctionLiteral* fun,
548 Scope* scope) 547 Scope* scope,
549 : Declaration(proxy, mode, scope), 548 int pos)
549 : Declaration(proxy, mode, scope, pos),
550 fun_(fun) { 550 fun_(fun) {
551 // At the moment there are no "const functions" in JavaScript... 551 // At the moment there are no "const functions" in JavaScript...
552 ASSERT(mode == VAR || mode == LET); 552 ASSERT(mode == VAR || mode == LET);
553 ASSERT(fun != NULL); 553 ASSERT(fun != NULL);
554 } 554 }
555 555
556 private: 556 private:
557 FunctionLiteral* fun_; 557 FunctionLiteral* fun_;
558 }; 558 };
559 559
560 560
561 class ModuleDeclaration V8_FINAL : public Declaration { 561 class ModuleDeclaration V8_FINAL : public Declaration {
562 public: 562 public:
563 DECLARE_NODE_TYPE(ModuleDeclaration) 563 DECLARE_NODE_TYPE(ModuleDeclaration)
564 564
565 Module* module() const { return module_; } 565 Module* module() const { return module_; }
566 virtual InitializationFlag initialization() const V8_OVERRIDE { 566 virtual InitializationFlag initialization() const V8_OVERRIDE {
567 return kCreatedInitialized; 567 return kCreatedInitialized;
568 } 568 }
569 569
570 protected: 570 protected:
571 ModuleDeclaration(VariableProxy* proxy, 571 ModuleDeclaration(VariableProxy* proxy,
572 Module* module, 572 Module* module,
573 Scope* scope) 573 Scope* scope,
574 : Declaration(proxy, MODULE, scope), 574 int pos)
575 : Declaration(proxy, MODULE, scope, pos),
575 module_(module) { 576 module_(module) {
576 } 577 }
577 578
578 private: 579 private:
579 Module* module_; 580 Module* module_;
580 }; 581 };
581 582
582 583
583 class ImportDeclaration V8_FINAL : public Declaration { 584 class ImportDeclaration V8_FINAL : public Declaration {
584 public: 585 public:
585 DECLARE_NODE_TYPE(ImportDeclaration) 586 DECLARE_NODE_TYPE(ImportDeclaration)
586 587
587 Module* module() const { return module_; } 588 Module* module() const { return module_; }
588 virtual InitializationFlag initialization() const V8_OVERRIDE { 589 virtual InitializationFlag initialization() const V8_OVERRIDE {
589 return kCreatedInitialized; 590 return kCreatedInitialized;
590 } 591 }
591 592
592 protected: 593 protected:
593 ImportDeclaration(VariableProxy* proxy, 594 ImportDeclaration(VariableProxy* proxy,
594 Module* module, 595 Module* module,
595 Scope* scope) 596 Scope* scope,
596 : Declaration(proxy, LET, scope), 597 int pos)
598 : Declaration(proxy, LET, scope, pos),
597 module_(module) { 599 module_(module) {
598 } 600 }
599 601
600 private: 602 private:
601 Module* module_; 603 Module* module_;
602 }; 604 };
603 605
604 606
605 class ExportDeclaration V8_FINAL : public Declaration { 607 class ExportDeclaration V8_FINAL : public Declaration {
606 public: 608 public:
607 DECLARE_NODE_TYPE(ExportDeclaration) 609 DECLARE_NODE_TYPE(ExportDeclaration)
608 610
609 virtual InitializationFlag initialization() const V8_OVERRIDE { 611 virtual InitializationFlag initialization() const V8_OVERRIDE {
610 return kCreatedInitialized; 612 return kCreatedInitialized;
611 } 613 }
612 614
613 protected: 615 protected:
614 ExportDeclaration(VariableProxy* proxy, Scope* scope) 616 ExportDeclaration(VariableProxy* proxy, Scope* scope, int pos)
615 : Declaration(proxy, LET, scope) {} 617 : Declaration(proxy, LET, scope, pos) {}
616 }; 618 };
617 619
618 620
619 class Module : public AstNode { 621 class Module : public AstNode {
620 public: 622 public:
621 Interface* interface() const { return interface_; } 623 Interface* interface() const { return interface_; }
622 Block* body() const { return body_; } 624 Block* body() const { return body_; }
623 625
624 protected: 626 protected:
625 explicit Module(Zone* zone) 627 Module(Zone* zone, int pos)
626 : interface_(Interface::NewModule(zone)), 628 : AstNode(pos),
629 interface_(Interface::NewModule(zone)),
627 body_(NULL) {} 630 body_(NULL) {}
628 explicit Module(Interface* interface, Block* body = NULL) 631 Module(Interface* interface, int pos, Block* body = NULL)
629 : interface_(interface), 632 : AstNode(pos),
633 interface_(interface),
630 body_(body) {} 634 body_(body) {}
631 635
632 private: 636 private:
633 Interface* interface_; 637 Interface* interface_;
634 Block* body_; 638 Block* body_;
635 }; 639 };
636 640
637 641
638 class ModuleLiteral V8_FINAL : public Module { 642 class ModuleLiteral V8_FINAL : public Module {
639 public: 643 public:
640 DECLARE_NODE_TYPE(ModuleLiteral) 644 DECLARE_NODE_TYPE(ModuleLiteral)
641 645
642 protected: 646 protected:
643 ModuleLiteral(Block* body, Interface* interface) : Module(interface, body) {} 647 ModuleLiteral(Block* body, Interface* interface, int pos)
648 : Module(interface, pos, body) {}
644 }; 649 };
645 650
646 651
647 class ModuleVariable V8_FINAL : public Module { 652 class ModuleVariable V8_FINAL : public Module {
648 public: 653 public:
649 DECLARE_NODE_TYPE(ModuleVariable) 654 DECLARE_NODE_TYPE(ModuleVariable)
650 655
651 VariableProxy* proxy() const { return proxy_; } 656 VariableProxy* proxy() const { return proxy_; }
652 657
653 protected: 658 protected:
654 inline explicit ModuleVariable(VariableProxy* proxy); 659 inline ModuleVariable(VariableProxy* proxy, int pos);
655 660
656 private: 661 private:
657 VariableProxy* proxy_; 662 VariableProxy* proxy_;
658 }; 663 };
659 664
660 665
661 class ModulePath V8_FINAL : public Module { 666 class ModulePath V8_FINAL : public Module {
662 public: 667 public:
663 DECLARE_NODE_TYPE(ModulePath) 668 DECLARE_NODE_TYPE(ModulePath)
664 669
665 Module* module() const { return module_; } 670 Module* module() const { return module_; }
666 Handle<String> name() const { return name_; } 671 Handle<String> name() const { return name_; }
667 672
668 protected: 673 protected:
669 ModulePath(Module* module, Handle<String> name, Zone* zone) 674 ModulePath(Module* module, Handle<String> name, Zone* zone, int pos)
670 : Module(zone), 675 : Module(zone, pos),
671 module_(module), 676 module_(module),
672 name_(name) { 677 name_(name) {
673 } 678 }
674 679
675 private: 680 private:
676 Module* module_; 681 Module* module_;
677 Handle<String> name_; 682 Handle<String> name_;
678 }; 683 };
679 684
680 685
681 class ModuleUrl V8_FINAL : public Module { 686 class ModuleUrl V8_FINAL : public Module {
682 public: 687 public:
683 DECLARE_NODE_TYPE(ModuleUrl) 688 DECLARE_NODE_TYPE(ModuleUrl)
684 689
685 Handle<String> url() const { return url_; } 690 Handle<String> url() const { return url_; }
686 691
687 protected: 692 protected:
688 ModuleUrl(Handle<String> url, Zone* zone) 693 ModuleUrl(Handle<String> url, Zone* zone, int pos)
689 : Module(zone), url_(url) { 694 : Module(zone, pos), url_(url) {
690 } 695 }
691 696
692 private: 697 private:
693 Handle<String> url_; 698 Handle<String> url_;
694 }; 699 };
695 700
696 701
697 class ModuleStatement V8_FINAL : public Statement { 702 class ModuleStatement V8_FINAL : public Statement {
698 public: 703 public:
699 DECLARE_NODE_TYPE(ModuleStatement) 704 DECLARE_NODE_TYPE(ModuleStatement)
700 705
701 VariableProxy* proxy() const { return proxy_; } 706 VariableProxy* proxy() const { return proxy_; }
702 Block* body() const { return body_; } 707 Block* body() const { return body_; }
703 708
704 protected: 709 protected:
705 ModuleStatement(VariableProxy* proxy, Block* body) 710 ModuleStatement(VariableProxy* proxy, Block* body, int pos)
706 : proxy_(proxy), 711 : Statement(pos),
712 proxy_(proxy),
707 body_(body) { 713 body_(body) {
708 } 714 }
709 715
710 private: 716 private:
711 VariableProxy* proxy_; 717 VariableProxy* proxy_;
712 Block* body_; 718 Block* body_;
713 }; 719 };
714 720
715 721
716 class IterationStatement : public BreakableStatement { 722 class IterationStatement : public BreakableStatement {
717 public: 723 public:
718 // Type testing & conversion. 724 // Type testing & conversion.
719 virtual IterationStatement* AsIterationStatement() V8_FINAL V8_OVERRIDE { 725 virtual IterationStatement* AsIterationStatement() V8_FINAL V8_OVERRIDE {
720 return this; 726 return this;
721 } 727 }
722 728
723 Statement* body() const { return body_; } 729 Statement* body() const { return body_; }
724 730
725 BailoutId OsrEntryId() const { return osr_entry_id_; } 731 BailoutId OsrEntryId() const { return osr_entry_id_; }
726 virtual BailoutId ContinueId() const = 0; 732 virtual BailoutId ContinueId() const = 0;
727 virtual BailoutId StackCheckId() const = 0; 733 virtual BailoutId StackCheckId() const = 0;
728 734
729 // Code generation 735 // Code generation
730 Label* continue_target() { return &continue_target_; } 736 Label* continue_target() { return &continue_target_; }
731 737
732 protected: 738 protected:
733 IterationStatement(Isolate* isolate, ZoneStringList* labels) 739 IterationStatement(Isolate* isolate, ZoneStringList* labels, int pos)
734 : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS), 740 : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS, pos),
735 body_(NULL), 741 body_(NULL),
736 osr_entry_id_(GetNextId(isolate)) { 742 osr_entry_id_(GetNextId(isolate)) {
737 } 743 }
738 744
739 void Initialize(Statement* body) { 745 void Initialize(Statement* body) {
740 body_ = body; 746 body_ = body;
741 } 747 }
742 748
743 private: 749 private:
744 Statement* body_; 750 Statement* body_;
745 Label continue_target_; 751 Label continue_target_;
746 752
747 const BailoutId osr_entry_id_; 753 const BailoutId osr_entry_id_;
748 }; 754 };
749 755
750 756
751 class DoWhileStatement V8_FINAL : public IterationStatement { 757 class DoWhileStatement V8_FINAL : public IterationStatement {
752 public: 758 public:
753 DECLARE_NODE_TYPE(DoWhileStatement) 759 DECLARE_NODE_TYPE(DoWhileStatement)
754 760
755 void Initialize(Expression* cond, Statement* body) { 761 void Initialize(Expression* cond, Statement* body) {
756 IterationStatement::Initialize(body); 762 IterationStatement::Initialize(body);
757 cond_ = cond; 763 cond_ = cond;
758 } 764 }
759 765
760 Expression* cond() const { return cond_; } 766 Expression* cond() const { return cond_; }
761 767
768 // TODO(rossberg): get rid of this.
762 // Position where condition expression starts. We need it to make 769 // Position where condition expression starts. We need it to make
763 // the loop's condition a breakable location. 770 // the loop's condition a breakable location.
764 int condition_position() { return condition_position_; } 771 int condition_position() { return condition_position_; }
765 void set_condition_position(int pos) { condition_position_ = pos; } 772 void set_condition_position(int pos) { condition_position_ = pos; }
766 773
767 virtual BailoutId ContinueId() const V8_OVERRIDE { return continue_id_; } 774 virtual BailoutId ContinueId() const V8_OVERRIDE { return continue_id_; }
768 virtual BailoutId StackCheckId() const V8_OVERRIDE { return back_edge_id_; } 775 virtual BailoutId StackCheckId() const V8_OVERRIDE { return back_edge_id_; }
769 BailoutId BackEdgeId() const { return back_edge_id_; } 776 BailoutId BackEdgeId() const { return back_edge_id_; }
770 777
771 protected: 778 protected:
772 DoWhileStatement(Isolate* isolate, ZoneStringList* labels) 779 DoWhileStatement(Isolate* isolate, ZoneStringList* labels, int pos)
773 : IterationStatement(isolate, labels), 780 : IterationStatement(isolate, labels, pos),
774 cond_(NULL), 781 cond_(NULL),
775 condition_position_(-1), 782 condition_position_(-1),
776 continue_id_(GetNextId(isolate)), 783 continue_id_(GetNextId(isolate)),
777 back_edge_id_(GetNextId(isolate)) { 784 back_edge_id_(GetNextId(isolate)) {
778 } 785 }
779 786
780 private: 787 private:
781 Expression* cond_; 788 Expression* cond_;
782 789
783 int condition_position_; 790 int condition_position_;
(...skipping 18 matching lines...) Expand all
802 } 809 }
803 void set_may_have_function_literal(bool value) { 810 void set_may_have_function_literal(bool value) {
804 may_have_function_literal_ = value; 811 may_have_function_literal_ = value;
805 } 812 }
806 813
807 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); } 814 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); }
808 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } 815 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; }
809 BailoutId BodyId() const { return body_id_; } 816 BailoutId BodyId() const { return body_id_; }
810 817
811 protected: 818 protected:
812 WhileStatement(Isolate* isolate, ZoneStringList* labels) 819 WhileStatement(Isolate* isolate, ZoneStringList* labels, int pos)
813 : IterationStatement(isolate, labels), 820 : IterationStatement(isolate, labels, pos),
814 cond_(NULL), 821 cond_(NULL),
815 may_have_function_literal_(true), 822 may_have_function_literal_(true),
816 body_id_(GetNextId(isolate)) { 823 body_id_(GetNextId(isolate)) {
817 } 824 }
818 825
819 private: 826 private:
820 Expression* cond_; 827 Expression* cond_;
821 828
822 // True if there is a function literal subexpression in the condition. 829 // True if there is a function literal subexpression in the condition.
823 bool may_have_function_literal_; 830 bool may_have_function_literal_;
(...skipping 29 matching lines...) Expand all
853 860
854 virtual BailoutId ContinueId() const V8_OVERRIDE { return continue_id_; } 861 virtual BailoutId ContinueId() const V8_OVERRIDE { return continue_id_; }
855 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } 862 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; }
856 BailoutId BodyId() const { return body_id_; } 863 BailoutId BodyId() const { return body_id_; }
857 864
858 bool is_fast_smi_loop() { return loop_variable_ != NULL; } 865 bool is_fast_smi_loop() { return loop_variable_ != NULL; }
859 Variable* loop_variable() { return loop_variable_; } 866 Variable* loop_variable() { return loop_variable_; }
860 void set_loop_variable(Variable* var) { loop_variable_ = var; } 867 void set_loop_variable(Variable* var) { loop_variable_ = var; }
861 868
862 protected: 869 protected:
863 ForStatement(Isolate* isolate, ZoneStringList* labels) 870 ForStatement(Isolate* isolate, ZoneStringList* labels, int pos)
864 : IterationStatement(isolate, labels), 871 : IterationStatement(isolate, labels, pos),
865 init_(NULL), 872 init_(NULL),
866 cond_(NULL), 873 cond_(NULL),
867 next_(NULL), 874 next_(NULL),
868 may_have_function_literal_(true), 875 may_have_function_literal_(true),
869 loop_variable_(NULL), 876 loop_variable_(NULL),
870 continue_id_(GetNextId(isolate)), 877 continue_id_(GetNextId(isolate)),
871 body_id_(GetNextId(isolate)) { 878 body_id_(GetNextId(isolate)) {
872 } 879 }
873 880
874 private: 881 private:
(...skipping 20 matching lines...) Expand all
895 void Initialize(Expression* each, Expression* subject, Statement* body) { 902 void Initialize(Expression* each, Expression* subject, Statement* body) {
896 IterationStatement::Initialize(body); 903 IterationStatement::Initialize(body);
897 each_ = each; 904 each_ = each;
898 subject_ = subject; 905 subject_ = subject;
899 } 906 }
900 907
901 Expression* each() const { return each_; } 908 Expression* each() const { return each_; }
902 Expression* subject() const { return subject_; } 909 Expression* subject() const { return subject_; }
903 910
904 protected: 911 protected:
905 ForEachStatement(Isolate* isolate, ZoneStringList* labels) 912 ForEachStatement(Isolate* isolate, ZoneStringList* labels, int pos)
906 : IterationStatement(isolate, labels), 913 : IterationStatement(isolate, labels, pos),
907 each_(NULL), 914 each_(NULL),
908 subject_(NULL) { 915 subject_(NULL) {
909 } 916 }
910 917
911 private: 918 private:
912 Expression* each_; 919 Expression* each_;
913 Expression* subject_; 920 Expression* subject_;
914 }; 921 };
915 922
916 923
917 class ForInStatement V8_FINAL : public ForEachStatement { 924 class ForInStatement V8_FINAL : public ForEachStatement {
918 public: 925 public:
919 DECLARE_NODE_TYPE(ForInStatement) 926 DECLARE_NODE_TYPE(ForInStatement)
920 927
921 Expression* enumerable() const { 928 Expression* enumerable() const {
922 return subject(); 929 return subject();
923 } 930 }
924 931
925 TypeFeedbackId ForInFeedbackId() const { return reuse(PrepareId()); } 932 TypeFeedbackId ForInFeedbackId() const { return reuse(PrepareId()); }
926 void RecordTypeFeedback(TypeFeedbackOracle* oracle); 933 void RecordTypeFeedback(TypeFeedbackOracle* oracle);
927 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; 934 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN };
928 ForInType for_in_type() const { return for_in_type_; } 935 ForInType for_in_type() const { return for_in_type_; }
929 936
930 BailoutId BodyId() const { return body_id_; } 937 BailoutId BodyId() const { return body_id_; }
931 BailoutId PrepareId() const { return prepare_id_; } 938 BailoutId PrepareId() const { return prepare_id_; }
932 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); } 939 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); }
933 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } 940 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; }
934 941
935 protected: 942 protected:
936 ForInStatement(Isolate* isolate, ZoneStringList* labels) 943 ForInStatement(Isolate* isolate, ZoneStringList* labels, int pos)
937 : ForEachStatement(isolate, labels), 944 : ForEachStatement(isolate, labels, pos),
938 for_in_type_(SLOW_FOR_IN), 945 for_in_type_(SLOW_FOR_IN),
939 body_id_(GetNextId(isolate)), 946 body_id_(GetNextId(isolate)),
940 prepare_id_(GetNextId(isolate)) { 947 prepare_id_(GetNextId(isolate)) {
941 } 948 }
942 949
943 ForInType for_in_type_; 950 ForInType for_in_type_;
944 const BailoutId body_id_; 951 const BailoutId body_id_;
945 const BailoutId prepare_id_; 952 const BailoutId prepare_id_;
946 }; 953 };
947 954
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 Expression* assign_each() const { 994 Expression* assign_each() const {
988 return assign_each_; 995 return assign_each_;
989 } 996 }
990 997
991 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); } 998 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); }
992 virtual BailoutId StackCheckId() const V8_OVERRIDE { return BackEdgeId(); } 999 virtual BailoutId StackCheckId() const V8_OVERRIDE { return BackEdgeId(); }
993 1000
994 BailoutId BackEdgeId() const { return back_edge_id_; } 1001 BailoutId BackEdgeId() const { return back_edge_id_; }
995 1002
996 protected: 1003 protected:
997 ForOfStatement(Isolate* isolate, ZoneStringList* labels) 1004 ForOfStatement(Isolate* isolate, ZoneStringList* labels, int pos)
998 : ForEachStatement(isolate, labels), 1005 : ForEachStatement(isolate, labels, pos),
999 assign_iterator_(NULL), 1006 assign_iterator_(NULL),
1000 next_result_(NULL), 1007 next_result_(NULL),
1001 result_done_(NULL), 1008 result_done_(NULL),
1002 assign_each_(NULL), 1009 assign_each_(NULL),
1003 back_edge_id_(GetNextId(isolate)) { 1010 back_edge_id_(GetNextId(isolate)) {
1004 } 1011 }
1005 1012
1006 Expression* assign_iterator_; 1013 Expression* assign_iterator_;
1007 Expression* next_result_; 1014 Expression* next_result_;
1008 Expression* result_done_; 1015 Expression* result_done_;
1009 Expression* assign_each_; 1016 Expression* assign_each_;
1010 const BailoutId back_edge_id_; 1017 const BailoutId back_edge_id_;
1011 }; 1018 };
1012 1019
1013 1020
1014 class ExpressionStatement V8_FINAL : public Statement { 1021 class ExpressionStatement V8_FINAL : public Statement {
1015 public: 1022 public:
1016 DECLARE_NODE_TYPE(ExpressionStatement) 1023 DECLARE_NODE_TYPE(ExpressionStatement)
1017 1024
1018 void set_expression(Expression* e) { expression_ = e; } 1025 void set_expression(Expression* e) { expression_ = e; }
1019 Expression* expression() const { return expression_; } 1026 Expression* expression() const { return expression_; }
1020 virtual bool IsJump() const V8_OVERRIDE { return expression_->IsThrow(); } 1027 virtual bool IsJump() const V8_OVERRIDE { return expression_->IsThrow(); }
1021 1028
1022 protected: 1029 protected:
1023 explicit ExpressionStatement(Expression* expression) 1030 ExpressionStatement(Expression* expression, int pos)
1024 : expression_(expression) { } 1031 : Statement(pos), expression_(expression) { }
1025 1032
1026 private: 1033 private:
1027 Expression* expression_; 1034 Expression* expression_;
1028 }; 1035 };
1029 1036
1030 1037
1031 class JumpStatement : public Statement { 1038 class JumpStatement : public Statement {
1032 public: 1039 public:
1033 virtual bool IsJump() const V8_FINAL V8_OVERRIDE { return true; } 1040 virtual bool IsJump() const V8_FINAL V8_OVERRIDE { return true; }
1034 1041
1035 protected: 1042 protected:
1036 JumpStatement() {} 1043 explicit JumpStatement(int pos) : Statement(pos) {}
1037 }; 1044 };
1038 1045
1039 1046
1040 class ContinueStatement V8_FINAL : public JumpStatement { 1047 class ContinueStatement V8_FINAL : public JumpStatement {
1041 public: 1048 public:
1042 DECLARE_NODE_TYPE(ContinueStatement) 1049 DECLARE_NODE_TYPE(ContinueStatement)
1043 1050
1044 IterationStatement* target() const { return target_; } 1051 IterationStatement* target() const { return target_; }
1045 1052
1046 protected: 1053 protected:
1047 explicit ContinueStatement(IterationStatement* target) 1054 explicit ContinueStatement(IterationStatement* target, int pos)
1048 : target_(target) { } 1055 : JumpStatement(pos), target_(target) { }
1049 1056
1050 private: 1057 private:
1051 IterationStatement* target_; 1058 IterationStatement* target_;
1052 }; 1059 };
1053 1060
1054 1061
1055 class BreakStatement V8_FINAL : public JumpStatement { 1062 class BreakStatement V8_FINAL : public JumpStatement {
1056 public: 1063 public:
1057 DECLARE_NODE_TYPE(BreakStatement) 1064 DECLARE_NODE_TYPE(BreakStatement)
1058 1065
1059 BreakableStatement* target() const { return target_; } 1066 BreakableStatement* target() const { return target_; }
1060 1067
1061 protected: 1068 protected:
1062 explicit BreakStatement(BreakableStatement* target) 1069 explicit BreakStatement(BreakableStatement* target, int pos)
1063 : target_(target) { } 1070 : JumpStatement(pos), target_(target) { }
1064 1071
1065 private: 1072 private:
1066 BreakableStatement* target_; 1073 BreakableStatement* target_;
1067 }; 1074 };
1068 1075
1069 1076
1070 class ReturnStatement V8_FINAL : public JumpStatement { 1077 class ReturnStatement V8_FINAL : public JumpStatement {
1071 public: 1078 public:
1072 DECLARE_NODE_TYPE(ReturnStatement) 1079 DECLARE_NODE_TYPE(ReturnStatement)
1073 1080
1074 Expression* expression() const { return expression_; } 1081 Expression* expression() const { return expression_; }
1075 1082
1076 protected: 1083 protected:
1077 explicit ReturnStatement(Expression* expression) 1084 explicit ReturnStatement(Expression* expression, int pos)
1078 : expression_(expression) { } 1085 : JumpStatement(pos), expression_(expression) { }
1079 1086
1080 private: 1087 private:
1081 Expression* expression_; 1088 Expression* expression_;
1082 }; 1089 };
1083 1090
1084 1091
1085 class WithStatement V8_FINAL : public Statement { 1092 class WithStatement V8_FINAL : public Statement {
1086 public: 1093 public:
1087 DECLARE_NODE_TYPE(WithStatement) 1094 DECLARE_NODE_TYPE(WithStatement)
1088 1095
1089 Scope* scope() { return scope_; } 1096 Scope* scope() { return scope_; }
1090 Expression* expression() const { return expression_; } 1097 Expression* expression() const { return expression_; }
1091 Statement* statement() const { return statement_; } 1098 Statement* statement() const { return statement_; }
1092 1099
1093 protected: 1100 protected:
1094 WithStatement(Scope* scope, Expression* expression, Statement* statement) 1101 WithStatement(
1095 : scope_(scope), 1102 Scope* scope, Expression* expression, Statement* statement, int pos)
1103 : Statement(pos),
1104 scope_(scope),
1096 expression_(expression), 1105 expression_(expression),
1097 statement_(statement) { } 1106 statement_(statement) { }
1098 1107
1099 private: 1108 private:
1100 Scope* scope_; 1109 Scope* scope_;
1101 Expression* expression_; 1110 Expression* expression_;
1102 Statement* statement_; 1111 Statement* statement_;
1103 }; 1112 };
1104 1113
1105 1114
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 } 1160 }
1152 1161
1153 Expression* tag() const { return tag_; } 1162 Expression* tag() const { return tag_; }
1154 ZoneList<CaseClause*>* cases() const { return cases_; } 1163 ZoneList<CaseClause*>* cases() const { return cases_; }
1155 1164
1156 enum SwitchType { UNKNOWN_SWITCH, SMI_SWITCH, STRING_SWITCH, GENERIC_SWITCH }; 1165 enum SwitchType { UNKNOWN_SWITCH, SMI_SWITCH, STRING_SWITCH, GENERIC_SWITCH };
1157 SwitchType switch_type() const { return switch_type_; } 1166 SwitchType switch_type() const { return switch_type_; }
1158 void set_switch_type(SwitchType switch_type) { switch_type_ = switch_type; } 1167 void set_switch_type(SwitchType switch_type) { switch_type_ = switch_type; }
1159 1168
1160 protected: 1169 protected:
1161 SwitchStatement(Isolate* isolate, ZoneStringList* labels) 1170 SwitchStatement(Isolate* isolate, ZoneStringList* labels, int pos)
1162 : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS), 1171 : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS, pos),
1163 tag_(NULL), 1172 tag_(NULL),
1164 cases_(NULL) { } 1173 cases_(NULL) { }
1165 1174
1166 private: 1175 private:
1167 Expression* tag_; 1176 Expression* tag_;
1168 ZoneList<CaseClause*>* cases_; 1177 ZoneList<CaseClause*>* cases_;
1169 SwitchType switch_type_; 1178 SwitchType switch_type_;
1170 }; 1179 };
1171 1180
1172 1181
(...skipping 19 matching lines...) Expand all
1192 } 1201 }
1193 1202
1194 BailoutId IfId() const { return if_id_; } 1203 BailoutId IfId() const { return if_id_; }
1195 BailoutId ThenId() const { return then_id_; } 1204 BailoutId ThenId() const { return then_id_; }
1196 BailoutId ElseId() const { return else_id_; } 1205 BailoutId ElseId() const { return else_id_; }
1197 1206
1198 protected: 1207 protected:
1199 IfStatement(Isolate* isolate, 1208 IfStatement(Isolate* isolate,
1200 Expression* condition, 1209 Expression* condition,
1201 Statement* then_statement, 1210 Statement* then_statement,
1202 Statement* else_statement) 1211 Statement* else_statement,
1203 : condition_(condition), 1212 int pos)
1213 : Statement(pos),
1214 condition_(condition),
1204 then_statement_(then_statement), 1215 then_statement_(then_statement),
1205 else_statement_(else_statement), 1216 else_statement_(else_statement),
1206 if_id_(GetNextId(isolate)), 1217 if_id_(GetNextId(isolate)),
1207 then_id_(GetNextId(isolate)), 1218 then_id_(GetNextId(isolate)),
1208 else_id_(GetNextId(isolate)) { 1219 else_id_(GetNextId(isolate)) {
1209 } 1220 }
1210 1221
1211 private: 1222 private:
1212 Expression* condition_; 1223 Expression* condition_;
1213 Statement* then_statement_; 1224 Statement* then_statement_;
1214 Statement* else_statement_; 1225 Statement* else_statement_;
1215 const BailoutId if_id_; 1226 const BailoutId if_id_;
1216 const BailoutId then_id_; 1227 const BailoutId then_id_;
1217 const BailoutId else_id_; 1228 const BailoutId else_id_;
1218 }; 1229 };
1219 1230
1220 1231
1221 // NOTE: TargetCollectors are represented as nodes to fit in the target 1232 // NOTE: TargetCollectors are represented as nodes to fit in the target
1222 // stack in the compiler; this should probably be reworked. 1233 // stack in the compiler; this should probably be reworked.
1223 class TargetCollector V8_FINAL : public AstNode { 1234 class TargetCollector V8_FINAL : public AstNode {
1224 public: 1235 public:
1225 explicit TargetCollector(Zone* zone) : targets_(0, zone) { } 1236 explicit TargetCollector(Zone* zone)
1237 : AstNode(RelocInfo::kNoPosition), targets_(0, zone) { }
1226 1238
1227 // Adds a jump target to the collector. The collector stores a pointer not 1239 // Adds a jump target to the collector. The collector stores a pointer not
1228 // a copy of the target to make binding work, so make sure not to pass in 1240 // a copy of the target to make binding work, so make sure not to pass in
1229 // references to something on the stack. 1241 // references to something on the stack.
1230 void AddTarget(Label* target, Zone* zone); 1242 void AddTarget(Label* target, Zone* zone);
1231 1243
1232 // Virtual behaviour. TargetCollectors are never part of the AST. 1244 // Virtual behaviour. TargetCollectors are never part of the AST.
1233 virtual void Accept(AstVisitor* v) V8_OVERRIDE { UNREACHABLE(); } 1245 virtual void Accept(AstVisitor* v) V8_OVERRIDE { UNREACHABLE(); }
1234 virtual NodeType node_type() const V8_OVERRIDE { return kInvalid; } 1246 virtual NodeType node_type() const V8_OVERRIDE { return kInvalid; }
1235 virtual TargetCollector* AsTargetCollector() V8_OVERRIDE { return this; } 1247 virtual TargetCollector* AsTargetCollector() V8_OVERRIDE { return this; }
1236 1248
1237 ZoneList<Label*>* targets() { return &targets_; } 1249 ZoneList<Label*>* targets() { return &targets_; }
1238 1250
1239 private: 1251 private:
1240 ZoneList<Label*> targets_; 1252 ZoneList<Label*> targets_;
1241 }; 1253 };
1242 1254
1243 1255
1244 class TryStatement : public Statement { 1256 class TryStatement : public Statement {
1245 public: 1257 public:
1246 void set_escaping_targets(ZoneList<Label*>* targets) { 1258 void set_escaping_targets(ZoneList<Label*>* targets) {
1247 escaping_targets_ = targets; 1259 escaping_targets_ = targets;
1248 } 1260 }
1249 1261
1250 int index() const { return index_; } 1262 int index() const { return index_; }
1251 Block* try_block() const { return try_block_; } 1263 Block* try_block() const { return try_block_; }
1252 ZoneList<Label*>* escaping_targets() const { return escaping_targets_; } 1264 ZoneList<Label*>* escaping_targets() const { return escaping_targets_; }
1253 1265
1254 protected: 1266 protected:
1255 TryStatement(int index, Block* try_block) 1267 TryStatement(int index, Block* try_block, int pos)
1256 : index_(index), 1268 : Statement(pos),
1269 index_(index),
1257 try_block_(try_block), 1270 try_block_(try_block),
1258 escaping_targets_(NULL) { } 1271 escaping_targets_(NULL) { }
1259 1272
1260 private: 1273 private:
1261 // Unique (per-function) index of this handler. This is not an AST ID. 1274 // Unique (per-function) index of this handler. This is not an AST ID.
1262 int index_; 1275 int index_;
1263 1276
1264 Block* try_block_; 1277 Block* try_block_;
1265 ZoneList<Label*>* escaping_targets_; 1278 ZoneList<Label*>* escaping_targets_;
1266 }; 1279 };
1267 1280
1268 1281
1269 class TryCatchStatement V8_FINAL : public TryStatement { 1282 class TryCatchStatement V8_FINAL : public TryStatement {
1270 public: 1283 public:
1271 DECLARE_NODE_TYPE(TryCatchStatement) 1284 DECLARE_NODE_TYPE(TryCatchStatement)
1272 1285
1273 Scope* scope() { return scope_; } 1286 Scope* scope() { return scope_; }
1274 Variable* variable() { return variable_; } 1287 Variable* variable() { return variable_; }
1275 Block* catch_block() const { return catch_block_; } 1288 Block* catch_block() const { return catch_block_; }
1276 1289
1277 protected: 1290 protected:
1278 TryCatchStatement(int index, 1291 TryCatchStatement(int index,
1279 Block* try_block, 1292 Block* try_block,
1280 Scope* scope, 1293 Scope* scope,
1281 Variable* variable, 1294 Variable* variable,
1282 Block* catch_block) 1295 Block* catch_block,
1283 : TryStatement(index, try_block), 1296 int pos)
1297 : TryStatement(index, try_block, pos),
1284 scope_(scope), 1298 scope_(scope),
1285 variable_(variable), 1299 variable_(variable),
1286 catch_block_(catch_block) { 1300 catch_block_(catch_block) {
1287 } 1301 }
1288 1302
1289 private: 1303 private:
1290 Scope* scope_; 1304 Scope* scope_;
1291 Variable* variable_; 1305 Variable* variable_;
1292 Block* catch_block_; 1306 Block* catch_block_;
1293 }; 1307 };
1294 1308
1295 1309
1296 class TryFinallyStatement V8_FINAL : public TryStatement { 1310 class TryFinallyStatement V8_FINAL : public TryStatement {
1297 public: 1311 public:
1298 DECLARE_NODE_TYPE(TryFinallyStatement) 1312 DECLARE_NODE_TYPE(TryFinallyStatement)
1299 1313
1300 Block* finally_block() const { return finally_block_; } 1314 Block* finally_block() const { return finally_block_; }
1301 1315
1302 protected: 1316 protected:
1303 TryFinallyStatement(int index, Block* try_block, Block* finally_block) 1317 TryFinallyStatement(
1304 : TryStatement(index, try_block), 1318 int index, Block* try_block, Block* finally_block, int pos)
1319 : TryStatement(index, try_block, pos),
1305 finally_block_(finally_block) { } 1320 finally_block_(finally_block) { }
1306 1321
1307 private: 1322 private:
1308 Block* finally_block_; 1323 Block* finally_block_;
1309 }; 1324 };
1310 1325
1311 1326
1312 class DebuggerStatement V8_FINAL : public Statement { 1327 class DebuggerStatement V8_FINAL : public Statement {
1313 public: 1328 public:
1314 DECLARE_NODE_TYPE(DebuggerStatement) 1329 DECLARE_NODE_TYPE(DebuggerStatement)
1315 1330
1316 protected: 1331 protected:
1317 DebuggerStatement() {} 1332 explicit DebuggerStatement(int pos): Statement(pos) {}
1318 }; 1333 };
1319 1334
1320 1335
1321 class EmptyStatement V8_FINAL : public Statement { 1336 class EmptyStatement V8_FINAL : public Statement {
1322 public: 1337 public:
1323 DECLARE_NODE_TYPE(EmptyStatement) 1338 DECLARE_NODE_TYPE(EmptyStatement)
1324 1339
1325 protected: 1340 protected:
1326 EmptyStatement() {} 1341 explicit EmptyStatement(int pos): Statement(pos) {}
1327 }; 1342 };
1328 1343
1329 1344
1330 class Literal V8_FINAL : public Expression { 1345 class Literal V8_FINAL : public Expression {
1331 public: 1346 public:
1332 DECLARE_NODE_TYPE(Literal) 1347 DECLARE_NODE_TYPE(Literal)
1333 1348
1334 virtual bool IsPropertyName() V8_OVERRIDE { 1349 virtual bool IsPropertyName() V8_OVERRIDE {
1335 if (value_->IsInternalizedString()) { 1350 if (value_->IsInternalizedString()) {
1336 uint32_t ignored; 1351 uint32_t ignored;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 1388
1374 static bool Match(void* literal1, void* literal2) { 1389 static bool Match(void* literal1, void* literal2) {
1375 Handle<String> s1 = static_cast<Literal*>(literal1)->ToString(); 1390 Handle<String> s1 = static_cast<Literal*>(literal1)->ToString();
1376 Handle<String> s2 = static_cast<Literal*>(literal2)->ToString(); 1391 Handle<String> s2 = static_cast<Literal*>(literal2)->ToString();
1377 return s1->Equals(*s2); 1392 return s1->Equals(*s2);
1378 } 1393 }
1379 1394
1380 TypeFeedbackId LiteralFeedbackId() const { return reuse(id()); } 1395 TypeFeedbackId LiteralFeedbackId() const { return reuse(id()); }
1381 1396
1382 protected: 1397 protected:
1383 Literal(Isolate* isolate, Handle<Object> value) 1398 Literal(
1384 : Expression(isolate), 1399 Isolate* isolate, Handle<Object> value, int position)
1400 : Expression(isolate, position),
1385 value_(value), 1401 value_(value),
1386 isolate_(isolate) { } 1402 isolate_(isolate) { }
1387 1403
1388 private: 1404 private:
1389 Handle<String> ToString(); 1405 Handle<String> ToString();
1390 1406
1391 Handle<Object> value_; 1407 Handle<Object> value_;
1392 // TODO(dcarney): remove. this is only needed for Match and Hash. 1408 // TODO(dcarney): remove. this is only needed for Match and Hash.
1393 Isolate* isolate_; 1409 Isolate* isolate_;
1394 }; 1410 };
1395 1411
1396 1412
1397 // Base class for literals that needs space in the corresponding JSFunction. 1413 // Base class for literals that needs space in the corresponding JSFunction.
1398 class MaterializedLiteral : public Expression { 1414 class MaterializedLiteral : public Expression {
1399 public: 1415 public:
1400 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } 1416 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; }
1401 1417
1402 int literal_index() { return literal_index_; } 1418 int literal_index() { return literal_index_; }
1403 1419
1404 // A materialized literal is simple if the values consist of only 1420 // A materialized literal is simple if the values consist of only
1405 // constants and simple object and array literals. 1421 // constants and simple object and array literals.
1406 bool is_simple() const { return is_simple_; } 1422 bool is_simple() const { return is_simple_; }
1407 1423
1408 int depth() const { return depth_; } 1424 int depth() const { return depth_; }
1409 1425
1410 protected: 1426 protected:
1411 MaterializedLiteral(Isolate* isolate, 1427 MaterializedLiteral(Isolate* isolate,
1412 int literal_index, 1428 int literal_index,
1413 bool is_simple, 1429 bool is_simple,
1414 int depth) 1430 int depth,
1415 : Expression(isolate), 1431 int pos)
1432 : Expression(isolate, pos),
1416 literal_index_(literal_index), 1433 literal_index_(literal_index),
1417 is_simple_(is_simple), 1434 is_simple_(is_simple),
1418 depth_(depth) {} 1435 depth_(depth) {}
1419 1436
1420 private: 1437 private:
1421 int literal_index_; 1438 int literal_index_;
1422 bool is_simple_; 1439 bool is_simple_;
1423 int depth_; 1440 int depth_;
1424 }; 1441 };
1425 1442
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 1520
1504 protected: 1521 protected:
1505 ObjectLiteral(Isolate* isolate, 1522 ObjectLiteral(Isolate* isolate,
1506 Handle<FixedArray> constant_properties, 1523 Handle<FixedArray> constant_properties,
1507 ZoneList<Property*>* properties, 1524 ZoneList<Property*>* properties,
1508 int literal_index, 1525 int literal_index,
1509 bool is_simple, 1526 bool is_simple,
1510 bool fast_elements, 1527 bool fast_elements,
1511 int depth, 1528 int depth,
1512 bool may_store_doubles, 1529 bool may_store_doubles,
1513 bool has_function) 1530 bool has_function,
1514 : MaterializedLiteral(isolate, literal_index, is_simple, depth), 1531 int pos)
1532 : MaterializedLiteral(isolate, literal_index, is_simple, depth, pos),
1515 constant_properties_(constant_properties), 1533 constant_properties_(constant_properties),
1516 properties_(properties), 1534 properties_(properties),
1517 fast_elements_(fast_elements), 1535 fast_elements_(fast_elements),
1518 may_store_doubles_(may_store_doubles), 1536 may_store_doubles_(may_store_doubles),
1519 has_function_(has_function) {} 1537 has_function_(has_function) {}
1520 1538
1521 private: 1539 private:
1522 Handle<FixedArray> constant_properties_; 1540 Handle<FixedArray> constant_properties_;
1523 ZoneList<Property*>* properties_; 1541 ZoneList<Property*>* properties_;
1524 bool fast_elements_; 1542 bool fast_elements_;
1525 bool may_store_doubles_; 1543 bool may_store_doubles_;
1526 bool has_function_; 1544 bool has_function_;
1527 }; 1545 };
1528 1546
1529 1547
1530 // Node for capturing a regexp literal. 1548 // Node for capturing a regexp literal.
1531 class RegExpLiteral V8_FINAL : public MaterializedLiteral { 1549 class RegExpLiteral V8_FINAL : public MaterializedLiteral {
1532 public: 1550 public:
1533 DECLARE_NODE_TYPE(RegExpLiteral) 1551 DECLARE_NODE_TYPE(RegExpLiteral)
1534 1552
1535 Handle<String> pattern() const { return pattern_; } 1553 Handle<String> pattern() const { return pattern_; }
1536 Handle<String> flags() const { return flags_; } 1554 Handle<String> flags() const { return flags_; }
1537 1555
1538 protected: 1556 protected:
1539 RegExpLiteral(Isolate* isolate, 1557 RegExpLiteral(Isolate* isolate,
1540 Handle<String> pattern, 1558 Handle<String> pattern,
1541 Handle<String> flags, 1559 Handle<String> flags,
1542 int literal_index) 1560 int literal_index,
1543 : MaterializedLiteral(isolate, literal_index, false, 1), 1561 int pos)
1562 : MaterializedLiteral(isolate, literal_index, false, 1, pos),
1544 pattern_(pattern), 1563 pattern_(pattern),
1545 flags_(flags) {} 1564 flags_(flags) {}
1546 1565
1547 private: 1566 private:
1548 Handle<String> pattern_; 1567 Handle<String> pattern_;
1549 Handle<String> flags_; 1568 Handle<String> flags_;
1550 }; 1569 };
1551 1570
1571
1552 // An array literal has a literals object that is used 1572 // An array literal has a literals object that is used
1553 // for minimizing the work when constructing it at runtime. 1573 // for minimizing the work when constructing it at runtime.
1554 class ArrayLiteral V8_FINAL : public MaterializedLiteral { 1574 class ArrayLiteral V8_FINAL : public MaterializedLiteral {
1555 public: 1575 public:
1556 DECLARE_NODE_TYPE(ArrayLiteral) 1576 DECLARE_NODE_TYPE(ArrayLiteral)
1557 1577
1558 Handle<FixedArray> constant_elements() const { return constant_elements_; } 1578 Handle<FixedArray> constant_elements() const { return constant_elements_; }
1559 ZoneList<Expression*>* values() const { return values_; } 1579 ZoneList<Expression*>* values() const { return values_; }
1560 1580
1561 // Return an AST id for an element that is used in simulate instructions. 1581 // Return an AST id for an element that is used in simulate instructions.
1562 BailoutId GetIdForElement(int i) { 1582 BailoutId GetIdForElement(int i) {
1563 return BailoutId(first_element_id_.ToInt() + i); 1583 return BailoutId(first_element_id_.ToInt() + i);
1564 } 1584 }
1565 1585
1566 protected: 1586 protected:
1567 ArrayLiteral(Isolate* isolate, 1587 ArrayLiteral(Isolate* isolate,
1568 Handle<FixedArray> constant_elements, 1588 Handle<FixedArray> constant_elements,
1569 ZoneList<Expression*>* values, 1589 ZoneList<Expression*>* values,
1570 int literal_index, 1590 int literal_index,
1571 bool is_simple, 1591 bool is_simple,
1572 int depth) 1592 int depth,
1573 : MaterializedLiteral(isolate, literal_index, is_simple, depth), 1593 int pos)
1594 : MaterializedLiteral(isolate, literal_index, is_simple, depth, pos),
1574 constant_elements_(constant_elements), 1595 constant_elements_(constant_elements),
1575 values_(values), 1596 values_(values),
1576 first_element_id_(ReserveIdRange(isolate, values->length())) {} 1597 first_element_id_(ReserveIdRange(isolate, values->length())) {}
1577 1598
1578 private: 1599 private:
1579 Handle<FixedArray> constant_elements_; 1600 Handle<FixedArray> constant_elements_;
1580 ZoneList<Expression*>* values_; 1601 ZoneList<Expression*>* values_;
1581 const BailoutId first_element_id_; 1602 const BailoutId first_element_id_;
1582 }; 1603 };
1583 1604
(...skipping 12 matching lines...) Expand all
1596 1617
1597 bool IsArguments() { return var_ != NULL && var_->is_arguments(); } 1618 bool IsArguments() { return var_ != NULL && var_->is_arguments(); }
1598 1619
1599 bool IsLValue() { 1620 bool IsLValue() {
1600 return is_lvalue_; 1621 return is_lvalue_;
1601 } 1622 }
1602 1623
1603 Handle<String> name() const { return name_; } 1624 Handle<String> name() const { return name_; }
1604 Variable* var() const { return var_; } 1625 Variable* var() const { return var_; }
1605 bool is_this() const { return is_this_; } 1626 bool is_this() const { return is_this_; }
1606 int position() const { return position_; }
1607 Interface* interface() const { return interface_; } 1627 Interface* interface() const { return interface_; }
1608 1628
1609 1629
1610 void MarkAsTrivial() { is_trivial_ = true; } 1630 void MarkAsTrivial() { is_trivial_ = true; }
1611 void MarkAsLValue() { is_lvalue_ = true; } 1631 void MarkAsLValue() { is_lvalue_ = true; }
1612 1632
1613 // Bind this proxy to the variable var. Interfaces must match. 1633 // Bind this proxy to the variable var. Interfaces must match.
1614 void BindTo(Variable* var); 1634 void BindTo(Variable* var);
1615 1635
1616 protected: 1636 protected:
1617 VariableProxy(Isolate* isolate, Variable* var); 1637 VariableProxy(Isolate* isolate, Variable* var, int position);
1618 1638
1619 VariableProxy(Isolate* isolate, 1639 VariableProxy(Isolate* isolate,
1620 Handle<String> name, 1640 Handle<String> name,
1621 bool is_this, 1641 bool is_this,
1622 Interface* interface, 1642 Interface* interface,
1623 int position); 1643 int position);
1624 1644
1625 Handle<String> name_; 1645 Handle<String> name_;
1626 Variable* var_; // resolved variable, or NULL 1646 Variable* var_; // resolved variable, or NULL
1627 bool is_this_; 1647 bool is_this_;
1628 bool is_trivial_; 1648 bool is_trivial_;
1629 // True if this variable proxy is being used in an assignment 1649 // True if this variable proxy is being used in an assignment
1630 // or with a increment/decrement operator. 1650 // or with a increment/decrement operator.
1631 bool is_lvalue_; 1651 bool is_lvalue_;
1632 int position_;
1633 Interface* interface_; 1652 Interface* interface_;
1634 }; 1653 };
1635 1654
1636 1655
1637 class Property V8_FINAL : public Expression { 1656 class Property V8_FINAL : public Expression {
1638 public: 1657 public:
1639 DECLARE_NODE_TYPE(Property) 1658 DECLARE_NODE_TYPE(Property)
1640 1659
1641 virtual bool IsValidLeftHandSide() V8_OVERRIDE { return true; } 1660 virtual bool IsValidLeftHandSide() V8_OVERRIDE { return true; }
1642 1661
1643 Expression* obj() const { return obj_; } 1662 Expression* obj() const { return obj_; }
1644 Expression* key() const { return key_; } 1663 Expression* key() const { return key_; }
1645 virtual int position() const V8_OVERRIDE { return pos_; }
1646 1664
1647 BailoutId LoadId() const { return load_id_; } 1665 BailoutId LoadId() const { return load_id_; }
1648 1666
1649 bool IsStringLength() const { return is_string_length_; } 1667 bool IsStringLength() const { return is_string_length_; }
1650 bool IsStringAccess() const { return is_string_access_; } 1668 bool IsStringAccess() const { return is_string_access_; }
1651 bool IsFunctionPrototype() const { return is_function_prototype_; } 1669 bool IsFunctionPrototype() const { return is_function_prototype_; }
1652 1670
1653 // Type feedback information. 1671 // Type feedback information.
1654 void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* zone); 1672 void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* zone);
1655 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; } 1673 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; }
1656 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { 1674 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE {
1657 return &receiver_types_; 1675 return &receiver_types_;
1658 } 1676 }
1659 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE { 1677 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE {
1660 return STANDARD_STORE; 1678 return STANDARD_STORE;
1661 } 1679 }
1662 bool IsUninitialized() { return is_uninitialized_; } 1680 bool IsUninitialized() { return is_uninitialized_; }
1663 TypeFeedbackId PropertyFeedbackId() { return reuse(id()); } 1681 TypeFeedbackId PropertyFeedbackId() { return reuse(id()); }
1664 1682
1665 protected: 1683 protected:
1666 Property(Isolate* isolate, 1684 Property(Isolate* isolate,
1667 Expression* obj, 1685 Expression* obj,
1668 Expression* key, 1686 Expression* key,
1669 int pos) 1687 int pos)
1670 : Expression(isolate), 1688 : Expression(isolate, pos),
1671 obj_(obj), 1689 obj_(obj),
1672 key_(key), 1690 key_(key),
1673 pos_(pos),
1674 load_id_(GetNextId(isolate)), 1691 load_id_(GetNextId(isolate)),
1675 is_monomorphic_(false), 1692 is_monomorphic_(false),
1676 is_uninitialized_(false), 1693 is_uninitialized_(false),
1677 is_string_length_(false), 1694 is_string_length_(false),
1678 is_string_access_(false), 1695 is_string_access_(false),
1679 is_function_prototype_(false) { } 1696 is_function_prototype_(false) { }
1680 1697
1681 private: 1698 private:
1682 Expression* obj_; 1699 Expression* obj_;
1683 Expression* key_; 1700 Expression* key_;
1684 int pos_;
1685 const BailoutId load_id_; 1701 const BailoutId load_id_;
1686 1702
1687 SmallMapList receiver_types_; 1703 SmallMapList receiver_types_;
1688 bool is_monomorphic_ : 1; 1704 bool is_monomorphic_ : 1;
1689 bool is_uninitialized_ : 1; 1705 bool is_uninitialized_ : 1;
1690 bool is_string_length_ : 1; 1706 bool is_string_length_ : 1;
1691 bool is_string_access_ : 1; 1707 bool is_string_access_ : 1;
1692 bool is_function_prototype_ : 1; 1708 bool is_function_prototype_ : 1;
1693 }; 1709 };
1694 1710
1695 1711
1696 class Call V8_FINAL : public Expression { 1712 class Call V8_FINAL : public Expression {
1697 public: 1713 public:
1698 DECLARE_NODE_TYPE(Call) 1714 DECLARE_NODE_TYPE(Call)
1699 1715
1700 Expression* expression() const { return expression_; } 1716 Expression* expression() const { return expression_; }
1701 ZoneList<Expression*>* arguments() const { return arguments_; } 1717 ZoneList<Expression*>* arguments() const { return arguments_; }
1702 virtual int position() const V8_FINAL { return pos_; }
1703 1718
1704 // Type feedback information. 1719 // Type feedback information.
1705 TypeFeedbackId CallFeedbackId() const { return reuse(id()); } 1720 TypeFeedbackId CallFeedbackId() const { return reuse(id()); }
1706 void RecordTypeFeedback(TypeFeedbackOracle* oracle, CallKind call_kind); 1721 void RecordTypeFeedback(TypeFeedbackOracle* oracle, CallKind call_kind);
1707 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { 1722 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE {
1708 return &receiver_types_; 1723 return &receiver_types_;
1709 } 1724 }
1710 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; } 1725 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; }
1711 CheckType check_type() const { return check_type_; } 1726 CheckType check_type() const { return check_type_; }
1712 1727
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1747 #ifdef DEBUG 1762 #ifdef DEBUG
1748 // Used to assert that the FullCodeGenerator records the return site. 1763 // Used to assert that the FullCodeGenerator records the return site.
1749 bool return_is_recorded_; 1764 bool return_is_recorded_;
1750 #endif 1765 #endif
1751 1766
1752 protected: 1767 protected:
1753 Call(Isolate* isolate, 1768 Call(Isolate* isolate,
1754 Expression* expression, 1769 Expression* expression,
1755 ZoneList<Expression*>* arguments, 1770 ZoneList<Expression*>* arguments,
1756 int pos) 1771 int pos)
1757 : Expression(isolate), 1772 : Expression(isolate, pos),
1758 expression_(expression), 1773 expression_(expression),
1759 arguments_(arguments), 1774 arguments_(arguments),
1760 pos_(pos),
1761 is_monomorphic_(false), 1775 is_monomorphic_(false),
1762 check_type_(RECEIVER_MAP_CHECK), 1776 check_type_(RECEIVER_MAP_CHECK),
1763 return_id_(GetNextId(isolate)) { } 1777 return_id_(GetNextId(isolate)) { }
1764 1778
1765 private: 1779 private:
1766 Expression* expression_; 1780 Expression* expression_;
1767 ZoneList<Expression*>* arguments_; 1781 ZoneList<Expression*>* arguments_;
1768 int pos_;
1769 1782
1770 bool is_monomorphic_; 1783 bool is_monomorphic_;
1771 CheckType check_type_; 1784 CheckType check_type_;
1772 SmallMapList receiver_types_; 1785 SmallMapList receiver_types_;
1773 Handle<JSFunction> target_; 1786 Handle<JSFunction> target_;
1774 Handle<JSObject> holder_; 1787 Handle<JSObject> holder_;
1775 Handle<Cell> cell_; 1788 Handle<Cell> cell_;
1776 1789
1777 const BailoutId return_id_; 1790 const BailoutId return_id_;
1778 }; 1791 };
1779 1792
1780 1793
1781 class CallNew V8_FINAL : public Expression { 1794 class CallNew V8_FINAL : public Expression {
1782 public: 1795 public:
1783 DECLARE_NODE_TYPE(CallNew) 1796 DECLARE_NODE_TYPE(CallNew)
1784 1797
1785 Expression* expression() const { return expression_; } 1798 Expression* expression() const { return expression_; }
1786 ZoneList<Expression*>* arguments() const { return arguments_; } 1799 ZoneList<Expression*>* arguments() const { return arguments_; }
1787 virtual int position() const V8_OVERRIDE { return pos_; }
1788 1800
1789 // Type feedback information. 1801 // Type feedback information.
1790 TypeFeedbackId CallNewFeedbackId() const { return reuse(id()); } 1802 TypeFeedbackId CallNewFeedbackId() const { return reuse(id()); }
1791 void RecordTypeFeedback(TypeFeedbackOracle* oracle); 1803 void RecordTypeFeedback(TypeFeedbackOracle* oracle);
1792 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; } 1804 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; }
1793 Handle<JSFunction> target() const { return target_; } 1805 Handle<JSFunction> target() const { return target_; }
1794 ElementsKind elements_kind() const { return elements_kind_; } 1806 ElementsKind elements_kind() const { return elements_kind_; }
1795 Handle<Cell> allocation_info_cell() const { 1807 Handle<Cell> allocation_info_cell() const {
1796 return allocation_info_cell_; 1808 return allocation_info_cell_;
1797 } 1809 }
1798 1810
1799 BailoutId ReturnId() const { return return_id_; } 1811 BailoutId ReturnId() const { return return_id_; }
1800 1812
1801 protected: 1813 protected:
1802 CallNew(Isolate* isolate, 1814 CallNew(Isolate* isolate,
1803 Expression* expression, 1815 Expression* expression,
1804 ZoneList<Expression*>* arguments, 1816 ZoneList<Expression*>* arguments,
1805 int pos) 1817 int pos)
1806 : Expression(isolate), 1818 : Expression(isolate, pos),
1807 expression_(expression), 1819 expression_(expression),
1808 arguments_(arguments), 1820 arguments_(arguments),
1809 pos_(pos),
1810 is_monomorphic_(false), 1821 is_monomorphic_(false),
1811 elements_kind_(GetInitialFastElementsKind()), 1822 elements_kind_(GetInitialFastElementsKind()),
1812 return_id_(GetNextId(isolate)) { } 1823 return_id_(GetNextId(isolate)) { }
1813 1824
1814 private: 1825 private:
1815 Expression* expression_; 1826 Expression* expression_;
1816 ZoneList<Expression*>* arguments_; 1827 ZoneList<Expression*>* arguments_;
1817 int pos_;
1818 1828
1819 bool is_monomorphic_; 1829 bool is_monomorphic_;
1820 Handle<JSFunction> target_; 1830 Handle<JSFunction> target_;
1821 ElementsKind elements_kind_; 1831 ElementsKind elements_kind_;
1822 Handle<Cell> allocation_info_cell_; 1832 Handle<Cell> allocation_info_cell_;
1823 1833
1824 const BailoutId return_id_; 1834 const BailoutId return_id_;
1825 }; 1835 };
1826 1836
1827 1837
1828 // The CallRuntime class does not represent any official JavaScript 1838 // The CallRuntime class does not represent any official JavaScript
1829 // language construct. Instead it is used to call a C or JS function 1839 // language construct. Instead it is used to call a C or JS function
1830 // with a set of arguments. This is used from the builtins that are 1840 // with a set of arguments. This is used from the builtins that are
1831 // implemented in JavaScript (see "v8natives.js"). 1841 // implemented in JavaScript (see "v8natives.js").
1832 class CallRuntime V8_FINAL : public Expression { 1842 class CallRuntime V8_FINAL : public Expression {
1833 public: 1843 public:
1834 DECLARE_NODE_TYPE(CallRuntime) 1844 DECLARE_NODE_TYPE(CallRuntime)
1835 1845
1836 Handle<String> name() const { return name_; } 1846 Handle<String> name() const { return name_; }
1837 const Runtime::Function* function() const { return function_; } 1847 const Runtime::Function* function() const { return function_; }
1838 ZoneList<Expression*>* arguments() const { return arguments_; } 1848 ZoneList<Expression*>* arguments() const { return arguments_; }
1839 bool is_jsruntime() const { return function_ == NULL; } 1849 bool is_jsruntime() const { return function_ == NULL; }
1840 1850
1841 TypeFeedbackId CallRuntimeFeedbackId() const { return reuse(id()); } 1851 TypeFeedbackId CallRuntimeFeedbackId() const { return reuse(id()); }
1842 1852
1843 protected: 1853 protected:
1844 CallRuntime(Isolate* isolate, 1854 CallRuntime(Isolate* isolate,
1845 Handle<String> name, 1855 Handle<String> name,
1846 const Runtime::Function* function, 1856 const Runtime::Function* function,
1847 ZoneList<Expression*>* arguments) 1857 ZoneList<Expression*>* arguments,
1848 : Expression(isolate), 1858 int pos)
1859 : Expression(isolate, pos),
1849 name_(name), 1860 name_(name),
1850 function_(function), 1861 function_(function),
1851 arguments_(arguments) { } 1862 arguments_(arguments) { }
1852 1863
1853 private: 1864 private:
1854 Handle<String> name_; 1865 Handle<String> name_;
1855 const Runtime::Function* function_; 1866 const Runtime::Function* function_;
1856 ZoneList<Expression*>* arguments_; 1867 ZoneList<Expression*>* arguments_;
1857 }; 1868 };
1858 1869
1859 1870
1860 class UnaryOperation V8_FINAL : public Expression { 1871 class UnaryOperation V8_FINAL : public Expression {
1861 public: 1872 public:
1862 DECLARE_NODE_TYPE(UnaryOperation) 1873 DECLARE_NODE_TYPE(UnaryOperation)
1863 1874
1864 Token::Value op() const { return op_; } 1875 Token::Value op() const { return op_; }
1865 Expression* expression() const { return expression_; } 1876 Expression* expression() const { return expression_; }
1866 virtual int position() const V8_OVERRIDE { return pos_; }
1867 1877
1868 BailoutId MaterializeTrueId() { return materialize_true_id_; } 1878 BailoutId MaterializeTrueId() { return materialize_true_id_; }
1869 BailoutId MaterializeFalseId() { return materialize_false_id_; } 1879 BailoutId MaterializeFalseId() { return materialize_false_id_; }
1870 1880
1871 virtual void RecordToBooleanTypeFeedback( 1881 virtual void RecordToBooleanTypeFeedback(
1872 TypeFeedbackOracle* oracle) V8_OVERRIDE; 1882 TypeFeedbackOracle* oracle) V8_OVERRIDE;
1873 1883
1874 protected: 1884 protected:
1875 UnaryOperation(Isolate* isolate, 1885 UnaryOperation(Isolate* isolate,
1876 Token::Value op, 1886 Token::Value op,
1877 Expression* expression, 1887 Expression* expression,
1878 int pos) 1888 int pos)
1879 : Expression(isolate), 1889 : Expression(isolate, pos),
1880 op_(op), 1890 op_(op),
1881 expression_(expression), 1891 expression_(expression),
1882 pos_(pos),
1883 materialize_true_id_(GetNextId(isolate)), 1892 materialize_true_id_(GetNextId(isolate)),
1884 materialize_false_id_(GetNextId(isolate)) { 1893 materialize_false_id_(GetNextId(isolate)) {
1885 ASSERT(Token::IsUnaryOp(op)); 1894 ASSERT(Token::IsUnaryOp(op));
1886 } 1895 }
1887 1896
1888 private: 1897 private:
1889 Token::Value op_; 1898 Token::Value op_;
1890 Expression* expression_; 1899 Expression* expression_;
1891 int pos_;
1892 1900
1893 // For unary not (Token::NOT), the AST ids where true and false will 1901 // For unary not (Token::NOT), the AST ids where true and false will
1894 // actually be materialized, respectively. 1902 // actually be materialized, respectively.
1895 const BailoutId materialize_true_id_; 1903 const BailoutId materialize_true_id_;
1896 const BailoutId materialize_false_id_; 1904 const BailoutId materialize_false_id_;
1897 }; 1905 };
1898 1906
1899 1907
1900 class BinaryOperation V8_FINAL : public Expression { 1908 class BinaryOperation V8_FINAL : public Expression {
1901 public: 1909 public:
1902 DECLARE_NODE_TYPE(BinaryOperation) 1910 DECLARE_NODE_TYPE(BinaryOperation)
1903 1911
1904 virtual bool ResultOverwriteAllowed(); 1912 virtual bool ResultOverwriteAllowed();
1905 1913
1906 Token::Value op() const { return op_; } 1914 Token::Value op() const { return op_; }
1907 Expression* left() const { return left_; } 1915 Expression* left() const { return left_; }
1908 Expression* right() const { return right_; } 1916 Expression* right() const { return right_; }
1909 virtual int position() const V8_OVERRIDE { return pos_; }
1910 1917
1911 BailoutId RightId() const { return right_id_; } 1918 BailoutId RightId() const { return right_id_; }
1912 1919
1913 TypeFeedbackId BinaryOperationFeedbackId() const { return reuse(id()); } 1920 TypeFeedbackId BinaryOperationFeedbackId() const { return reuse(id()); }
1914 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; } 1921 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; }
1915 void set_fixed_right_arg(Maybe<int> arg) { fixed_right_arg_ = arg; } 1922 void set_fixed_right_arg(Maybe<int> arg) { fixed_right_arg_ = arg; }
1916 1923
1917 virtual void RecordToBooleanTypeFeedback( 1924 virtual void RecordToBooleanTypeFeedback(
1918 TypeFeedbackOracle* oracle) V8_OVERRIDE; 1925 TypeFeedbackOracle* oracle) V8_OVERRIDE;
1919 1926
1920 protected: 1927 protected:
1921 BinaryOperation(Isolate* isolate, 1928 BinaryOperation(Isolate* isolate,
1922 Token::Value op, 1929 Token::Value op,
1923 Expression* left, 1930 Expression* left,
1924 Expression* right, 1931 Expression* right,
1925 int pos) 1932 int pos)
1926 : Expression(isolate), 1933 : Expression(isolate, pos),
1927 op_(op), 1934 op_(op),
1928 left_(left), 1935 left_(left),
1929 right_(right), 1936 right_(right),
1930 pos_(pos),
1931 right_id_(GetNextId(isolate)) { 1937 right_id_(GetNextId(isolate)) {
1932 ASSERT(Token::IsBinaryOp(op)); 1938 ASSERT(Token::IsBinaryOp(op));
1933 } 1939 }
1934 1940
1935 private: 1941 private:
1936 Token::Value op_; 1942 Token::Value op_;
1937 Expression* left_; 1943 Expression* left_;
1938 Expression* right_; 1944 Expression* right_;
1939 int pos_;
1940 1945
1941 // TODO(rossberg): the fixed arg should probably be represented as a Constant 1946 // TODO(rossberg): the fixed arg should probably be represented as a Constant
1942 // type for the RHS. 1947 // type for the RHS.
1943 Maybe<int> fixed_right_arg_; 1948 Maybe<int> fixed_right_arg_;
1944 1949
1945 // The short-circuit logical operations need an AST ID for their 1950 // The short-circuit logical operations need an AST ID for their
1946 // right-hand subexpression. 1951 // right-hand subexpression.
1947 const BailoutId right_id_; 1952 const BailoutId right_id_;
1948 }; 1953 };
1949 1954
1950 1955
1951 class CountOperation V8_FINAL : public Expression { 1956 class CountOperation V8_FINAL : public Expression {
1952 public: 1957 public:
1953 DECLARE_NODE_TYPE(CountOperation) 1958 DECLARE_NODE_TYPE(CountOperation)
1954 1959
1955 bool is_prefix() const { return is_prefix_; } 1960 bool is_prefix() const { return is_prefix_; }
1956 bool is_postfix() const { return !is_prefix_; } 1961 bool is_postfix() const { return !is_prefix_; }
1957 1962
1958 Token::Value op() const { return op_; } 1963 Token::Value op() const { return op_; }
1959 Token::Value binary_op() { 1964 Token::Value binary_op() {
1960 return (op() == Token::INC) ? Token::ADD : Token::SUB; 1965 return (op() == Token::INC) ? Token::ADD : Token::SUB;
1961 } 1966 }
1962 1967
1963 Expression* expression() const { return expression_; } 1968 Expression* expression() const { return expression_; }
1964 virtual int position() const V8_OVERRIDE { return pos_; }
1965 1969
1966 void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* zone); 1970 void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* zone);
1967 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; } 1971 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; }
1968 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { 1972 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE {
1969 return &receiver_types_; 1973 return &receiver_types_;
1970 } 1974 }
1971 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE { 1975 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE {
1972 return store_mode_; 1976 return store_mode_;
1973 } 1977 }
1974 TypeInfo type() const { return type_; } 1978 TypeInfo type() const { return type_; }
1975 1979
1976 BailoutId AssignmentId() const { return assignment_id_; } 1980 BailoutId AssignmentId() const { return assignment_id_; }
1977 1981
1978 TypeFeedbackId CountBinOpFeedbackId() const { return count_id_; } 1982 TypeFeedbackId CountBinOpFeedbackId() const { return count_id_; }
1979 TypeFeedbackId CountStoreFeedbackId() const { return reuse(id()); } 1983 TypeFeedbackId CountStoreFeedbackId() const { return reuse(id()); }
1980 1984
1981 protected: 1985 protected:
1982 CountOperation(Isolate* isolate, 1986 CountOperation(Isolate* isolate,
1983 Token::Value op, 1987 Token::Value op,
1984 bool is_prefix, 1988 bool is_prefix,
1985 Expression* expr, 1989 Expression* expr,
1986 int pos) 1990 int pos)
1987 : Expression(isolate), 1991 : Expression(isolate, pos),
1988 op_(op), 1992 op_(op),
1989 is_prefix_(is_prefix), 1993 is_prefix_(is_prefix),
1990 is_monomorphic_(false), 1994 is_monomorphic_(false),
1991 store_mode_(STANDARD_STORE), 1995 store_mode_(STANDARD_STORE),
1992 expression_(expr), 1996 expression_(expr),
1993 pos_(pos),
1994 assignment_id_(GetNextId(isolate)), 1997 assignment_id_(GetNextId(isolate)),
1995 count_id_(GetNextId(isolate)) {} 1998 count_id_(GetNextId(isolate)) {}
1996 1999
1997 private: 2000 private:
1998 Token::Value op_; 2001 Token::Value op_;
1999 bool is_prefix_ : 1; 2002 bool is_prefix_ : 1;
2000 bool is_monomorphic_ : 1; 2003 bool is_monomorphic_ : 1;
2001 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, 2004 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed,
2002 // must have extra bit. 2005 // must have extra bit.
2003 TypeInfo type_; 2006 TypeInfo type_;
2004 2007
2005 Expression* expression_; 2008 Expression* expression_;
2006 int pos_;
2007 const BailoutId assignment_id_; 2009 const BailoutId assignment_id_;
2008 const TypeFeedbackId count_id_; 2010 const TypeFeedbackId count_id_;
2009 SmallMapList receiver_types_; 2011 SmallMapList receiver_types_;
2010 }; 2012 };
2011 2013
2012 2014
2013 class CompareOperation V8_FINAL : public Expression { 2015 class CompareOperation V8_FINAL : public Expression {
2014 public: 2016 public:
2015 DECLARE_NODE_TYPE(CompareOperation) 2017 DECLARE_NODE_TYPE(CompareOperation)
2016 2018
2017 Token::Value op() const { return op_; } 2019 Token::Value op() const { return op_; }
2018 Expression* left() const { return left_; } 2020 Expression* left() const { return left_; }
2019 Expression* right() const { return right_; } 2021 Expression* right() const { return right_; }
2020 virtual int position() const V8_OVERRIDE { return pos_; }
2021 2022
2022 // Type feedback information. 2023 // Type feedback information.
2023 TypeFeedbackId CompareOperationFeedbackId() const { return reuse(id()); } 2024 TypeFeedbackId CompareOperationFeedbackId() const { return reuse(id()); }
2024 Handle<Type> combined_type() const { return combined_type_; } 2025 Handle<Type> combined_type() const { return combined_type_; }
2025 void set_combined_type(Handle<Type> type) { combined_type_ = type; } 2026 void set_combined_type(Handle<Type> type) { combined_type_ = type; }
2026 2027
2027 // Match special cases. 2028 // Match special cases.
2028 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); 2029 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check);
2029 bool IsLiteralCompareUndefined(Expression** expr, Isolate* isolate); 2030 bool IsLiteralCompareUndefined(Expression** expr, Isolate* isolate);
2030 bool IsLiteralCompareNull(Expression** expr); 2031 bool IsLiteralCompareNull(Expression** expr);
2031 2032
2032 protected: 2033 protected:
2033 CompareOperation(Isolate* isolate, 2034 CompareOperation(Isolate* isolate,
2034 Token::Value op, 2035 Token::Value op,
2035 Expression* left, 2036 Expression* left,
2036 Expression* right, 2037 Expression* right,
2037 int pos) 2038 int pos)
2038 : Expression(isolate), 2039 : Expression(isolate, pos),
2039 op_(op), 2040 op_(op),
2040 left_(left), 2041 left_(left),
2041 right_(right), 2042 right_(right),
2042 pos_(pos),
2043 combined_type_(Type::Null(), isolate) { 2043 combined_type_(Type::Null(), isolate) {
2044 ASSERT(Token::IsCompareOp(op)); 2044 ASSERT(Token::IsCompareOp(op));
2045 } 2045 }
2046 2046
2047 private: 2047 private:
2048 Token::Value op_; 2048 Token::Value op_;
2049 Expression* left_; 2049 Expression* left_;
2050 Expression* right_; 2050 Expression* right_;
2051 int pos_;
2052 2051
2053 Handle<Type> combined_type_; 2052 Handle<Type> combined_type_;
2054 }; 2053 };
2055 2054
2056 2055
2057 class Conditional V8_FINAL : public Expression { 2056 class Conditional V8_FINAL : public Expression {
2058 public: 2057 public:
2059 DECLARE_NODE_TYPE(Conditional) 2058 DECLARE_NODE_TYPE(Conditional)
2060 2059
2061 Expression* condition() const { return condition_; } 2060 Expression* condition() const { return condition_; }
2062 Expression* then_expression() const { return then_expression_; } 2061 Expression* then_expression() const { return then_expression_; }
2063 Expression* else_expression() const { return else_expression_; } 2062 Expression* else_expression() const { return else_expression_; }
2064 2063
2064 // TODO(rossberg): get rid of this.
2065 int then_expression_position() const { return then_expression_position_; } 2065 int then_expression_position() const { return then_expression_position_; }
2066 int else_expression_position() const { return else_expression_position_; } 2066 int else_expression_position() const { return else_expression_position_; }
2067 2067
2068 BailoutId ThenId() const { return then_id_; } 2068 BailoutId ThenId() const { return then_id_; }
2069 BailoutId ElseId() const { return else_id_; } 2069 BailoutId ElseId() const { return else_id_; }
2070 2070
2071 protected: 2071 protected:
2072 Conditional(Isolate* isolate, 2072 Conditional(Isolate* isolate,
2073 Expression* condition, 2073 Expression* condition,
2074 Expression* then_expression, 2074 Expression* then_expression,
2075 Expression* else_expression, 2075 Expression* else_expression,
2076 int then_expression_position, 2076 int then_expression_position,
2077 int else_expression_position) 2077 int else_expression_position,
2078 : Expression(isolate), 2078 int position)
2079 : Expression(isolate, position),
2079 condition_(condition), 2080 condition_(condition),
2080 then_expression_(then_expression), 2081 then_expression_(then_expression),
2081 else_expression_(else_expression), 2082 else_expression_(else_expression),
2082 then_expression_position_(then_expression_position), 2083 then_expression_position_(then_expression_position),
2083 else_expression_position_(else_expression_position), 2084 else_expression_position_(else_expression_position),
2084 then_id_(GetNextId(isolate)), 2085 then_id_(GetNextId(isolate)),
2085 else_id_(GetNextId(isolate)) { } 2086 else_id_(GetNextId(isolate)) { }
2086 2087
2087 private: 2088 private:
2088 Expression* condition_; 2089 Expression* condition_;
(...skipping 10 matching lines...) Expand all
2099 public: 2100 public:
2100 DECLARE_NODE_TYPE(Assignment) 2101 DECLARE_NODE_TYPE(Assignment)
2101 2102
2102 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } 2103 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; }
2103 2104
2104 Token::Value binary_op() const; 2105 Token::Value binary_op() const;
2105 2106
2106 Token::Value op() const { return op_; } 2107 Token::Value op() const { return op_; }
2107 Expression* target() const { return target_; } 2108 Expression* target() const { return target_; }
2108 Expression* value() const { return value_; } 2109 Expression* value() const { return value_; }
2109 virtual int position() const V8_OVERRIDE { return pos_; }
2110 BinaryOperation* binary_operation() const { return binary_operation_; } 2110 BinaryOperation* binary_operation() const { return binary_operation_; }
2111 2111
2112 // This check relies on the definition order of token in token.h. 2112 // This check relies on the definition order of token in token.h.
2113 bool is_compound() const { return op() > Token::ASSIGN; } 2113 bool is_compound() const { return op() > Token::ASSIGN; }
2114 2114
2115 BailoutId AssignmentId() const { return assignment_id_; } 2115 BailoutId AssignmentId() const { return assignment_id_; }
2116 2116
2117 // Type feedback information. 2117 // Type feedback information.
2118 TypeFeedbackId AssignmentFeedbackId() { return reuse(id()); } 2118 TypeFeedbackId AssignmentFeedbackId() { return reuse(id()); }
2119 void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* zone); 2119 void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* zone);
(...skipping 10 matching lines...) Expand all
2130 Assignment(Isolate* isolate, 2130 Assignment(Isolate* isolate,
2131 Token::Value op, 2131 Token::Value op,
2132 Expression* target, 2132 Expression* target,
2133 Expression* value, 2133 Expression* value,
2134 int pos); 2134 int pos);
2135 2135
2136 template<class Visitor> 2136 template<class Visitor>
2137 void Init(Isolate* isolate, AstNodeFactory<Visitor>* factory) { 2137 void Init(Isolate* isolate, AstNodeFactory<Visitor>* factory) {
2138 ASSERT(Token::IsAssignmentOp(op_)); 2138 ASSERT(Token::IsAssignmentOp(op_));
2139 if (is_compound()) { 2139 if (is_compound()) {
2140 binary_operation_ = 2140 binary_operation_ = factory->NewBinaryOperation(
2141 factory->NewBinaryOperation(binary_op(), target_, value_, pos_ + 1); 2141 binary_op(), target_, value_, position() + 1);
2142 } 2142 }
2143 } 2143 }
2144 2144
2145 private: 2145 private:
2146 Token::Value op_; 2146 Token::Value op_;
2147 Expression* target_; 2147 Expression* target_;
2148 Expression* value_; 2148 Expression* value_;
2149 int pos_;
2150 BinaryOperation* binary_operation_; 2149 BinaryOperation* binary_operation_;
2151 const BailoutId assignment_id_; 2150 const BailoutId assignment_id_;
2152 2151
2153 bool is_monomorphic_ : 1; 2152 bool is_monomorphic_ : 1;
2154 bool is_uninitialized_ : 1; 2153 bool is_uninitialized_ : 1;
2155 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, 2154 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed,
2156 // must have extra bit. 2155 // must have extra bit.
2157 SmallMapList receiver_types_; 2156 SmallMapList receiver_types_;
2158 }; 2157 };
2159 2158
2160 2159
2161 class Yield V8_FINAL : public Expression { 2160 class Yield V8_FINAL : public Expression {
2162 public: 2161 public:
2163 DECLARE_NODE_TYPE(Yield) 2162 DECLARE_NODE_TYPE(Yield)
2164 2163
2165 enum Kind { 2164 enum Kind {
2166 INITIAL, // The initial yield that returns the unboxed generator object. 2165 INITIAL, // The initial yield that returns the unboxed generator object.
2167 SUSPEND, // A normal yield: { value: EXPRESSION, done: false } 2166 SUSPEND, // A normal yield: { value: EXPRESSION, done: false }
2168 DELEGATING, // A yield*. 2167 DELEGATING, // A yield*.
2169 FINAL // A return: { value: EXPRESSION, done: true } 2168 FINAL // A return: { value: EXPRESSION, done: true }
2170 }; 2169 };
2171 2170
2172 Expression* generator_object() const { return generator_object_; } 2171 Expression* generator_object() const { return generator_object_; }
2173 Expression* expression() const { return expression_; } 2172 Expression* expression() const { return expression_; }
2174 Kind yield_kind() const { return yield_kind_; } 2173 Kind yield_kind() const { return yield_kind_; }
2175 virtual int position() const V8_OVERRIDE { return pos_; }
2176 2174
2177 // Delegating yield surrounds the "yield" in a "try/catch". This index 2175 // Delegating yield surrounds the "yield" in a "try/catch". This index
2178 // locates the catch handler in the handler table, and is equivalent to 2176 // locates the catch handler in the handler table, and is equivalent to
2179 // TryCatchStatement::index(). 2177 // TryCatchStatement::index().
2180 int index() const { 2178 int index() const {
2181 ASSERT(yield_kind() == DELEGATING); 2179 ASSERT(yield_kind() == DELEGATING);
2182 return index_; 2180 return index_;
2183 } 2181 }
2184 void set_index(int index) { 2182 void set_index(int index) {
2185 ASSERT(yield_kind() == DELEGATING); 2183 ASSERT(yield_kind() == DELEGATING);
2186 index_ = index; 2184 index_ = index;
2187 } 2185 }
2188 2186
2189 protected: 2187 protected:
2190 Yield(Isolate* isolate, 2188 Yield(Isolate* isolate,
2191 Expression* generator_object, 2189 Expression* generator_object,
2192 Expression* expression, 2190 Expression* expression,
2193 Kind yield_kind, 2191 Kind yield_kind,
2194 int pos) 2192 int pos)
2195 : Expression(isolate), 2193 : Expression(isolate, pos),
2196 generator_object_(generator_object), 2194 generator_object_(generator_object),
2197 expression_(expression), 2195 expression_(expression),
2198 yield_kind_(yield_kind), 2196 yield_kind_(yield_kind),
2199 index_(-1), 2197 index_(-1) { }
2200 pos_(pos) { }
2201 2198
2202 private: 2199 private:
2203 Expression* generator_object_; 2200 Expression* generator_object_;
2204 Expression* expression_; 2201 Expression* expression_;
2205 Kind yield_kind_; 2202 Kind yield_kind_;
2206 int index_; 2203 int index_;
2207 int pos_;
2208 }; 2204 };
2209 2205
2210 2206
2211 class Throw V8_FINAL : public Expression { 2207 class Throw V8_FINAL : public Expression {
2212 public: 2208 public:
2213 DECLARE_NODE_TYPE(Throw) 2209 DECLARE_NODE_TYPE(Throw)
2214 2210
2215 Expression* exception() const { return exception_; } 2211 Expression* exception() const { return exception_; }
2216 virtual int position() const V8_OVERRIDE { return pos_; }
2217 2212
2218 protected: 2213 protected:
2219 Throw(Isolate* isolate, Expression* exception, int pos) 2214 Throw(Isolate* isolate, Expression* exception, int pos)
2220 : Expression(isolate), exception_(exception), pos_(pos) {} 2215 : Expression(isolate, pos), exception_(exception) {}
2221 2216
2222 private: 2217 private:
2223 Expression* exception_; 2218 Expression* exception_;
2224 int pos_;
2225 }; 2219 };
2226 2220
2227 2221
2228 class FunctionLiteral V8_FINAL : public Expression { 2222 class FunctionLiteral V8_FINAL : public Expression {
2229 public: 2223 public:
2230 enum FunctionType { 2224 enum FunctionType {
2231 ANONYMOUS_EXPRESSION, 2225 ANONYMOUS_EXPRESSION,
2232 NAMED_EXPRESSION, 2226 NAMED_EXPRESSION,
2233 DECLARATION 2227 DECLARATION
2234 }; 2228 };
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
2329 Scope* scope, 2323 Scope* scope,
2330 ZoneList<Statement*>* body, 2324 ZoneList<Statement*>* body,
2331 int materialized_literal_count, 2325 int materialized_literal_count,
2332 int expected_property_count, 2326 int expected_property_count,
2333 int handler_count, 2327 int handler_count,
2334 int parameter_count, 2328 int parameter_count,
2335 FunctionType function_type, 2329 FunctionType function_type,
2336 ParameterFlag has_duplicate_parameters, 2330 ParameterFlag has_duplicate_parameters,
2337 IsFunctionFlag is_function, 2331 IsFunctionFlag is_function,
2338 IsParenthesizedFlag is_parenthesized, 2332 IsParenthesizedFlag is_parenthesized,
2339 IsGeneratorFlag is_generator) 2333 IsGeneratorFlag is_generator,
2340 : Expression(isolate), 2334 int position)
2335 : Expression(isolate, position),
2341 name_(name), 2336 name_(name),
2342 scope_(scope), 2337 scope_(scope),
2343 body_(body), 2338 body_(body),
2344 inferred_name_(isolate->factory()->empty_string()), 2339 inferred_name_(isolate->factory()->empty_string()),
2345 dont_optimize_reason_(kNoReason), 2340 dont_optimize_reason_(kNoReason),
2346 materialized_literal_count_(materialized_literal_count), 2341 materialized_literal_count_(materialized_literal_count),
2347 expected_property_count_(expected_property_count), 2342 expected_property_count_(expected_property_count),
2348 handler_count_(handler_count), 2343 handler_count_(handler_count),
2349 parameter_count_(parameter_count), 2344 parameter_count_(parameter_count),
2350 function_token_position_(RelocInfo::kNoPosition) { 2345 function_token_position_(RelocInfo::kNoPosition) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2387 public: 2382 public:
2388 DECLARE_NODE_TYPE(SharedFunctionInfoLiteral) 2383 DECLARE_NODE_TYPE(SharedFunctionInfoLiteral)
2389 2384
2390 Handle<SharedFunctionInfo> shared_function_info() const { 2385 Handle<SharedFunctionInfo> shared_function_info() const {
2391 return shared_function_info_; 2386 return shared_function_info_;
2392 } 2387 }
2393 2388
2394 protected: 2389 protected:
2395 SharedFunctionInfoLiteral( 2390 SharedFunctionInfoLiteral(
2396 Isolate* isolate, 2391 Isolate* isolate,
2397 Handle<SharedFunctionInfo> shared_function_info) 2392 Handle<SharedFunctionInfo> shared_function_info,
2398 : Expression(isolate), 2393 int pos)
2394 : Expression(isolate, pos),
2399 shared_function_info_(shared_function_info) { } 2395 shared_function_info_(shared_function_info) { }
2400 2396
2401 private: 2397 private:
2402 Handle<SharedFunctionInfo> shared_function_info_; 2398 Handle<SharedFunctionInfo> shared_function_info_;
2403 }; 2399 };
2404 2400
2405 2401
2406 class ThisFunction V8_FINAL : public Expression { 2402 class ThisFunction V8_FINAL : public Expression {
2407 public: 2403 public:
2408 DECLARE_NODE_TYPE(ThisFunction) 2404 DECLARE_NODE_TYPE(ThisFunction)
2409 2405
2410 protected: 2406 protected:
2411 explicit ThisFunction(Isolate* isolate): Expression(isolate) {} 2407 explicit ThisFunction(Isolate* isolate, int pos): Expression(isolate, pos) {}
2412 }; 2408 };
2413 2409
2414 #undef DECLARE_NODE_TYPE 2410 #undef DECLARE_NODE_TYPE
2415 2411
2416 2412
2417 // ---------------------------------------------------------------------------- 2413 // ----------------------------------------------------------------------------
2418 // Regular expressions 2414 // Regular expressions
2419 2415
2420 2416
2421 class RegExpVisitor BASE_EMBEDDED { 2417 class RegExpVisitor BASE_EMBEDDED {
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
2768 static RegExpEmpty* GetInstance() { 2764 static RegExpEmpty* GetInstance() {
2769 static RegExpEmpty* instance = ::new RegExpEmpty(); 2765 static RegExpEmpty* instance = ::new RegExpEmpty();
2770 return instance; 2766 return instance;
2771 } 2767 }
2772 }; 2768 };
2773 2769
2774 2770
2775 // ---------------------------------------------------------------------------- 2771 // ----------------------------------------------------------------------------
2776 // Out-of-line inline constructors (to side-step cyclic dependencies). 2772 // Out-of-line inline constructors (to side-step cyclic dependencies).
2777 2773
2778 inline ModuleVariable::ModuleVariable(VariableProxy* proxy) 2774 inline ModuleVariable::ModuleVariable(VariableProxy* proxy, int pos)
2779 : Module(proxy->interface()), 2775 : Module(proxy->interface(), pos),
2780 proxy_(proxy) { 2776 proxy_(proxy) {
2781 } 2777 }
2782 2778
2783 2779
2784 // ---------------------------------------------------------------------------- 2780 // ----------------------------------------------------------------------------
2785 // Basic visitor 2781 // Basic visitor
2786 // - leaf node visitors are abstract. 2782 // - leaf node visitors are abstract.
2787 2783
2788 class AstVisitor BASE_EMBEDDED { 2784 class AstVisitor BASE_EMBEDDED {
2789 public: 2785 public:
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
2886 zone_(zone) { } 2882 zone_(zone) { }
2887 2883
2888 Visitor* visitor() { return &visitor_; } 2884 Visitor* visitor() { return &visitor_; }
2889 2885
2890 #define VISIT_AND_RETURN(NodeType, node) \ 2886 #define VISIT_AND_RETURN(NodeType, node) \
2891 visitor_.Visit##NodeType((node)); \ 2887 visitor_.Visit##NodeType((node)); \
2892 return node; 2888 return node;
2893 2889
2894 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy, 2890 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy,
2895 VariableMode mode, 2891 VariableMode mode,
2896 Scope* scope) { 2892 Scope* scope,
2893 int pos) {
2897 VariableDeclaration* decl = 2894 VariableDeclaration* decl =
2898 new(zone_) VariableDeclaration(proxy, mode, scope); 2895 new(zone_) VariableDeclaration(proxy, mode, scope, pos);
2899 VISIT_AND_RETURN(VariableDeclaration, decl) 2896 VISIT_AND_RETURN(VariableDeclaration, decl)
2900 } 2897 }
2901 2898
2902 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy, 2899 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy,
2903 VariableMode mode, 2900 VariableMode mode,
2904 FunctionLiteral* fun, 2901 FunctionLiteral* fun,
2905 Scope* scope) { 2902 Scope* scope,
2903 int pos) {
2906 FunctionDeclaration* decl = 2904 FunctionDeclaration* decl =
2907 new(zone_) FunctionDeclaration(proxy, mode, fun, scope); 2905 new(zone_) FunctionDeclaration(proxy, mode, fun, scope, pos);
2908 VISIT_AND_RETURN(FunctionDeclaration, decl) 2906 VISIT_AND_RETURN(FunctionDeclaration, decl)
2909 } 2907 }
2910 2908
2911 ModuleDeclaration* NewModuleDeclaration(VariableProxy* proxy, 2909 ModuleDeclaration* NewModuleDeclaration(VariableProxy* proxy,
2912 Module* module, 2910 Module* module,
2913 Scope* scope) { 2911 Scope* scope,
2912 int pos) {
2914 ModuleDeclaration* decl = 2913 ModuleDeclaration* decl =
2915 new(zone_) ModuleDeclaration(proxy, module, scope); 2914 new(zone_) ModuleDeclaration(proxy, module, scope, pos);
2916 VISIT_AND_RETURN(ModuleDeclaration, decl) 2915 VISIT_AND_RETURN(ModuleDeclaration, decl)
2917 } 2916 }
2918 2917
2919 ImportDeclaration* NewImportDeclaration(VariableProxy* proxy, 2918 ImportDeclaration* NewImportDeclaration(VariableProxy* proxy,
2920 Module* module, 2919 Module* module,
2921 Scope* scope) { 2920 Scope* scope,
2921 int pos) {
2922 ImportDeclaration* decl = 2922 ImportDeclaration* decl =
2923 new(zone_) ImportDeclaration(proxy, module, scope); 2923 new(zone_) ImportDeclaration(proxy, module, scope, pos);
2924 VISIT_AND_RETURN(ImportDeclaration, decl) 2924 VISIT_AND_RETURN(ImportDeclaration, decl)
2925 } 2925 }
2926 2926
2927 ExportDeclaration* NewExportDeclaration(VariableProxy* proxy, 2927 ExportDeclaration* NewExportDeclaration(VariableProxy* proxy,
2928 Scope* scope) { 2928 Scope* scope,
2929 int pos) {
2929 ExportDeclaration* decl = 2930 ExportDeclaration* decl =
2930 new(zone_) ExportDeclaration(proxy, scope); 2931 new(zone_) ExportDeclaration(proxy, scope, pos);
2931 VISIT_AND_RETURN(ExportDeclaration, decl) 2932 VISIT_AND_RETURN(ExportDeclaration, decl)
2932 } 2933 }
2933 2934
2934 ModuleLiteral* NewModuleLiteral(Block* body, Interface* interface) { 2935 ModuleLiteral* NewModuleLiteral(Block* body, Interface* interface, int pos) {
2935 ModuleLiteral* module = new(zone_) ModuleLiteral(body, interface); 2936 ModuleLiteral* module = new(zone_) ModuleLiteral(body, interface, pos);
2936 VISIT_AND_RETURN(ModuleLiteral, module) 2937 VISIT_AND_RETURN(ModuleLiteral, module)
2937 } 2938 }
2938 2939
2939 ModuleVariable* NewModuleVariable(VariableProxy* proxy) { 2940 ModuleVariable* NewModuleVariable(VariableProxy* proxy, int pos) {
2940 ModuleVariable* module = new(zone_) ModuleVariable(proxy); 2941 ModuleVariable* module = new(zone_) ModuleVariable(proxy, pos);
2941 VISIT_AND_RETURN(ModuleVariable, module) 2942 VISIT_AND_RETURN(ModuleVariable, module)
2942 } 2943 }
2943 2944
2944 ModulePath* NewModulePath(Module* origin, Handle<String> name) { 2945 ModulePath* NewModulePath(Module* origin, Handle<String> name, int pos) {
2945 ModulePath* module = new(zone_) ModulePath(origin, name, zone_); 2946 ModulePath* module = new(zone_) ModulePath(origin, name, zone_, pos);
2946 VISIT_AND_RETURN(ModulePath, module) 2947 VISIT_AND_RETURN(ModulePath, module)
2947 } 2948 }
2948 2949
2949 ModuleUrl* NewModuleUrl(Handle<String> url) { 2950 ModuleUrl* NewModuleUrl(Handle<String> url, int pos) {
2950 ModuleUrl* module = new(zone_) ModuleUrl(url, zone_); 2951 ModuleUrl* module = new(zone_) ModuleUrl(url, zone_, pos);
2951 VISIT_AND_RETURN(ModuleUrl, module) 2952 VISIT_AND_RETURN(ModuleUrl, module)
2952 } 2953 }
2953 2954
2954 Block* NewBlock(ZoneStringList* labels, 2955 Block* NewBlock(ZoneStringList* labels,
2955 int capacity, 2956 int capacity,
2956 bool is_initializer_block) { 2957 bool is_initializer_block,
2958 int pos) {
2957 Block* block = new(zone_) Block( 2959 Block* block = new(zone_) Block(
2958 isolate_, labels, capacity, is_initializer_block, zone_); 2960 isolate_, labels, capacity, is_initializer_block, pos, zone_);
2959 VISIT_AND_RETURN(Block, block) 2961 VISIT_AND_RETURN(Block, block)
2960 } 2962 }
2961 2963
2962 #define STATEMENT_WITH_LABELS(NodeType) \ 2964 #define STATEMENT_WITH_LABELS(NodeType) \
2963 NodeType* New##NodeType(ZoneStringList* labels) { \ 2965 NodeType* New##NodeType(ZoneStringList* labels, int pos) { \
2964 NodeType* stmt = new(zone_) NodeType(isolate_, labels); \ 2966 NodeType* stmt = new(zone_) NodeType(isolate_, labels, pos); \
2965 VISIT_AND_RETURN(NodeType, stmt); \ 2967 VISIT_AND_RETURN(NodeType, stmt); \
2966 } 2968 }
2967 STATEMENT_WITH_LABELS(DoWhileStatement) 2969 STATEMENT_WITH_LABELS(DoWhileStatement)
2968 STATEMENT_WITH_LABELS(WhileStatement) 2970 STATEMENT_WITH_LABELS(WhileStatement)
2969 STATEMENT_WITH_LABELS(ForStatement) 2971 STATEMENT_WITH_LABELS(ForStatement)
2970 STATEMENT_WITH_LABELS(SwitchStatement) 2972 STATEMENT_WITH_LABELS(SwitchStatement)
2971 #undef STATEMENT_WITH_LABELS 2973 #undef STATEMENT_WITH_LABELS
2972 2974
2973 ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode, 2975 ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode,
2974 ZoneStringList* labels) { 2976 ZoneStringList* labels,
2977 int pos) {
2975 switch (visit_mode) { 2978 switch (visit_mode) {
2976 case ForEachStatement::ENUMERATE: { 2979 case ForEachStatement::ENUMERATE: {
2977 ForInStatement* stmt = new(zone_) ForInStatement(isolate_, labels); 2980 ForInStatement* stmt = new(zone_) ForInStatement(isolate_, labels, pos);
2978 VISIT_AND_RETURN(ForInStatement, stmt); 2981 VISIT_AND_RETURN(ForInStatement, stmt);
2979 } 2982 }
2980 case ForEachStatement::ITERATE: { 2983 case ForEachStatement::ITERATE: {
2981 ForOfStatement* stmt = new(zone_) ForOfStatement(isolate_, labels); 2984 ForOfStatement* stmt = new(zone_) ForOfStatement(isolate_, labels, pos);
2982 VISIT_AND_RETURN(ForOfStatement, stmt); 2985 VISIT_AND_RETURN(ForOfStatement, stmt);
2983 } 2986 }
2984 } 2987 }
2985 UNREACHABLE(); 2988 UNREACHABLE();
2986 return NULL; 2989 return NULL;
2987 } 2990 }
2988 2991
2989 ModuleStatement* NewModuleStatement(VariableProxy* proxy, Block* body) { 2992 ModuleStatement* NewModuleStatement(
2990 ModuleStatement* stmt = new(zone_) ModuleStatement(proxy, body); 2993 VariableProxy* proxy, Block* body, int pos) {
2994 ModuleStatement* stmt = new(zone_) ModuleStatement(proxy, body, pos);
2991 VISIT_AND_RETURN(ModuleStatement, stmt) 2995 VISIT_AND_RETURN(ModuleStatement, stmt)
2992 } 2996 }
2993 2997
2994 ExpressionStatement* NewExpressionStatement(Expression* expression) { 2998 ExpressionStatement* NewExpressionStatement(Expression* expression, int pos) {
2995 ExpressionStatement* stmt = new(zone_) ExpressionStatement(expression); 2999 ExpressionStatement* stmt = new(zone_) ExpressionStatement(expression, pos);
2996 VISIT_AND_RETURN(ExpressionStatement, stmt) 3000 VISIT_AND_RETURN(ExpressionStatement, stmt)
2997 } 3001 }
2998 3002
2999 ContinueStatement* NewContinueStatement(IterationStatement* target) { 3003 ContinueStatement* NewContinueStatement(IterationStatement* target, int pos) {
3000 ContinueStatement* stmt = new(zone_) ContinueStatement(target); 3004 ContinueStatement* stmt = new(zone_) ContinueStatement(target, pos);
3001 VISIT_AND_RETURN(ContinueStatement, stmt) 3005 VISIT_AND_RETURN(ContinueStatement, stmt)
3002 } 3006 }
3003 3007
3004 BreakStatement* NewBreakStatement(BreakableStatement* target) { 3008 BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) {
3005 BreakStatement* stmt = new(zone_) BreakStatement(target); 3009 BreakStatement* stmt = new(zone_) BreakStatement(target, pos);
3006 VISIT_AND_RETURN(BreakStatement, stmt) 3010 VISIT_AND_RETURN(BreakStatement, stmt)
3007 } 3011 }
3008 3012
3009 ReturnStatement* NewReturnStatement(Expression* expression) { 3013 ReturnStatement* NewReturnStatement(Expression* expression, int pos) {
3010 ReturnStatement* stmt = new(zone_) ReturnStatement(expression); 3014 ReturnStatement* stmt = new(zone_) ReturnStatement(expression, pos);
3011 VISIT_AND_RETURN(ReturnStatement, stmt) 3015 VISIT_AND_RETURN(ReturnStatement, stmt)
3012 } 3016 }
3013 3017
3014 WithStatement* NewWithStatement(Scope* scope, 3018 WithStatement* NewWithStatement(Scope* scope,
3015 Expression* expression, 3019 Expression* expression,
3016 Statement* statement) { 3020 Statement* statement,
3021 int pos) {
3017 WithStatement* stmt = new(zone_) WithStatement( 3022 WithStatement* stmt = new(zone_) WithStatement(
3018 scope, expression, statement); 3023 scope, expression, statement, pos);
3019 VISIT_AND_RETURN(WithStatement, stmt) 3024 VISIT_AND_RETURN(WithStatement, stmt)
3020 } 3025 }
3021 3026
3022 IfStatement* NewIfStatement(Expression* condition, 3027 IfStatement* NewIfStatement(Expression* condition,
3023 Statement* then_statement, 3028 Statement* then_statement,
3024 Statement* else_statement) { 3029 Statement* else_statement,
3030 int pos) {
3025 IfStatement* stmt = new(zone_) IfStatement( 3031 IfStatement* stmt = new(zone_) IfStatement(
3026 isolate_, condition, then_statement, else_statement); 3032 isolate_, condition, then_statement, else_statement, pos);
3027 VISIT_AND_RETURN(IfStatement, stmt) 3033 VISIT_AND_RETURN(IfStatement, stmt)
3028 } 3034 }
3029 3035
3030 TryCatchStatement* NewTryCatchStatement(int index, 3036 TryCatchStatement* NewTryCatchStatement(int index,
3031 Block* try_block, 3037 Block* try_block,
3032 Scope* scope, 3038 Scope* scope,
3033 Variable* variable, 3039 Variable* variable,
3034 Block* catch_block) { 3040 Block* catch_block,
3041 int pos) {
3035 TryCatchStatement* stmt = new(zone_) TryCatchStatement( 3042 TryCatchStatement* stmt = new(zone_) TryCatchStatement(
3036 index, try_block, scope, variable, catch_block); 3043 index, try_block, scope, variable, catch_block, pos);
3037 VISIT_AND_RETURN(TryCatchStatement, stmt) 3044 VISIT_AND_RETURN(TryCatchStatement, stmt)
3038 } 3045 }
3039 3046
3040 TryFinallyStatement* NewTryFinallyStatement(int index, 3047 TryFinallyStatement* NewTryFinallyStatement(int index,
3041 Block* try_block, 3048 Block* try_block,
3042 Block* finally_block) { 3049 Block* finally_block,
3050 int pos) {
3043 TryFinallyStatement* stmt = 3051 TryFinallyStatement* stmt =
3044 new(zone_) TryFinallyStatement(index, try_block, finally_block); 3052 new(zone_) TryFinallyStatement(index, try_block, finally_block, pos);
3045 VISIT_AND_RETURN(TryFinallyStatement, stmt) 3053 VISIT_AND_RETURN(TryFinallyStatement, stmt)
3046 } 3054 }
3047 3055
3048 DebuggerStatement* NewDebuggerStatement() { 3056 DebuggerStatement* NewDebuggerStatement(int pos) {
3049 DebuggerStatement* stmt = new(zone_) DebuggerStatement(); 3057 DebuggerStatement* stmt = new(zone_) DebuggerStatement(pos);
3050 VISIT_AND_RETURN(DebuggerStatement, stmt) 3058 VISIT_AND_RETURN(DebuggerStatement, stmt)
3051 } 3059 }
3052 3060
3053 EmptyStatement* NewEmptyStatement() { 3061 EmptyStatement* NewEmptyStatement(int pos) {
3054 return new(zone_) EmptyStatement(); 3062 return new(zone_) EmptyStatement(pos);
3055 } 3063 }
3056 3064
3057 Literal* NewLiteral(Handle<Object> handle) { 3065 Literal* NewLiteral(Handle<Object> handle, int pos) {
3058 Literal* lit = new(zone_) Literal(isolate_, handle); 3066 Literal* lit = new(zone_) Literal(isolate_, handle, pos);
3059 VISIT_AND_RETURN(Literal, lit) 3067 VISIT_AND_RETURN(Literal, lit)
3060 } 3068 }
3061 3069
3062 Literal* NewNumberLiteral(double number) { 3070 Literal* NewNumberLiteral(double number, int pos) {
3063 return NewLiteral(isolate_->factory()->NewNumber(number, TENURED)); 3071 return NewLiteral(isolate_->factory()->NewNumber(number, TENURED), pos);
3064 } 3072 }
3065 3073
3066 ObjectLiteral* NewObjectLiteral( 3074 ObjectLiteral* NewObjectLiteral(
3067 Handle<FixedArray> constant_properties, 3075 Handle<FixedArray> constant_properties,
3068 ZoneList<ObjectLiteral::Property*>* properties, 3076 ZoneList<ObjectLiteral::Property*>* properties,
3069 int literal_index, 3077 int literal_index,
3070 bool is_simple, 3078 bool is_simple,
3071 bool fast_elements, 3079 bool fast_elements,
3072 int depth, 3080 int depth,
3073 bool may_store_doubles, 3081 bool may_store_doubles,
3074 bool has_function) { 3082 bool has_function,
3083 int pos) {
3075 ObjectLiteral* lit = new(zone_) ObjectLiteral( 3084 ObjectLiteral* lit = new(zone_) ObjectLiteral(
3076 isolate_, constant_properties, properties, literal_index, 3085 isolate_, constant_properties, properties, literal_index,
3077 is_simple, fast_elements, depth, may_store_doubles, has_function); 3086 is_simple, fast_elements, depth, may_store_doubles, has_function, pos);
3078 VISIT_AND_RETURN(ObjectLiteral, lit) 3087 VISIT_AND_RETURN(ObjectLiteral, lit)
3079 } 3088 }
3080 3089
3081 ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter, 3090 ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter,
3082 FunctionLiteral* value) { 3091 FunctionLiteral* value,
3092 int pos) {
3083 ObjectLiteral::Property* prop = 3093 ObjectLiteral::Property* prop =
3084 new(zone_) ObjectLiteral::Property(is_getter, value); 3094 new(zone_) ObjectLiteral::Property(is_getter, value);
3085 prop->set_key(NewLiteral(value->name())); 3095 prop->set_key(NewLiteral(value->name(), pos));
3086 return prop; // Not an AST node, will not be visited. 3096 return prop; // Not an AST node, will not be visited.
3087 } 3097 }
3088 3098
3089 RegExpLiteral* NewRegExpLiteral(Handle<String> pattern, 3099 RegExpLiteral* NewRegExpLiteral(Handle<String> pattern,
3090 Handle<String> flags, 3100 Handle<String> flags,
3091 int literal_index) { 3101 int literal_index,
3102 int pos) {
3092 RegExpLiteral* lit = 3103 RegExpLiteral* lit =
3093 new(zone_) RegExpLiteral(isolate_, pattern, flags, literal_index); 3104 new(zone_) RegExpLiteral(isolate_, pattern, flags, literal_index, pos);
3094 VISIT_AND_RETURN(RegExpLiteral, lit); 3105 VISIT_AND_RETURN(RegExpLiteral, lit);
3095 } 3106 }
3096 3107
3097 ArrayLiteral* NewArrayLiteral(Handle<FixedArray> constant_elements, 3108 ArrayLiteral* NewArrayLiteral(Handle<FixedArray> constant_elements,
3098 ZoneList<Expression*>* values, 3109 ZoneList<Expression*>* values,
3099 int literal_index, 3110 int literal_index,
3100 bool is_simple, 3111 bool is_simple,
3101 int depth) { 3112 int depth,
3113 int pos) {
3102 ArrayLiteral* lit = new(zone_) ArrayLiteral( 3114 ArrayLiteral* lit = new(zone_) ArrayLiteral(
3103 isolate_, constant_elements, values, literal_index, is_simple, depth); 3115 isolate_, constant_elements, values, literal_index, is_simple,
3116 depth, pos);
3104 VISIT_AND_RETURN(ArrayLiteral, lit) 3117 VISIT_AND_RETURN(ArrayLiteral, lit)
3105 } 3118 }
3106 3119
3107 VariableProxy* NewVariableProxy(Variable* var) { 3120 VariableProxy* NewVariableProxy(Variable* var,
3108 VariableProxy* proxy = new(zone_) VariableProxy(isolate_, var); 3121 int pos = RelocInfo::kNoPosition) {
3122 VariableProxy* proxy = new(zone_) VariableProxy(isolate_, var, pos);
3109 VISIT_AND_RETURN(VariableProxy, proxy) 3123 VISIT_AND_RETURN(VariableProxy, proxy)
3110 } 3124 }
3111 3125
3112 VariableProxy* NewVariableProxy(Handle<String> name, 3126 VariableProxy* NewVariableProxy(Handle<String> name,
3113 bool is_this, 3127 bool is_this,
3114 Interface* interface = Interface::NewValue(), 3128 Interface* interface = Interface::NewValue(),
3115 int position = RelocInfo::kNoPosition) { 3129 int position = RelocInfo::kNoPosition) {
3116 VariableProxy* proxy = 3130 VariableProxy* proxy =
3117 new(zone_) VariableProxy(isolate_, name, is_this, interface, position); 3131 new(zone_) VariableProxy(isolate_, name, is_this, interface, position);
3118 VISIT_AND_RETURN(VariableProxy, proxy) 3132 VISIT_AND_RETURN(VariableProxy, proxy)
(...skipping 13 matching lines...) Expand all
3132 3146
3133 CallNew* NewCallNew(Expression* expression, 3147 CallNew* NewCallNew(Expression* expression,
3134 ZoneList<Expression*>* arguments, 3148 ZoneList<Expression*>* arguments,
3135 int pos) { 3149 int pos) {
3136 CallNew* call = new(zone_) CallNew(isolate_, expression, arguments, pos); 3150 CallNew* call = new(zone_) CallNew(isolate_, expression, arguments, pos);
3137 VISIT_AND_RETURN(CallNew, call) 3151 VISIT_AND_RETURN(CallNew, call)
3138 } 3152 }
3139 3153
3140 CallRuntime* NewCallRuntime(Handle<String> name, 3154 CallRuntime* NewCallRuntime(Handle<String> name,
3141 const Runtime::Function* function, 3155 const Runtime::Function* function,
3142 ZoneList<Expression*>* arguments) { 3156 ZoneList<Expression*>* arguments,
3157 int pos) {
3143 CallRuntime* call = 3158 CallRuntime* call =
3144 new(zone_) CallRuntime(isolate_, name, function, arguments); 3159 new(zone_) CallRuntime(isolate_, name, function, arguments, pos);
3145 VISIT_AND_RETURN(CallRuntime, call) 3160 VISIT_AND_RETURN(CallRuntime, call)
3146 } 3161 }
3147 3162
3148 UnaryOperation* NewUnaryOperation(Token::Value op, 3163 UnaryOperation* NewUnaryOperation(Token::Value op,
3149 Expression* expression, 3164 Expression* expression,
3150 int pos) { 3165 int pos) {
3151 UnaryOperation* node = 3166 UnaryOperation* node =
3152 new(zone_) UnaryOperation(isolate_, op, expression, pos); 3167 new(zone_) UnaryOperation(isolate_, op, expression, pos);
3153 VISIT_AND_RETURN(UnaryOperation, node) 3168 VISIT_AND_RETURN(UnaryOperation, node)
3154 } 3169 }
(...skipping 22 matching lines...) Expand all
3177 int pos) { 3192 int pos) {
3178 CompareOperation* node = 3193 CompareOperation* node =
3179 new(zone_) CompareOperation(isolate_, op, left, right, pos); 3194 new(zone_) CompareOperation(isolate_, op, left, right, pos);
3180 VISIT_AND_RETURN(CompareOperation, node) 3195 VISIT_AND_RETURN(CompareOperation, node)
3181 } 3196 }
3182 3197
3183 Conditional* NewConditional(Expression* condition, 3198 Conditional* NewConditional(Expression* condition,
3184 Expression* then_expression, 3199 Expression* then_expression,
3185 Expression* else_expression, 3200 Expression* else_expression,
3186 int then_expression_position, 3201 int then_expression_position,
3187 int else_expression_position) { 3202 int else_expression_position,
3203 int position) {
3188 Conditional* cond = new(zone_) Conditional( 3204 Conditional* cond = new(zone_) Conditional(
3189 isolate_, condition, then_expression, else_expression, 3205 isolate_, condition, then_expression, else_expression,
3190 then_expression_position, else_expression_position); 3206 then_expression_position, else_expression_position, position);
3191 VISIT_AND_RETURN(Conditional, cond) 3207 VISIT_AND_RETURN(Conditional, cond)
3192 } 3208 }
3193 3209
3194 Assignment* NewAssignment(Token::Value op, 3210 Assignment* NewAssignment(Token::Value op,
3195 Expression* target, 3211 Expression* target,
3196 Expression* value, 3212 Expression* value,
3197 int pos) { 3213 int pos) {
3198 Assignment* assign = 3214 Assignment* assign =
3199 new(zone_) Assignment(isolate_, op, target, value, pos); 3215 new(zone_) Assignment(isolate_, op, target, value, pos);
3200 assign->Init(isolate_, this); 3216 assign->Init(isolate_, this);
(...skipping 19 matching lines...) Expand all
3220 Scope* scope, 3236 Scope* scope,
3221 ZoneList<Statement*>* body, 3237 ZoneList<Statement*>* body,
3222 int materialized_literal_count, 3238 int materialized_literal_count,
3223 int expected_property_count, 3239 int expected_property_count,
3224 int handler_count, 3240 int handler_count,
3225 int parameter_count, 3241 int parameter_count,
3226 FunctionLiteral::ParameterFlag has_duplicate_parameters, 3242 FunctionLiteral::ParameterFlag has_duplicate_parameters,
3227 FunctionLiteral::FunctionType function_type, 3243 FunctionLiteral::FunctionType function_type,
3228 FunctionLiteral::IsFunctionFlag is_function, 3244 FunctionLiteral::IsFunctionFlag is_function,
3229 FunctionLiteral::IsParenthesizedFlag is_parenthesized, 3245 FunctionLiteral::IsParenthesizedFlag is_parenthesized,
3230 FunctionLiteral::IsGeneratorFlag is_generator) { 3246 FunctionLiteral::IsGeneratorFlag is_generator,
3247 int position) {
3231 FunctionLiteral* lit = new(zone_) FunctionLiteral( 3248 FunctionLiteral* lit = new(zone_) FunctionLiteral(
3232 isolate_, name, scope, body, 3249 isolate_, name, scope, body,
3233 materialized_literal_count, expected_property_count, handler_count, 3250 materialized_literal_count, expected_property_count, handler_count,
3234 parameter_count, function_type, has_duplicate_parameters, is_function, 3251 parameter_count, function_type, has_duplicate_parameters, is_function,
3235 is_parenthesized, is_generator); 3252 is_parenthesized, is_generator, position);
3236 // Top-level literal doesn't count for the AST's properties. 3253 // Top-level literal doesn't count for the AST's properties.
3237 if (is_function == FunctionLiteral::kIsFunction) { 3254 if (is_function == FunctionLiteral::kIsFunction) {
3238 visitor_.VisitFunctionLiteral(lit); 3255 visitor_.VisitFunctionLiteral(lit);
3239 } 3256 }
3240 return lit; 3257 return lit;
3241 } 3258 }
3242 3259
3243 SharedFunctionInfoLiteral* NewSharedFunctionInfoLiteral( 3260 SharedFunctionInfoLiteral* NewSharedFunctionInfoLiteral(
3244 Handle<SharedFunctionInfo> shared_function_info) { 3261 Handle<SharedFunctionInfo> shared_function_info, int pos) {
3245 SharedFunctionInfoLiteral* lit = 3262 SharedFunctionInfoLiteral* lit =
3246 new(zone_) SharedFunctionInfoLiteral(isolate_, shared_function_info); 3263 new(zone_) SharedFunctionInfoLiteral(
3264 isolate_, shared_function_info, pos);
3247 VISIT_AND_RETURN(SharedFunctionInfoLiteral, lit) 3265 VISIT_AND_RETURN(SharedFunctionInfoLiteral, lit)
3248 } 3266 }
3249 3267
3250 ThisFunction* NewThisFunction() { 3268 ThisFunction* NewThisFunction(int pos) {
3251 ThisFunction* fun = new(zone_) ThisFunction(isolate_); 3269 ThisFunction* fun = new(zone_) ThisFunction(isolate_, pos);
3252 VISIT_AND_RETURN(ThisFunction, fun) 3270 VISIT_AND_RETURN(ThisFunction, fun)
3253 } 3271 }
3254 3272
3255 #undef VISIT_AND_RETURN 3273 #undef VISIT_AND_RETURN
3256 3274
3257 private: 3275 private:
3258 Isolate* isolate_; 3276 Isolate* isolate_;
3259 Zone* zone_; 3277 Zone* zone_;
3260 Visitor visitor_; 3278 Visitor visitor_;
3261 }; 3279 };
3262 3280
3263 3281
3264 } } // namespace v8::internal 3282 } } // namespace v8::internal
3265 3283
3266 #endif // V8_AST_H_ 3284 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast.cc » ('j') | src/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698