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

Side by Side Diff: src/ast.h

Issue 185653004: Experimental parser: merge to r19637 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 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 | « src/assembler.cc ('k') | src/ast.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // 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 14 matching lines...) Expand all
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_AST_H_ 28 #ifndef V8_AST_H_
29 #define V8_AST_H_ 29 #define V8_AST_H_
30 30
31 #include "v8.h" 31 #include "v8.h"
32 32
33 #include "assembler.h" 33 #include "assembler.h"
34 #include "factory.h" 34 #include "factory.h"
35 #include "feedback-slots.h"
35 #include "isolate.h" 36 #include "isolate.h"
36 #include "jsregexp.h" 37 #include "jsregexp.h"
37 #include "list-inl.h" 38 #include "list-inl.h"
38 #include "runtime.h" 39 #include "runtime.h"
39 #include "small-pointer-list.h" 40 #include "small-pointer-list.h"
40 #include "smart-pointers.h" 41 #include "smart-pointers.h"
41 #include "token.h" 42 #include "token.h"
42 #include "types.h" 43 #include "types.h"
43 #include "utils.h" 44 #include "utils.h"
44 #include "variables.h" 45 #include "variables.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 kDontSelfOptimize, 175 kDontSelfOptimize,
175 kDontSoftInline, 176 kDontSoftInline,
176 kDontCache 177 kDontCache
177 }; 178 };
178 179
179 180
180 class AstProperties V8_FINAL BASE_EMBEDDED { 181 class AstProperties V8_FINAL BASE_EMBEDDED {
181 public: 182 public:
182 class Flags : public EnumSet<AstPropertiesFlag, int> {}; 183 class Flags : public EnumSet<AstPropertiesFlag, int> {};
183 184
184 AstProperties() : node_count_(0) { } 185 AstProperties() : node_count_(0) {}
185 186
186 Flags* flags() { return &flags_; } 187 Flags* flags() { return &flags_; }
187 int node_count() { return node_count_; } 188 int node_count() { return node_count_; }
188 void add_node_count(int count) { node_count_ += count; } 189 void add_node_count(int count) { node_count_ += count; }
189 190
190 private: 191 private:
191 Flags flags_; 192 Flags flags_;
192 int node_count_; 193 int node_count_;
193 }; 194 };
194 195
(...skipping 24 matching lines...) Expand all
219 type* As##type() { return Is##type() ? reinterpret_cast<type*>(this) : NULL; } 220 type* As##type() { return Is##type() ? reinterpret_cast<type*>(this) : NULL; }
220 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 221 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
221 #undef DECLARE_NODE_FUNCTIONS 222 #undef DECLARE_NODE_FUNCTIONS
222 223
223 virtual TargetCollector* AsTargetCollector() { return NULL; } 224 virtual TargetCollector* AsTargetCollector() { return NULL; }
224 virtual BreakableStatement* AsBreakableStatement() { return NULL; } 225 virtual BreakableStatement* AsBreakableStatement() { return NULL; }
225 virtual IterationStatement* AsIterationStatement() { return NULL; } 226 virtual IterationStatement* AsIterationStatement() { return NULL; }
226 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } 227 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; }
227 228
228 protected: 229 protected:
229 static int GetNextId(Isolate* isolate) { 230 static int GetNextId(Zone* zone) {
230 return ReserveIdRange(isolate, 1); 231 return ReserveIdRange(zone, 1);
231 } 232 }
232 233
233 static int ReserveIdRange(Isolate* isolate, int n) { 234 static int ReserveIdRange(Zone* zone, int n) {
234 int tmp = isolate->ast_node_id(); 235 int tmp = zone->isolate()->ast_node_id();
235 isolate->set_ast_node_id(tmp + n); 236 zone->isolate()->set_ast_node_id(tmp + n);
236 return tmp; 237 return tmp;
237 } 238 }
238 239
239 // Some nodes re-use bailout IDs for type feedback. 240 // Some nodes re-use bailout IDs for type feedback.
240 static TypeFeedbackId reuse(BailoutId id) { 241 static TypeFeedbackId reuse(BailoutId id) {
241 return TypeFeedbackId(id.ToInt()); 242 return TypeFeedbackId(id.ToInt());
242 } 243 }
243 244
244 245
245 private: 246 private:
246 // Hidden to prevent accidental usage. It would have to load the 247 // Hidden to prevent accidental usage. It would have to load the
247 // current zone from the TLS. 248 // current zone from the TLS.
248 void* operator new(size_t size); 249 void* operator new(size_t size);
249 250
250 friend class CaseClause; // Generates AST IDs. 251 friend class CaseClause; // Generates AST IDs.
251 252
252 int position_; 253 int position_;
253 }; 254 };
254 255
255 256
256 class Statement : public AstNode { 257 class Statement : public AstNode {
257 public: 258 public:
258 explicit Statement(int position) : AstNode(position) {} 259 explicit Statement(Zone* zone, int position) : AstNode(position) {}
259 260
260 bool IsEmpty() { return AsEmptyStatement() != NULL; } 261 bool IsEmpty() { return AsEmptyStatement() != NULL; }
261 virtual bool IsJump() const { return false; } 262 virtual bool IsJump() const { return false; }
262 }; 263 };
263 264
264 265
265 class SmallMapList V8_FINAL { 266 class SmallMapList V8_FINAL {
266 public: 267 public:
267 SmallMapList() {} 268 SmallMapList() {}
268 SmallMapList(int capacity, Zone* zone) : list_(capacity, zone) {} 269 SmallMapList(int capacity, Zone* zone) : list_(capacity, zone) {}
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 } 371 }
371 372
372 // TODO(rossberg): this should move to its own AST node eventually. 373 // TODO(rossberg): this should move to its own AST node eventually.
373 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); 374 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle);
374 byte to_boolean_types() const { return to_boolean_types_; } 375 byte to_boolean_types() const { return to_boolean_types_; }
375 376
376 BailoutId id() const { return id_; } 377 BailoutId id() const { return id_; }
377 TypeFeedbackId test_id() const { return test_id_; } 378 TypeFeedbackId test_id() const { return test_id_; }
378 379
379 protected: 380 protected:
380 Expression(Isolate* isolate, int pos) 381 Expression(Zone* zone, int pos)
381 : AstNode(pos), 382 : AstNode(pos),
382 bounds_(Bounds::Unbounded(isolate)), 383 bounds_(Bounds::Unbounded(zone)),
383 id_(GetNextId(isolate)), 384 id_(GetNextId(zone)),
384 test_id_(GetNextId(isolate)) {} 385 test_id_(GetNextId(zone)) {}
385 void set_to_boolean_types(byte types) { to_boolean_types_ = types; } 386 void set_to_boolean_types(byte types) { to_boolean_types_ = types; }
386 387
387 private: 388 private:
388 Bounds bounds_; 389 Bounds bounds_;
389 byte to_boolean_types_; 390 byte to_boolean_types_;
390 391
391 const BailoutId id_; 392 const BailoutId id_;
392 const TypeFeedbackId test_id_; 393 const TypeFeedbackId test_id_;
393 }; 394 };
394 395
(...skipping 20 matching lines...) Expand all
415 // Testers. 416 // Testers.
416 bool is_target_for_anonymous() const { 417 bool is_target_for_anonymous() const {
417 return breakable_type_ == TARGET_FOR_ANONYMOUS; 418 return breakable_type_ == TARGET_FOR_ANONYMOUS;
418 } 419 }
419 420
420 BailoutId EntryId() const { return entry_id_; } 421 BailoutId EntryId() const { return entry_id_; }
421 BailoutId ExitId() const { return exit_id_; } 422 BailoutId ExitId() const { return exit_id_; }
422 423
423 protected: 424 protected:
424 BreakableStatement( 425 BreakableStatement(
425 Isolate* isolate, ZoneStringList* labels, 426 Zone* zone, ZoneStringList* labels,
426 BreakableType breakable_type, int position) 427 BreakableType breakable_type, int position)
427 : Statement(position), 428 : Statement(zone, position),
428 labels_(labels), 429 labels_(labels),
429 breakable_type_(breakable_type), 430 breakable_type_(breakable_type),
430 entry_id_(GetNextId(isolate)), 431 entry_id_(GetNextId(zone)),
431 exit_id_(GetNextId(isolate)) { 432 exit_id_(GetNextId(zone)) {
432 ASSERT(labels == NULL || labels->length() > 0); 433 ASSERT(labels == NULL || labels->length() > 0);
433 } 434 }
434 435
435 436
436 private: 437 private:
437 ZoneStringList* labels_; 438 ZoneStringList* labels_;
438 BreakableType breakable_type_; 439 BreakableType breakable_type_;
439 Label break_target_; 440 Label break_target_;
440 const BailoutId entry_id_; 441 const BailoutId entry_id_;
441 const BailoutId exit_id_; 442 const BailoutId exit_id_;
(...skipping 13 matching lines...) Expand all
455 456
456 virtual bool IsJump() const V8_OVERRIDE { 457 virtual bool IsJump() const V8_OVERRIDE {
457 return !statements_.is_empty() && statements_.last()->IsJump() 458 return !statements_.is_empty() && statements_.last()->IsJump()
458 && labels() == NULL; // Good enough as an approximation... 459 && labels() == NULL; // Good enough as an approximation...
459 } 460 }
460 461
461 Scope* scope() const { return scope_; } 462 Scope* scope() const { return scope_; }
462 void set_scope(Scope* scope) { scope_ = scope; } 463 void set_scope(Scope* scope) { scope_ = scope; }
463 464
464 protected: 465 protected:
465 Block(Isolate* isolate, 466 Block(Zone* zone,
466 ZoneStringList* labels, 467 ZoneStringList* labels,
467 int capacity, 468 int capacity,
468 bool is_initializer_block, 469 bool is_initializer_block,
469 int pos, 470 int pos)
470 Zone* zone) 471 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos),
471 : BreakableStatement(isolate, labels, TARGET_FOR_NAMED_ONLY, pos),
472 statements_(capacity, zone), 472 statements_(capacity, zone),
473 is_initializer_block_(is_initializer_block), 473 is_initializer_block_(is_initializer_block),
474 scope_(NULL) { 474 scope_(NULL) {
475 } 475 }
476 476
477 private: 477 private:
478 ZoneList<Statement*> statements_; 478 ZoneList<Statement*> statements_;
479 bool is_initializer_block_; 479 bool is_initializer_block_;
480 Scope* scope_; 480 Scope* scope_;
481 }; 481 };
482 482
483 483
484 class Declaration : public AstNode { 484 class Declaration : public AstNode {
485 public: 485 public:
486 VariableProxy* proxy() const { return proxy_; } 486 VariableProxy* proxy() const { return proxy_; }
487 VariableMode mode() const { return mode_; } 487 VariableMode mode() const { return mode_; }
488 Scope* scope() const { return scope_; } 488 Scope* scope() const { return scope_; }
489 virtual InitializationFlag initialization() const = 0; 489 virtual InitializationFlag initialization() const = 0;
490 virtual bool IsInlineable() const; 490 virtual bool IsInlineable() const;
491 491
492 protected: 492 protected:
493 Declaration(VariableProxy* proxy, 493 Declaration(Zone* zone,
494 VariableProxy* proxy,
494 VariableMode mode, 495 VariableMode mode,
495 Scope* scope, 496 Scope* scope,
496 int pos) 497 int pos)
497 : AstNode(pos), 498 : AstNode(pos),
498 proxy_(proxy), 499 proxy_(proxy),
499 mode_(mode), 500 mode_(mode),
500 scope_(scope) { 501 scope_(scope) {
501 ASSERT(IsDeclaredVariableMode(mode)); 502 ASSERT(IsDeclaredVariableMode(mode));
502 } 503 }
503 504
504 private: 505 private:
505 VariableProxy* proxy_; 506 VariableProxy* proxy_;
506 VariableMode mode_; 507 VariableMode mode_;
507 508
508 // Nested scope from which the declaration originated. 509 // Nested scope from which the declaration originated.
509 Scope* scope_; 510 Scope* scope_;
510 }; 511 };
511 512
512 513
513 class VariableDeclaration V8_FINAL : public Declaration { 514 class VariableDeclaration V8_FINAL : public Declaration {
514 public: 515 public:
515 DECLARE_NODE_TYPE(VariableDeclaration) 516 DECLARE_NODE_TYPE(VariableDeclaration)
516 517
517 virtual InitializationFlag initialization() const V8_OVERRIDE { 518 virtual InitializationFlag initialization() const V8_OVERRIDE {
518 return mode() == VAR ? kCreatedInitialized : kNeedsInitialization; 519 return mode() == VAR ? kCreatedInitialized : kNeedsInitialization;
519 } 520 }
520 521
521 protected: 522 protected:
522 VariableDeclaration(VariableProxy* proxy, 523 VariableDeclaration(Zone* zone,
524 VariableProxy* proxy,
523 VariableMode mode, 525 VariableMode mode,
524 Scope* scope, 526 Scope* scope,
525 int pos) 527 int pos)
526 : Declaration(proxy, mode, scope, pos) { 528 : Declaration(zone, proxy, mode, scope, pos) {
527 } 529 }
528 }; 530 };
529 531
530 532
531 class FunctionDeclaration V8_FINAL : public Declaration { 533 class FunctionDeclaration V8_FINAL : public Declaration {
532 public: 534 public:
533 DECLARE_NODE_TYPE(FunctionDeclaration) 535 DECLARE_NODE_TYPE(FunctionDeclaration)
534 536
535 FunctionLiteral* fun() const { return fun_; } 537 FunctionLiteral* fun() const { return fun_; }
536 virtual InitializationFlag initialization() const V8_OVERRIDE { 538 virtual InitializationFlag initialization() const V8_OVERRIDE {
537 return kCreatedInitialized; 539 return kCreatedInitialized;
538 } 540 }
539 virtual bool IsInlineable() const V8_OVERRIDE; 541 virtual bool IsInlineable() const V8_OVERRIDE;
540 542
541 protected: 543 protected:
542 FunctionDeclaration(VariableProxy* proxy, 544 FunctionDeclaration(Zone* zone,
545 VariableProxy* proxy,
543 VariableMode mode, 546 VariableMode mode,
544 FunctionLiteral* fun, 547 FunctionLiteral* fun,
545 Scope* scope, 548 Scope* scope,
546 int pos) 549 int pos)
547 : Declaration(proxy, mode, scope, pos), 550 : Declaration(zone, proxy, mode, scope, pos),
548 fun_(fun) { 551 fun_(fun) {
549 // At the moment there are no "const functions" in JavaScript... 552 // At the moment there are no "const functions" in JavaScript...
550 ASSERT(mode == VAR || mode == LET); 553 ASSERT(mode == VAR || mode == LET);
551 ASSERT(fun != NULL); 554 ASSERT(fun != NULL);
552 } 555 }
553 556
554 private: 557 private:
555 FunctionLiteral* fun_; 558 FunctionLiteral* fun_;
556 }; 559 };
557 560
558 561
559 class ModuleDeclaration V8_FINAL : public Declaration { 562 class ModuleDeclaration V8_FINAL : public Declaration {
560 public: 563 public:
561 DECLARE_NODE_TYPE(ModuleDeclaration) 564 DECLARE_NODE_TYPE(ModuleDeclaration)
562 565
563 Module* module() const { return module_; } 566 Module* module() const { return module_; }
564 virtual InitializationFlag initialization() const V8_OVERRIDE { 567 virtual InitializationFlag initialization() const V8_OVERRIDE {
565 return kCreatedInitialized; 568 return kCreatedInitialized;
566 } 569 }
567 570
568 protected: 571 protected:
569 ModuleDeclaration(VariableProxy* proxy, 572 ModuleDeclaration(Zone* zone,
573 VariableProxy* proxy,
570 Module* module, 574 Module* module,
571 Scope* scope, 575 Scope* scope,
572 int pos) 576 int pos)
573 : Declaration(proxy, MODULE, scope, pos), 577 : Declaration(zone, proxy, MODULE, scope, pos),
574 module_(module) { 578 module_(module) {
575 } 579 }
576 580
577 private: 581 private:
578 Module* module_; 582 Module* module_;
579 }; 583 };
580 584
581 585
582 class ImportDeclaration V8_FINAL : public Declaration { 586 class ImportDeclaration V8_FINAL : public Declaration {
583 public: 587 public:
584 DECLARE_NODE_TYPE(ImportDeclaration) 588 DECLARE_NODE_TYPE(ImportDeclaration)
585 589
586 Module* module() const { return module_; } 590 Module* module() const { return module_; }
587 virtual InitializationFlag initialization() const V8_OVERRIDE { 591 virtual InitializationFlag initialization() const V8_OVERRIDE {
588 return kCreatedInitialized; 592 return kCreatedInitialized;
589 } 593 }
590 594
591 protected: 595 protected:
592 ImportDeclaration(VariableProxy* proxy, 596 ImportDeclaration(Zone* zone,
597 VariableProxy* proxy,
593 Module* module, 598 Module* module,
594 Scope* scope, 599 Scope* scope,
595 int pos) 600 int pos)
596 : Declaration(proxy, LET, scope, pos), 601 : Declaration(zone, proxy, LET, scope, pos),
597 module_(module) { 602 module_(module) {
598 } 603 }
599 604
600 private: 605 private:
601 Module* module_; 606 Module* module_;
602 }; 607 };
603 608
604 609
605 class ExportDeclaration V8_FINAL : public Declaration { 610 class ExportDeclaration V8_FINAL : public Declaration {
606 public: 611 public:
607 DECLARE_NODE_TYPE(ExportDeclaration) 612 DECLARE_NODE_TYPE(ExportDeclaration)
608 613
609 virtual InitializationFlag initialization() const V8_OVERRIDE { 614 virtual InitializationFlag initialization() const V8_OVERRIDE {
610 return kCreatedInitialized; 615 return kCreatedInitialized;
611 } 616 }
612 617
613 protected: 618 protected:
614 ExportDeclaration(VariableProxy* proxy, Scope* scope, int pos) 619 ExportDeclaration(Zone* zone, VariableProxy* proxy, Scope* scope, int pos)
615 : Declaration(proxy, LET, scope, pos) {} 620 : Declaration(zone, proxy, LET, scope, pos) {}
616 }; 621 };
617 622
618 623
619 class Module : public AstNode { 624 class Module : public AstNode {
620 public: 625 public:
621 Interface* interface() const { return interface_; } 626 Interface* interface() const { return interface_; }
622 Block* body() const { return body_; } 627 Block* body() const { return body_; }
623 628
624 protected: 629 protected:
625 Module(Zone* zone, int pos) 630 Module(Zone* zone, int pos)
626 : AstNode(pos), 631 : AstNode(pos),
627 interface_(Interface::NewModule(zone)), 632 interface_(Interface::NewModule(zone)),
628 body_(NULL) {} 633 body_(NULL) {}
629 Module(Interface* interface, int pos, Block* body = NULL) 634 Module(Zone* zone, Interface* interface, int pos, Block* body = NULL)
630 : AstNode(pos), 635 : AstNode(pos),
631 interface_(interface), 636 interface_(interface),
632 body_(body) {} 637 body_(body) {}
633 638
634 private: 639 private:
635 Interface* interface_; 640 Interface* interface_;
636 Block* body_; 641 Block* body_;
637 }; 642 };
638 643
639 644
640 class ModuleLiteral V8_FINAL : public Module { 645 class ModuleLiteral V8_FINAL : public Module {
641 public: 646 public:
642 DECLARE_NODE_TYPE(ModuleLiteral) 647 DECLARE_NODE_TYPE(ModuleLiteral)
643 648
644 protected: 649 protected:
645 ModuleLiteral(Block* body, Interface* interface, int pos) 650 ModuleLiteral(Zone* zone, Block* body, Interface* interface, int pos)
646 : Module(interface, pos, body) {} 651 : Module(zone, interface, pos, body) {}
647 }; 652 };
648 653
649 654
650 class ModuleVariable V8_FINAL : public Module { 655 class ModuleVariable V8_FINAL : public Module {
651 public: 656 public:
652 DECLARE_NODE_TYPE(ModuleVariable) 657 DECLARE_NODE_TYPE(ModuleVariable)
653 658
654 VariableProxy* proxy() const { return proxy_; } 659 VariableProxy* proxy() const { return proxy_; }
655 660
656 protected: 661 protected:
657 inline ModuleVariable(VariableProxy* proxy, int pos); 662 inline ModuleVariable(Zone* zone, VariableProxy* proxy, int pos);
658 663
659 private: 664 private:
660 VariableProxy* proxy_; 665 VariableProxy* proxy_;
661 }; 666 };
662 667
663 668
664 class ModulePath V8_FINAL : public Module { 669 class ModulePath V8_FINAL : public Module {
665 public: 670 public:
666 DECLARE_NODE_TYPE(ModulePath) 671 DECLARE_NODE_TYPE(ModulePath)
667 672
668 Module* module() const { return module_; } 673 Module* module() const { return module_; }
669 Handle<String> name() const { return name_; } 674 Handle<String> name() const { return name_; }
670 675
671 protected: 676 protected:
672 ModulePath(Module* module, Handle<String> name, Zone* zone, int pos) 677 ModulePath(Zone* zone, Module* module, Handle<String> name, int pos)
673 : Module(zone, pos), 678 : Module(zone, pos),
674 module_(module), 679 module_(module),
675 name_(name) { 680 name_(name) {
676 } 681 }
677 682
678 private: 683 private:
679 Module* module_; 684 Module* module_;
680 Handle<String> name_; 685 Handle<String> name_;
681 }; 686 };
682 687
683 688
684 class ModuleUrl V8_FINAL : public Module { 689 class ModuleUrl V8_FINAL : public Module {
685 public: 690 public:
686 DECLARE_NODE_TYPE(ModuleUrl) 691 DECLARE_NODE_TYPE(ModuleUrl)
687 692
688 Handle<String> url() const { return url_; } 693 Handle<String> url() const { return url_; }
689 694
690 protected: 695 protected:
691 ModuleUrl(Handle<String> url, Zone* zone, int pos) 696 ModuleUrl(Zone* zone, Handle<String> url, int pos)
692 : Module(zone, pos), url_(url) { 697 : Module(zone, pos), url_(url) {
693 } 698 }
694 699
695 private: 700 private:
696 Handle<String> url_; 701 Handle<String> url_;
697 }; 702 };
698 703
699 704
700 class ModuleStatement V8_FINAL : public Statement { 705 class ModuleStatement V8_FINAL : public Statement {
701 public: 706 public:
702 DECLARE_NODE_TYPE(ModuleStatement) 707 DECLARE_NODE_TYPE(ModuleStatement)
703 708
704 VariableProxy* proxy() const { return proxy_; } 709 VariableProxy* proxy() const { return proxy_; }
705 Block* body() const { return body_; } 710 Block* body() const { return body_; }
706 711
707 protected: 712 protected:
708 ModuleStatement(VariableProxy* proxy, Block* body, int pos) 713 ModuleStatement(Zone* zone, VariableProxy* proxy, Block* body, int pos)
709 : Statement(pos), 714 : Statement(zone, pos),
710 proxy_(proxy), 715 proxy_(proxy),
711 body_(body) { 716 body_(body) {
712 } 717 }
713 718
714 private: 719 private:
715 VariableProxy* proxy_; 720 VariableProxy* proxy_;
716 Block* body_; 721 Block* body_;
717 }; 722 };
718 723
719 724
720 class IterationStatement : public BreakableStatement { 725 class IterationStatement : public BreakableStatement {
721 public: 726 public:
722 // Type testing & conversion. 727 // Type testing & conversion.
723 virtual IterationStatement* AsIterationStatement() V8_FINAL V8_OVERRIDE { 728 virtual IterationStatement* AsIterationStatement() V8_FINAL V8_OVERRIDE {
724 return this; 729 return this;
725 } 730 }
726 731
727 Statement* body() const { return body_; } 732 Statement* body() const { return body_; }
728 733
729 BailoutId OsrEntryId() const { return osr_entry_id_; } 734 BailoutId OsrEntryId() const { return osr_entry_id_; }
730 virtual BailoutId ContinueId() const = 0; 735 virtual BailoutId ContinueId() const = 0;
731 virtual BailoutId StackCheckId() const = 0; 736 virtual BailoutId StackCheckId() const = 0;
732 737
733 // Code generation 738 // Code generation
734 Label* continue_target() { return &continue_target_; } 739 Label* continue_target() { return &continue_target_; }
735 740
736 protected: 741 protected:
737 IterationStatement(Isolate* isolate, ZoneStringList* labels, int pos) 742 IterationStatement(Zone* zone, ZoneStringList* labels, int pos)
738 : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS, pos), 743 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos),
739 body_(NULL), 744 body_(NULL),
740 osr_entry_id_(GetNextId(isolate)) { 745 osr_entry_id_(GetNextId(zone)) {
741 } 746 }
742 747
743 void Initialize(Statement* body) { 748 void Initialize(Statement* body) {
744 body_ = body; 749 body_ = body;
745 } 750 }
746 751
747 private: 752 private:
748 Statement* body_; 753 Statement* body_;
749 Label continue_target_; 754 Label continue_target_;
750 755
(...skipping 10 matching lines...) Expand all
761 cond_ = cond; 766 cond_ = cond;
762 } 767 }
763 768
764 Expression* cond() const { return cond_; } 769 Expression* cond() const { return cond_; }
765 770
766 virtual BailoutId ContinueId() const V8_OVERRIDE { return continue_id_; } 771 virtual BailoutId ContinueId() const V8_OVERRIDE { return continue_id_; }
767 virtual BailoutId StackCheckId() const V8_OVERRIDE { return back_edge_id_; } 772 virtual BailoutId StackCheckId() const V8_OVERRIDE { return back_edge_id_; }
768 BailoutId BackEdgeId() const { return back_edge_id_; } 773 BailoutId BackEdgeId() const { return back_edge_id_; }
769 774
770 protected: 775 protected:
771 DoWhileStatement(Isolate* isolate, ZoneStringList* labels, int pos) 776 DoWhileStatement(Zone* zone, ZoneStringList* labels, int pos)
772 : IterationStatement(isolate, labels, pos), 777 : IterationStatement(zone, labels, pos),
773 cond_(NULL), 778 cond_(NULL),
774 continue_id_(GetNextId(isolate)), 779 continue_id_(GetNextId(zone)),
775 back_edge_id_(GetNextId(isolate)) { 780 back_edge_id_(GetNextId(zone)) {
776 } 781 }
777 782
778 private: 783 private:
779 Expression* cond_; 784 Expression* cond_;
780 785
781 const BailoutId continue_id_; 786 const BailoutId continue_id_;
782 const BailoutId back_edge_id_; 787 const BailoutId back_edge_id_;
783 }; 788 };
784 789
785 790
(...skipping 12 matching lines...) Expand all
798 } 803 }
799 void set_may_have_function_literal(bool value) { 804 void set_may_have_function_literal(bool value) {
800 may_have_function_literal_ = value; 805 may_have_function_literal_ = value;
801 } 806 }
802 807
803 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); } 808 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); }
804 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } 809 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; }
805 BailoutId BodyId() const { return body_id_; } 810 BailoutId BodyId() const { return body_id_; }
806 811
807 protected: 812 protected:
808 WhileStatement(Isolate* isolate, ZoneStringList* labels, int pos) 813 WhileStatement(Zone* zone, ZoneStringList* labels, int pos)
809 : IterationStatement(isolate, labels, pos), 814 : IterationStatement(zone, labels, pos),
810 cond_(NULL), 815 cond_(NULL),
811 may_have_function_literal_(true), 816 may_have_function_literal_(true),
812 body_id_(GetNextId(isolate)) { 817 body_id_(GetNextId(zone)) {
813 } 818 }
814 819
815 private: 820 private:
816 Expression* cond_; 821 Expression* cond_;
817 822
818 // True if there is a function literal subexpression in the condition. 823 // True if there is a function literal subexpression in the condition.
819 bool may_have_function_literal_; 824 bool may_have_function_literal_;
820 825
821 const BailoutId body_id_; 826 const BailoutId body_id_;
822 }; 827 };
(...skipping 26 matching lines...) Expand all
849 854
850 virtual BailoutId ContinueId() const V8_OVERRIDE { return continue_id_; } 855 virtual BailoutId ContinueId() const V8_OVERRIDE { return continue_id_; }
851 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } 856 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; }
852 BailoutId BodyId() const { return body_id_; } 857 BailoutId BodyId() const { return body_id_; }
853 858
854 bool is_fast_smi_loop() { return loop_variable_ != NULL; } 859 bool is_fast_smi_loop() { return loop_variable_ != NULL; }
855 Variable* loop_variable() { return loop_variable_; } 860 Variable* loop_variable() { return loop_variable_; }
856 void set_loop_variable(Variable* var) { loop_variable_ = var; } 861 void set_loop_variable(Variable* var) { loop_variable_ = var; }
857 862
858 protected: 863 protected:
859 ForStatement(Isolate* isolate, ZoneStringList* labels, int pos) 864 ForStatement(Zone* zone, ZoneStringList* labels, int pos)
860 : IterationStatement(isolate, labels, pos), 865 : IterationStatement(zone, labels, pos),
861 init_(NULL), 866 init_(NULL),
862 cond_(NULL), 867 cond_(NULL),
863 next_(NULL), 868 next_(NULL),
864 may_have_function_literal_(true), 869 may_have_function_literal_(true),
865 loop_variable_(NULL), 870 loop_variable_(NULL),
866 continue_id_(GetNextId(isolate)), 871 continue_id_(GetNextId(zone)),
867 body_id_(GetNextId(isolate)) { 872 body_id_(GetNextId(zone)) {
868 } 873 }
869 874
870 private: 875 private:
871 Statement* init_; 876 Statement* init_;
872 Expression* cond_; 877 Expression* cond_;
873 Statement* next_; 878 Statement* next_;
874 879
875 // True if there is a function literal subexpression in the condition. 880 // True if there is a function literal subexpression in the condition.
876 bool may_have_function_literal_; 881 bool may_have_function_literal_;
877 Variable* loop_variable_; 882 Variable* loop_variable_;
(...skipping 13 matching lines...) Expand all
891 void Initialize(Expression* each, Expression* subject, Statement* body) { 896 void Initialize(Expression* each, Expression* subject, Statement* body) {
892 IterationStatement::Initialize(body); 897 IterationStatement::Initialize(body);
893 each_ = each; 898 each_ = each;
894 subject_ = subject; 899 subject_ = subject;
895 } 900 }
896 901
897 Expression* each() const { return each_; } 902 Expression* each() const { return each_; }
898 Expression* subject() const { return subject_; } 903 Expression* subject() const { return subject_; }
899 904
900 protected: 905 protected:
901 ForEachStatement(Isolate* isolate, ZoneStringList* labels, int pos) 906 ForEachStatement(Zone* zone, ZoneStringList* labels, int pos)
902 : IterationStatement(isolate, labels, pos), 907 : IterationStatement(zone, labels, pos),
903 each_(NULL), 908 each_(NULL),
904 subject_(NULL) { 909 subject_(NULL) {
905 } 910 }
906 911
907 private: 912 private:
908 Expression* each_; 913 Expression* each_;
909 Expression* subject_; 914 Expression* subject_;
910 }; 915 };
911 916
912 917
913 class ForInStatement V8_FINAL : public ForEachStatement { 918 class ForInStatement V8_FINAL : public ForEachStatement,
919 public FeedbackSlotInterface {
914 public: 920 public:
915 DECLARE_NODE_TYPE(ForInStatement) 921 DECLARE_NODE_TYPE(ForInStatement)
916 922
917 Expression* enumerable() const { 923 Expression* enumerable() const {
918 return subject(); 924 return subject();
919 } 925 }
920 926
921 TypeFeedbackId ForInFeedbackId() const { return reuse(PrepareId()); } 927 // Type feedback information.
928 virtual ComputablePhase GetComputablePhase() { return DURING_PARSE; }
929 virtual int ComputeFeedbackSlotCount(Isolate* isolate) { return 1; }
930 virtual void SetFirstFeedbackSlot(int slot) { for_in_feedback_slot_ = slot; }
931
932 int ForInFeedbackSlot() {
933 ASSERT(for_in_feedback_slot_ != kInvalidFeedbackSlot);
934 return for_in_feedback_slot_;
935 }
936
922 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; 937 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN };
923 ForInType for_in_type() const { return for_in_type_; } 938 ForInType for_in_type() const { return for_in_type_; }
924 void set_for_in_type(ForInType type) { for_in_type_ = type; } 939 void set_for_in_type(ForInType type) { for_in_type_ = type; }
925 940
926 BailoutId BodyId() const { return body_id_; } 941 BailoutId BodyId() const { return body_id_; }
927 BailoutId PrepareId() const { return prepare_id_; } 942 BailoutId PrepareId() const { return prepare_id_; }
928 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); } 943 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); }
929 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } 944 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; }
930 945
931 protected: 946 protected:
932 ForInStatement(Isolate* isolate, ZoneStringList* labels, int pos) 947 ForInStatement(Zone* zone, ZoneStringList* labels, int pos)
933 : ForEachStatement(isolate, labels, pos), 948 : ForEachStatement(zone, labels, pos),
934 for_in_type_(SLOW_FOR_IN), 949 for_in_type_(SLOW_FOR_IN),
935 body_id_(GetNextId(isolate)), 950 for_in_feedback_slot_(kInvalidFeedbackSlot),
936 prepare_id_(GetNextId(isolate)) { 951 body_id_(GetNextId(zone)),
952 prepare_id_(GetNextId(zone)) {
937 } 953 }
938 954
939 ForInType for_in_type_; 955 ForInType for_in_type_;
956 int for_in_feedback_slot_;
940 const BailoutId body_id_; 957 const BailoutId body_id_;
941 const BailoutId prepare_id_; 958 const BailoutId prepare_id_;
942 }; 959 };
943 960
944 961
945 class ForOfStatement V8_FINAL : public ForEachStatement { 962 class ForOfStatement V8_FINAL : public ForEachStatement {
946 public: 963 public:
947 DECLARE_NODE_TYPE(ForOfStatement) 964 DECLARE_NODE_TYPE(ForOfStatement)
948 965
949 void Initialize(Expression* each, 966 void Initialize(Expression* each,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 Expression* assign_each() const { 1000 Expression* assign_each() const {
984 return assign_each_; 1001 return assign_each_;
985 } 1002 }
986 1003
987 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); } 1004 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); }
988 virtual BailoutId StackCheckId() const V8_OVERRIDE { return BackEdgeId(); } 1005 virtual BailoutId StackCheckId() const V8_OVERRIDE { return BackEdgeId(); }
989 1006
990 BailoutId BackEdgeId() const { return back_edge_id_; } 1007 BailoutId BackEdgeId() const { return back_edge_id_; }
991 1008
992 protected: 1009 protected:
993 ForOfStatement(Isolate* isolate, ZoneStringList* labels, int pos) 1010 ForOfStatement(Zone* zone, ZoneStringList* labels, int pos)
994 : ForEachStatement(isolate, labels, pos), 1011 : ForEachStatement(zone, labels, pos),
995 assign_iterator_(NULL), 1012 assign_iterator_(NULL),
996 next_result_(NULL), 1013 next_result_(NULL),
997 result_done_(NULL), 1014 result_done_(NULL),
998 assign_each_(NULL), 1015 assign_each_(NULL),
999 back_edge_id_(GetNextId(isolate)) { 1016 back_edge_id_(GetNextId(zone)) {
1000 } 1017 }
1001 1018
1002 Expression* assign_iterator_; 1019 Expression* assign_iterator_;
1003 Expression* next_result_; 1020 Expression* next_result_;
1004 Expression* result_done_; 1021 Expression* result_done_;
1005 Expression* assign_each_; 1022 Expression* assign_each_;
1006 const BailoutId back_edge_id_; 1023 const BailoutId back_edge_id_;
1007 }; 1024 };
1008 1025
1009 1026
1010 class ExpressionStatement V8_FINAL : public Statement { 1027 class ExpressionStatement V8_FINAL : public Statement {
1011 public: 1028 public:
1012 DECLARE_NODE_TYPE(ExpressionStatement) 1029 DECLARE_NODE_TYPE(ExpressionStatement)
1013 1030
1014 void set_expression(Expression* e) { expression_ = e; } 1031 void set_expression(Expression* e) { expression_ = e; }
1015 Expression* expression() const { return expression_; } 1032 Expression* expression() const { return expression_; }
1016 virtual bool IsJump() const V8_OVERRIDE { return expression_->IsThrow(); } 1033 virtual bool IsJump() const V8_OVERRIDE { return expression_->IsThrow(); }
1017 1034
1018 protected: 1035 protected:
1019 ExpressionStatement(Expression* expression, int pos) 1036 ExpressionStatement(Zone* zone, Expression* expression, int pos)
1020 : Statement(pos), expression_(expression) { } 1037 : Statement(zone, pos), expression_(expression) { }
1021 1038
1022 private: 1039 private:
1023 Expression* expression_; 1040 Expression* expression_;
1024 }; 1041 };
1025 1042
1026 1043
1027 class JumpStatement : public Statement { 1044 class JumpStatement : public Statement {
1028 public: 1045 public:
1029 virtual bool IsJump() const V8_FINAL V8_OVERRIDE { return true; } 1046 virtual bool IsJump() const V8_FINAL V8_OVERRIDE { return true; }
1030 1047
1031 protected: 1048 protected:
1032 explicit JumpStatement(int pos) : Statement(pos) {} 1049 explicit JumpStatement(Zone* zone, int pos) : Statement(zone, pos) {}
1033 }; 1050 };
1034 1051
1035 1052
1036 class ContinueStatement V8_FINAL : public JumpStatement { 1053 class ContinueStatement V8_FINAL : public JumpStatement {
1037 public: 1054 public:
1038 DECLARE_NODE_TYPE(ContinueStatement) 1055 DECLARE_NODE_TYPE(ContinueStatement)
1039 1056
1040 IterationStatement* target() const { return target_; } 1057 IterationStatement* target() const { return target_; }
1041 1058
1042 protected: 1059 protected:
1043 explicit ContinueStatement(IterationStatement* target, int pos) 1060 explicit ContinueStatement(Zone* zone, IterationStatement* target, int pos)
1044 : JumpStatement(pos), target_(target) { } 1061 : JumpStatement(zone, pos), target_(target) { }
1045 1062
1046 private: 1063 private:
1047 IterationStatement* target_; 1064 IterationStatement* target_;
1048 }; 1065 };
1049 1066
1050 1067
1051 class BreakStatement V8_FINAL : public JumpStatement { 1068 class BreakStatement V8_FINAL : public JumpStatement {
1052 public: 1069 public:
1053 DECLARE_NODE_TYPE(BreakStatement) 1070 DECLARE_NODE_TYPE(BreakStatement)
1054 1071
1055 BreakableStatement* target() const { return target_; } 1072 BreakableStatement* target() const { return target_; }
1056 1073
1057 protected: 1074 protected:
1058 explicit BreakStatement(BreakableStatement* target, int pos) 1075 explicit BreakStatement(Zone* zone, BreakableStatement* target, int pos)
1059 : JumpStatement(pos), target_(target) { } 1076 : JumpStatement(zone, pos), target_(target) { }
1060 1077
1061 private: 1078 private:
1062 BreakableStatement* target_; 1079 BreakableStatement* target_;
1063 }; 1080 };
1064 1081
1065 1082
1066 class ReturnStatement V8_FINAL : public JumpStatement { 1083 class ReturnStatement V8_FINAL : public JumpStatement {
1067 public: 1084 public:
1068 DECLARE_NODE_TYPE(ReturnStatement) 1085 DECLARE_NODE_TYPE(ReturnStatement)
1069 1086
1070 Expression* expression() const { return expression_; } 1087 Expression* expression() const { return expression_; }
1071 1088
1072 protected: 1089 protected:
1073 explicit ReturnStatement(Expression* expression, int pos) 1090 explicit ReturnStatement(Zone* zone, Expression* expression, int pos)
1074 : JumpStatement(pos), expression_(expression) { } 1091 : JumpStatement(zone, pos), expression_(expression) { }
1075 1092
1076 private: 1093 private:
1077 Expression* expression_; 1094 Expression* expression_;
1078 }; 1095 };
1079 1096
1080 1097
1081 class WithStatement V8_FINAL : public Statement { 1098 class WithStatement V8_FINAL : public Statement {
1082 public: 1099 public:
1083 DECLARE_NODE_TYPE(WithStatement) 1100 DECLARE_NODE_TYPE(WithStatement)
1084 1101
1085 Scope* scope() { return scope_; } 1102 Scope* scope() { return scope_; }
1086 Expression* expression() const { return expression_; } 1103 Expression* expression() const { return expression_; }
1087 Statement* statement() const { return statement_; } 1104 Statement* statement() const { return statement_; }
1088 1105
1089 protected: 1106 protected:
1090 WithStatement( 1107 WithStatement(
1091 Scope* scope, Expression* expression, Statement* statement, int pos) 1108 Zone* zone, Scope* scope,
1092 : Statement(pos), 1109 Expression* expression, Statement* statement, int pos)
1110 : Statement(zone, pos),
1093 scope_(scope), 1111 scope_(scope),
1094 expression_(expression), 1112 expression_(expression),
1095 statement_(statement) { } 1113 statement_(statement) { }
1096 1114
1097 private: 1115 private:
1098 Scope* scope_; 1116 Scope* scope_;
1099 Expression* expression_; 1117 Expression* expression_;
1100 Statement* statement_; 1118 Statement* statement_;
1101 }; 1119 };
1102 1120
1103 1121
1104 class CaseClause V8_FINAL : public Expression { 1122 class CaseClause V8_FINAL : public Expression {
1105 public: 1123 public:
1106 DECLARE_NODE_TYPE(CaseClause) 1124 DECLARE_NODE_TYPE(CaseClause)
1107 1125
1108 bool is_default() const { return label_ == NULL; } 1126 bool is_default() const { return label_ == NULL; }
1109 Expression* label() const { 1127 Expression* label() const {
1110 CHECK(!is_default()); 1128 CHECK(!is_default());
1111 return label_; 1129 return label_;
1112 } 1130 }
1113 Label* body_target() { return &body_target_; } 1131 Label* body_target() { return &body_target_; }
1114 ZoneList<Statement*>* statements() const { return statements_; } 1132 ZoneList<Statement*>* statements() const { return statements_; }
1115 1133
1116 BailoutId EntryId() const { return entry_id_; } 1134 BailoutId EntryId() const { return entry_id_; }
1117 1135
1118 // Type feedback information. 1136 // Type feedback information.
1119 TypeFeedbackId CompareId() { return compare_id_; } 1137 TypeFeedbackId CompareId() { return compare_id_; }
1120 Handle<Type> compare_type() { return compare_type_; } 1138 Type* compare_type() { return compare_type_; }
1121 void set_compare_type(Handle<Type> type) { compare_type_ = type; } 1139 void set_compare_type(Type* type) { compare_type_ = type; }
1122 1140
1123 private: 1141 private:
1124 CaseClause(Isolate* isolate, 1142 CaseClause(Zone* zone,
1125 Expression* label, 1143 Expression* label,
1126 ZoneList<Statement*>* statements, 1144 ZoneList<Statement*>* statements,
1127 int pos); 1145 int pos);
1128 1146
1129 Expression* label_; 1147 Expression* label_;
1130 Label body_target_; 1148 Label body_target_;
1131 ZoneList<Statement*>* statements_; 1149 ZoneList<Statement*>* statements_;
1132 Handle<Type> compare_type_; 1150 Type* compare_type_;
1133 1151
1134 const TypeFeedbackId compare_id_; 1152 const TypeFeedbackId compare_id_;
1135 const BailoutId entry_id_; 1153 const BailoutId entry_id_;
1136 }; 1154 };
1137 1155
1138 1156
1139 class SwitchStatement V8_FINAL : public BreakableStatement { 1157 class SwitchStatement V8_FINAL : public BreakableStatement {
1140 public: 1158 public:
1141 DECLARE_NODE_TYPE(SwitchStatement) 1159 DECLARE_NODE_TYPE(SwitchStatement)
1142 1160
1143 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { 1161 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) {
1144 tag_ = tag; 1162 tag_ = tag;
1145 cases_ = cases; 1163 cases_ = cases;
1146 } 1164 }
1147 1165
1148 Expression* tag() const { return tag_; } 1166 Expression* tag() const { return tag_; }
1149 ZoneList<CaseClause*>* cases() const { return cases_; } 1167 ZoneList<CaseClause*>* cases() const { return cases_; }
1150 1168
1151 protected: 1169 protected:
1152 SwitchStatement(Isolate* isolate, ZoneStringList* labels, int pos) 1170 SwitchStatement(Zone* zone, ZoneStringList* labels, int pos)
1153 : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS, pos), 1171 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos),
1154 tag_(NULL), 1172 tag_(NULL),
1155 cases_(NULL) { } 1173 cases_(NULL) { }
1156 1174
1157 private: 1175 private:
1158 Expression* tag_; 1176 Expression* tag_;
1159 ZoneList<CaseClause*>* cases_; 1177 ZoneList<CaseClause*>* cases_;
1160 }; 1178 };
1161 1179
1162 1180
1163 // If-statements always have non-null references to their then- and 1181 // If-statements always have non-null references to their then- and
(...skipping 15 matching lines...) Expand all
1179 virtual bool IsJump() const V8_OVERRIDE { 1197 virtual bool IsJump() const V8_OVERRIDE {
1180 return HasThenStatement() && then_statement()->IsJump() 1198 return HasThenStatement() && then_statement()->IsJump()
1181 && HasElseStatement() && else_statement()->IsJump(); 1199 && HasElseStatement() && else_statement()->IsJump();
1182 } 1200 }
1183 1201
1184 BailoutId IfId() const { return if_id_; } 1202 BailoutId IfId() const { return if_id_; }
1185 BailoutId ThenId() const { return then_id_; } 1203 BailoutId ThenId() const { return then_id_; }
1186 BailoutId ElseId() const { return else_id_; } 1204 BailoutId ElseId() const { return else_id_; }
1187 1205
1188 protected: 1206 protected:
1189 IfStatement(Isolate* isolate, 1207 IfStatement(Zone* zone,
1190 Expression* condition, 1208 Expression* condition,
1191 Statement* then_statement, 1209 Statement* then_statement,
1192 Statement* else_statement, 1210 Statement* else_statement,
1193 int pos) 1211 int pos)
1194 : Statement(pos), 1212 : Statement(zone, pos),
1195 condition_(condition), 1213 condition_(condition),
1196 then_statement_(then_statement), 1214 then_statement_(then_statement),
1197 else_statement_(else_statement), 1215 else_statement_(else_statement),
1198 if_id_(GetNextId(isolate)), 1216 if_id_(GetNextId(zone)),
1199 then_id_(GetNextId(isolate)), 1217 then_id_(GetNextId(zone)),
1200 else_id_(GetNextId(isolate)) { 1218 else_id_(GetNextId(zone)) {
1201 } 1219 }
1202 1220
1203 private: 1221 private:
1204 Expression* condition_; 1222 Expression* condition_;
1205 Statement* then_statement_; 1223 Statement* then_statement_;
1206 Statement* else_statement_; 1224 Statement* else_statement_;
1207 const BailoutId if_id_; 1225 const BailoutId if_id_;
1208 const BailoutId then_id_; 1226 const BailoutId then_id_;
1209 const BailoutId else_id_; 1227 const BailoutId else_id_;
1210 }; 1228 };
(...skipping 27 matching lines...) Expand all
1238 public: 1256 public:
1239 void set_escaping_targets(ZoneList<Label*>* targets) { 1257 void set_escaping_targets(ZoneList<Label*>* targets) {
1240 escaping_targets_ = targets; 1258 escaping_targets_ = targets;
1241 } 1259 }
1242 1260
1243 int index() const { return index_; } 1261 int index() const { return index_; }
1244 Block* try_block() const { return try_block_; } 1262 Block* try_block() const { return try_block_; }
1245 ZoneList<Label*>* escaping_targets() const { return escaping_targets_; } 1263 ZoneList<Label*>* escaping_targets() const { return escaping_targets_; }
1246 1264
1247 protected: 1265 protected:
1248 TryStatement(int index, Block* try_block, int pos) 1266 TryStatement(Zone* zone, int index, Block* try_block, int pos)
1249 : Statement(pos), 1267 : Statement(zone, pos),
1250 index_(index), 1268 index_(index),
1251 try_block_(try_block), 1269 try_block_(try_block),
1252 escaping_targets_(NULL) { } 1270 escaping_targets_(NULL) { }
1253 1271
1254 private: 1272 private:
1255 // Unique (per-function) index of this handler. This is not an AST ID. 1273 // Unique (per-function) index of this handler. This is not an AST ID.
1256 int index_; 1274 int index_;
1257 1275
1258 Block* try_block_; 1276 Block* try_block_;
1259 ZoneList<Label*>* escaping_targets_; 1277 ZoneList<Label*>* escaping_targets_;
1260 }; 1278 };
1261 1279
1262 1280
1263 class TryCatchStatement V8_FINAL : public TryStatement { 1281 class TryCatchStatement V8_FINAL : public TryStatement {
1264 public: 1282 public:
1265 DECLARE_NODE_TYPE(TryCatchStatement) 1283 DECLARE_NODE_TYPE(TryCatchStatement)
1266 1284
1267 Scope* scope() { return scope_; } 1285 Scope* scope() { return scope_; }
1268 Variable* variable() { return variable_; } 1286 Variable* variable() { return variable_; }
1269 Block* catch_block() const { return catch_block_; } 1287 Block* catch_block() const { return catch_block_; }
1270 1288
1271 protected: 1289 protected:
1272 TryCatchStatement(int index, 1290 TryCatchStatement(Zone* zone,
1291 int index,
1273 Block* try_block, 1292 Block* try_block,
1274 Scope* scope, 1293 Scope* scope,
1275 Variable* variable, 1294 Variable* variable,
1276 Block* catch_block, 1295 Block* catch_block,
1277 int pos) 1296 int pos)
1278 : TryStatement(index, try_block, pos), 1297 : TryStatement(zone, index, try_block, pos),
1279 scope_(scope), 1298 scope_(scope),
1280 variable_(variable), 1299 variable_(variable),
1281 catch_block_(catch_block) { 1300 catch_block_(catch_block) {
1282 } 1301 }
1283 1302
1284 private: 1303 private:
1285 Scope* scope_; 1304 Scope* scope_;
1286 Variable* variable_; 1305 Variable* variable_;
1287 Block* catch_block_; 1306 Block* catch_block_;
1288 }; 1307 };
1289 1308
1290 1309
1291 class TryFinallyStatement V8_FINAL : public TryStatement { 1310 class TryFinallyStatement V8_FINAL : public TryStatement {
1292 public: 1311 public:
1293 DECLARE_NODE_TYPE(TryFinallyStatement) 1312 DECLARE_NODE_TYPE(TryFinallyStatement)
1294 1313
1295 Block* finally_block() const { return finally_block_; } 1314 Block* finally_block() const { return finally_block_; }
1296 1315
1297 protected: 1316 protected:
1298 TryFinallyStatement( 1317 TryFinallyStatement(
1299 int index, Block* try_block, Block* finally_block, int pos) 1318 Zone* zone, int index, Block* try_block, Block* finally_block, int pos)
1300 : TryStatement(index, try_block, pos), 1319 : TryStatement(zone, index, try_block, pos),
1301 finally_block_(finally_block) { } 1320 finally_block_(finally_block) { }
1302 1321
1303 private: 1322 private:
1304 Block* finally_block_; 1323 Block* finally_block_;
1305 }; 1324 };
1306 1325
1307 1326
1308 class DebuggerStatement V8_FINAL : public Statement { 1327 class DebuggerStatement V8_FINAL : public Statement {
1309 public: 1328 public:
1310 DECLARE_NODE_TYPE(DebuggerStatement) 1329 DECLARE_NODE_TYPE(DebuggerStatement)
1311 1330
1312 protected: 1331 protected:
1313 explicit DebuggerStatement(int pos): Statement(pos) {} 1332 explicit DebuggerStatement(Zone* zone, int pos): Statement(zone, pos) {}
1314 }; 1333 };
1315 1334
1316 1335
1317 class EmptyStatement V8_FINAL : public Statement { 1336 class EmptyStatement V8_FINAL : public Statement {
1318 public: 1337 public:
1319 DECLARE_NODE_TYPE(EmptyStatement) 1338 DECLARE_NODE_TYPE(EmptyStatement)
1320 1339
1321 protected: 1340 protected:
1322 explicit EmptyStatement(int pos): Statement(pos) {} 1341 explicit EmptyStatement(Zone* zone, int pos): Statement(zone, pos) {}
1323 }; 1342 };
1324 1343
1325 1344
1326 class Literal V8_FINAL : public Expression { 1345 class Literal V8_FINAL : public Expression {
1327 public: 1346 public:
1328 DECLARE_NODE_TYPE(Literal) 1347 DECLARE_NODE_TYPE(Literal)
1329 1348
1330 virtual bool IsPropertyName() V8_OVERRIDE { 1349 virtual bool IsPropertyName() V8_OVERRIDE {
1331 if (value_->IsInternalizedString()) { 1350 if (value_->IsInternalizedString()) {
1332 uint32_t ignored; 1351 uint32_t ignored;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 1388
1370 static bool Match(void* literal1, void* literal2) { 1389 static bool Match(void* literal1, void* literal2) {
1371 Handle<String> s1 = static_cast<Literal*>(literal1)->ToString(); 1390 Handle<String> s1 = static_cast<Literal*>(literal1)->ToString();
1372 Handle<String> s2 = static_cast<Literal*>(literal2)->ToString(); 1391 Handle<String> s2 = static_cast<Literal*>(literal2)->ToString();
1373 return s1->Equals(*s2); 1392 return s1->Equals(*s2);
1374 } 1393 }
1375 1394
1376 TypeFeedbackId LiteralFeedbackId() const { return reuse(id()); } 1395 TypeFeedbackId LiteralFeedbackId() const { return reuse(id()); }
1377 1396
1378 protected: 1397 protected:
1379 Literal( 1398 Literal(Zone* zone, Handle<Object> value, int position)
1380 Isolate* isolate, Handle<Object> value, int position) 1399 : Expression(zone, position),
1381 : Expression(isolate, position),
1382 value_(value), 1400 value_(value),
1383 isolate_(isolate) { } 1401 isolate_(zone->isolate()) { }
1384 1402
1385 private: 1403 private:
1386 Handle<String> ToString(); 1404 Handle<String> ToString();
1387 1405
1388 Handle<Object> value_; 1406 Handle<Object> value_;
1389 // TODO(dcarney): remove. this is only needed for Match and Hash. 1407 // TODO(dcarney): remove. this is only needed for Match and Hash.
1390 Isolate* isolate_; 1408 Isolate* isolate_;
1391 }; 1409 };
1392 1410
1393 1411
1394 // Base class for literals that needs space in the corresponding JSFunction. 1412 // Base class for literals that needs space in the corresponding JSFunction.
1395 class MaterializedLiteral : public Expression { 1413 class MaterializedLiteral : public Expression {
1396 public: 1414 public:
1397 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } 1415 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; }
1398 1416
1399 int literal_index() { return literal_index_; } 1417 int literal_index() { return literal_index_; }
1400 1418
1401 int depth() const { 1419 int depth() const {
1402 // only callable after initialization. 1420 // only callable after initialization.
1403 ASSERT(depth_ >= 1); 1421 ASSERT(depth_ >= 1);
1404 return depth_; 1422 return depth_;
1405 } 1423 }
1406 1424
1407 protected: 1425 protected:
1408 MaterializedLiteral(Isolate* isolate, 1426 MaterializedLiteral(Zone* zone,
1409 int literal_index, 1427 int literal_index,
1410 int pos) 1428 int pos)
1411 : Expression(isolate, pos), 1429 : Expression(zone, pos),
1412 literal_index_(literal_index), 1430 literal_index_(literal_index),
1413 is_simple_(false), 1431 is_simple_(false),
1414 depth_(0) {} 1432 depth_(0) {}
1415 1433
1416 // A materialized literal is simple if the values consist of only 1434 // A materialized literal is simple if the values consist of only
1417 // constants and simple object and array literals. 1435 // constants and simple object and array literals.
1418 bool is_simple() const { return is_simple_; } 1436 bool is_simple() const { return is_simple_; }
1419 void set_is_simple(bool is_simple) { is_simple_ = is_simple; } 1437 void set_is_simple(bool is_simple) { is_simple_ = is_simple; }
1420 friend class CompileTimeValue; 1438 friend class CompileTimeValue;
1421 1439
(...skipping 27 matching lines...) Expand all
1449 class ObjectLiteralProperty V8_FINAL : public ZoneObject { 1467 class ObjectLiteralProperty V8_FINAL : public ZoneObject {
1450 public: 1468 public:
1451 enum Kind { 1469 enum Kind {
1452 CONSTANT, // Property with constant value (compile time). 1470 CONSTANT, // Property with constant value (compile time).
1453 COMPUTED, // Property with computed value (execution time). 1471 COMPUTED, // Property with computed value (execution time).
1454 MATERIALIZED_LITERAL, // Property value is a materialized literal. 1472 MATERIALIZED_LITERAL, // Property value is a materialized literal.
1455 GETTER, SETTER, // Property is an accessor function. 1473 GETTER, SETTER, // Property is an accessor function.
1456 PROTOTYPE // Property is __proto__. 1474 PROTOTYPE // Property is __proto__.
1457 }; 1475 };
1458 1476
1459 ObjectLiteralProperty(Literal* key, Expression* value, Isolate* isolate); 1477 ObjectLiteralProperty(Zone* zone, Literal* key, Expression* value);
1460 1478
1461 Literal* key() { return key_; } 1479 Literal* key() { return key_; }
1462 Expression* value() { return value_; } 1480 Expression* value() { return value_; }
1463 Kind kind() { return kind_; } 1481 Kind kind() { return kind_; }
1464 1482
1465 // Type feedback information. 1483 // Type feedback information.
1466 void RecordTypeFeedback(TypeFeedbackOracle* oracle); 1484 void RecordTypeFeedback(TypeFeedbackOracle* oracle);
1467 bool IsMonomorphic() { return !receiver_type_.is_null(); } 1485 bool IsMonomorphic() { return !receiver_type_.is_null(); }
1468 Handle<Map> GetReceiverType() { return receiver_type_; } 1486 Handle<Map> GetReceiverType() { return receiver_type_; }
1469 1487
1470 bool IsCompileTimeValue(); 1488 bool IsCompileTimeValue();
1471 1489
1472 void set_emit_store(bool emit_store); 1490 void set_emit_store(bool emit_store);
1473 bool emit_store(); 1491 bool emit_store();
1474 1492
1475 protected: 1493 protected:
1476 template<class> friend class AstNodeFactory; 1494 template<class> friend class AstNodeFactory;
1477 1495
1478 ObjectLiteralProperty(bool is_getter, FunctionLiteral* value); 1496 ObjectLiteralProperty(Zone* zone, bool is_getter, FunctionLiteral* value);
1479 void set_key(Literal* key) { key_ = key; } 1497 void set_key(Literal* key) { key_ = key; }
1480 1498
1481 private: 1499 private:
1482 Literal* key_; 1500 Literal* key_;
1483 Expression* value_; 1501 Expression* value_;
1484 Kind kind_; 1502 Kind kind_;
1485 bool emit_store_; 1503 bool emit_store_;
1486 Handle<Map> receiver_type_; 1504 Handle<Map> receiver_type_;
1487 }; 1505 };
1488 1506
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 kHasFunction = 1 << 1 1538 kHasFunction = 1 << 1
1521 }; 1539 };
1522 1540
1523 struct Accessors: public ZoneObject { 1541 struct Accessors: public ZoneObject {
1524 Accessors() : getter(NULL), setter(NULL) { } 1542 Accessors() : getter(NULL), setter(NULL) { }
1525 Expression* getter; 1543 Expression* getter;
1526 Expression* setter; 1544 Expression* setter;
1527 }; 1545 };
1528 1546
1529 protected: 1547 protected:
1530 ObjectLiteral(Isolate* isolate, 1548 ObjectLiteral(Zone* zone,
1531 ZoneList<Property*>* properties, 1549 ZoneList<Property*>* properties,
1532 int literal_index, 1550 int literal_index,
1533 int boilerplate_properties, 1551 int boilerplate_properties,
1534 bool has_function, 1552 bool has_function,
1535 int pos) 1553 int pos)
1536 : MaterializedLiteral(isolate, literal_index, pos), 1554 : MaterializedLiteral(zone, literal_index, pos),
1537 properties_(properties), 1555 properties_(properties),
1538 boilerplate_properties_(boilerplate_properties), 1556 boilerplate_properties_(boilerplate_properties),
1539 fast_elements_(false), 1557 fast_elements_(false),
1540 may_store_doubles_(false), 1558 may_store_doubles_(false),
1541 has_function_(has_function) {} 1559 has_function_(has_function) {}
1542 1560
1543 private: 1561 private:
1544 Handle<FixedArray> constant_properties_; 1562 Handle<FixedArray> constant_properties_;
1545 ZoneList<Property*>* properties_; 1563 ZoneList<Property*>* properties_;
1546 int boilerplate_properties_; 1564 int boilerplate_properties_;
1547 bool fast_elements_; 1565 bool fast_elements_;
1548 bool may_store_doubles_; 1566 bool may_store_doubles_;
1549 bool has_function_; 1567 bool has_function_;
1550 }; 1568 };
1551 1569
1552 1570
1553 // Node for capturing a regexp literal. 1571 // Node for capturing a regexp literal.
1554 class RegExpLiteral V8_FINAL : public MaterializedLiteral { 1572 class RegExpLiteral V8_FINAL : public MaterializedLiteral {
1555 public: 1573 public:
1556 DECLARE_NODE_TYPE(RegExpLiteral) 1574 DECLARE_NODE_TYPE(RegExpLiteral)
1557 1575
1558 Handle<String> pattern() const { return pattern_; } 1576 Handle<String> pattern() const { return pattern_; }
1559 Handle<String> flags() const { return flags_; } 1577 Handle<String> flags() const { return flags_; }
1560 1578
1561 protected: 1579 protected:
1562 RegExpLiteral(Isolate* isolate, 1580 RegExpLiteral(Zone* zone,
1563 Handle<String> pattern, 1581 Handle<String> pattern,
1564 Handle<String> flags, 1582 Handle<String> flags,
1565 int literal_index, 1583 int literal_index,
1566 int pos) 1584 int pos)
1567 : MaterializedLiteral(isolate, literal_index, pos), 1585 : MaterializedLiteral(zone, literal_index, pos),
1568 pattern_(pattern), 1586 pattern_(pattern),
1569 flags_(flags) { 1587 flags_(flags) {
1570 set_depth(1); 1588 set_depth(1);
1571 } 1589 }
1572 1590
1573 private: 1591 private:
1574 Handle<String> pattern_; 1592 Handle<String> pattern_;
1575 Handle<String> flags_; 1593 Handle<String> flags_;
1576 }; 1594 };
1577 1595
(...skipping 15 matching lines...) Expand all
1593 // Populate the constant elements fixed array. 1611 // Populate the constant elements fixed array.
1594 void BuildConstantElements(Isolate* isolate); 1612 void BuildConstantElements(Isolate* isolate);
1595 1613
1596 enum Flags { 1614 enum Flags {
1597 kNoFlags = 0, 1615 kNoFlags = 0,
1598 kShallowElements = 1, 1616 kShallowElements = 1,
1599 kDisableMementos = 1 << 1 1617 kDisableMementos = 1 << 1
1600 }; 1618 };
1601 1619
1602 protected: 1620 protected:
1603 ArrayLiteral(Isolate* isolate, 1621 ArrayLiteral(Zone* zone,
1604 ZoneList<Expression*>* values, 1622 ZoneList<Expression*>* values,
1605 int literal_index, 1623 int literal_index,
1606 int pos) 1624 int pos)
1607 : MaterializedLiteral(isolate, literal_index, pos), 1625 : MaterializedLiteral(zone, literal_index, pos),
1608 values_(values), 1626 values_(values),
1609 first_element_id_(ReserveIdRange(isolate, values->length())) {} 1627 first_element_id_(ReserveIdRange(zone, values->length())) {}
1610 1628
1611 private: 1629 private:
1612 Handle<FixedArray> constant_elements_; 1630 Handle<FixedArray> constant_elements_;
1613 ZoneList<Expression*>* values_; 1631 ZoneList<Expression*>* values_;
1614 const BailoutId first_element_id_; 1632 const BailoutId first_element_id_;
1615 }; 1633 };
1616 1634
1617 1635
1618 class VariableProxy V8_FINAL : public Expression { 1636 class VariableProxy V8_FINAL : public Expression {
1619 public: 1637 public:
(...skipping 19 matching lines...) Expand all
1639 Interface* interface() const { return interface_; } 1657 Interface* interface() const { return interface_; }
1640 1658
1641 1659
1642 void MarkAsTrivial() { is_trivial_ = true; } 1660 void MarkAsTrivial() { is_trivial_ = true; }
1643 void MarkAsLValue() { is_lvalue_ = true; } 1661 void MarkAsLValue() { is_lvalue_ = true; }
1644 1662
1645 // Bind this proxy to the variable var. Interfaces must match. 1663 // Bind this proxy to the variable var. Interfaces must match.
1646 void BindTo(Variable* var); 1664 void BindTo(Variable* var);
1647 1665
1648 protected: 1666 protected:
1649 VariableProxy(Isolate* isolate, Variable* var, int position); 1667 VariableProxy(Zone* zone, Variable* var, int position);
1650 1668
1651 VariableProxy(Isolate* isolate, 1669 VariableProxy(Zone* zone,
1652 Handle<String> name, 1670 Handle<String> name,
1653 bool is_this, 1671 bool is_this,
1654 Interface* interface, 1672 Interface* interface,
1655 int position); 1673 int position);
1656 1674
1657 Handle<String> name_; 1675 Handle<String> name_;
1658 Variable* var_; // resolved variable, or NULL 1676 Variable* var_; // resolved variable, or NULL
1659 bool is_this_; 1677 bool is_this_;
1660 bool is_trivial_; 1678 bool is_trivial_;
1661 // True if this variable proxy is being used in an assignment 1679 // True if this variable proxy is being used in an assignment
(...skipping 20 matching lines...) Expand all
1682 // Type feedback information. 1700 // Type feedback information.
1683 virtual bool IsMonomorphic() V8_OVERRIDE { 1701 virtual bool IsMonomorphic() V8_OVERRIDE {
1684 return receiver_types_.length() == 1; 1702 return receiver_types_.length() == 1;
1685 } 1703 }
1686 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { 1704 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE {
1687 return &receiver_types_; 1705 return &receiver_types_;
1688 } 1706 }
1689 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE { 1707 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE {
1690 return STANDARD_STORE; 1708 return STANDARD_STORE;
1691 } 1709 }
1692 bool IsUninitialized() { return is_uninitialized_; } 1710 bool IsUninitialized() { return !is_for_call_ && is_uninitialized_; }
1693 bool IsPreMonomorphic() { return is_pre_monomorphic_; }
1694 bool HasNoTypeInformation() { 1711 bool HasNoTypeInformation() {
1695 return is_uninitialized_ || is_pre_monomorphic_; 1712 return is_uninitialized_;
1696 } 1713 }
1697 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } 1714 void set_is_uninitialized(bool b) { is_uninitialized_ = b; }
1698 void set_is_pre_monomorphic(bool b) { is_pre_monomorphic_ = b; }
1699 void set_is_string_access(bool b) { is_string_access_ = b; } 1715 void set_is_string_access(bool b) { is_string_access_ = b; }
1700 void set_is_function_prototype(bool b) { is_function_prototype_ = b; } 1716 void set_is_function_prototype(bool b) { is_function_prototype_ = b; }
1717 void mark_for_call() { is_for_call_ = true; }
1718 bool IsForCall() { return is_for_call_; }
1701 1719
1702 TypeFeedbackId PropertyFeedbackId() { return reuse(id()); } 1720 TypeFeedbackId PropertyFeedbackId() { return reuse(id()); }
1703 1721
1704 protected: 1722 protected:
1705 Property(Isolate* isolate, 1723 Property(Zone* zone,
1706 Expression* obj, 1724 Expression* obj,
1707 Expression* key, 1725 Expression* key,
1708 int pos) 1726 int pos)
1709 : Expression(isolate, pos), 1727 : Expression(zone, pos),
1710 obj_(obj), 1728 obj_(obj),
1711 key_(key), 1729 key_(key),
1712 load_id_(GetNextId(isolate)), 1730 load_id_(GetNextId(zone)),
1713 is_pre_monomorphic_(false), 1731 is_for_call_(false),
1714 is_uninitialized_(false), 1732 is_uninitialized_(false),
1715 is_string_access_(false), 1733 is_string_access_(false),
1716 is_function_prototype_(false) { } 1734 is_function_prototype_(false) { }
1717 1735
1718 private: 1736 private:
1719 Expression* obj_; 1737 Expression* obj_;
1720 Expression* key_; 1738 Expression* key_;
1721 const BailoutId load_id_; 1739 const BailoutId load_id_;
1722 1740
1723 SmallMapList receiver_types_; 1741 SmallMapList receiver_types_;
1724 bool is_pre_monomorphic_ : 1; 1742 bool is_for_call_ : 1;
1725 bool is_uninitialized_ : 1; 1743 bool is_uninitialized_ : 1;
1726 bool is_string_access_ : 1; 1744 bool is_string_access_ : 1;
1727 bool is_function_prototype_ : 1; 1745 bool is_function_prototype_ : 1;
1728 }; 1746 };
1729 1747
1730 1748
1731 class Call V8_FINAL : public Expression { 1749 class Call V8_FINAL : public Expression, public FeedbackSlotInterface {
1732 public: 1750 public:
1733 DECLARE_NODE_TYPE(Call) 1751 DECLARE_NODE_TYPE(Call)
1734 1752
1735 Expression* expression() const { return expression_; } 1753 Expression* expression() const { return expression_; }
1736 ZoneList<Expression*>* arguments() const { return arguments_; } 1754 ZoneList<Expression*>* arguments() const { return arguments_; }
1737 1755
1738 // Type feedback information. 1756 // Type feedback information.
1739 TypeFeedbackId CallFeedbackId() const { return reuse(id()); } 1757 virtual ComputablePhase GetComputablePhase() { return AFTER_SCOPING; }
1740 void RecordTypeFeedback(TypeFeedbackOracle* oracle); 1758 virtual int ComputeFeedbackSlotCount(Isolate* isolate);
1741 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { 1759 virtual void SetFirstFeedbackSlot(int slot) {
1742 return &receiver_types_; 1760 call_feedback_slot_ = slot;
1743 }
1744 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; }
1745 bool KeyedArrayCallIsHoley() { return keyed_array_call_is_holey_; }
1746 CheckType check_type() const { return check_type_; }
1747
1748 void set_string_check(Handle<JSObject> holder) {
1749 holder_ = holder;
1750 check_type_ = STRING_CHECK;
1751 } 1761 }
1752 1762
1753 void set_number_check(Handle<JSObject> holder) { 1763 bool HasCallFeedbackSlot() const {
1754 holder_ = holder; 1764 return call_feedback_slot_ != kInvalidFeedbackSlot;
1755 check_type_ = NUMBER_CHECK; 1765 }
1766 int CallFeedbackSlot() const { return call_feedback_slot_; }
1767
1768 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE {
1769 if (expression()->IsProperty()) {
1770 return expression()->AsProperty()->GetReceiverTypes();
1771 }
1772 return NULL;
1756 } 1773 }
1757 1774
1758 void set_map_check() { 1775 virtual bool IsMonomorphic() V8_OVERRIDE {
1759 holder_ = Handle<JSObject>::null(); 1776 if (expression()->IsProperty()) {
1760 check_type_ = RECEIVER_MAP_CHECK; 1777 return expression()->AsProperty()->IsMonomorphic();
1778 }
1779 return !target_.is_null();
1761 } 1780 }
1762 1781
1763 Handle<JSFunction> target() { return target_; } 1782 Handle<JSFunction> target() { return target_; }
1764 1783
1765 // A cache for the holder, set as a side effect of computing the target of the
1766 // call. Note that it contains the null handle when the receiver is the same
1767 // as the holder!
1768 Handle<JSObject> holder() { return holder_; }
1769
1770 Handle<Cell> cell() { return cell_; } 1784 Handle<Cell> cell() { return cell_; }
1771 1785
1772 bool ComputeTarget(Handle<Map> type, Handle<String> name); 1786 void set_target(Handle<JSFunction> target) { target_ = target; }
1773 bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupResult* lookup); 1787 bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupResult* lookup);
1774 1788
1775 BailoutId ReturnId() const { return return_id_; } 1789 BailoutId ReturnId() const { return return_id_; }
1776 1790
1777 enum CallType { 1791 enum CallType {
1778 POSSIBLY_EVAL_CALL, 1792 POSSIBLY_EVAL_CALL,
1779 GLOBAL_CALL, 1793 GLOBAL_CALL,
1780 LOOKUP_SLOT_CALL, 1794 LOOKUP_SLOT_CALL,
1781 PROPERTY_CALL, 1795 PROPERTY_CALL,
1782 OTHER_CALL 1796 OTHER_CALL
1783 }; 1797 };
1784 1798
1785 // Helpers to determine how to handle the call. 1799 // Helpers to determine how to handle the call.
1786 CallType GetCallType(Isolate* isolate) const; 1800 CallType GetCallType(Isolate* isolate) const;
1787 1801
1788 // TODO(rossberg): this should really move somewhere else (and be merged with
1789 // various similar methods in objets.cc), but for now...
1790 static Handle<JSObject> GetPrototypeForPrimitiveCheck(
1791 CheckType check, Isolate* isolate);
1792
1793 #ifdef DEBUG 1802 #ifdef DEBUG
1794 // Used to assert that the FullCodeGenerator records the return site. 1803 // Used to assert that the FullCodeGenerator records the return site.
1795 bool return_is_recorded_; 1804 bool return_is_recorded_;
1796 #endif 1805 #endif
1797 1806
1798 protected: 1807 protected:
1799 Call(Isolate* isolate, 1808 Call(Zone* zone,
1800 Expression* expression, 1809 Expression* expression,
1801 ZoneList<Expression*>* arguments, 1810 ZoneList<Expression*>* arguments,
1802 int pos) 1811 int pos)
1803 : Expression(isolate, pos), 1812 : Expression(zone, pos),
1804 expression_(expression), 1813 expression_(expression),
1805 arguments_(arguments), 1814 arguments_(arguments),
1806 is_monomorphic_(false), 1815 call_feedback_slot_(kInvalidFeedbackSlot),
1807 keyed_array_call_is_holey_(true), 1816 return_id_(GetNextId(zone)) {
1808 check_type_(RECEIVER_MAP_CHECK), 1817 if (expression->IsProperty()) {
1809 return_id_(GetNextId(isolate)) { } 1818 expression->AsProperty()->mark_for_call();
1819 }
1820 }
1810 1821
1811 private: 1822 private:
1812 Expression* expression_; 1823 Expression* expression_;
1813 ZoneList<Expression*>* arguments_; 1824 ZoneList<Expression*>* arguments_;
1814 1825
1815 bool is_monomorphic_;
1816 bool keyed_array_call_is_holey_;
1817 CheckType check_type_;
1818 SmallMapList receiver_types_;
1819 Handle<JSFunction> target_; 1826 Handle<JSFunction> target_;
1820 Handle<JSObject> holder_;
1821 Handle<Cell> cell_; 1827 Handle<Cell> cell_;
1828 int call_feedback_slot_;
1822 1829
1823 const BailoutId return_id_; 1830 const BailoutId return_id_;
1824 }; 1831 };
1825 1832
1826 1833
1827 class CallNew V8_FINAL : public Expression { 1834 class CallNew V8_FINAL : public Expression, public FeedbackSlotInterface {
1828 public: 1835 public:
1829 DECLARE_NODE_TYPE(CallNew) 1836 DECLARE_NODE_TYPE(CallNew)
1830 1837
1831 Expression* expression() const { return expression_; } 1838 Expression* expression() const { return expression_; }
1832 ZoneList<Expression*>* arguments() const { return arguments_; } 1839 ZoneList<Expression*>* arguments() const { return arguments_; }
1833 1840
1834 // Type feedback information. 1841 // Type feedback information.
1842 virtual ComputablePhase GetComputablePhase() { return DURING_PARSE; }
1843 virtual int ComputeFeedbackSlotCount(Isolate* isolate) { return 1; }
1844 virtual void SetFirstFeedbackSlot(int slot) {
1845 callnew_feedback_slot_ = slot;
1846 }
1847
1848 int CallNewFeedbackSlot() {
1849 ASSERT(callnew_feedback_slot_ != kInvalidFeedbackSlot);
1850 return callnew_feedback_slot_;
1851 }
1852
1835 TypeFeedbackId CallNewFeedbackId() const { return reuse(id()); } 1853 TypeFeedbackId CallNewFeedbackId() const { return reuse(id()); }
1836 void RecordTypeFeedback(TypeFeedbackOracle* oracle); 1854 void RecordTypeFeedback(TypeFeedbackOracle* oracle);
1837 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; } 1855 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; }
1838 Handle<JSFunction> target() const { return target_; } 1856 Handle<JSFunction> target() const { return target_; }
1839 ElementsKind elements_kind() const { return elements_kind_; } 1857 ElementsKind elements_kind() const { return elements_kind_; }
1840 Handle<Cell> allocation_info_cell() const { 1858 Handle<AllocationSite> allocation_site() const {
1841 return allocation_info_cell_; 1859 return allocation_site_;
1842 } 1860 }
1843 1861
1862 static int feedback_slots() { return 1; }
1863
1844 BailoutId ReturnId() const { return return_id_; } 1864 BailoutId ReturnId() const { return return_id_; }
1845 1865
1846 protected: 1866 protected:
1847 CallNew(Isolate* isolate, 1867 CallNew(Zone* zone,
1848 Expression* expression, 1868 Expression* expression,
1849 ZoneList<Expression*>* arguments, 1869 ZoneList<Expression*>* arguments,
1850 int pos) 1870 int pos)
1851 : Expression(isolate, pos), 1871 : Expression(zone, pos),
1852 expression_(expression), 1872 expression_(expression),
1853 arguments_(arguments), 1873 arguments_(arguments),
1854 is_monomorphic_(false), 1874 is_monomorphic_(false),
1855 elements_kind_(GetInitialFastElementsKind()), 1875 elements_kind_(GetInitialFastElementsKind()),
1856 return_id_(GetNextId(isolate)) { } 1876 callnew_feedback_slot_(kInvalidFeedbackSlot),
1877 return_id_(GetNextId(zone)) { }
1857 1878
1858 private: 1879 private:
1859 Expression* expression_; 1880 Expression* expression_;
1860 ZoneList<Expression*>* arguments_; 1881 ZoneList<Expression*>* arguments_;
1861 1882
1862 bool is_monomorphic_; 1883 bool is_monomorphic_;
1863 Handle<JSFunction> target_; 1884 Handle<JSFunction> target_;
1864 ElementsKind elements_kind_; 1885 ElementsKind elements_kind_;
1865 Handle<Cell> allocation_info_cell_; 1886 Handle<AllocationSite> allocation_site_;
1887 int callnew_feedback_slot_;
1866 1888
1867 const BailoutId return_id_; 1889 const BailoutId return_id_;
1868 }; 1890 };
1869 1891
1870 1892
1871 // The CallRuntime class does not represent any official JavaScript 1893 // The CallRuntime class does not represent any official JavaScript
1872 // language construct. Instead it is used to call a C or JS function 1894 // language construct. Instead it is used to call a C or JS function
1873 // with a set of arguments. This is used from the builtins that are 1895 // with a set of arguments. This is used from the builtins that are
1874 // implemented in JavaScript (see "v8natives.js"). 1896 // implemented in JavaScript (see "v8natives.js").
1875 class CallRuntime V8_FINAL : public Expression { 1897 class CallRuntime V8_FINAL : public Expression {
1876 public: 1898 public:
1877 DECLARE_NODE_TYPE(CallRuntime) 1899 DECLARE_NODE_TYPE(CallRuntime)
1878 1900
1879 Handle<String> name() const { return name_; } 1901 Handle<String> name() const { return name_; }
1880 const Runtime::Function* function() const { return function_; } 1902 const Runtime::Function* function() const { return function_; }
1881 ZoneList<Expression*>* arguments() const { return arguments_; } 1903 ZoneList<Expression*>* arguments() const { return arguments_; }
1882 bool is_jsruntime() const { return function_ == NULL; } 1904 bool is_jsruntime() const { return function_ == NULL; }
1883 1905
1884 TypeFeedbackId CallRuntimeFeedbackId() const { return reuse(id()); } 1906 TypeFeedbackId CallRuntimeFeedbackId() const { return reuse(id()); }
1885 1907
1886 protected: 1908 protected:
1887 CallRuntime(Isolate* isolate, 1909 CallRuntime(Zone* zone,
1888 Handle<String> name, 1910 Handle<String> name,
1889 const Runtime::Function* function, 1911 const Runtime::Function* function,
1890 ZoneList<Expression*>* arguments, 1912 ZoneList<Expression*>* arguments,
1891 int pos) 1913 int pos)
1892 : Expression(isolate, pos), 1914 : Expression(zone, pos),
1893 name_(name), 1915 name_(name),
1894 function_(function), 1916 function_(function),
1895 arguments_(arguments) { } 1917 arguments_(arguments) { }
1896 1918
1897 private: 1919 private:
1898 Handle<String> name_; 1920 Handle<String> name_;
1899 const Runtime::Function* function_; 1921 const Runtime::Function* function_;
1900 ZoneList<Expression*>* arguments_; 1922 ZoneList<Expression*>* arguments_;
1901 }; 1923 };
1902 1924
1903 1925
1904 class UnaryOperation V8_FINAL : public Expression { 1926 class UnaryOperation V8_FINAL : public Expression {
1905 public: 1927 public:
1906 DECLARE_NODE_TYPE(UnaryOperation) 1928 DECLARE_NODE_TYPE(UnaryOperation)
1907 1929
1908 Token::Value op() const { return op_; } 1930 Token::Value op() const { return op_; }
1909 Expression* expression() const { return expression_; } 1931 Expression* expression() const { return expression_; }
1910 1932
1911 BailoutId MaterializeTrueId() { return materialize_true_id_; } 1933 BailoutId MaterializeTrueId() { return materialize_true_id_; }
1912 BailoutId MaterializeFalseId() { return materialize_false_id_; } 1934 BailoutId MaterializeFalseId() { return materialize_false_id_; }
1913 1935
1914 virtual void RecordToBooleanTypeFeedback( 1936 virtual void RecordToBooleanTypeFeedback(
1915 TypeFeedbackOracle* oracle) V8_OVERRIDE; 1937 TypeFeedbackOracle* oracle) V8_OVERRIDE;
1916 1938
1917 protected: 1939 protected:
1918 UnaryOperation(Isolate* isolate, 1940 UnaryOperation(Zone* zone,
1919 Token::Value op, 1941 Token::Value op,
1920 Expression* expression, 1942 Expression* expression,
1921 int pos) 1943 int pos)
1922 : Expression(isolate, pos), 1944 : Expression(zone, pos),
1923 op_(op), 1945 op_(op),
1924 expression_(expression), 1946 expression_(expression),
1925 materialize_true_id_(GetNextId(isolate)), 1947 materialize_true_id_(GetNextId(zone)),
1926 materialize_false_id_(GetNextId(isolate)) { 1948 materialize_false_id_(GetNextId(zone)) {
1927 ASSERT(Token::IsUnaryOp(op)); 1949 ASSERT(Token::IsUnaryOp(op));
1928 } 1950 }
1929 1951
1930 private: 1952 private:
1931 Token::Value op_; 1953 Token::Value op_;
1932 Expression* expression_; 1954 Expression* expression_;
1933 1955
1934 // For unary not (Token::NOT), the AST ids where true and false will 1956 // For unary not (Token::NOT), the AST ids where true and false will
1935 // actually be materialized, respectively. 1957 // actually be materialized, respectively.
1936 const BailoutId materialize_true_id_; 1958 const BailoutId materialize_true_id_;
(...skipping 18 matching lines...) Expand all
1955 BailoutId RightId() const { return right_id_; } 1977 BailoutId RightId() const { return right_id_; }
1956 1978
1957 TypeFeedbackId BinaryOperationFeedbackId() const { return reuse(id()); } 1979 TypeFeedbackId BinaryOperationFeedbackId() const { return reuse(id()); }
1958 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; } 1980 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; }
1959 void set_fixed_right_arg(Maybe<int> arg) { fixed_right_arg_ = arg; } 1981 void set_fixed_right_arg(Maybe<int> arg) { fixed_right_arg_ = arg; }
1960 1982
1961 virtual void RecordToBooleanTypeFeedback( 1983 virtual void RecordToBooleanTypeFeedback(
1962 TypeFeedbackOracle* oracle) V8_OVERRIDE; 1984 TypeFeedbackOracle* oracle) V8_OVERRIDE;
1963 1985
1964 protected: 1986 protected:
1965 BinaryOperation(Isolate* isolate, 1987 BinaryOperation(Zone* zone,
1966 Token::Value op, 1988 Token::Value op,
1967 Expression* left, 1989 Expression* left,
1968 Expression* right, 1990 Expression* right,
1969 int pos) 1991 int pos)
1970 : Expression(isolate, pos), 1992 : Expression(zone, pos),
1971 op_(op), 1993 op_(op),
1972 left_(left), 1994 left_(left),
1973 right_(right), 1995 right_(right),
1974 right_id_(GetNextId(isolate)) { 1996 right_id_(GetNextId(zone)) {
1975 ASSERT(Token::IsBinaryOp(op)); 1997 ASSERT(Token::IsBinaryOp(op));
1976 } 1998 }
1977 1999
1978 private: 2000 private:
1979 Token::Value op_; 2001 Token::Value op_;
1980 Expression* left_; 2002 Expression* left_;
1981 Expression* right_; 2003 Expression* right_;
1982 Handle<AllocationSite> allocation_site_; 2004 Handle<AllocationSite> allocation_site_;
1983 2005
1984 // TODO(rossberg): the fixed arg should probably be represented as a Constant 2006 // TODO(rossberg): the fixed arg should probably be represented as a Constant
(...skipping 22 matching lines...) Expand all
2007 2029
2008 virtual bool IsMonomorphic() V8_OVERRIDE { 2030 virtual bool IsMonomorphic() V8_OVERRIDE {
2009 return receiver_types_.length() == 1; 2031 return receiver_types_.length() == 1;
2010 } 2032 }
2011 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { 2033 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE {
2012 return &receiver_types_; 2034 return &receiver_types_;
2013 } 2035 }
2014 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE { 2036 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE {
2015 return store_mode_; 2037 return store_mode_;
2016 } 2038 }
2017 Handle<Type> type() const { return type_; } 2039 Type* type() const { return type_; }
2018 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } 2040 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; }
2019 void set_type(Handle<Type> type) { type_ = type; } 2041 void set_type(Type* type) { type_ = type; }
2020 2042
2021 BailoutId AssignmentId() const { return assignment_id_; } 2043 BailoutId AssignmentId() const { return assignment_id_; }
2022 2044
2023 TypeFeedbackId CountBinOpFeedbackId() const { return count_id_; } 2045 TypeFeedbackId CountBinOpFeedbackId() const { return count_id_; }
2024 TypeFeedbackId CountStoreFeedbackId() const { return reuse(id()); } 2046 TypeFeedbackId CountStoreFeedbackId() const { return reuse(id()); }
2025 2047
2026 protected: 2048 protected:
2027 CountOperation(Isolate* isolate, 2049 CountOperation(Zone* zone,
2028 Token::Value op, 2050 Token::Value op,
2029 bool is_prefix, 2051 bool is_prefix,
2030 Expression* expr, 2052 Expression* expr,
2031 int pos) 2053 int pos)
2032 : Expression(isolate, pos), 2054 : Expression(zone, pos),
2033 op_(op), 2055 op_(op),
2034 is_prefix_(is_prefix), 2056 is_prefix_(is_prefix),
2035 store_mode_(STANDARD_STORE), 2057 store_mode_(STANDARD_STORE),
2036 expression_(expr), 2058 expression_(expr),
2037 assignment_id_(GetNextId(isolate)), 2059 assignment_id_(GetNextId(zone)),
2038 count_id_(GetNextId(isolate)) {} 2060 count_id_(GetNextId(zone)) {}
2039 2061
2040 private: 2062 private:
2041 Token::Value op_; 2063 Token::Value op_;
2042 bool is_prefix_ : 1; 2064 bool is_prefix_ : 1;
2043 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, 2065 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed,
2044 // must have extra bit. 2066 // must have extra bit.
2045 Handle<Type> type_; 2067 Type* type_;
2046 2068
2047 Expression* expression_; 2069 Expression* expression_;
2048 const BailoutId assignment_id_; 2070 const BailoutId assignment_id_;
2049 const TypeFeedbackId count_id_; 2071 const TypeFeedbackId count_id_;
2050 SmallMapList receiver_types_; 2072 SmallMapList receiver_types_;
2051 }; 2073 };
2052 2074
2053 2075
2054 class CompareOperation V8_FINAL : public Expression { 2076 class CompareOperation V8_FINAL : public Expression {
2055 public: 2077 public:
2056 DECLARE_NODE_TYPE(CompareOperation) 2078 DECLARE_NODE_TYPE(CompareOperation)
2057 2079
2058 Token::Value op() const { return op_; } 2080 Token::Value op() const { return op_; }
2059 Expression* left() const { return left_; } 2081 Expression* left() const { return left_; }
2060 Expression* right() const { return right_; } 2082 Expression* right() const { return right_; }
2061 2083
2062 // Type feedback information. 2084 // Type feedback information.
2063 TypeFeedbackId CompareOperationFeedbackId() const { return reuse(id()); } 2085 TypeFeedbackId CompareOperationFeedbackId() const { return reuse(id()); }
2064 Handle<Type> combined_type() const { return combined_type_; } 2086 Type* combined_type() const { return combined_type_; }
2065 void set_combined_type(Handle<Type> type) { combined_type_ = type; } 2087 void set_combined_type(Type* type) { combined_type_ = type; }
2066 2088
2067 // Match special cases. 2089 // Match special cases.
2068 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); 2090 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check);
2069 bool IsLiteralCompareUndefined(Expression** expr, Isolate* isolate); 2091 bool IsLiteralCompareUndefined(Expression** expr, Isolate* isolate);
2070 bool IsLiteralCompareNull(Expression** expr); 2092 bool IsLiteralCompareNull(Expression** expr);
2071 2093
2072 protected: 2094 protected:
2073 CompareOperation(Isolate* isolate, 2095 CompareOperation(Zone* zone,
2074 Token::Value op, 2096 Token::Value op,
2075 Expression* left, 2097 Expression* left,
2076 Expression* right, 2098 Expression* right,
2077 int pos) 2099 int pos)
2078 : Expression(isolate, pos), 2100 : Expression(zone, pos),
2079 op_(op), 2101 op_(op),
2080 left_(left), 2102 left_(left),
2081 right_(right), 2103 right_(right),
2082 combined_type_(Type::None(isolate)) { 2104 combined_type_(Type::None(zone)) {
2083 ASSERT(Token::IsCompareOp(op)); 2105 ASSERT(Token::IsCompareOp(op));
2084 } 2106 }
2085 2107
2086 private: 2108 private:
2087 Token::Value op_; 2109 Token::Value op_;
2088 Expression* left_; 2110 Expression* left_;
2089 Expression* right_; 2111 Expression* right_;
2090 2112
2091 Handle<Type> combined_type_; 2113 Type* combined_type_;
2092 }; 2114 };
2093 2115
2094 2116
2095 class Conditional V8_FINAL : public Expression { 2117 class Conditional V8_FINAL : public Expression {
2096 public: 2118 public:
2097 DECLARE_NODE_TYPE(Conditional) 2119 DECLARE_NODE_TYPE(Conditional)
2098 2120
2099 Expression* condition() const { return condition_; } 2121 Expression* condition() const { return condition_; }
2100 Expression* then_expression() const { return then_expression_; } 2122 Expression* then_expression() const { return then_expression_; }
2101 Expression* else_expression() const { return else_expression_; } 2123 Expression* else_expression() const { return else_expression_; }
2102 2124
2103 BailoutId ThenId() const { return then_id_; } 2125 BailoutId ThenId() const { return then_id_; }
2104 BailoutId ElseId() const { return else_id_; } 2126 BailoutId ElseId() const { return else_id_; }
2105 2127
2106 protected: 2128 protected:
2107 Conditional(Isolate* isolate, 2129 Conditional(Zone* zone,
2108 Expression* condition, 2130 Expression* condition,
2109 Expression* then_expression, 2131 Expression* then_expression,
2110 Expression* else_expression, 2132 Expression* else_expression,
2111 int position) 2133 int position)
2112 : Expression(isolate, position), 2134 : Expression(zone, position),
2113 condition_(condition), 2135 condition_(condition),
2114 then_expression_(then_expression), 2136 then_expression_(then_expression),
2115 else_expression_(else_expression), 2137 else_expression_(else_expression),
2116 then_id_(GetNextId(isolate)), 2138 then_id_(GetNextId(zone)),
2117 else_id_(GetNextId(isolate)) { } 2139 else_id_(GetNextId(zone)) { }
2118 2140
2119 private: 2141 private:
2120 Expression* condition_; 2142 Expression* condition_;
2121 Expression* then_expression_; 2143 Expression* then_expression_;
2122 Expression* else_expression_; 2144 Expression* else_expression_;
2123 const BailoutId then_id_; 2145 const BailoutId then_id_;
2124 const BailoutId else_id_; 2146 const BailoutId else_id_;
2125 }; 2147 };
2126 2148
2127 2149
(...skipping 14 matching lines...) Expand all
2142 bool is_compound() const { return op() > Token::ASSIGN; } 2164 bool is_compound() const { return op() > Token::ASSIGN; }
2143 2165
2144 BailoutId AssignmentId() const { return assignment_id_; } 2166 BailoutId AssignmentId() const { return assignment_id_; }
2145 2167
2146 // Type feedback information. 2168 // Type feedback information.
2147 TypeFeedbackId AssignmentFeedbackId() { return reuse(id()); } 2169 TypeFeedbackId AssignmentFeedbackId() { return reuse(id()); }
2148 virtual bool IsMonomorphic() V8_OVERRIDE { 2170 virtual bool IsMonomorphic() V8_OVERRIDE {
2149 return receiver_types_.length() == 1; 2171 return receiver_types_.length() == 1;
2150 } 2172 }
2151 bool IsUninitialized() { return is_uninitialized_; } 2173 bool IsUninitialized() { return is_uninitialized_; }
2152 bool IsPreMonomorphic() { return is_pre_monomorphic_; }
2153 bool HasNoTypeInformation() { 2174 bool HasNoTypeInformation() {
2154 return is_uninitialized_ || is_pre_monomorphic_; 2175 return is_uninitialized_;
2155 } 2176 }
2156 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { 2177 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE {
2157 return &receiver_types_; 2178 return &receiver_types_;
2158 } 2179 }
2159 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE { 2180 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE {
2160 return store_mode_; 2181 return store_mode_;
2161 } 2182 }
2162 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } 2183 void set_is_uninitialized(bool b) { is_uninitialized_ = b; }
2163 void set_is_pre_monomorphic(bool b) { is_pre_monomorphic_ = b; }
2164 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } 2184 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; }
2165 2185
2166 protected: 2186 protected:
2167 Assignment(Isolate* isolate, 2187 Assignment(Zone* zone,
2168 Token::Value op, 2188 Token::Value op,
2169 Expression* target, 2189 Expression* target,
2170 Expression* value, 2190 Expression* value,
2171 int pos); 2191 int pos);
2172 2192
2173 template<class Visitor> 2193 template<class Visitor>
2174 void Init(Isolate* isolate, AstNodeFactory<Visitor>* factory) { 2194 void Init(Zone* zone, AstNodeFactory<Visitor>* factory) {
2175 ASSERT(Token::IsAssignmentOp(op_)); 2195 ASSERT(Token::IsAssignmentOp(op_));
2176 if (is_compound()) { 2196 if (is_compound()) {
2177 binary_operation_ = factory->NewBinaryOperation( 2197 binary_operation_ = factory->NewBinaryOperation(
2178 binary_op(), target_, value_, position() + 1); 2198 binary_op(), target_, value_, position() + 1);
2179 } 2199 }
2180 } 2200 }
2181 2201
2182 private: 2202 private:
2183 Token::Value op_; 2203 Token::Value op_;
2184 Expression* target_; 2204 Expression* target_;
2185 Expression* value_; 2205 Expression* value_;
2186 BinaryOperation* binary_operation_; 2206 BinaryOperation* binary_operation_;
2187 const BailoutId assignment_id_; 2207 const BailoutId assignment_id_;
2188 2208
2189 bool is_uninitialized_ : 1; 2209 bool is_uninitialized_ : 1;
2190 bool is_pre_monomorphic_ : 1;
2191 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, 2210 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed,
2192 // must have extra bit. 2211 // must have extra bit.
2193 SmallMapList receiver_types_; 2212 SmallMapList receiver_types_;
2194 }; 2213 };
2195 2214
2196 2215
2197 class Yield V8_FINAL : public Expression { 2216 class Yield V8_FINAL : public Expression {
2198 public: 2217 public:
2199 DECLARE_NODE_TYPE(Yield) 2218 DECLARE_NODE_TYPE(Yield)
2200 2219
(...skipping 14 matching lines...) Expand all
2215 int index() const { 2234 int index() const {
2216 ASSERT(yield_kind() == DELEGATING); 2235 ASSERT(yield_kind() == DELEGATING);
2217 return index_; 2236 return index_;
2218 } 2237 }
2219 void set_index(int index) { 2238 void set_index(int index) {
2220 ASSERT(yield_kind() == DELEGATING); 2239 ASSERT(yield_kind() == DELEGATING);
2221 index_ = index; 2240 index_ = index;
2222 } 2241 }
2223 2242
2224 protected: 2243 protected:
2225 Yield(Isolate* isolate, 2244 Yield(Zone* zone,
2226 Expression* generator_object, 2245 Expression* generator_object,
2227 Expression* expression, 2246 Expression* expression,
2228 Kind yield_kind, 2247 Kind yield_kind,
2229 int pos) 2248 int pos)
2230 : Expression(isolate, pos), 2249 : Expression(zone, pos),
2231 generator_object_(generator_object), 2250 generator_object_(generator_object),
2232 expression_(expression), 2251 expression_(expression),
2233 yield_kind_(yield_kind), 2252 yield_kind_(yield_kind),
2234 index_(-1) { } 2253 index_(-1) { }
2235 2254
2236 private: 2255 private:
2237 Expression* generator_object_; 2256 Expression* generator_object_;
2238 Expression* expression_; 2257 Expression* expression_;
2239 Kind yield_kind_; 2258 Kind yield_kind_;
2240 int index_; 2259 int index_;
2241 }; 2260 };
2242 2261
2243 2262
2244 class Throw V8_FINAL : public Expression { 2263 class Throw V8_FINAL : public Expression {
2245 public: 2264 public:
2246 DECLARE_NODE_TYPE(Throw) 2265 DECLARE_NODE_TYPE(Throw)
2247 2266
2248 Expression* exception() const { return exception_; } 2267 Expression* exception() const { return exception_; }
2249 2268
2250 protected: 2269 protected:
2251 Throw(Isolate* isolate, Expression* exception, int pos) 2270 Throw(Zone* zone, Expression* exception, int pos)
2252 : Expression(isolate, pos), exception_(exception) {} 2271 : Expression(zone, pos), exception_(exception) {}
2253 2272
2254 private: 2273 private:
2255 Expression* exception_; 2274 Expression* exception_;
2256 }; 2275 };
2257 2276
2258 2277
2259 class FunctionLiteral V8_FINAL : public Expression { 2278 class FunctionLiteral V8_FINAL : public Expression {
2260 public: 2279 public:
2261 enum FunctionType { 2280 enum FunctionType {
2262 ANONYMOUS_EXPRESSION, 2281 ANONYMOUS_EXPRESSION,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2345 2364
2346 bool is_generator() { 2365 bool is_generator() {
2347 return IsGenerator::decode(bitfield_) == kIsGenerator; 2366 return IsGenerator::decode(bitfield_) == kIsGenerator;
2348 } 2367 }
2349 2368
2350 int ast_node_count() { return ast_properties_.node_count(); } 2369 int ast_node_count() { return ast_properties_.node_count(); }
2351 AstProperties::Flags* flags() { return ast_properties_.flags(); } 2370 AstProperties::Flags* flags() { return ast_properties_.flags(); }
2352 void set_ast_properties(AstProperties* ast_properties) { 2371 void set_ast_properties(AstProperties* ast_properties) {
2353 ast_properties_ = *ast_properties; 2372 ast_properties_ = *ast_properties;
2354 } 2373 }
2355 2374 void set_slot_processor(DeferredFeedbackSlotProcessor* slot_processor) {
2375 slot_processor_ = *slot_processor;
2376 }
2377 void ProcessFeedbackSlots(Isolate* isolate) {
2378 slot_processor_.ProcessFeedbackSlots(isolate);
2379 }
2380 int slot_count() {
2381 return slot_processor_.slot_count();
2382 }
2356 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } 2383 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; }
2357 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } 2384 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; }
2358 void set_dont_optimize_reason(BailoutReason reason) { 2385 void set_dont_optimize_reason(BailoutReason reason) {
2359 dont_optimize_reason_ = reason; 2386 dont_optimize_reason_ = reason;
2360 } 2387 }
2361 2388
2362 protected: 2389 protected:
2363 FunctionLiteral(Isolate* isolate, 2390 FunctionLiteral(Zone* zone,
2364 Handle<String> name, 2391 Handle<String> name,
2365 Scope* scope, 2392 Scope* scope,
2366 ZoneList<Statement*>* body, 2393 ZoneList<Statement*>* body,
2367 int materialized_literal_count, 2394 int materialized_literal_count,
2368 int expected_property_count, 2395 int expected_property_count,
2369 int handler_count, 2396 int handler_count,
2370 int parameter_count, 2397 int parameter_count,
2371 FunctionType function_type, 2398 FunctionType function_type,
2372 ParameterFlag has_duplicate_parameters, 2399 ParameterFlag has_duplicate_parameters,
2373 IsFunctionFlag is_function, 2400 IsFunctionFlag is_function,
2374 IsParenthesizedFlag is_parenthesized, 2401 IsParenthesizedFlag is_parenthesized,
2375 IsGeneratorFlag is_generator, 2402 IsGeneratorFlag is_generator,
2376 int position) 2403 int position)
2377 : Expression(isolate, position), 2404 : Expression(zone, position),
2378 name_(name), 2405 name_(name),
2379 scope_(scope), 2406 scope_(scope),
2380 body_(body), 2407 body_(body),
2381 inferred_name_(isolate->factory()->empty_string()), 2408 inferred_name_(zone->isolate()->factory()->empty_string()),
2382 dont_optimize_reason_(kNoReason), 2409 dont_optimize_reason_(kNoReason),
2383 materialized_literal_count_(materialized_literal_count), 2410 materialized_literal_count_(materialized_literal_count),
2384 expected_property_count_(expected_property_count), 2411 expected_property_count_(expected_property_count),
2385 handler_count_(handler_count), 2412 handler_count_(handler_count),
2386 parameter_count_(parameter_count), 2413 parameter_count_(parameter_count),
2387 function_token_position_(RelocInfo::kNoPosition) { 2414 function_token_position_(RelocInfo::kNoPosition) {
2388 bitfield_ = 2415 bitfield_ =
2389 IsExpression::encode(function_type != DECLARATION) | 2416 IsExpression::encode(function_type != DECLARATION) |
2390 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) | 2417 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) |
2391 Pretenure::encode(false) | 2418 Pretenure::encode(false) |
2392 HasDuplicateParameters::encode(has_duplicate_parameters) | 2419 HasDuplicateParameters::encode(has_duplicate_parameters) |
2393 IsFunction::encode(is_function) | 2420 IsFunction::encode(is_function) |
2394 IsParenthesized::encode(is_parenthesized) | 2421 IsParenthesized::encode(is_parenthesized) |
2395 IsGenerator::encode(is_generator); 2422 IsGenerator::encode(is_generator);
2396 } 2423 }
2397 2424
2398 private: 2425 private:
2399 Handle<String> name_; 2426 Handle<String> name_;
2400 Handle<SharedFunctionInfo> shared_info_; 2427 Handle<SharedFunctionInfo> shared_info_;
2401 Scope* scope_; 2428 Scope* scope_;
2402 ZoneList<Statement*>* body_; 2429 ZoneList<Statement*>* body_;
2403 Handle<String> inferred_name_; 2430 Handle<String> inferred_name_;
2404 AstProperties ast_properties_; 2431 AstProperties ast_properties_;
2432 DeferredFeedbackSlotProcessor slot_processor_;
2405 BailoutReason dont_optimize_reason_; 2433 BailoutReason dont_optimize_reason_;
2406 2434
2407 int materialized_literal_count_; 2435 int materialized_literal_count_;
2408 int expected_property_count_; 2436 int expected_property_count_;
2409 int handler_count_; 2437 int handler_count_;
2410 int parameter_count_; 2438 int parameter_count_;
2411 int function_token_position_; 2439 int function_token_position_;
2412 2440
2413 unsigned bitfield_; 2441 unsigned bitfield_;
2414 class IsExpression: public BitField<bool, 0, 1> {}; 2442 class IsExpression: public BitField<bool, 0, 1> {};
2415 class IsAnonymous: public BitField<bool, 1, 1> {}; 2443 class IsAnonymous: public BitField<bool, 1, 1> {};
2416 class Pretenure: public BitField<bool, 2, 1> {}; 2444 class Pretenure: public BitField<bool, 2, 1> {};
2417 class HasDuplicateParameters: public BitField<ParameterFlag, 3, 1> {}; 2445 class HasDuplicateParameters: public BitField<ParameterFlag, 3, 1> {};
2418 class IsFunction: public BitField<IsFunctionFlag, 4, 1> {}; 2446 class IsFunction: public BitField<IsFunctionFlag, 4, 1> {};
2419 class IsParenthesized: public BitField<IsParenthesizedFlag, 5, 1> {}; 2447 class IsParenthesized: public BitField<IsParenthesizedFlag, 5, 1> {};
2420 class IsGenerator: public BitField<IsGeneratorFlag, 6, 1> {}; 2448 class IsGenerator: public BitField<IsGeneratorFlag, 6, 1> {};
2421 }; 2449 };
2422 2450
2423 2451
2424 class NativeFunctionLiteral V8_FINAL : public Expression { 2452 class NativeFunctionLiteral V8_FINAL : public Expression {
2425 public: 2453 public:
2426 DECLARE_NODE_TYPE(NativeFunctionLiteral) 2454 DECLARE_NODE_TYPE(NativeFunctionLiteral)
2427 2455
2428 Handle<String> name() const { return name_; } 2456 Handle<String> name() const { return name_; }
2429 v8::Extension* extension() const { return extension_; } 2457 v8::Extension* extension() const { return extension_; }
2430 2458
2431 protected: 2459 protected:
2432 NativeFunctionLiteral( 2460 NativeFunctionLiteral(
2433 Isolate* isolate, Handle<String> name, v8::Extension* extension, int pos) 2461 Zone* zone, Handle<String> name, v8::Extension* extension, int pos)
2434 : Expression(isolate, pos), name_(name), extension_(extension) {} 2462 : Expression(zone, pos), name_(name), extension_(extension) {}
2435 2463
2436 private: 2464 private:
2437 Handle<String> name_; 2465 Handle<String> name_;
2438 v8::Extension* extension_; 2466 v8::Extension* extension_;
2439 }; 2467 };
2440 2468
2441 2469
2442 class ThisFunction V8_FINAL : public Expression { 2470 class ThisFunction V8_FINAL : public Expression {
2443 public: 2471 public:
2444 DECLARE_NODE_TYPE(ThisFunction) 2472 DECLARE_NODE_TYPE(ThisFunction)
2445 2473
2446 protected: 2474 protected:
2447 explicit ThisFunction(Isolate* isolate, int pos): Expression(isolate, pos) {} 2475 explicit ThisFunction(Zone* zone, int pos): Expression(zone, pos) {}
2448 }; 2476 };
2449 2477
2450 #undef DECLARE_NODE_TYPE 2478 #undef DECLARE_NODE_TYPE
2451 2479
2452 2480
2453 // ---------------------------------------------------------------------------- 2481 // ----------------------------------------------------------------------------
2454 // Regular expressions 2482 // Regular expressions
2455 2483
2456 2484
2457 class RegExpVisitor BASE_EMBEDDED { 2485 class RegExpVisitor BASE_EMBEDDED {
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
2804 static RegExpEmpty* GetInstance() { 2832 static RegExpEmpty* GetInstance() {
2805 static RegExpEmpty* instance = ::new RegExpEmpty(); 2833 static RegExpEmpty* instance = ::new RegExpEmpty();
2806 return instance; 2834 return instance;
2807 } 2835 }
2808 }; 2836 };
2809 2837
2810 2838
2811 // ---------------------------------------------------------------------------- 2839 // ----------------------------------------------------------------------------
2812 // Out-of-line inline constructors (to side-step cyclic dependencies). 2840 // Out-of-line inline constructors (to side-step cyclic dependencies).
2813 2841
2814 inline ModuleVariable::ModuleVariable(VariableProxy* proxy, int pos) 2842 inline ModuleVariable::ModuleVariable(Zone* zone, VariableProxy* proxy, int pos)
2815 : Module(proxy->interface(), pos), 2843 : Module(zone, proxy->interface(), pos),
2816 proxy_(proxy) { 2844 proxy_(proxy) {
2817 } 2845 }
2818 2846
2819 2847
2820 // ---------------------------------------------------------------------------- 2848 // ----------------------------------------------------------------------------
2821 // Basic visitor 2849 // Basic visitor
2822 // - leaf node visitors are abstract. 2850 // - leaf node visitors are abstract.
2823 2851
2824 class AstVisitor BASE_EMBEDDED { 2852 class AstVisitor BASE_EMBEDDED {
2825 public: 2853 public:
(...skipping 11 matching lines...) Expand all
2837 // Individual AST nodes. 2865 // Individual AST nodes.
2838 #define DEF_VISIT(type) \ 2866 #define DEF_VISIT(type) \
2839 virtual void Visit##type(type* node) = 0; 2867 virtual void Visit##type(type* node) = 0;
2840 AST_NODE_LIST(DEF_VISIT) 2868 AST_NODE_LIST(DEF_VISIT)
2841 #undef DEF_VISIT 2869 #undef DEF_VISIT
2842 }; 2870 };
2843 2871
2844 2872
2845 #define DEFINE_AST_VISITOR_SUBCLASS_MEMBERS() \ 2873 #define DEFINE_AST_VISITOR_SUBCLASS_MEMBERS() \
2846 public: \ 2874 public: \
2847 virtual void Visit(AstNode* node) V8_FINAL V8_OVERRIDE { \ 2875 virtual void Visit(AstNode* node) V8_FINAL V8_OVERRIDE { \
2848 if (!CheckStackOverflow()) node->Accept(this); \ 2876 if (!CheckStackOverflow()) node->Accept(this); \
2849 } \ 2877 } \
2850 \ 2878 \
2851 void SetStackOverflow() { stack_overflow_ = true; } \ 2879 void SetStackOverflow() { stack_overflow_ = true; } \
2852 void ClearStackOverflow() { stack_overflow_ = false; } \ 2880 void ClearStackOverflow() { stack_overflow_ = false; } \
2853 bool HasStackOverflow() const { return stack_overflow_; } \ 2881 bool HasStackOverflow() const { return stack_overflow_; } \
2854 \ 2882 \
2855 bool CheckStackOverflow() { \ 2883 bool CheckStackOverflow() { \
2856 if (stack_overflow_) return true; \ 2884 if (stack_overflow_) return true; \
2857 StackLimitCheck check(isolate_); \ 2885 StackLimitCheck check(zone_->isolate()); \
2858 if (!check.HasOverflowed()) return false; \ 2886 if (!check.HasOverflowed()) return false; \
2859 return (stack_overflow_ = true); \ 2887 return (stack_overflow_ = true); \
2860 } \ 2888 } \
2861 \ 2889 \
2862 private: \ 2890 private: \
2863 void InitializeAstVisitor(Isolate* isolate) { \ 2891 void InitializeAstVisitor(Zone* zone) { \
2864 isolate_ = isolate; \ 2892 zone_ = zone; \
2865 stack_overflow_ = false; \ 2893 stack_overflow_ = false; \
2866 } \ 2894 } \
2867 Isolate* isolate() { return isolate_; } \ 2895 Zone* zone() { return zone_; } \
2896 Isolate* isolate() { return zone_->isolate(); } \
2868 \ 2897 \
2869 Isolate* isolate_; \ 2898 Zone* zone_; \
2870 bool stack_overflow_ 2899 bool stack_overflow_
2871 2900
2872 2901
2873 // ---------------------------------------------------------------------------- 2902 // ----------------------------------------------------------------------------
2874 // Construction time visitor. 2903 // Construction time visitor.
2875 2904
2876 class AstConstructionVisitor BASE_EMBEDDED { 2905 class AstConstructionVisitor BASE_EMBEDDED {
2877 public: 2906 public:
2878 AstConstructionVisitor() : dont_optimize_reason_(kNoReason) { } 2907 explicit AstConstructionVisitor(Zone* zone)
2908 : dont_optimize_reason_(kNoReason),
2909 zone_(zone) { }
2879 2910
2880 AstProperties* ast_properties() { return &properties_; } 2911 AstProperties* ast_properties() { return &properties_; }
2881 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } 2912 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; }
2913 DeferredFeedbackSlotProcessor* slot_processor() { return &slot_processor_; }
2882 2914
2883 private: 2915 private:
2884 template<class> friend class AstNodeFactory; 2916 template<class> friend class AstNodeFactory;
2885 2917
2886 // Node visitors. 2918 // Node visitors.
2887 #define DEF_VISIT(type) \ 2919 #define DEF_VISIT(type) \
2888 void Visit##type(type* node); 2920 void Visit##type(type* node);
2889 AST_NODE_LIST(DEF_VISIT) 2921 AST_NODE_LIST(DEF_VISIT)
2890 #undef DEF_VISIT 2922 #undef DEF_VISIT
2891 2923
2892 void increase_node_count() { properties_.add_node_count(1); } 2924 void increase_node_count() { properties_.add_node_count(1); }
2893 void add_flag(AstPropertiesFlag flag) { properties_.flags()->Add(flag); } 2925 void add_flag(AstPropertiesFlag flag) { properties_.flags()->Add(flag); }
2894 void set_dont_optimize_reason(BailoutReason reason) { 2926 void set_dont_optimize_reason(BailoutReason reason) {
2895 dont_optimize_reason_ = reason; 2927 dont_optimize_reason_ = reason;
2896 } 2928 }
2897 2929
2930 void add_slot_node(FeedbackSlotInterface* slot_node) {
2931 slot_processor_.add_slot_node(zone_, slot_node);
2932 }
2933
2898 AstProperties properties_; 2934 AstProperties properties_;
2935 DeferredFeedbackSlotProcessor slot_processor_;
2899 BailoutReason dont_optimize_reason_; 2936 BailoutReason dont_optimize_reason_;
2937 Zone* zone_;
2900 }; 2938 };
2901 2939
2902 2940
2903 class AstNullVisitor BASE_EMBEDDED { 2941 class AstNullVisitor BASE_EMBEDDED {
2904 public: 2942 public:
2943 explicit AstNullVisitor(Zone* zone) {}
2944
2905 // Node visitors. 2945 // Node visitors.
2906 #define DEF_VISIT(type) \ 2946 #define DEF_VISIT(type) \
2907 void Visit##type(type* node) {} 2947 void Visit##type(type* node) {}
2908 AST_NODE_LIST(DEF_VISIT) 2948 AST_NODE_LIST(DEF_VISIT)
2909 #undef DEF_VISIT 2949 #undef DEF_VISIT
2910 }; 2950 };
2911 2951
2912 2952
2913 2953
2914 // ---------------------------------------------------------------------------- 2954 // ----------------------------------------------------------------------------
2915 // AstNode factory 2955 // AstNode factory
2916 2956
2917 template<class Visitor> 2957 template<class Visitor>
2918 class AstNodeFactory V8_FINAL BASE_EMBEDDED { 2958 class AstNodeFactory V8_FINAL BASE_EMBEDDED {
2919 public: 2959 public:
2920 AstNodeFactory(Isolate* isolate, Zone* zone) 2960 explicit AstNodeFactory(Zone* zone)
2921 : isolate_(isolate), 2961 : zone_(zone),
2922 zone_(zone) { } 2962 visitor_(zone) { }
2923 2963
2924 Visitor* visitor() { return &visitor_; } 2964 Visitor* visitor() { return &visitor_; }
2925 2965
2926 #define VISIT_AND_RETURN(NodeType, node) \ 2966 #define VISIT_AND_RETURN(NodeType, node) \
2927 visitor_.Visit##NodeType((node)); \ 2967 visitor_.Visit##NodeType((node)); \
2928 return node; 2968 return node;
2929 2969
2930 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy, 2970 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy,
2931 VariableMode mode, 2971 VariableMode mode,
2932 Scope* scope, 2972 Scope* scope,
2933 int pos) { 2973 int pos) {
2934 VariableDeclaration* decl = 2974 VariableDeclaration* decl =
2935 new(zone_) VariableDeclaration(proxy, mode, scope, pos); 2975 new(zone_) VariableDeclaration(zone_, proxy, mode, scope, pos);
2936 VISIT_AND_RETURN(VariableDeclaration, decl) 2976 VISIT_AND_RETURN(VariableDeclaration, decl)
2937 } 2977 }
2938 2978
2939 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy, 2979 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy,
2940 VariableMode mode, 2980 VariableMode mode,
2941 FunctionLiteral* fun, 2981 FunctionLiteral* fun,
2942 Scope* scope, 2982 Scope* scope,
2943 int pos) { 2983 int pos) {
2944 FunctionDeclaration* decl = 2984 FunctionDeclaration* decl =
2945 new(zone_) FunctionDeclaration(proxy, mode, fun, scope, pos); 2985 new(zone_) FunctionDeclaration(zone_, proxy, mode, fun, scope, pos);
2946 VISIT_AND_RETURN(FunctionDeclaration, decl) 2986 VISIT_AND_RETURN(FunctionDeclaration, decl)
2947 } 2987 }
2948 2988
2949 ModuleDeclaration* NewModuleDeclaration(VariableProxy* proxy, 2989 ModuleDeclaration* NewModuleDeclaration(VariableProxy* proxy,
2950 Module* module, 2990 Module* module,
2951 Scope* scope, 2991 Scope* scope,
2952 int pos) { 2992 int pos) {
2953 ModuleDeclaration* decl = 2993 ModuleDeclaration* decl =
2954 new(zone_) ModuleDeclaration(proxy, module, scope, pos); 2994 new(zone_) ModuleDeclaration(zone_, proxy, module, scope, pos);
2955 VISIT_AND_RETURN(ModuleDeclaration, decl) 2995 VISIT_AND_RETURN(ModuleDeclaration, decl)
2956 } 2996 }
2957 2997
2958 ImportDeclaration* NewImportDeclaration(VariableProxy* proxy, 2998 ImportDeclaration* NewImportDeclaration(VariableProxy* proxy,
2959 Module* module, 2999 Module* module,
2960 Scope* scope, 3000 Scope* scope,
2961 int pos) { 3001 int pos) {
2962 ImportDeclaration* decl = 3002 ImportDeclaration* decl =
2963 new(zone_) ImportDeclaration(proxy, module, scope, pos); 3003 new(zone_) ImportDeclaration(zone_, proxy, module, scope, pos);
2964 VISIT_AND_RETURN(ImportDeclaration, decl) 3004 VISIT_AND_RETURN(ImportDeclaration, decl)
2965 } 3005 }
2966 3006
2967 ExportDeclaration* NewExportDeclaration(VariableProxy* proxy, 3007 ExportDeclaration* NewExportDeclaration(VariableProxy* proxy,
2968 Scope* scope, 3008 Scope* scope,
2969 int pos) { 3009 int pos) {
2970 ExportDeclaration* decl = 3010 ExportDeclaration* decl =
2971 new(zone_) ExportDeclaration(proxy, scope, pos); 3011 new(zone_) ExportDeclaration(zone_, proxy, scope, pos);
2972 VISIT_AND_RETURN(ExportDeclaration, decl) 3012 VISIT_AND_RETURN(ExportDeclaration, decl)
2973 } 3013 }
2974 3014
2975 ModuleLiteral* NewModuleLiteral(Block* body, Interface* interface, int pos) { 3015 ModuleLiteral* NewModuleLiteral(Block* body, Interface* interface, int pos) {
2976 ModuleLiteral* module = new(zone_) ModuleLiteral(body, interface, pos); 3016 ModuleLiteral* module =
3017 new(zone_) ModuleLiteral(zone_, body, interface, pos);
2977 VISIT_AND_RETURN(ModuleLiteral, module) 3018 VISIT_AND_RETURN(ModuleLiteral, module)
2978 } 3019 }
2979 3020
2980 ModuleVariable* NewModuleVariable(VariableProxy* proxy, int pos) { 3021 ModuleVariable* NewModuleVariable(VariableProxy* proxy, int pos) {
2981 ModuleVariable* module = new(zone_) ModuleVariable(proxy, pos); 3022 ModuleVariable* module = new(zone_) ModuleVariable(zone_, proxy, pos);
2982 VISIT_AND_RETURN(ModuleVariable, module) 3023 VISIT_AND_RETURN(ModuleVariable, module)
2983 } 3024 }
2984 3025
2985 ModulePath* NewModulePath(Module* origin, Handle<String> name, int pos) { 3026 ModulePath* NewModulePath(Module* origin, Handle<String> name, int pos) {
2986 ModulePath* module = new(zone_) ModulePath(origin, name, zone_, pos); 3027 ModulePath* module = new(zone_) ModulePath(zone_, origin, name, pos);
2987 VISIT_AND_RETURN(ModulePath, module) 3028 VISIT_AND_RETURN(ModulePath, module)
2988 } 3029 }
2989 3030
2990 ModuleUrl* NewModuleUrl(Handle<String> url, int pos) { 3031 ModuleUrl* NewModuleUrl(Handle<String> url, int pos) {
2991 ModuleUrl* module = new(zone_) ModuleUrl(url, zone_, pos); 3032 ModuleUrl* module = new(zone_) ModuleUrl(zone_, url, pos);
2992 VISIT_AND_RETURN(ModuleUrl, module) 3033 VISIT_AND_RETURN(ModuleUrl, module)
2993 } 3034 }
2994 3035
2995 Block* NewBlock(ZoneStringList* labels, 3036 Block* NewBlock(ZoneStringList* labels,
2996 int capacity, 3037 int capacity,
2997 bool is_initializer_block, 3038 bool is_initializer_block,
2998 int pos) { 3039 int pos) {
2999 Block* block = new(zone_) Block( 3040 Block* block = new(zone_) Block(
3000 isolate_, labels, capacity, is_initializer_block, pos, zone_); 3041 zone_, labels, capacity, is_initializer_block, pos);
3001 VISIT_AND_RETURN(Block, block) 3042 VISIT_AND_RETURN(Block, block)
3002 } 3043 }
3003 3044
3004 #define STATEMENT_WITH_LABELS(NodeType) \ 3045 #define STATEMENT_WITH_LABELS(NodeType) \
3005 NodeType* New##NodeType(ZoneStringList* labels, int pos) { \ 3046 NodeType* New##NodeType(ZoneStringList* labels, int pos) { \
3006 NodeType* stmt = new(zone_) NodeType(isolate_, labels, pos); \ 3047 NodeType* stmt = new(zone_) NodeType(zone_, labels, pos); \
3007 VISIT_AND_RETURN(NodeType, stmt); \ 3048 VISIT_AND_RETURN(NodeType, stmt); \
3008 } 3049 }
3009 STATEMENT_WITH_LABELS(DoWhileStatement) 3050 STATEMENT_WITH_LABELS(DoWhileStatement)
3010 STATEMENT_WITH_LABELS(WhileStatement) 3051 STATEMENT_WITH_LABELS(WhileStatement)
3011 STATEMENT_WITH_LABELS(ForStatement) 3052 STATEMENT_WITH_LABELS(ForStatement)
3012 STATEMENT_WITH_LABELS(SwitchStatement) 3053 STATEMENT_WITH_LABELS(SwitchStatement)
3013 #undef STATEMENT_WITH_LABELS 3054 #undef STATEMENT_WITH_LABELS
3014 3055
3015 ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode, 3056 ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode,
3016 ZoneStringList* labels, 3057 ZoneStringList* labels,
3017 int pos) { 3058 int pos) {
3018 switch (visit_mode) { 3059 switch (visit_mode) {
3019 case ForEachStatement::ENUMERATE: { 3060 case ForEachStatement::ENUMERATE: {
3020 ForInStatement* stmt = new(zone_) ForInStatement(isolate_, labels, pos); 3061 ForInStatement* stmt = new(zone_) ForInStatement(zone_, labels, pos);
3021 VISIT_AND_RETURN(ForInStatement, stmt); 3062 VISIT_AND_RETURN(ForInStatement, stmt);
3022 } 3063 }
3023 case ForEachStatement::ITERATE: { 3064 case ForEachStatement::ITERATE: {
3024 ForOfStatement* stmt = new(zone_) ForOfStatement(isolate_, labels, pos); 3065 ForOfStatement* stmt = new(zone_) ForOfStatement(zone_, labels, pos);
3025 VISIT_AND_RETURN(ForOfStatement, stmt); 3066 VISIT_AND_RETURN(ForOfStatement, stmt);
3026 } 3067 }
3027 } 3068 }
3028 UNREACHABLE(); 3069 UNREACHABLE();
3029 return NULL; 3070 return NULL;
3030 } 3071 }
3031 3072
3032 ModuleStatement* NewModuleStatement( 3073 ModuleStatement* NewModuleStatement(
3033 VariableProxy* proxy, Block* body, int pos) { 3074 VariableProxy* proxy, Block* body, int pos) {
3034 ModuleStatement* stmt = new(zone_) ModuleStatement(proxy, body, pos); 3075 ModuleStatement* stmt = new(zone_) ModuleStatement(zone_, proxy, body, pos);
3035 VISIT_AND_RETURN(ModuleStatement, stmt) 3076 VISIT_AND_RETURN(ModuleStatement, stmt)
3036 } 3077 }
3037 3078
3038 ExpressionStatement* NewExpressionStatement(Expression* expression, int pos) { 3079 ExpressionStatement* NewExpressionStatement(Expression* expression, int pos) {
3039 ExpressionStatement* stmt = new(zone_) ExpressionStatement(expression, pos); 3080 ExpressionStatement* stmt =
3081 new(zone_) ExpressionStatement(zone_, expression, pos);
3040 VISIT_AND_RETURN(ExpressionStatement, stmt) 3082 VISIT_AND_RETURN(ExpressionStatement, stmt)
3041 } 3083 }
3042 3084
3043 ContinueStatement* NewContinueStatement(IterationStatement* target, int pos) { 3085 ContinueStatement* NewContinueStatement(IterationStatement* target, int pos) {
3044 ContinueStatement* stmt = new(zone_) ContinueStatement(target, pos); 3086 ContinueStatement* stmt = new(zone_) ContinueStatement(zone_, target, pos);
3045 VISIT_AND_RETURN(ContinueStatement, stmt) 3087 VISIT_AND_RETURN(ContinueStatement, stmt)
3046 } 3088 }
3047 3089
3048 BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) { 3090 BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) {
3049 BreakStatement* stmt = new(zone_) BreakStatement(target, pos); 3091 BreakStatement* stmt = new(zone_) BreakStatement(zone_, target, pos);
3050 VISIT_AND_RETURN(BreakStatement, stmt) 3092 VISIT_AND_RETURN(BreakStatement, stmt)
3051 } 3093 }
3052 3094
3053 ReturnStatement* NewReturnStatement(Expression* expression, int pos) { 3095 ReturnStatement* NewReturnStatement(Expression* expression, int pos) {
3054 ReturnStatement* stmt = new(zone_) ReturnStatement(expression, pos); 3096 ReturnStatement* stmt = new(zone_) ReturnStatement(zone_, expression, pos);
3055 VISIT_AND_RETURN(ReturnStatement, stmt) 3097 VISIT_AND_RETURN(ReturnStatement, stmt)
3056 } 3098 }
3057 3099
3058 WithStatement* NewWithStatement(Scope* scope, 3100 WithStatement* NewWithStatement(Scope* scope,
3059 Expression* expression, 3101 Expression* expression,
3060 Statement* statement, 3102 Statement* statement,
3061 int pos) { 3103 int pos) {
3062 WithStatement* stmt = new(zone_) WithStatement( 3104 WithStatement* stmt = new(zone_) WithStatement(
3063 scope, expression, statement, pos); 3105 zone_, scope, expression, statement, pos);
3064 VISIT_AND_RETURN(WithStatement, stmt) 3106 VISIT_AND_RETURN(WithStatement, stmt)
3065 } 3107 }
3066 3108
3067 IfStatement* NewIfStatement(Expression* condition, 3109 IfStatement* NewIfStatement(Expression* condition,
3068 Statement* then_statement, 3110 Statement* then_statement,
3069 Statement* else_statement, 3111 Statement* else_statement,
3070 int pos) { 3112 int pos) {
3071 IfStatement* stmt = new(zone_) IfStatement( 3113 IfStatement* stmt = new(zone_) IfStatement(
3072 isolate_, condition, then_statement, else_statement, pos); 3114 zone_, condition, then_statement, else_statement, pos);
3073 VISIT_AND_RETURN(IfStatement, stmt) 3115 VISIT_AND_RETURN(IfStatement, stmt)
3074 } 3116 }
3075 3117
3076 TryCatchStatement* NewTryCatchStatement(int index, 3118 TryCatchStatement* NewTryCatchStatement(int index,
3077 Block* try_block, 3119 Block* try_block,
3078 Scope* scope, 3120 Scope* scope,
3079 Variable* variable, 3121 Variable* variable,
3080 Block* catch_block, 3122 Block* catch_block,
3081 int pos) { 3123 int pos) {
3082 TryCatchStatement* stmt = new(zone_) TryCatchStatement( 3124 TryCatchStatement* stmt = new(zone_) TryCatchStatement(
3083 index, try_block, scope, variable, catch_block, pos); 3125 zone_, index, try_block, scope, variable, catch_block, pos);
3084 VISIT_AND_RETURN(TryCatchStatement, stmt) 3126 VISIT_AND_RETURN(TryCatchStatement, stmt)
3085 } 3127 }
3086 3128
3087 TryFinallyStatement* NewTryFinallyStatement(int index, 3129 TryFinallyStatement* NewTryFinallyStatement(int index,
3088 Block* try_block, 3130 Block* try_block,
3089 Block* finally_block, 3131 Block* finally_block,
3090 int pos) { 3132 int pos) {
3091 TryFinallyStatement* stmt = 3133 TryFinallyStatement* stmt = new(zone_) TryFinallyStatement(
3092 new(zone_) TryFinallyStatement(index, try_block, finally_block, pos); 3134 zone_, index, try_block, finally_block, pos);
3093 VISIT_AND_RETURN(TryFinallyStatement, stmt) 3135 VISIT_AND_RETURN(TryFinallyStatement, stmt)
3094 } 3136 }
3095 3137
3096 DebuggerStatement* NewDebuggerStatement(int pos) { 3138 DebuggerStatement* NewDebuggerStatement(int pos) {
3097 DebuggerStatement* stmt = new(zone_) DebuggerStatement(pos); 3139 DebuggerStatement* stmt = new(zone_) DebuggerStatement(zone_, pos);
3098 VISIT_AND_RETURN(DebuggerStatement, stmt) 3140 VISIT_AND_RETURN(DebuggerStatement, stmt)
3099 } 3141 }
3100 3142
3101 EmptyStatement* NewEmptyStatement(int pos) { 3143 EmptyStatement* NewEmptyStatement(int pos) {
3102 return new(zone_) EmptyStatement(pos); 3144 return new(zone_) EmptyStatement(zone_, pos);
3103 } 3145 }
3104 3146
3105 CaseClause* NewCaseClause( 3147 CaseClause* NewCaseClause(
3106 Expression* label, ZoneList<Statement*>* statements, int pos) { 3148 Expression* label, ZoneList<Statement*>* statements, int pos) {
3107 CaseClause* clause = 3149 CaseClause* clause =
3108 new(zone_) CaseClause(isolate_, label, statements, pos); 3150 new(zone_) CaseClause(zone_, label, statements, pos);
3109 VISIT_AND_RETURN(CaseClause, clause) 3151 VISIT_AND_RETURN(CaseClause, clause)
3110 } 3152 }
3111 3153
3112 Literal* NewLiteral(Handle<Object> handle, int pos) { 3154 Literal* NewLiteral(Handle<Object> handle, int pos) {
3113 Literal* lit = new(zone_) Literal(isolate_, handle, pos); 3155 Literal* lit = new(zone_) Literal(zone_, handle, pos);
3114 VISIT_AND_RETURN(Literal, lit) 3156 VISIT_AND_RETURN(Literal, lit)
3115 } 3157 }
3116 3158
3117 Literal* NewNumberLiteral(double number, int pos) { 3159 Literal* NewNumberLiteral(double number, int pos) {
3118 return NewLiteral(isolate_->factory()->NewNumber(number, TENURED), pos); 3160 return NewLiteral(
3161 zone_->isolate()->factory()->NewNumber(number, TENURED), pos);
3119 } 3162 }
3120 3163
3121 ObjectLiteral* NewObjectLiteral( 3164 ObjectLiteral* NewObjectLiteral(
3122 ZoneList<ObjectLiteral::Property*>* properties, 3165 ZoneList<ObjectLiteral::Property*>* properties,
3123 int literal_index, 3166 int literal_index,
3124 int boilerplate_properties, 3167 int boilerplate_properties,
3125 bool has_function, 3168 bool has_function,
3126 int pos) { 3169 int pos) {
3127 ObjectLiteral* lit = new(zone_) ObjectLiteral( 3170 ObjectLiteral* lit = new(zone_) ObjectLiteral(
3128 isolate_, properties, literal_index, boilerplate_properties, 3171 zone_, properties, literal_index, boilerplate_properties,
3129 has_function, pos); 3172 has_function, pos);
3130 VISIT_AND_RETURN(ObjectLiteral, lit) 3173 VISIT_AND_RETURN(ObjectLiteral, lit)
3131 } 3174 }
3132 3175
3176 ObjectLiteral::Property* NewObjectLiteralProperty(Literal* key,
3177 Expression* value) {
3178 return new(zone_) ObjectLiteral::Property(zone_, key, value);
3179 }
3180
3133 ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter, 3181 ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter,
3134 FunctionLiteral* value, 3182 FunctionLiteral* value,
3135 int pos) { 3183 int pos) {
3136 ObjectLiteral::Property* prop = 3184 ObjectLiteral::Property* prop =
3137 new(zone_) ObjectLiteral::Property(is_getter, value); 3185 new(zone_) ObjectLiteral::Property(zone_, is_getter, value);
3138 prop->set_key(NewLiteral(value->name(), pos)); 3186 prop->set_key(NewLiteral(value->name(), pos));
3139 return prop; // Not an AST node, will not be visited. 3187 return prop; // Not an AST node, will not be visited.
3140 } 3188 }
3141 3189
3142 RegExpLiteral* NewRegExpLiteral(Handle<String> pattern, 3190 RegExpLiteral* NewRegExpLiteral(Handle<String> pattern,
3143 Handle<String> flags, 3191 Handle<String> flags,
3144 int literal_index, 3192 int literal_index,
3145 int pos) { 3193 int pos) {
3146 RegExpLiteral* lit = 3194 RegExpLiteral* lit =
3147 new(zone_) RegExpLiteral(isolate_, pattern, flags, literal_index, pos); 3195 new(zone_) RegExpLiteral(zone_, pattern, flags, literal_index, pos);
3148 VISIT_AND_RETURN(RegExpLiteral, lit); 3196 VISIT_AND_RETURN(RegExpLiteral, lit);
3149 } 3197 }
3150 3198
3151 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, 3199 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values,
3152 int literal_index, 3200 int literal_index,
3153 int pos) { 3201 int pos) {
3154 ArrayLiteral* lit = new(zone_) ArrayLiteral( 3202 ArrayLiteral* lit = new(zone_) ArrayLiteral(
3155 isolate_, values, literal_index, pos); 3203 zone_, values, literal_index, pos);
3156 VISIT_AND_RETURN(ArrayLiteral, lit) 3204 VISIT_AND_RETURN(ArrayLiteral, lit)
3157 } 3205 }
3158 3206
3159 VariableProxy* NewVariableProxy(Variable* var, 3207 VariableProxy* NewVariableProxy(Variable* var,
3160 int pos = RelocInfo::kNoPosition) { 3208 int pos = RelocInfo::kNoPosition) {
3161 VariableProxy* proxy = new(zone_) VariableProxy(isolate_, var, pos); 3209 VariableProxy* proxy = new(zone_) VariableProxy(zone_, var, pos);
3162 VISIT_AND_RETURN(VariableProxy, proxy) 3210 VISIT_AND_RETURN(VariableProxy, proxy)
3163 } 3211 }
3164 3212
3165 VariableProxy* NewVariableProxy(Handle<String> name, 3213 VariableProxy* NewVariableProxy(Handle<String> name,
3166 bool is_this, 3214 bool is_this,
3167 Interface* interface = Interface::NewValue(), 3215 Interface* interface = Interface::NewValue(),
3168 int position = RelocInfo::kNoPosition) { 3216 int position = RelocInfo::kNoPosition) {
3169 VariableProxy* proxy = 3217 VariableProxy* proxy =
3170 new(zone_) VariableProxy(isolate_, name, is_this, interface, position); 3218 new(zone_) VariableProxy(zone_, name, is_this, interface, position);
3171 VISIT_AND_RETURN(VariableProxy, proxy) 3219 VISIT_AND_RETURN(VariableProxy, proxy)
3172 } 3220 }
3173 3221
3174 Property* NewProperty(Expression* obj, Expression* key, int pos) { 3222 Property* NewProperty(Expression* obj, Expression* key, int pos) {
3175 Property* prop = new(zone_) Property(isolate_, obj, key, pos); 3223 Property* prop = new(zone_) Property(zone_, obj, key, pos);
3176 VISIT_AND_RETURN(Property, prop) 3224 VISIT_AND_RETURN(Property, prop)
3177 } 3225 }
3178 3226
3179 Call* NewCall(Expression* expression, 3227 Call* NewCall(Expression* expression,
3180 ZoneList<Expression*>* arguments, 3228 ZoneList<Expression*>* arguments,
3181 int pos) { 3229 int pos) {
3182 Call* call = new(zone_) Call(isolate_, expression, arguments, pos); 3230 Call* call = new(zone_) Call(zone_, expression, arguments, pos);
3183 VISIT_AND_RETURN(Call, call) 3231 VISIT_AND_RETURN(Call, call)
3184 } 3232 }
3185 3233
3186 CallNew* NewCallNew(Expression* expression, 3234 CallNew* NewCallNew(Expression* expression,
3187 ZoneList<Expression*>* arguments, 3235 ZoneList<Expression*>* arguments,
3188 int pos) { 3236 int pos) {
3189 CallNew* call = new(zone_) CallNew(isolate_, expression, arguments, pos); 3237 CallNew* call = new(zone_) CallNew(zone_, expression, arguments, pos);
3190 VISIT_AND_RETURN(CallNew, call) 3238 VISIT_AND_RETURN(CallNew, call)
3191 } 3239 }
3192 3240
3193 CallRuntime* NewCallRuntime(Handle<String> name, 3241 CallRuntime* NewCallRuntime(Handle<String> name,
3194 const Runtime::Function* function, 3242 const Runtime::Function* function,
3195 ZoneList<Expression*>* arguments, 3243 ZoneList<Expression*>* arguments,
3196 int pos) { 3244 int pos) {
3197 CallRuntime* call = 3245 CallRuntime* call =
3198 new(zone_) CallRuntime(isolate_, name, function, arguments, pos); 3246 new(zone_) CallRuntime(zone_, name, function, arguments, pos);
3199 VISIT_AND_RETURN(CallRuntime, call) 3247 VISIT_AND_RETURN(CallRuntime, call)
3200 } 3248 }
3201 3249
3202 UnaryOperation* NewUnaryOperation(Token::Value op, 3250 UnaryOperation* NewUnaryOperation(Token::Value op,
3203 Expression* expression, 3251 Expression* expression,
3204 int pos) { 3252 int pos) {
3205 UnaryOperation* node = 3253 UnaryOperation* node =
3206 new(zone_) UnaryOperation(isolate_, op, expression, pos); 3254 new(zone_) UnaryOperation(zone_, op, expression, pos);
3207 VISIT_AND_RETURN(UnaryOperation, node) 3255 VISIT_AND_RETURN(UnaryOperation, node)
3208 } 3256 }
3209 3257
3210 BinaryOperation* NewBinaryOperation(Token::Value op, 3258 BinaryOperation* NewBinaryOperation(Token::Value op,
3211 Expression* left, 3259 Expression* left,
3212 Expression* right, 3260 Expression* right,
3213 int pos) { 3261 int pos) {
3214 BinaryOperation* node = 3262 BinaryOperation* node =
3215 new(zone_) BinaryOperation(isolate_, op, left, right, pos); 3263 new(zone_) BinaryOperation(zone_, op, left, right, pos);
3216 VISIT_AND_RETURN(BinaryOperation, node) 3264 VISIT_AND_RETURN(BinaryOperation, node)
3217 } 3265 }
3218 3266
3219 CountOperation* NewCountOperation(Token::Value op, 3267 CountOperation* NewCountOperation(Token::Value op,
3220 bool is_prefix, 3268 bool is_prefix,
3221 Expression* expr, 3269 Expression* expr,
3222 int pos) { 3270 int pos) {
3223 CountOperation* node = 3271 CountOperation* node =
3224 new(zone_) CountOperation(isolate_, op, is_prefix, expr, pos); 3272 new(zone_) CountOperation(zone_, op, is_prefix, expr, pos);
3225 VISIT_AND_RETURN(CountOperation, node) 3273 VISIT_AND_RETURN(CountOperation, node)
3226 } 3274 }
3227 3275
3228 CompareOperation* NewCompareOperation(Token::Value op, 3276 CompareOperation* NewCompareOperation(Token::Value op,
3229 Expression* left, 3277 Expression* left,
3230 Expression* right, 3278 Expression* right,
3231 int pos) { 3279 int pos) {
3232 CompareOperation* node = 3280 CompareOperation* node =
3233 new(zone_) CompareOperation(isolate_, op, left, right, pos); 3281 new(zone_) CompareOperation(zone_, op, left, right, pos);
3234 VISIT_AND_RETURN(CompareOperation, node) 3282 VISIT_AND_RETURN(CompareOperation, node)
3235 } 3283 }
3236 3284
3237 Conditional* NewConditional(Expression* condition, 3285 Conditional* NewConditional(Expression* condition,
3238 Expression* then_expression, 3286 Expression* then_expression,
3239 Expression* else_expression, 3287 Expression* else_expression,
3240 int position) { 3288 int position) {
3241 Conditional* cond = new(zone_) Conditional( 3289 Conditional* cond = new(zone_) Conditional(
3242 isolate_, condition, then_expression, else_expression, position); 3290 zone_, condition, then_expression, else_expression, position);
3243 VISIT_AND_RETURN(Conditional, cond) 3291 VISIT_AND_RETURN(Conditional, cond)
3244 } 3292 }
3245 3293
3246 Assignment* NewAssignment(Token::Value op, 3294 Assignment* NewAssignment(Token::Value op,
3247 Expression* target, 3295 Expression* target,
3248 Expression* value, 3296 Expression* value,
3249 int pos) { 3297 int pos) {
3250 Assignment* assign = 3298 Assignment* assign =
3251 new(zone_) Assignment(isolate_, op, target, value, pos); 3299 new(zone_) Assignment(zone_, op, target, value, pos);
3252 assign->Init(isolate_, this); 3300 assign->Init(zone_, this);
3253 VISIT_AND_RETURN(Assignment, assign) 3301 VISIT_AND_RETURN(Assignment, assign)
3254 } 3302 }
3255 3303
3256 Yield* NewYield(Expression *generator_object, 3304 Yield* NewYield(Expression *generator_object,
3257 Expression* expression, 3305 Expression* expression,
3258 Yield::Kind yield_kind, 3306 Yield::Kind yield_kind,
3259 int pos) { 3307 int pos) {
3260 Yield* yield = new(zone_) Yield( 3308 Yield* yield = new(zone_) Yield(
3261 isolate_, generator_object, expression, yield_kind, pos); 3309 zone_, generator_object, expression, yield_kind, pos);
3262 VISIT_AND_RETURN(Yield, yield) 3310 VISIT_AND_RETURN(Yield, yield)
3263 } 3311 }
3264 3312
3265 Throw* NewThrow(Expression* exception, int pos) { 3313 Throw* NewThrow(Expression* exception, int pos) {
3266 Throw* t = new(zone_) Throw(isolate_, exception, pos); 3314 Throw* t = new(zone_) Throw(zone_, exception, pos);
3267 VISIT_AND_RETURN(Throw, t) 3315 VISIT_AND_RETURN(Throw, t)
3268 } 3316 }
3269 3317
3270 FunctionLiteral* NewFunctionLiteral( 3318 FunctionLiteral* NewFunctionLiteral(
3271 Handle<String> name, 3319 Handle<String> name,
3272 Scope* scope, 3320 Scope* scope,
3273 ZoneList<Statement*>* body, 3321 ZoneList<Statement*>* body,
3274 int materialized_literal_count, 3322 int materialized_literal_count,
3275 int expected_property_count, 3323 int expected_property_count,
3276 int handler_count, 3324 int handler_count,
3277 int parameter_count, 3325 int parameter_count,
3278 FunctionLiteral::ParameterFlag has_duplicate_parameters, 3326 FunctionLiteral::ParameterFlag has_duplicate_parameters,
3279 FunctionLiteral::FunctionType function_type, 3327 FunctionLiteral::FunctionType function_type,
3280 FunctionLiteral::IsFunctionFlag is_function, 3328 FunctionLiteral::IsFunctionFlag is_function,
3281 FunctionLiteral::IsParenthesizedFlag is_parenthesized, 3329 FunctionLiteral::IsParenthesizedFlag is_parenthesized,
3282 FunctionLiteral::IsGeneratorFlag is_generator, 3330 FunctionLiteral::IsGeneratorFlag is_generator,
3283 int position) { 3331 int position) {
3284 FunctionLiteral* lit = new(zone_) FunctionLiteral( 3332 FunctionLiteral* lit = new(zone_) FunctionLiteral(
3285 isolate_, name, scope, body, 3333 zone_, name, scope, body,
3286 materialized_literal_count, expected_property_count, handler_count, 3334 materialized_literal_count, expected_property_count, handler_count,
3287 parameter_count, function_type, has_duplicate_parameters, is_function, 3335 parameter_count, function_type, has_duplicate_parameters, is_function,
3288 is_parenthesized, is_generator, position); 3336 is_parenthesized, is_generator, position);
3289 // Top-level literal doesn't count for the AST's properties. 3337 // Top-level literal doesn't count for the AST's properties.
3290 if (is_function == FunctionLiteral::kIsFunction) { 3338 if (is_function == FunctionLiteral::kIsFunction) {
3291 visitor_.VisitFunctionLiteral(lit); 3339 visitor_.VisitFunctionLiteral(lit);
3292 } 3340 }
3293 return lit; 3341 return lit;
3294 } 3342 }
3295 3343
3296 NativeFunctionLiteral* NewNativeFunctionLiteral( 3344 NativeFunctionLiteral* NewNativeFunctionLiteral(
3297 Handle<String> name, v8::Extension* extension, int pos) { 3345 Handle<String> name, v8::Extension* extension, int pos) {
3298 NativeFunctionLiteral* lit = 3346 NativeFunctionLiteral* lit =
3299 new(zone_) NativeFunctionLiteral(isolate_, name, extension, pos); 3347 new(zone_) NativeFunctionLiteral(zone_, name, extension, pos);
3300 VISIT_AND_RETURN(NativeFunctionLiteral, lit) 3348 VISIT_AND_RETURN(NativeFunctionLiteral, lit)
3301 } 3349 }
3302 3350
3303 ThisFunction* NewThisFunction(int pos) { 3351 ThisFunction* NewThisFunction(int pos) {
3304 ThisFunction* fun = new(zone_) ThisFunction(isolate_, pos); 3352 ThisFunction* fun = new(zone_) ThisFunction(zone_, pos);
3305 VISIT_AND_RETURN(ThisFunction, fun) 3353 VISIT_AND_RETURN(ThisFunction, fun)
3306 } 3354 }
3307 3355
3308 #undef VISIT_AND_RETURN 3356 #undef VISIT_AND_RETURN
3309 3357
3310 private: 3358 private:
3311 Isolate* isolate_;
3312 Zone* zone_; 3359 Zone* zone_;
3313 Visitor visitor_; 3360 Visitor visitor_;
3314 }; 3361 };
3315 3362
3316 3363
3317 } } // namespace v8::internal 3364 } } // namespace v8::internal
3318 3365
3319 #endif // V8_AST_H_ 3366 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « src/assembler.cc ('k') | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698