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

Side by Side Diff: src/ast.h

Issue 335293004: New try: Parser: Delay internalizing strings and values (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased (trivial) Created 6 years, 6 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 | « include/v8.h ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_AST_H_ 5 #ifndef V8_AST_H_
6 #define V8_AST_H_ 6 #define V8_AST_H_
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/assembler.h" 10 #include "src/assembler.h"
11 #include "src/ast-value-factory.h"
11 #include "src/factory.h" 12 #include "src/factory.h"
12 #include "src/feedback-slots.h" 13 #include "src/feedback-slots.h"
13 #include "src/interface.h" 14 #include "src/interface.h"
14 #include "src/isolate.h" 15 #include "src/isolate.h"
15 #include "src/jsregexp.h" 16 #include "src/jsregexp.h"
16 #include "src/list-inl.h" 17 #include "src/list-inl.h"
17 #include "src/runtime.h" 18 #include "src/runtime.h"
18 #include "src/small-pointer-list.h" 19 #include "src/small-pointer-list.h"
19 #include "src/smart-pointers.h" 20 #include "src/smart-pointers.h"
20 #include "src/token.h" 21 #include "src/token.h"
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 // TODO(rossberg): this should move to its own AST node eventually. 361 // TODO(rossberg): this should move to its own AST node eventually.
361 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); 362 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle);
362 byte to_boolean_types() const { return to_boolean_types_; } 363 byte to_boolean_types() const { return to_boolean_types_; }
363 364
364 BailoutId id() const { return id_; } 365 BailoutId id() const { return id_; }
365 TypeFeedbackId test_id() const { return test_id_; } 366 TypeFeedbackId test_id() const { return test_id_; }
366 367
367 protected: 368 protected:
368 Expression(Zone* zone, int pos) 369 Expression(Zone* zone, int pos)
369 : AstNode(pos), 370 : AstNode(pos),
371 zone_(zone),
370 bounds_(Bounds::Unbounded(zone)), 372 bounds_(Bounds::Unbounded(zone)),
371 id_(GetNextId(zone)), 373 id_(GetNextId(zone)),
372 test_id_(GetNextId(zone)) {} 374 test_id_(GetNextId(zone)) {}
373 void set_to_boolean_types(byte types) { to_boolean_types_ = types; } 375 void set_to_boolean_types(byte types) { to_boolean_types_ = types; }
374 376
377 Zone* zone_;
378
375 private: 379 private:
376 Bounds bounds_; 380 Bounds bounds_;
377 byte to_boolean_types_; 381 byte to_boolean_types_;
378 382
379 const BailoutId id_; 383 const BailoutId id_;
380 const TypeFeedbackId test_id_; 384 const TypeFeedbackId test_id_;
381 }; 385 };
382 386
383 387
384 class BreakableStatement : public Statement { 388 class BreakableStatement : public Statement {
385 public: 389 public:
386 enum BreakableType { 390 enum BreakableType {
387 TARGET_FOR_ANONYMOUS, 391 TARGET_FOR_ANONYMOUS,
388 TARGET_FOR_NAMED_ONLY 392 TARGET_FOR_NAMED_ONLY
389 }; 393 };
390 394
391 // The labels associated with this statement. May be NULL; 395 // The labels associated with this statement. May be NULL;
392 // if it is != NULL, guaranteed to contain at least one entry. 396 // if it is != NULL, guaranteed to contain at least one entry.
393 ZoneStringList* labels() const { return labels_; } 397 ZoneList<const AstRawString*>* labels() const { return labels_; }
394 398
395 // Type testing & conversion. 399 // Type testing & conversion.
396 virtual BreakableStatement* AsBreakableStatement() V8_FINAL V8_OVERRIDE { 400 virtual BreakableStatement* AsBreakableStatement() V8_FINAL V8_OVERRIDE {
397 return this; 401 return this;
398 } 402 }
399 403
400 // Code generation 404 // Code generation
401 Label* break_target() { return &break_target_; } 405 Label* break_target() { return &break_target_; }
402 406
403 // Testers. 407 // Testers.
404 bool is_target_for_anonymous() const { 408 bool is_target_for_anonymous() const {
405 return breakable_type_ == TARGET_FOR_ANONYMOUS; 409 return breakable_type_ == TARGET_FOR_ANONYMOUS;
406 } 410 }
407 411
408 BailoutId EntryId() const { return entry_id_; } 412 BailoutId EntryId() const { return entry_id_; }
409 BailoutId ExitId() const { return exit_id_; } 413 BailoutId ExitId() const { return exit_id_; }
410 414
411 protected: 415 protected:
412 BreakableStatement( 416 BreakableStatement(
413 Zone* zone, ZoneStringList* labels, 417 Zone* zone, ZoneList<const AstRawString*>* labels,
414 BreakableType breakable_type, int position) 418 BreakableType breakable_type, int position)
415 : Statement(zone, position), 419 : Statement(zone, position),
416 labels_(labels), 420 labels_(labels),
417 breakable_type_(breakable_type), 421 breakable_type_(breakable_type),
418 entry_id_(GetNextId(zone)), 422 entry_id_(GetNextId(zone)),
419 exit_id_(GetNextId(zone)) { 423 exit_id_(GetNextId(zone)) {
420 ASSERT(labels == NULL || labels->length() > 0); 424 ASSERT(labels == NULL || labels->length() > 0);
421 } 425 }
422 426
423 427
424 private: 428 private:
425 ZoneStringList* labels_; 429 ZoneList<const AstRawString*>* labels_;
426 BreakableType breakable_type_; 430 BreakableType breakable_type_;
427 Label break_target_; 431 Label break_target_;
428 const BailoutId entry_id_; 432 const BailoutId entry_id_;
429 const BailoutId exit_id_; 433 const BailoutId exit_id_;
430 }; 434 };
431 435
432 436
433 class Block V8_FINAL : public BreakableStatement { 437 class Block V8_FINAL : public BreakableStatement {
434 public: 438 public:
435 DECLARE_NODE_TYPE(Block) 439 DECLARE_NODE_TYPE(Block)
(...skipping 10 matching lines...) Expand all
446 virtual bool IsJump() const V8_OVERRIDE { 450 virtual bool IsJump() const V8_OVERRIDE {
447 return !statements_.is_empty() && statements_.last()->IsJump() 451 return !statements_.is_empty() && statements_.last()->IsJump()
448 && labels() == NULL; // Good enough as an approximation... 452 && labels() == NULL; // Good enough as an approximation...
449 } 453 }
450 454
451 Scope* scope() const { return scope_; } 455 Scope* scope() const { return scope_; }
452 void set_scope(Scope* scope) { scope_ = scope; } 456 void set_scope(Scope* scope) { scope_ = scope; }
453 457
454 protected: 458 protected:
455 Block(Zone* zone, 459 Block(Zone* zone,
456 ZoneStringList* labels, 460 ZoneList<const AstRawString*>* labels,
457 int capacity, 461 int capacity,
458 bool is_initializer_block, 462 bool is_initializer_block,
459 int pos) 463 int pos)
460 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos), 464 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos),
461 statements_(capacity, zone), 465 statements_(capacity, zone),
462 is_initializer_block_(is_initializer_block), 466 is_initializer_block_(is_initializer_block),
463 decls_id_(GetNextId(zone)), 467 decls_id_(GetNextId(zone)),
464 scope_(NULL) { 468 scope_(NULL) {
465 } 469 }
466 470
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 private: 659 private:
656 VariableProxy* proxy_; 660 VariableProxy* proxy_;
657 }; 661 };
658 662
659 663
660 class ModulePath V8_FINAL : public Module { 664 class ModulePath V8_FINAL : public Module {
661 public: 665 public:
662 DECLARE_NODE_TYPE(ModulePath) 666 DECLARE_NODE_TYPE(ModulePath)
663 667
664 Module* module() const { return module_; } 668 Module* module() const { return module_; }
665 Handle<String> name() const { return name_; } 669 Handle<String> name() const { return name_->string(); }
666 670
667 protected: 671 protected:
668 ModulePath(Zone* zone, Module* module, Handle<String> name, int pos) 672 ModulePath(Zone* zone, Module* module, const AstRawString* name, int pos)
669 : Module(zone, pos), 673 : Module(zone, pos), module_(module), name_(name) {}
670 module_(module),
671 name_(name) {
672 }
673 674
674 private: 675 private:
675 Module* module_; 676 Module* module_;
676 Handle<String> name_; 677 const AstRawString* name_;
677 }; 678 };
678 679
679 680
680 class ModuleUrl V8_FINAL : public Module { 681 class ModuleUrl V8_FINAL : public Module {
681 public: 682 public:
682 DECLARE_NODE_TYPE(ModuleUrl) 683 DECLARE_NODE_TYPE(ModuleUrl)
683 684
684 Handle<String> url() const { return url_; } 685 Handle<String> url() const { return url_; }
685 686
686 protected: 687 protected:
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 Statement* body() const { return body_; } 724 Statement* body() const { return body_; }
724 725
725 BailoutId OsrEntryId() const { return osr_entry_id_; } 726 BailoutId OsrEntryId() const { return osr_entry_id_; }
726 virtual BailoutId ContinueId() const = 0; 727 virtual BailoutId ContinueId() const = 0;
727 virtual BailoutId StackCheckId() const = 0; 728 virtual BailoutId StackCheckId() const = 0;
728 729
729 // Code generation 730 // Code generation
730 Label* continue_target() { return &continue_target_; } 731 Label* continue_target() { return &continue_target_; }
731 732
732 protected: 733 protected:
733 IterationStatement(Zone* zone, ZoneStringList* labels, int pos) 734 IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
734 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), 735 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos),
735 body_(NULL), 736 body_(NULL),
736 osr_entry_id_(GetNextId(zone)) { 737 osr_entry_id_(GetNextId(zone)) {
737 } 738 }
738 739
739 void Initialize(Statement* body) { 740 void Initialize(Statement* body) {
740 body_ = body; 741 body_ = body;
741 } 742 }
742 743
743 private: 744 private:
(...skipping 13 matching lines...) Expand all
757 cond_ = cond; 758 cond_ = cond;
758 } 759 }
759 760
760 Expression* cond() const { return cond_; } 761 Expression* cond() const { return cond_; }
761 762
762 virtual BailoutId ContinueId() const V8_OVERRIDE { return continue_id_; } 763 virtual BailoutId ContinueId() const V8_OVERRIDE { return continue_id_; }
763 virtual BailoutId StackCheckId() const V8_OVERRIDE { return back_edge_id_; } 764 virtual BailoutId StackCheckId() const V8_OVERRIDE { return back_edge_id_; }
764 BailoutId BackEdgeId() const { return back_edge_id_; } 765 BailoutId BackEdgeId() const { return back_edge_id_; }
765 766
766 protected: 767 protected:
767 DoWhileStatement(Zone* zone, ZoneStringList* labels, int pos) 768 DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
768 : IterationStatement(zone, labels, pos), 769 : IterationStatement(zone, labels, pos),
769 cond_(NULL), 770 cond_(NULL),
770 continue_id_(GetNextId(zone)), 771 continue_id_(GetNextId(zone)),
771 back_edge_id_(GetNextId(zone)) { 772 back_edge_id_(GetNextId(zone)) {
772 } 773 }
773 774
774 private: 775 private:
775 Expression* cond_; 776 Expression* cond_;
776 777
777 const BailoutId continue_id_; 778 const BailoutId continue_id_;
(...skipping 16 matching lines...) Expand all
794 } 795 }
795 void set_may_have_function_literal(bool value) { 796 void set_may_have_function_literal(bool value) {
796 may_have_function_literal_ = value; 797 may_have_function_literal_ = value;
797 } 798 }
798 799
799 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); } 800 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); }
800 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } 801 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; }
801 BailoutId BodyId() const { return body_id_; } 802 BailoutId BodyId() const { return body_id_; }
802 803
803 protected: 804 protected:
804 WhileStatement(Zone* zone, ZoneStringList* labels, int pos) 805 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
805 : IterationStatement(zone, labels, pos), 806 : IterationStatement(zone, labels, pos),
806 cond_(NULL), 807 cond_(NULL),
807 may_have_function_literal_(true), 808 may_have_function_literal_(true),
808 body_id_(GetNextId(zone)) { 809 body_id_(GetNextId(zone)) {
809 } 810 }
810 811
811 private: 812 private:
812 Expression* cond_; 813 Expression* cond_;
813 814
814 // True if there is a function literal subexpression in the condition. 815 // True if there is a function literal subexpression in the condition.
(...skipping 30 matching lines...) Expand all
845 846
846 virtual BailoutId ContinueId() const V8_OVERRIDE { return continue_id_; } 847 virtual BailoutId ContinueId() const V8_OVERRIDE { return continue_id_; }
847 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } 848 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; }
848 BailoutId BodyId() const { return body_id_; } 849 BailoutId BodyId() const { return body_id_; }
849 850
850 bool is_fast_smi_loop() { return loop_variable_ != NULL; } 851 bool is_fast_smi_loop() { return loop_variable_ != NULL; }
851 Variable* loop_variable() { return loop_variable_; } 852 Variable* loop_variable() { return loop_variable_; }
852 void set_loop_variable(Variable* var) { loop_variable_ = var; } 853 void set_loop_variable(Variable* var) { loop_variable_ = var; }
853 854
854 protected: 855 protected:
855 ForStatement(Zone* zone, ZoneStringList* labels, int pos) 856 ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
856 : IterationStatement(zone, labels, pos), 857 : IterationStatement(zone, labels, pos),
857 init_(NULL), 858 init_(NULL),
858 cond_(NULL), 859 cond_(NULL),
859 next_(NULL), 860 next_(NULL),
860 may_have_function_literal_(true), 861 may_have_function_literal_(true),
861 loop_variable_(NULL), 862 loop_variable_(NULL),
862 continue_id_(GetNextId(zone)), 863 continue_id_(GetNextId(zone)),
863 body_id_(GetNextId(zone)) { 864 body_id_(GetNextId(zone)) {
864 } 865 }
865 866
(...skipping 21 matching lines...) Expand all
887 void Initialize(Expression* each, Expression* subject, Statement* body) { 888 void Initialize(Expression* each, Expression* subject, Statement* body) {
888 IterationStatement::Initialize(body); 889 IterationStatement::Initialize(body);
889 each_ = each; 890 each_ = each;
890 subject_ = subject; 891 subject_ = subject;
891 } 892 }
892 893
893 Expression* each() const { return each_; } 894 Expression* each() const { return each_; }
894 Expression* subject() const { return subject_; } 895 Expression* subject() const { return subject_; }
895 896
896 protected: 897 protected:
897 ForEachStatement(Zone* zone, ZoneStringList* labels, int pos) 898 ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
898 : IterationStatement(zone, labels, pos), 899 : IterationStatement(zone, labels, pos), each_(NULL), subject_(NULL) {}
899 each_(NULL),
900 subject_(NULL) {
901 }
902 900
903 private: 901 private:
904 Expression* each_; 902 Expression* each_;
905 Expression* subject_; 903 Expression* subject_;
906 }; 904 };
907 905
908 906
909 class ForInStatement V8_FINAL : public ForEachStatement, 907 class ForInStatement V8_FINAL : public ForEachStatement,
910 public FeedbackSlotInterface { 908 public FeedbackSlotInterface {
911 public: 909 public:
(...skipping 15 matching lines...) Expand all
927 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; 925 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN };
928 ForInType for_in_type() const { return for_in_type_; } 926 ForInType for_in_type() const { return for_in_type_; }
929 void set_for_in_type(ForInType type) { for_in_type_ = type; } 927 void set_for_in_type(ForInType type) { for_in_type_ = type; }
930 928
931 BailoutId BodyId() const { return body_id_; } 929 BailoutId BodyId() const { return body_id_; }
932 BailoutId PrepareId() const { return prepare_id_; } 930 BailoutId PrepareId() const { return prepare_id_; }
933 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); } 931 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); }
934 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } 932 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; }
935 933
936 protected: 934 protected:
937 ForInStatement(Zone* zone, ZoneStringList* labels, int pos) 935 ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
938 : ForEachStatement(zone, labels, pos), 936 : ForEachStatement(zone, labels, pos),
939 for_in_type_(SLOW_FOR_IN), 937 for_in_type_(SLOW_FOR_IN),
940 for_in_feedback_slot_(kInvalidFeedbackSlot), 938 for_in_feedback_slot_(kInvalidFeedbackSlot),
941 body_id_(GetNextId(zone)), 939 body_id_(GetNextId(zone)),
942 prepare_id_(GetNextId(zone)) { 940 prepare_id_(GetNextId(zone)) {
943 } 941 }
944 942
945 ForInType for_in_type_; 943 ForInType for_in_type_;
946 int for_in_feedback_slot_; 944 int for_in_feedback_slot_;
947 const BailoutId body_id_; 945 const BailoutId body_id_;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 Expression* assign_each() const { 995 Expression* assign_each() const {
998 return assign_each_; 996 return assign_each_;
999 } 997 }
1000 998
1001 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); } 999 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); }
1002 virtual BailoutId StackCheckId() const V8_OVERRIDE { return BackEdgeId(); } 1000 virtual BailoutId StackCheckId() const V8_OVERRIDE { return BackEdgeId(); }
1003 1001
1004 BailoutId BackEdgeId() const { return back_edge_id_; } 1002 BailoutId BackEdgeId() const { return back_edge_id_; }
1005 1003
1006 protected: 1004 protected:
1007 ForOfStatement(Zone* zone, ZoneStringList* labels, int pos) 1005 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
1008 : ForEachStatement(zone, labels, pos), 1006 : ForEachStatement(zone, labels, pos),
1009 assign_iterator_(NULL), 1007 assign_iterator_(NULL),
1010 next_result_(NULL), 1008 next_result_(NULL),
1011 result_done_(NULL), 1009 result_done_(NULL),
1012 assign_each_(NULL), 1010 assign_each_(NULL),
1013 back_edge_id_(GetNextId(zone)) { 1011 back_edge_id_(GetNextId(zone)) {
1014 } 1012 }
1015 1013
1016 Expression* assign_iterable_; 1014 Expression* assign_iterable_;
1017 Expression* assign_iterator_; 1015 Expression* assign_iterator_;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 1156
1159 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { 1157 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) {
1160 tag_ = tag; 1158 tag_ = tag;
1161 cases_ = cases; 1159 cases_ = cases;
1162 } 1160 }
1163 1161
1164 Expression* tag() const { return tag_; } 1162 Expression* tag() const { return tag_; }
1165 ZoneList<CaseClause*>* cases() const { return cases_; } 1163 ZoneList<CaseClause*>* cases() const { return cases_; }
1166 1164
1167 protected: 1165 protected:
1168 SwitchStatement(Zone* zone, ZoneStringList* labels, int pos) 1166 SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
1169 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), 1167 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos),
1170 tag_(NULL), 1168 tag_(NULL),
1171 cases_(NULL) { } 1169 cases_(NULL) { }
1172 1170
1173 private: 1171 private:
1174 Expression* tag_; 1172 Expression* tag_;
1175 ZoneList<CaseClause*>* cases_; 1173 ZoneList<CaseClause*>* cases_;
1176 }; 1174 };
1177 1175
1178 1176
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 protected: 1336 protected:
1339 explicit EmptyStatement(Zone* zone, int pos): Statement(zone, pos) {} 1337 explicit EmptyStatement(Zone* zone, int pos): Statement(zone, pos) {}
1340 }; 1338 };
1341 1339
1342 1340
1343 class Literal V8_FINAL : public Expression { 1341 class Literal V8_FINAL : public Expression {
1344 public: 1342 public:
1345 DECLARE_NODE_TYPE(Literal) 1343 DECLARE_NODE_TYPE(Literal)
1346 1344
1347 virtual bool IsPropertyName() const V8_OVERRIDE { 1345 virtual bool IsPropertyName() const V8_OVERRIDE {
1348 if (value_->IsInternalizedString()) { 1346 return value_->IsPropertyName();
1349 uint32_t ignored;
1350 return !String::cast(*value_)->AsArrayIndex(&ignored);
1351 }
1352 return false;
1353 } 1347 }
1354 1348
1355 Handle<String> AsPropertyName() { 1349 Handle<String> AsPropertyName() {
1356 ASSERT(IsPropertyName()); 1350 ASSERT(IsPropertyName());
1357 return Handle<String>::cast(value_); 1351 return Handle<String>::cast(value());
1352 }
1353
1354 const AstRawString* AsRawPropertyName() {
1355 ASSERT(IsPropertyName());
1356 return value_->AsString();
1358 } 1357 }
1359 1358
1360 virtual bool ToBooleanIsTrue() const V8_OVERRIDE { 1359 virtual bool ToBooleanIsTrue() const V8_OVERRIDE {
1361 return value_->BooleanValue(); 1360 return value()->BooleanValue();
1362 } 1361 }
1363 virtual bool ToBooleanIsFalse() const V8_OVERRIDE { 1362 virtual bool ToBooleanIsFalse() const V8_OVERRIDE {
1364 return !value_->BooleanValue(); 1363 return !value()->BooleanValue();
1365 } 1364 }
1366 1365
1367 Handle<Object> value() const { return value_; } 1366 Handle<Object> value() const { return value_->value(); }
1367 const AstValue* raw_value() const { return value_; }
1368 1368
1369 // Support for using Literal as a HashMap key. NOTE: Currently, this works 1369 // Support for using Literal as a HashMap key. NOTE: Currently, this works
1370 // only for string and number literals! 1370 // only for string and number literals!
1371 uint32_t Hash() { return ToString()->Hash(); } 1371 uint32_t Hash() { return ToString()->Hash(); }
1372 1372
1373 static bool Match(void* literal1, void* literal2) { 1373 static bool Match(void* literal1, void* literal2) {
1374 Handle<String> s1 = static_cast<Literal*>(literal1)->ToString(); 1374 Handle<String> s1 = static_cast<Literal*>(literal1)->ToString();
1375 Handle<String> s2 = static_cast<Literal*>(literal2)->ToString(); 1375 Handle<String> s2 = static_cast<Literal*>(literal2)->ToString();
1376 return String::Equals(s1, s2); 1376 return String::Equals(s1, s2);
1377 } 1377 }
1378 1378
1379 TypeFeedbackId LiteralFeedbackId() const { return reuse(id()); } 1379 TypeFeedbackId LiteralFeedbackId() const { return reuse(id()); }
1380 1380
1381 protected: 1381 protected:
1382 Literal(Zone* zone, Handle<Object> value, int position) 1382 Literal(Zone* zone, const AstValue* value, int position)
1383 : Expression(zone, position), 1383 : Expression(zone, position),
1384 value_(value), 1384 value_(value),
1385 isolate_(zone->isolate()) { } 1385 isolate_(zone->isolate()) { }
1386 1386
1387 private: 1387 private:
1388 Handle<String> ToString(); 1388 Handle<String> ToString();
1389 1389
1390 Handle<Object> value_; 1390 const AstValue* value_;
1391 // TODO(dcarney): remove. this is only needed for Match and Hash. 1391 // TODO(dcarney): remove. this is only needed for Match and Hash.
1392 Isolate* isolate_; 1392 Isolate* isolate_;
1393 }; 1393 };
1394 1394
1395 1395
1396 // Base class for literals that needs space in the corresponding JSFunction. 1396 // Base class for literals that needs space in the corresponding JSFunction.
1397 class MaterializedLiteral : public Expression { 1397 class MaterializedLiteral : public Expression {
1398 public: 1398 public:
1399 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } 1399 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; }
1400 1400
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 class ObjectLiteralProperty V8_FINAL : public ZoneObject { 1451 class ObjectLiteralProperty V8_FINAL : public ZoneObject {
1452 public: 1452 public:
1453 enum Kind { 1453 enum Kind {
1454 CONSTANT, // Property with constant value (compile time). 1454 CONSTANT, // Property with constant value (compile time).
1455 COMPUTED, // Property with computed value (execution time). 1455 COMPUTED, // Property with computed value (execution time).
1456 MATERIALIZED_LITERAL, // Property value is a materialized literal. 1456 MATERIALIZED_LITERAL, // Property value is a materialized literal.
1457 GETTER, SETTER, // Property is an accessor function. 1457 GETTER, SETTER, // Property is an accessor function.
1458 PROTOTYPE // Property is __proto__. 1458 PROTOTYPE // Property is __proto__.
1459 }; 1459 };
1460 1460
1461 ObjectLiteralProperty(Zone* zone, Literal* key, Expression* value); 1461 ObjectLiteralProperty(Zone* zone, AstValueFactory* ast_value_factory,
1462 Literal* key, Expression* value);
1462 1463
1463 Literal* key() { return key_; } 1464 Literal* key() { return key_; }
1464 Expression* value() { return value_; } 1465 Expression* value() { return value_; }
1465 Kind kind() { return kind_; } 1466 Kind kind() { return kind_; }
1466 1467
1467 // Type feedback information. 1468 // Type feedback information.
1468 void RecordTypeFeedback(TypeFeedbackOracle* oracle); 1469 void RecordTypeFeedback(TypeFeedbackOracle* oracle);
1469 bool IsMonomorphic() { return !receiver_type_.is_null(); } 1470 bool IsMonomorphic() { return !receiver_type_.is_null(); }
1470 Handle<Map> GetReceiverType() { return receiver_type_; } 1471 Handle<Map> GetReceiverType() { return receiver_type_; }
1471 1472
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1550 bool may_store_doubles_; 1551 bool may_store_doubles_;
1551 bool has_function_; 1552 bool has_function_;
1552 }; 1553 };
1553 1554
1554 1555
1555 // Node for capturing a regexp literal. 1556 // Node for capturing a regexp literal.
1556 class RegExpLiteral V8_FINAL : public MaterializedLiteral { 1557 class RegExpLiteral V8_FINAL : public MaterializedLiteral {
1557 public: 1558 public:
1558 DECLARE_NODE_TYPE(RegExpLiteral) 1559 DECLARE_NODE_TYPE(RegExpLiteral)
1559 1560
1560 Handle<String> pattern() const { return pattern_; } 1561 Handle<String> pattern() const { return pattern_->string(); }
1561 Handle<String> flags() const { return flags_; } 1562 Handle<String> flags() const { return flags_->string(); }
1562 1563
1563 protected: 1564 protected:
1564 RegExpLiteral(Zone* zone, 1565 RegExpLiteral(Zone* zone,
1565 Handle<String> pattern, 1566 const AstRawString* pattern,
1566 Handle<String> flags, 1567 const AstRawString* flags,
1567 int literal_index, 1568 int literal_index,
1568 int pos) 1569 int pos)
1569 : MaterializedLiteral(zone, literal_index, pos), 1570 : MaterializedLiteral(zone, literal_index, pos),
1570 pattern_(pattern), 1571 pattern_(pattern),
1571 flags_(flags) { 1572 flags_(flags) {
1572 set_depth(1); 1573 set_depth(1);
1573 } 1574 }
1574 1575
1575 private: 1576 private:
1576 Handle<String> pattern_; 1577 const AstRawString* pattern_;
1577 Handle<String> flags_; 1578 const AstRawString* flags_;
1578 }; 1579 };
1579 1580
1580 1581
1581 // An array literal has a literals object that is used 1582 // An array literal has a literals object that is used
1582 // for minimizing the work when constructing it at runtime. 1583 // for minimizing the work when constructing it at runtime.
1583 class ArrayLiteral V8_FINAL : public MaterializedLiteral { 1584 class ArrayLiteral V8_FINAL : public MaterializedLiteral {
1584 public: 1585 public:
1585 DECLARE_NODE_TYPE(ArrayLiteral) 1586 DECLARE_NODE_TYPE(ArrayLiteral)
1586 1587
1587 Handle<FixedArray> constant_elements() const { return constant_elements_; } 1588 Handle<FixedArray> constant_elements() const { return constant_elements_; }
(...skipping 30 matching lines...) Expand all
1618 1619
1619 1620
1620 class VariableProxy V8_FINAL : public Expression { 1621 class VariableProxy V8_FINAL : public Expression {
1621 public: 1622 public:
1622 DECLARE_NODE_TYPE(VariableProxy) 1623 DECLARE_NODE_TYPE(VariableProxy)
1623 1624
1624 virtual bool IsValidReferenceExpression() const V8_OVERRIDE { 1625 virtual bool IsValidReferenceExpression() const V8_OVERRIDE {
1625 return var_ == NULL ? true : var_->IsValidReference(); 1626 return var_ == NULL ? true : var_->IsValidReference();
1626 } 1627 }
1627 1628
1628 bool IsVariable(Handle<String> n) const {
1629 return !is_this() && name().is_identical_to(n);
1630 }
1631
1632 bool IsArguments() const { return var_ != NULL && var_->is_arguments(); } 1629 bool IsArguments() const { return var_ != NULL && var_->is_arguments(); }
1633 1630
1634 bool IsLValue() const { return is_lvalue_; } 1631 bool IsLValue() const { return is_lvalue_; }
1635 1632
1636 Handle<String> name() const { return name_; } 1633 Handle<String> name() const { return name_->string(); }
1634 const AstRawString* raw_name() const { return name_; }
1637 Variable* var() const { return var_; } 1635 Variable* var() const { return var_; }
1638 bool is_this() const { return is_this_; } 1636 bool is_this() const { return is_this_; }
1639 Interface* interface() const { return interface_; } 1637 Interface* interface() const { return interface_; }
1640 1638
1641 1639
1642 void MarkAsTrivial() { is_trivial_ = true; } 1640 void MarkAsTrivial() { is_trivial_ = true; }
1643 void MarkAsLValue() { is_lvalue_ = true; } 1641 void MarkAsLValue() { is_lvalue_ = true; }
1644 1642
1645 // Bind this proxy to the variable var. Interfaces must match. 1643 // Bind this proxy to the variable var. Interfaces must match.
1646 void BindTo(Variable* var); 1644 void BindTo(Variable* var);
1647 1645
1648 protected: 1646 protected:
1649 VariableProxy(Zone* zone, Variable* var, int position); 1647 VariableProxy(Zone* zone, Variable* var, int position);
1650 1648
1651 VariableProxy(Zone* zone, 1649 VariableProxy(Zone* zone,
1652 Handle<String> name, 1650 const AstRawString* name,
1653 bool is_this, 1651 bool is_this,
1654 Interface* interface, 1652 Interface* interface,
1655 int position); 1653 int position);
1656 1654
1657 Handle<String> name_; 1655 const AstRawString* name_;
1658 Variable* var_; // resolved variable, or NULL 1656 Variable* var_; // resolved variable, or NULL
1659 bool is_this_; 1657 bool is_this_;
1660 bool is_trivial_; 1658 bool is_trivial_;
1661 // True if this variable proxy is being used in an assignment 1659 // True if this variable proxy is being used in an assignment
1662 // or with a increment/decrement operator. 1660 // or with a increment/decrement operator.
1663 bool is_lvalue_; 1661 bool is_lvalue_;
1664 Interface* interface_; 1662 Interface* interface_;
1665 }; 1663 };
1666 1664
1667 1665
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 1891
1894 1892
1895 // The CallRuntime class does not represent any official JavaScript 1893 // The CallRuntime class does not represent any official JavaScript
1896 // 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
1897 // 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
1898 // implemented in JavaScript (see "v8natives.js"). 1896 // implemented in JavaScript (see "v8natives.js").
1899 class CallRuntime V8_FINAL : public Expression { 1897 class CallRuntime V8_FINAL : public Expression {
1900 public: 1898 public:
1901 DECLARE_NODE_TYPE(CallRuntime) 1899 DECLARE_NODE_TYPE(CallRuntime)
1902 1900
1903 Handle<String> name() const { return name_; } 1901 Handle<String> name() const { return raw_name_->string(); }
1902 const AstRawString* raw_name() const { return raw_name_; }
1904 const Runtime::Function* function() const { return function_; } 1903 const Runtime::Function* function() const { return function_; }
1905 ZoneList<Expression*>* arguments() const { return arguments_; } 1904 ZoneList<Expression*>* arguments() const { return arguments_; }
1906 bool is_jsruntime() const { return function_ == NULL; } 1905 bool is_jsruntime() const { return function_ == NULL; }
1907 1906
1908 TypeFeedbackId CallRuntimeFeedbackId() const { return reuse(id()); } 1907 TypeFeedbackId CallRuntimeFeedbackId() const { return reuse(id()); }
1909 1908
1910 protected: 1909 protected:
1911 CallRuntime(Zone* zone, 1910 CallRuntime(Zone* zone,
1912 Handle<String> name, 1911 const AstRawString* name,
1913 const Runtime::Function* function, 1912 const Runtime::Function* function,
1914 ZoneList<Expression*>* arguments, 1913 ZoneList<Expression*>* arguments,
1915 int pos) 1914 int pos)
1916 : Expression(zone, pos), 1915 : Expression(zone, pos),
1917 name_(name), 1916 raw_name_(name),
1918 function_(function), 1917 function_(function),
1919 arguments_(arguments) { } 1918 arguments_(arguments) { }
1920 1919
1921 private: 1920 private:
1922 Handle<String> name_; 1921 const AstRawString* raw_name_;
1923 const Runtime::Function* function_; 1922 const Runtime::Function* function_;
1924 ZoneList<Expression*>* arguments_; 1923 ZoneList<Expression*>* arguments_;
1925 }; 1924 };
1926 1925
1927 1926
1928 class UnaryOperation V8_FINAL : public Expression { 1927 class UnaryOperation V8_FINAL : public Expression {
1929 public: 1928 public:
1930 DECLARE_NODE_TYPE(UnaryOperation) 1929 DECLARE_NODE_TYPE(UnaryOperation)
1931 1930
1932 Token::Value op() const { return op_; } 1931 Token::Value op() const { return op_; }
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
2306 }; 2305 };
2307 2306
2308 enum ArityRestriction { 2307 enum ArityRestriction {
2309 NORMAL_ARITY, 2308 NORMAL_ARITY,
2310 GETTER_ARITY, 2309 GETTER_ARITY,
2311 SETTER_ARITY 2310 SETTER_ARITY
2312 }; 2311 };
2313 2312
2314 DECLARE_NODE_TYPE(FunctionLiteral) 2313 DECLARE_NODE_TYPE(FunctionLiteral)
2315 2314
2316 Handle<String> name() const { return name_; } 2315 Handle<String> name() const { return raw_name_->string(); }
2316 const AstRawString* raw_name() const { return raw_name_; }
2317 Scope* scope() const { return scope_; } 2317 Scope* scope() const { return scope_; }
2318 ZoneList<Statement*>* body() const { return body_; } 2318 ZoneList<Statement*>* body() const { return body_; }
2319 void set_function_token_position(int pos) { function_token_position_ = pos; } 2319 void set_function_token_position(int pos) { function_token_position_ = pos; }
2320 int function_token_position() const { return function_token_position_; } 2320 int function_token_position() const { return function_token_position_; }
2321 int start_position() const; 2321 int start_position() const;
2322 int end_position() const; 2322 int end_position() const;
2323 int SourceSize() const { return end_position() - start_position(); } 2323 int SourceSize() const { return end_position() - start_position(); }
2324 bool is_expression() const { return IsExpression::decode(bitfield_); } 2324 bool is_expression() const { return IsExpression::decode(bitfield_); }
2325 bool is_anonymous() const { return IsAnonymous::decode(bitfield_); } 2325 bool is_anonymous() const { return IsAnonymous::decode(bitfield_); }
2326 StrictMode strict_mode() const; 2326 StrictMode strict_mode() const;
2327 2327
2328 int materialized_literal_count() { return materialized_literal_count_; } 2328 int materialized_literal_count() { return materialized_literal_count_; }
2329 int expected_property_count() { return expected_property_count_; } 2329 int expected_property_count() { return expected_property_count_; }
2330 int handler_count() { return handler_count_; } 2330 int handler_count() { return handler_count_; }
2331 int parameter_count() { return parameter_count_; } 2331 int parameter_count() { return parameter_count_; }
2332 2332
2333 bool AllowsLazyCompilation(); 2333 bool AllowsLazyCompilation();
2334 bool AllowsLazyCompilationWithoutContext(); 2334 bool AllowsLazyCompilationWithoutContext();
2335 2335
2336 void InitializeSharedInfo(Handle<Code> code); 2336 void InitializeSharedInfo(Handle<Code> code);
2337 2337
2338 Handle<String> debug_name() const { 2338 Handle<String> debug_name() const {
2339 if (name_->length() > 0) return name_; 2339 if (raw_name_ != NULL && !raw_name_->IsEmpty()) {
2340 return raw_name_->string();
2341 }
2340 return inferred_name(); 2342 return inferred_name();
2341 } 2343 }
2342 2344
2343 Handle<String> inferred_name() const { return inferred_name_; } 2345 Handle<String> inferred_name() const {
2346 if (!inferred_name_.is_null()) {
2347 ASSERT(raw_inferred_name_ == NULL);
2348 return inferred_name_;
2349 }
2350 if (raw_inferred_name_ != NULL) {
2351 return raw_inferred_name_->string();
2352 }
2353 UNREACHABLE();
2354 return Handle<String>();
2355 }
2356
2357 // Only one of {set_inferred_name, set_raw_inferred_name} should be called.
2344 void set_inferred_name(Handle<String> inferred_name) { 2358 void set_inferred_name(Handle<String> inferred_name) {
2359 ASSERT(!inferred_name.is_null());
2345 inferred_name_ = inferred_name; 2360 inferred_name_ = inferred_name;
2361 ASSERT(raw_inferred_name_== NULL || raw_inferred_name_->IsEmpty());
2362 raw_inferred_name_ = NULL;
2363 }
2364
2365 void set_raw_inferred_name(const AstString* raw_inferred_name) {
2366 ASSERT(raw_inferred_name != NULL);
2367 raw_inferred_name_ = raw_inferred_name;
2368 ASSERT(inferred_name_.is_null());
2369 inferred_name_ = Handle<String>();
2346 } 2370 }
2347 2371
2348 // shared_info may be null if it's not cached in full code. 2372 // shared_info may be null if it's not cached in full code.
2349 Handle<SharedFunctionInfo> shared_info() { return shared_info_; } 2373 Handle<SharedFunctionInfo> shared_info() { return shared_info_; }
2350 2374
2351 bool pretenure() { return Pretenure::decode(bitfield_); } 2375 bool pretenure() { return Pretenure::decode(bitfield_); }
2352 void set_pretenure() { bitfield_ |= Pretenure::encode(true); } 2376 void set_pretenure() { bitfield_ |= Pretenure::encode(true); }
2353 2377
2354 bool has_duplicate_parameters() { 2378 bool has_duplicate_parameters() {
2355 return HasDuplicateParameters::decode(bitfield_); 2379 return HasDuplicateParameters::decode(bitfield_);
(...skipping 26 matching lines...) Expand all
2382 return ast_properties_.feedback_slots(); 2406 return ast_properties_.feedback_slots();
2383 } 2407 }
2384 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } 2408 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; }
2385 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } 2409 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; }
2386 void set_dont_optimize_reason(BailoutReason reason) { 2410 void set_dont_optimize_reason(BailoutReason reason) {
2387 dont_optimize_reason_ = reason; 2411 dont_optimize_reason_ = reason;
2388 } 2412 }
2389 2413
2390 protected: 2414 protected:
2391 FunctionLiteral(Zone* zone, 2415 FunctionLiteral(Zone* zone,
2392 Handle<String> name, 2416 const AstRawString* name,
2417 AstValueFactory* ast_value_factory,
2393 Scope* scope, 2418 Scope* scope,
2394 ZoneList<Statement*>* body, 2419 ZoneList<Statement*>* body,
2395 int materialized_literal_count, 2420 int materialized_literal_count,
2396 int expected_property_count, 2421 int expected_property_count,
2397 int handler_count, 2422 int handler_count,
2398 int parameter_count, 2423 int parameter_count,
2399 FunctionType function_type, 2424 FunctionType function_type,
2400 ParameterFlag has_duplicate_parameters, 2425 ParameterFlag has_duplicate_parameters,
2401 IsFunctionFlag is_function, 2426 IsFunctionFlag is_function,
2402 IsParenthesizedFlag is_parenthesized, 2427 IsParenthesizedFlag is_parenthesized,
2403 IsGeneratorFlag is_generator, 2428 IsGeneratorFlag is_generator,
2404 int position) 2429 int position)
2405 : Expression(zone, position), 2430 : Expression(zone, position),
2406 name_(name), 2431 raw_name_(name),
2407 scope_(scope), 2432 scope_(scope),
2408 body_(body), 2433 body_(body),
2409 inferred_name_(zone->isolate()->factory()->empty_string()), 2434 raw_inferred_name_(ast_value_factory->empty_string()),
2410 dont_optimize_reason_(kNoReason), 2435 dont_optimize_reason_(kNoReason),
2411 materialized_literal_count_(materialized_literal_count), 2436 materialized_literal_count_(materialized_literal_count),
2412 expected_property_count_(expected_property_count), 2437 expected_property_count_(expected_property_count),
2413 handler_count_(handler_count), 2438 handler_count_(handler_count),
2414 parameter_count_(parameter_count), 2439 parameter_count_(parameter_count),
2415 function_token_position_(RelocInfo::kNoPosition) { 2440 function_token_position_(RelocInfo::kNoPosition) {
2416 bitfield_ = 2441 bitfield_ =
2417 IsExpression::encode(function_type != DECLARATION) | 2442 IsExpression::encode(function_type != DECLARATION) |
2418 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) | 2443 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) |
2419 Pretenure::encode(false) | 2444 Pretenure::encode(false) |
2420 HasDuplicateParameters::encode(has_duplicate_parameters) | 2445 HasDuplicateParameters::encode(has_duplicate_parameters) |
2421 IsFunction::encode(is_function) | 2446 IsFunction::encode(is_function) |
2422 IsParenthesized::encode(is_parenthesized) | 2447 IsParenthesized::encode(is_parenthesized) |
2423 IsGenerator::encode(is_generator); 2448 IsGenerator::encode(is_generator);
2424 } 2449 }
2425 2450
2426 private: 2451 private:
2452 const AstRawString* raw_name_;
2427 Handle<String> name_; 2453 Handle<String> name_;
2428 Handle<SharedFunctionInfo> shared_info_; 2454 Handle<SharedFunctionInfo> shared_info_;
2429 Scope* scope_; 2455 Scope* scope_;
2430 ZoneList<Statement*>* body_; 2456 ZoneList<Statement*>* body_;
2457 const AstString* raw_inferred_name_;
2431 Handle<String> inferred_name_; 2458 Handle<String> inferred_name_;
2432 AstProperties ast_properties_; 2459 AstProperties ast_properties_;
2433 BailoutReason dont_optimize_reason_; 2460 BailoutReason dont_optimize_reason_;
2434 2461
2435 int materialized_literal_count_; 2462 int materialized_literal_count_;
2436 int expected_property_count_; 2463 int expected_property_count_;
2437 int handler_count_; 2464 int handler_count_;
2438 int parameter_count_; 2465 int parameter_count_;
2439 int function_token_position_; 2466 int function_token_position_;
2440 2467
2441 unsigned bitfield_; 2468 unsigned bitfield_;
2442 class IsExpression: public BitField<bool, 0, 1> {}; 2469 class IsExpression: public BitField<bool, 0, 1> {};
2443 class IsAnonymous: public BitField<bool, 1, 1> {}; 2470 class IsAnonymous: public BitField<bool, 1, 1> {};
2444 class Pretenure: public BitField<bool, 2, 1> {}; 2471 class Pretenure: public BitField<bool, 2, 1> {};
2445 class HasDuplicateParameters: public BitField<ParameterFlag, 3, 1> {}; 2472 class HasDuplicateParameters: public BitField<ParameterFlag, 3, 1> {};
2446 class IsFunction: public BitField<IsFunctionFlag, 4, 1> {}; 2473 class IsFunction: public BitField<IsFunctionFlag, 4, 1> {};
2447 class IsParenthesized: public BitField<IsParenthesizedFlag, 5, 1> {}; 2474 class IsParenthesized: public BitField<IsParenthesizedFlag, 5, 1> {};
2448 class IsGenerator: public BitField<IsGeneratorFlag, 6, 1> {}; 2475 class IsGenerator: public BitField<IsGeneratorFlag, 6, 1> {};
2449 }; 2476 };
2450 2477
2451 2478
2452 class NativeFunctionLiteral V8_FINAL : public Expression { 2479 class NativeFunctionLiteral V8_FINAL : public Expression {
2453 public: 2480 public:
2454 DECLARE_NODE_TYPE(NativeFunctionLiteral) 2481 DECLARE_NODE_TYPE(NativeFunctionLiteral)
2455 2482
2456 Handle<String> name() const { return name_; } 2483 Handle<String> name() const { return name_->string(); }
2457 v8::Extension* extension() const { return extension_; } 2484 v8::Extension* extension() const { return extension_; }
2458 2485
2459 protected: 2486 protected:
2460 NativeFunctionLiteral( 2487 NativeFunctionLiteral(Zone* zone, const AstRawString* name,
2461 Zone* zone, Handle<String> name, v8::Extension* extension, int pos) 2488 v8::Extension* extension, int pos)
2462 : Expression(zone, pos), name_(name), extension_(extension) {} 2489 : Expression(zone, pos), name_(name), extension_(extension) {}
2463 2490
2464 private: 2491 private:
2465 Handle<String> name_; 2492 const AstRawString* name_;
2466 v8::Extension* extension_; 2493 v8::Extension* extension_;
2467 }; 2494 };
2468 2495
2469 2496
2470 class ThisFunction V8_FINAL : public Expression { 2497 class ThisFunction V8_FINAL : public Expression {
2471 public: 2498 public:
2472 DECLARE_NODE_TYPE(ThisFunction) 2499 DECLARE_NODE_TYPE(ThisFunction)
2473 2500
2474 protected: 2501 protected:
2475 explicit ThisFunction(Zone* zone, int pos): Expression(zone, pos) {} 2502 explicit ThisFunction(Zone* zone, int pos): Expression(zone, pos) {}
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
2947 }; 2974 };
2948 2975
2949 2976
2950 2977
2951 // ---------------------------------------------------------------------------- 2978 // ----------------------------------------------------------------------------
2952 // AstNode factory 2979 // AstNode factory
2953 2980
2954 template<class Visitor> 2981 template<class Visitor>
2955 class AstNodeFactory V8_FINAL BASE_EMBEDDED { 2982 class AstNodeFactory V8_FINAL BASE_EMBEDDED {
2956 public: 2983 public:
2957 explicit AstNodeFactory(Zone* zone) : zone_(zone) { } 2984 explicit AstNodeFactory(Zone* zone, AstValueFactory* ast_value_factory)
2985 : zone_(zone), ast_value_factory_(ast_value_factory) {}
2958 2986
2959 Visitor* visitor() { return &visitor_; } 2987 Visitor* visitor() { return &visitor_; }
2960 2988
2961 #define VISIT_AND_RETURN(NodeType, node) \ 2989 #define VISIT_AND_RETURN(NodeType, node) \
2962 visitor_.Visit##NodeType((node)); \ 2990 visitor_.Visit##NodeType((node)); \
2963 return node; 2991 return node;
2964 2992
2965 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy, 2993 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy,
2966 VariableMode mode, 2994 VariableMode mode,
2967 Scope* scope, 2995 Scope* scope,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
3011 ModuleLiteral* module = 3039 ModuleLiteral* module =
3012 new(zone_) ModuleLiteral(zone_, body, interface, pos); 3040 new(zone_) ModuleLiteral(zone_, body, interface, pos);
3013 VISIT_AND_RETURN(ModuleLiteral, module) 3041 VISIT_AND_RETURN(ModuleLiteral, module)
3014 } 3042 }
3015 3043
3016 ModuleVariable* NewModuleVariable(VariableProxy* proxy, int pos) { 3044 ModuleVariable* NewModuleVariable(VariableProxy* proxy, int pos) {
3017 ModuleVariable* module = new(zone_) ModuleVariable(zone_, proxy, pos); 3045 ModuleVariable* module = new(zone_) ModuleVariable(zone_, proxy, pos);
3018 VISIT_AND_RETURN(ModuleVariable, module) 3046 VISIT_AND_RETURN(ModuleVariable, module)
3019 } 3047 }
3020 3048
3021 ModulePath* NewModulePath(Module* origin, Handle<String> name, int pos) { 3049 ModulePath* NewModulePath(Module* origin, const AstRawString* name, int pos) {
3022 ModulePath* module = new(zone_) ModulePath(zone_, origin, name, pos); 3050 ModulePath* module = new (zone_) ModulePath(zone_, origin, name, pos);
3023 VISIT_AND_RETURN(ModulePath, module) 3051 VISIT_AND_RETURN(ModulePath, module)
3024 } 3052 }
3025 3053
3026 ModuleUrl* NewModuleUrl(Handle<String> url, int pos) { 3054 ModuleUrl* NewModuleUrl(Handle<String> url, int pos) {
3027 ModuleUrl* module = new(zone_) ModuleUrl(zone_, url, pos); 3055 ModuleUrl* module = new(zone_) ModuleUrl(zone_, url, pos);
3028 VISIT_AND_RETURN(ModuleUrl, module) 3056 VISIT_AND_RETURN(ModuleUrl, module)
3029 } 3057 }
3030 3058
3031 Block* NewBlock(ZoneStringList* labels, 3059 Block* NewBlock(ZoneList<const AstRawString*>* labels,
3032 int capacity, 3060 int capacity,
3033 bool is_initializer_block, 3061 bool is_initializer_block,
3034 int pos) { 3062 int pos) {
3035 Block* block = new(zone_) Block( 3063 Block* block = new(zone_) Block(
3036 zone_, labels, capacity, is_initializer_block, pos); 3064 zone_, labels, capacity, is_initializer_block, pos);
3037 VISIT_AND_RETURN(Block, block) 3065 VISIT_AND_RETURN(Block, block)
3038 } 3066 }
3039 3067
3040 #define STATEMENT_WITH_LABELS(NodeType) \ 3068 #define STATEMENT_WITH_LABELS(NodeType) \
3041 NodeType* New##NodeType(ZoneStringList* labels, int pos) { \ 3069 NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \
3042 NodeType* stmt = new(zone_) NodeType(zone_, labels, pos); \ 3070 NodeType* stmt = new(zone_) NodeType(zone_, labels, pos); \
3043 VISIT_AND_RETURN(NodeType, stmt); \ 3071 VISIT_AND_RETURN(NodeType, stmt); \
3044 } 3072 }
3045 STATEMENT_WITH_LABELS(DoWhileStatement) 3073 STATEMENT_WITH_LABELS(DoWhileStatement)
3046 STATEMENT_WITH_LABELS(WhileStatement) 3074 STATEMENT_WITH_LABELS(WhileStatement)
3047 STATEMENT_WITH_LABELS(ForStatement) 3075 STATEMENT_WITH_LABELS(ForStatement)
3048 STATEMENT_WITH_LABELS(SwitchStatement) 3076 STATEMENT_WITH_LABELS(SwitchStatement)
3049 #undef STATEMENT_WITH_LABELS 3077 #undef STATEMENT_WITH_LABELS
3050 3078
3051 ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode, 3079 ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode,
3052 ZoneStringList* labels, 3080 ZoneList<const AstRawString*>* labels,
3053 int pos) { 3081 int pos) {
3054 switch (visit_mode) { 3082 switch (visit_mode) {
3055 case ForEachStatement::ENUMERATE: { 3083 case ForEachStatement::ENUMERATE: {
3056 ForInStatement* stmt = new(zone_) ForInStatement(zone_, labels, pos); 3084 ForInStatement* stmt = new(zone_) ForInStatement(zone_, labels, pos);
3057 VISIT_AND_RETURN(ForInStatement, stmt); 3085 VISIT_AND_RETURN(ForInStatement, stmt);
3058 } 3086 }
3059 case ForEachStatement::ITERATE: { 3087 case ForEachStatement::ITERATE: {
3060 ForOfStatement* stmt = new(zone_) ForOfStatement(zone_, labels, pos); 3088 ForOfStatement* stmt = new(zone_) ForOfStatement(zone_, labels, pos);
3061 VISIT_AND_RETURN(ForOfStatement, stmt); 3089 VISIT_AND_RETURN(ForOfStatement, stmt);
3062 } 3090 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
3139 return new(zone_) EmptyStatement(zone_, pos); 3167 return new(zone_) EmptyStatement(zone_, pos);
3140 } 3168 }
3141 3169
3142 CaseClause* NewCaseClause( 3170 CaseClause* NewCaseClause(
3143 Expression* label, ZoneList<Statement*>* statements, int pos) { 3171 Expression* label, ZoneList<Statement*>* statements, int pos) {
3144 CaseClause* clause = 3172 CaseClause* clause =
3145 new(zone_) CaseClause(zone_, label, statements, pos); 3173 new(zone_) CaseClause(zone_, label, statements, pos);
3146 VISIT_AND_RETURN(CaseClause, clause) 3174 VISIT_AND_RETURN(CaseClause, clause)
3147 } 3175 }
3148 3176
3149 Literal* NewLiteral(Handle<Object> handle, int pos) { 3177 Literal* NewStringLiteral(const AstRawString* string, int pos) {
3150 Literal* lit = new(zone_) Literal(zone_, handle, pos); 3178 Literal* lit =
3179 new (zone_) Literal(zone_, ast_value_factory_->NewString(string), pos);
3180 VISIT_AND_RETURN(Literal, lit)
3181 }
3182
3183 // A JavaScript symbol (ECMA-262 edition 6).
3184 Literal* NewSymbolLiteral(const char* name, int pos) {
3185 Literal* lit =
3186 new (zone_) Literal(zone_, ast_value_factory_->NewSymbol(name), pos);
3151 VISIT_AND_RETURN(Literal, lit) 3187 VISIT_AND_RETURN(Literal, lit)
3152 } 3188 }
3153 3189
3154 Literal* NewNumberLiteral(double number, int pos) { 3190 Literal* NewNumberLiteral(double number, int pos) {
3155 return NewLiteral( 3191 Literal* lit = new (zone_)
3156 zone_->isolate()->factory()->NewNumber(number, TENURED), pos); 3192 Literal(zone_, ast_value_factory_->NewNumber(number), pos);
3193 VISIT_AND_RETURN(Literal, lit)
3194 }
3195
3196 Literal* NewSmiLiteral(int number, int pos) {
3197 Literal* lit =
3198 new (zone_) Literal(zone_, ast_value_factory_->NewSmi(number), pos);
3199 VISIT_AND_RETURN(Literal, lit)
3200 }
3201
3202 Literal* NewBooleanLiteral(bool b, int pos) {
3203 Literal* lit =
3204 new (zone_) Literal(zone_, ast_value_factory_->NewBoolean(b), pos);
3205 VISIT_AND_RETURN(Literal, lit)
3206 }
3207
3208 Literal* NewStringListLiteral(ZoneList<const AstRawString*>* strings,
3209 int pos) {
3210 Literal* lit = new (zone_)
3211 Literal(zone_, ast_value_factory_->NewStringList(strings), pos);
3212 VISIT_AND_RETURN(Literal, lit)
3213 }
3214
3215 Literal* NewNullLiteral(int pos) {
3216 Literal* lit =
3217 new (zone_) Literal(zone_, ast_value_factory_->NewNull(), pos);
3218 VISIT_AND_RETURN(Literal, lit)
3219 }
3220
3221 Literal* NewUndefinedLiteral(int pos) {
3222 Literal* lit =
3223 new (zone_) Literal(zone_, ast_value_factory_->NewUndefined(), pos);
3224 VISIT_AND_RETURN(Literal, lit)
3225 }
3226
3227 Literal* NewTheHoleLiteral(int pos) {
3228 Literal* lit =
3229 new (zone_) Literal(zone_, ast_value_factory_->NewTheHole(), pos);
3230 VISIT_AND_RETURN(Literal, lit)
3157 } 3231 }
3158 3232
3159 ObjectLiteral* NewObjectLiteral( 3233 ObjectLiteral* NewObjectLiteral(
3160 ZoneList<ObjectLiteral::Property*>* properties, 3234 ZoneList<ObjectLiteral::Property*>* properties,
3161 int literal_index, 3235 int literal_index,
3162 int boilerplate_properties, 3236 int boilerplate_properties,
3163 bool has_function, 3237 bool has_function,
3164 int pos) { 3238 int pos) {
3165 ObjectLiteral* lit = new(zone_) ObjectLiteral( 3239 ObjectLiteral* lit = new(zone_) ObjectLiteral(
3166 zone_, properties, literal_index, boilerplate_properties, 3240 zone_, properties, literal_index, boilerplate_properties,
3167 has_function, pos); 3241 has_function, pos);
3168 VISIT_AND_RETURN(ObjectLiteral, lit) 3242 VISIT_AND_RETURN(ObjectLiteral, lit)
3169 } 3243 }
3170 3244
3171 ObjectLiteral::Property* NewObjectLiteralProperty(Literal* key, 3245 ObjectLiteral::Property* NewObjectLiteralProperty(Literal* key,
3172 Expression* value) { 3246 Expression* value) {
3173 return new(zone_) ObjectLiteral::Property(zone_, key, value); 3247 return new (zone_)
3248 ObjectLiteral::Property(zone_, ast_value_factory_, key, value);
3174 } 3249 }
3175 3250
3176 ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter, 3251 ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter,
3177 FunctionLiteral* value, 3252 FunctionLiteral* value,
3178 int pos) { 3253 int pos) {
3179 ObjectLiteral::Property* prop = 3254 ObjectLiteral::Property* prop =
3180 new(zone_) ObjectLiteral::Property(zone_, is_getter, value); 3255 new(zone_) ObjectLiteral::Property(zone_, is_getter, value);
3181 prop->set_key(NewLiteral(value->name(), pos)); 3256 prop->set_key(NewStringLiteral(value->raw_name(), pos));
3182 return prop; // Not an AST node, will not be visited. 3257 return prop; // Not an AST node, will not be visited.
3183 } 3258 }
3184 3259
3185 RegExpLiteral* NewRegExpLiteral(Handle<String> pattern, 3260 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern,
3186 Handle<String> flags, 3261 const AstRawString* flags,
3187 int literal_index, 3262 int literal_index,
3188 int pos) { 3263 int pos) {
3189 RegExpLiteral* lit = 3264 RegExpLiteral* lit =
3190 new(zone_) RegExpLiteral(zone_, pattern, flags, literal_index, pos); 3265 new(zone_) RegExpLiteral(zone_, pattern, flags, literal_index, pos);
3191 VISIT_AND_RETURN(RegExpLiteral, lit); 3266 VISIT_AND_RETURN(RegExpLiteral, lit);
3192 } 3267 }
3193 3268
3194 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, 3269 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values,
3195 int literal_index, 3270 int literal_index,
3196 int pos) { 3271 int pos) {
3197 ArrayLiteral* lit = new(zone_) ArrayLiteral( 3272 ArrayLiteral* lit = new(zone_) ArrayLiteral(
3198 zone_, values, literal_index, pos); 3273 zone_, values, literal_index, pos);
3199 VISIT_AND_RETURN(ArrayLiteral, lit) 3274 VISIT_AND_RETURN(ArrayLiteral, lit)
3200 } 3275 }
3201 3276
3202 VariableProxy* NewVariableProxy(Variable* var, 3277 VariableProxy* NewVariableProxy(Variable* var,
3203 int pos = RelocInfo::kNoPosition) { 3278 int pos = RelocInfo::kNoPosition) {
3204 VariableProxy* proxy = new(zone_) VariableProxy(zone_, var, pos); 3279 VariableProxy* proxy = new(zone_) VariableProxy(zone_, var, pos);
3205 VISIT_AND_RETURN(VariableProxy, proxy) 3280 VISIT_AND_RETURN(VariableProxy, proxy)
3206 } 3281 }
3207 3282
3208 VariableProxy* NewVariableProxy(Handle<String> name, 3283 VariableProxy* NewVariableProxy(const AstRawString* name,
3209 bool is_this, 3284 bool is_this,
3210 Interface* interface = Interface::NewValue(), 3285 Interface* interface = Interface::NewValue(),
3211 int position = RelocInfo::kNoPosition) { 3286 int position = RelocInfo::kNoPosition) {
3212 VariableProxy* proxy = 3287 VariableProxy* proxy =
3213 new(zone_) VariableProxy(zone_, name, is_this, interface, position); 3288 new(zone_) VariableProxy(zone_, name, is_this, interface, position);
3214 VISIT_AND_RETURN(VariableProxy, proxy) 3289 VISIT_AND_RETURN(VariableProxy, proxy)
3215 } 3290 }
3216 3291
3217 Property* NewProperty(Expression* obj, Expression* key, int pos) { 3292 Property* NewProperty(Expression* obj, Expression* key, int pos) {
3218 Property* prop = new(zone_) Property(zone_, obj, key, pos); 3293 Property* prop = new(zone_) Property(zone_, obj, key, pos);
3219 VISIT_AND_RETURN(Property, prop) 3294 VISIT_AND_RETURN(Property, prop)
3220 } 3295 }
3221 3296
3222 Call* NewCall(Expression* expression, 3297 Call* NewCall(Expression* expression,
3223 ZoneList<Expression*>* arguments, 3298 ZoneList<Expression*>* arguments,
3224 int pos) { 3299 int pos) {
3225 Call* call = new(zone_) Call(zone_, expression, arguments, pos); 3300 Call* call = new(zone_) Call(zone_, expression, arguments, pos);
3226 VISIT_AND_RETURN(Call, call) 3301 VISIT_AND_RETURN(Call, call)
3227 } 3302 }
3228 3303
3229 CallNew* NewCallNew(Expression* expression, 3304 CallNew* NewCallNew(Expression* expression,
3230 ZoneList<Expression*>* arguments, 3305 ZoneList<Expression*>* arguments,
3231 int pos) { 3306 int pos) {
3232 CallNew* call = new(zone_) CallNew(zone_, expression, arguments, pos); 3307 CallNew* call = new(zone_) CallNew(zone_, expression, arguments, pos);
3233 VISIT_AND_RETURN(CallNew, call) 3308 VISIT_AND_RETURN(CallNew, call)
3234 } 3309 }
3235 3310
3236 CallRuntime* NewCallRuntime(Handle<String> name, 3311 CallRuntime* NewCallRuntime(const AstRawString* name,
3237 const Runtime::Function* function, 3312 const Runtime::Function* function,
3238 ZoneList<Expression*>* arguments, 3313 ZoneList<Expression*>* arguments,
3239 int pos) { 3314 int pos) {
3240 CallRuntime* call = 3315 CallRuntime* call =
3241 new(zone_) CallRuntime(zone_, name, function, arguments, pos); 3316 new(zone_) CallRuntime(zone_, name, function, arguments, pos);
3242 VISIT_AND_RETURN(CallRuntime, call) 3317 VISIT_AND_RETURN(CallRuntime, call)
3243 } 3318 }
3244 3319
3245 UnaryOperation* NewUnaryOperation(Token::Value op, 3320 UnaryOperation* NewUnaryOperation(Token::Value op,
3246 Expression* expression, 3321 Expression* expression,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3304 zone_, generator_object, expression, yield_kind, pos); 3379 zone_, generator_object, expression, yield_kind, pos);
3305 VISIT_AND_RETURN(Yield, yield) 3380 VISIT_AND_RETURN(Yield, yield)
3306 } 3381 }
3307 3382
3308 Throw* NewThrow(Expression* exception, int pos) { 3383 Throw* NewThrow(Expression* exception, int pos) {
3309 Throw* t = new(zone_) Throw(zone_, exception, pos); 3384 Throw* t = new(zone_) Throw(zone_, exception, pos);
3310 VISIT_AND_RETURN(Throw, t) 3385 VISIT_AND_RETURN(Throw, t)
3311 } 3386 }
3312 3387
3313 FunctionLiteral* NewFunctionLiteral( 3388 FunctionLiteral* NewFunctionLiteral(
3314 Handle<String> name, 3389 const AstRawString* name,
3390 AstValueFactory* ast_value_factory,
3315 Scope* scope, 3391 Scope* scope,
3316 ZoneList<Statement*>* body, 3392 ZoneList<Statement*>* body,
3317 int materialized_literal_count, 3393 int materialized_literal_count,
3318 int expected_property_count, 3394 int expected_property_count,
3319 int handler_count, 3395 int handler_count,
3320 int parameter_count, 3396 int parameter_count,
3321 FunctionLiteral::ParameterFlag has_duplicate_parameters, 3397 FunctionLiteral::ParameterFlag has_duplicate_parameters,
3322 FunctionLiteral::FunctionType function_type, 3398 FunctionLiteral::FunctionType function_type,
3323 FunctionLiteral::IsFunctionFlag is_function, 3399 FunctionLiteral::IsFunctionFlag is_function,
3324 FunctionLiteral::IsParenthesizedFlag is_parenthesized, 3400 FunctionLiteral::IsParenthesizedFlag is_parenthesized,
3325 FunctionLiteral::IsGeneratorFlag is_generator, 3401 FunctionLiteral::IsGeneratorFlag is_generator,
3326 int position) { 3402 int position) {
3327 FunctionLiteral* lit = new(zone_) FunctionLiteral( 3403 FunctionLiteral* lit = new(zone_) FunctionLiteral(
3328 zone_, name, scope, body, 3404 zone_, name, ast_value_factory, scope, body,
3329 materialized_literal_count, expected_property_count, handler_count, 3405 materialized_literal_count, expected_property_count, handler_count,
3330 parameter_count, function_type, has_duplicate_parameters, is_function, 3406 parameter_count, function_type, has_duplicate_parameters, is_function,
3331 is_parenthesized, is_generator, position); 3407 is_parenthesized, is_generator, position);
3332 // Top-level literal doesn't count for the AST's properties. 3408 // Top-level literal doesn't count for the AST's properties.
3333 if (is_function == FunctionLiteral::kIsFunction) { 3409 if (is_function == FunctionLiteral::kIsFunction) {
3334 visitor_.VisitFunctionLiteral(lit); 3410 visitor_.VisitFunctionLiteral(lit);
3335 } 3411 }
3336 return lit; 3412 return lit;
3337 } 3413 }
3338 3414
3339 NativeFunctionLiteral* NewNativeFunctionLiteral( 3415 NativeFunctionLiteral* NewNativeFunctionLiteral(
3340 Handle<String> name, v8::Extension* extension, int pos) { 3416 const AstRawString* name, v8::Extension* extension,
3417 int pos) {
3341 NativeFunctionLiteral* lit = 3418 NativeFunctionLiteral* lit =
3342 new(zone_) NativeFunctionLiteral(zone_, name, extension, pos); 3419 new(zone_) NativeFunctionLiteral(zone_, name, extension, pos);
3343 VISIT_AND_RETURN(NativeFunctionLiteral, lit) 3420 VISIT_AND_RETURN(NativeFunctionLiteral, lit)
3344 } 3421 }
3345 3422
3346 ThisFunction* NewThisFunction(int pos) { 3423 ThisFunction* NewThisFunction(int pos) {
3347 ThisFunction* fun = new(zone_) ThisFunction(zone_, pos); 3424 ThisFunction* fun = new(zone_) ThisFunction(zone_, pos);
3348 VISIT_AND_RETURN(ThisFunction, fun) 3425 VISIT_AND_RETURN(ThisFunction, fun)
3349 } 3426 }
3350 3427
3351 #undef VISIT_AND_RETURN 3428 #undef VISIT_AND_RETURN
3352 3429
3353 private: 3430 private:
3354 Zone* zone_; 3431 Zone* zone_;
3355 Visitor visitor_; 3432 Visitor visitor_;
3433 AstValueFactory* ast_value_factory_;
3356 }; 3434 };
3357 3435
3358 3436
3359 } } // namespace v8::internal 3437 } } // namespace v8::internal
3360 3438
3361 #endif // V8_AST_H_ 3439 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698