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

Side by Side Diff: src/ast.h

Issue 7399023: Pass isolate to AST ID functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: A bit less ugly Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/ast.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } 162 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; }
163 virtual Slot* AsSlot() { return NULL; } 163 virtual Slot* AsSlot() { return NULL; }
164 164
165 // True if the node is simple enough for us to inline calls containing it. 165 // True if the node is simple enough for us to inline calls containing it.
166 virtual bool IsInlineable() const = 0; 166 virtual bool IsInlineable() const = 0;
167 167
168 static int Count() { return Isolate::Current()->ast_node_count(); } 168 static int Count() { return Isolate::Current()->ast_node_count(); }
169 static void ResetIds() { Isolate::Current()->set_ast_node_id(0); } 169 static void ResetIds() { Isolate::Current()->set_ast_node_id(0); }
170 170
171 protected: 171 protected:
172 static unsigned GetNextId() { return ReserveIdRange(1); } 172 static unsigned GetNextId(Isolate* isolate) {
173 static unsigned ReserveIdRange(int n) { 173 return ReserveIdRange(isolate, 1);
174 Isolate* isolate = Isolate::Current(); 174 }
175
176 static unsigned ReserveIdRange(Isolate* isolate, int n) {
175 unsigned tmp = isolate->ast_node_id(); 177 unsigned tmp = isolate->ast_node_id();
176 isolate->set_ast_node_id(tmp + n); 178 isolate->set_ast_node_id(tmp + n);
177 return tmp; 179 return tmp;
178 } 180 }
179 181
180 private: 182 private:
181 // Hidden to prevent accidental usage. It would have to load the 183 // Hidden to prevent accidental usage. It would have to load the
182 // current zone from the TLS. 184 // current zone from the TLS.
183 void* operator new(size_t size); 185 void* operator new(size_t size);
184 186
(...skipping 27 matching lines...) Expand all
212 // code generation. 214 // code generation.
213 kUninitialized, 215 kUninitialized,
214 // Evaluated for its side effects. 216 // Evaluated for its side effects.
215 kEffect, 217 kEffect,
216 // Evaluated for its value (and side effects). 218 // Evaluated for its value (and side effects).
217 kValue, 219 kValue,
218 // Evaluated for control flow (and side effects). 220 // Evaluated for control flow (and side effects).
219 kTest 221 kTest
220 }; 222 };
221 223
222 Expression() : id_(GetNextId()), test_id_(GetNextId()) {} 224 explicit Expression(Isolate* isolate)
225 : id_(GetNextId(isolate)),
226 test_id_(GetNextId(isolate)) {}
223 227
224 virtual int position() const { 228 virtual int position() const {
225 UNREACHABLE(); 229 UNREACHABLE();
226 return 0; 230 return 0;
227 } 231 }
228 232
229 virtual Expression* AsExpression() { return this; } 233 virtual Expression* AsExpression() { return this; }
230 234
231 virtual bool IsTrivial() { return false; } 235 virtual bool IsTrivial() { return false; }
232 virtual bool IsValidLeftHandSide() { return false; } 236 virtual bool IsValidLeftHandSide() { return false; }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 }; 283 };
280 284
281 285
282 /** 286 /**
283 * A sentinel used during pre parsing that represents some expression 287 * A sentinel used during pre parsing that represents some expression
284 * that is a valid left hand side without having to actually build 288 * that is a valid left hand side without having to actually build
285 * the expression. 289 * the expression.
286 */ 290 */
287 class ValidLeftHandSideSentinel: public Expression { 291 class ValidLeftHandSideSentinel: public Expression {
288 public: 292 public:
293 explicit ValidLeftHandSideSentinel(Isolate* isolate) : Expression(isolate) {}
289 virtual bool IsValidLeftHandSide() { return true; } 294 virtual bool IsValidLeftHandSide() { return true; }
290 virtual void Accept(AstVisitor* v) { UNREACHABLE(); } 295 virtual void Accept(AstVisitor* v) { UNREACHABLE(); }
291 virtual bool IsInlineable() const; 296 virtual bool IsInlineable() const;
292 }; 297 };
293 298
294 299
295 class BreakableStatement: public Statement { 300 class BreakableStatement: public Statement {
296 public: 301 public:
297 enum Type { 302 enum Type {
298 TARGET_FOR_ANONYMOUS, 303 TARGET_FOR_ANONYMOUS,
(...skipping 11 matching lines...) Expand all
310 Label* break_target() { return &break_target_; } 315 Label* break_target() { return &break_target_; }
311 316
312 // Testers. 317 // Testers.
313 bool is_target_for_anonymous() const { return type_ == TARGET_FOR_ANONYMOUS; } 318 bool is_target_for_anonymous() const { return type_ == TARGET_FOR_ANONYMOUS; }
314 319
315 // Bailout support. 320 // Bailout support.
316 int EntryId() const { return entry_id_; } 321 int EntryId() const { return entry_id_; }
317 int ExitId() const { return exit_id_; } 322 int ExitId() const { return exit_id_; }
318 323
319 protected: 324 protected:
320 inline BreakableStatement(ZoneStringList* labels, Type type); 325 BreakableStatement(Isolate* isolate, ZoneStringList* labels, Type type);
321 326
322 private: 327 private:
323 ZoneStringList* labels_; 328 ZoneStringList* labels_;
324 Type type_; 329 Type type_;
325 Label break_target_; 330 Label break_target_;
326 int entry_id_; 331 int entry_id_;
327 int exit_id_; 332 int exit_id_;
328 }; 333 };
329 334
330 335
331 class Block: public BreakableStatement { 336 class Block: public BreakableStatement {
332 public: 337 public:
333 inline Block(ZoneStringList* labels, int capacity, bool is_initializer_block); 338 inline Block(Isolate* isolate,
339 ZoneStringList* labels,
340 int capacity,
341 bool is_initializer_block);
334 342
335 DECLARE_NODE_TYPE(Block) 343 DECLARE_NODE_TYPE(Block)
336 344
337 virtual Assignment* StatementAsSimpleAssignment() { 345 virtual Assignment* StatementAsSimpleAssignment() {
338 if (statements_.length() != 1) return NULL; 346 if (statements_.length() != 1) return NULL;
339 return statements_[0]->StatementAsSimpleAssignment(); 347 return statements_[0]->StatementAsSimpleAssignment();
340 } 348 }
341 349
342 virtual CountOperation* StatementAsCountOperation() { 350 virtual CountOperation* StatementAsCountOperation() {
343 if (statements_.length() != 1) return NULL; 351 if (statements_.length() != 1) return NULL;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 399
392 // Bailout support. 400 // Bailout support.
393 int OsrEntryId() const { return osr_entry_id_; } 401 int OsrEntryId() const { return osr_entry_id_; }
394 virtual int ContinueId() const = 0; 402 virtual int ContinueId() const = 0;
395 virtual int StackCheckId() const = 0; 403 virtual int StackCheckId() const = 0;
396 404
397 // Code generation 405 // Code generation
398 Label* continue_target() { return &continue_target_; } 406 Label* continue_target() { return &continue_target_; }
399 407
400 protected: 408 protected:
401 explicit inline IterationStatement(ZoneStringList* labels); 409 inline IterationStatement(Isolate* isolate, ZoneStringList* labels);
402 410
403 void Initialize(Statement* body) { 411 void Initialize(Statement* body) {
404 body_ = body; 412 body_ = body;
405 } 413 }
406 414
407 private: 415 private:
408 Statement* body_; 416 Statement* body_;
409 Label continue_target_; 417 Label continue_target_;
410 int osr_entry_id_; 418 int osr_entry_id_;
411 }; 419 };
412 420
413 421
414 class DoWhileStatement: public IterationStatement { 422 class DoWhileStatement: public IterationStatement {
415 public: 423 public:
416 explicit inline DoWhileStatement(ZoneStringList* labels); 424 inline DoWhileStatement(Isolate* isolate, ZoneStringList* labels);
417 425
418 DECLARE_NODE_TYPE(DoWhileStatement) 426 DECLARE_NODE_TYPE(DoWhileStatement)
419 427
420 void Initialize(Expression* cond, Statement* body) { 428 void Initialize(Expression* cond, Statement* body) {
421 IterationStatement::Initialize(body); 429 IterationStatement::Initialize(body);
422 cond_ = cond; 430 cond_ = cond;
423 } 431 }
424 432
425 Expression* cond() const { return cond_; } 433 Expression* cond() const { return cond_; }
426 434
(...skipping 12 matching lines...) Expand all
439 private: 447 private:
440 Expression* cond_; 448 Expression* cond_;
441 int condition_position_; 449 int condition_position_;
442 int continue_id_; 450 int continue_id_;
443 int back_edge_id_; 451 int back_edge_id_;
444 }; 452 };
445 453
446 454
447 class WhileStatement: public IterationStatement { 455 class WhileStatement: public IterationStatement {
448 public: 456 public:
449 explicit inline WhileStatement(ZoneStringList* labels); 457 inline WhileStatement(Isolate* isolate, ZoneStringList* labels);
450 458
451 DECLARE_NODE_TYPE(WhileStatement) 459 DECLARE_NODE_TYPE(WhileStatement)
452 460
453 void Initialize(Expression* cond, Statement* body) { 461 void Initialize(Expression* cond, Statement* body) {
454 IterationStatement::Initialize(body); 462 IterationStatement::Initialize(body);
455 cond_ = cond; 463 cond_ = cond;
456 } 464 }
457 465
458 Expression* cond() const { return cond_; } 466 Expression* cond() const { return cond_; }
459 bool may_have_function_literal() const { 467 bool may_have_function_literal() const {
(...skipping 12 matching lines...) Expand all
472 private: 480 private:
473 Expression* cond_; 481 Expression* cond_;
474 // True if there is a function literal subexpression in the condition. 482 // True if there is a function literal subexpression in the condition.
475 bool may_have_function_literal_; 483 bool may_have_function_literal_;
476 int body_id_; 484 int body_id_;
477 }; 485 };
478 486
479 487
480 class ForStatement: public IterationStatement { 488 class ForStatement: public IterationStatement {
481 public: 489 public:
482 explicit inline ForStatement(ZoneStringList* labels); 490 inline ForStatement(Isolate* isolate, ZoneStringList* labels);
483 491
484 DECLARE_NODE_TYPE(ForStatement) 492 DECLARE_NODE_TYPE(ForStatement)
485 493
486 void Initialize(Statement* init, 494 void Initialize(Statement* init,
487 Expression* cond, 495 Expression* cond,
488 Statement* next, 496 Statement* next,
489 Statement* body) { 497 Statement* body) {
490 IterationStatement::Initialize(body); 498 IterationStatement::Initialize(body);
491 init_ = init; 499 init_ = init;
492 cond_ = cond; 500 cond_ = cond;
(...skipping 28 matching lines...) Expand all
521 // True if there is a function literal subexpression in the condition. 529 // True if there is a function literal subexpression in the condition.
522 bool may_have_function_literal_; 530 bool may_have_function_literal_;
523 Variable* loop_variable_; 531 Variable* loop_variable_;
524 int continue_id_; 532 int continue_id_;
525 int body_id_; 533 int body_id_;
526 }; 534 };
527 535
528 536
529 class ForInStatement: public IterationStatement { 537 class ForInStatement: public IterationStatement {
530 public: 538 public:
531 explicit inline ForInStatement(ZoneStringList* labels); 539 inline ForInStatement(Isolate* isolate, ZoneStringList* labels);
532 540
533 DECLARE_NODE_TYPE(ForInStatement) 541 DECLARE_NODE_TYPE(ForInStatement)
534 542
535 void Initialize(Expression* each, Expression* enumerable, Statement* body) { 543 void Initialize(Expression* each, Expression* enumerable, Statement* body) {
536 IterationStatement::Initialize(body); 544 IterationStatement::Initialize(body);
537 each_ = each; 545 each_ = each;
538 enumerable_ = enumerable; 546 enumerable_ = enumerable;
539 } 547 }
540 548
541 Expression* each() const { return each_; } 549 Expression* each() const { return each_; }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 class ExitContextStatement: public Statement { 646 class ExitContextStatement: public Statement {
639 public: 647 public:
640 virtual bool IsInlineable() const; 648 virtual bool IsInlineable() const;
641 649
642 DECLARE_NODE_TYPE(ExitContextStatement) 650 DECLARE_NODE_TYPE(ExitContextStatement)
643 }; 651 };
644 652
645 653
646 class CaseClause: public ZoneObject { 654 class CaseClause: public ZoneObject {
647 public: 655 public:
648 CaseClause(Expression* label, ZoneList<Statement*>* statements, int pos); 656 CaseClause(Isolate* isolate,
657 Expression* label,
658 ZoneList<Statement*>* statements,
659 int pos);
649 660
650 bool is_default() const { return label_ == NULL; } 661 bool is_default() const { return label_ == NULL; }
651 Expression* label() const { 662 Expression* label() const {
652 CHECK(!is_default()); 663 CHECK(!is_default());
653 return label_; 664 return label_;
654 } 665 }
655 Label* body_target() { return &body_target_; } 666 Label* body_target() { return &body_target_; }
656 ZoneList<Statement*>* statements() const { return statements_; } 667 ZoneList<Statement*>* statements() const { return statements_; }
657 668
658 int position() const { return position_; } 669 int position() const { return position_; }
(...skipping 14 matching lines...) Expand all
673 int position_; 684 int position_;
674 enum CompareTypeFeedback { NONE, SMI_ONLY, OBJECT_ONLY }; 685 enum CompareTypeFeedback { NONE, SMI_ONLY, OBJECT_ONLY };
675 CompareTypeFeedback compare_type_; 686 CompareTypeFeedback compare_type_;
676 int compare_id_; 687 int compare_id_;
677 int entry_id_; 688 int entry_id_;
678 }; 689 };
679 690
680 691
681 class SwitchStatement: public BreakableStatement { 692 class SwitchStatement: public BreakableStatement {
682 public: 693 public:
683 explicit inline SwitchStatement(ZoneStringList* labels); 694 inline SwitchStatement(Isolate* isolate, ZoneStringList* labels);
684 695
685 DECLARE_NODE_TYPE(SwitchStatement) 696 DECLARE_NODE_TYPE(SwitchStatement)
686 697
687 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { 698 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) {
688 tag_ = tag; 699 tag_ = tag;
689 cases_ = cases; 700 cases_ = cases;
690 } 701 }
691 702
692 Expression* tag() const { return tag_; } 703 Expression* tag() const { return tag_; }
693 ZoneList<CaseClause*>* cases() const { return cases_; } 704 ZoneList<CaseClause*>* cases() const { return cases_; }
694 virtual bool IsInlineable() const; 705 virtual bool IsInlineable() const;
695 706
696 private: 707 private:
697 Expression* tag_; 708 Expression* tag_;
698 ZoneList<CaseClause*>* cases_; 709 ZoneList<CaseClause*>* cases_;
699 }; 710 };
700 711
701 712
702 // If-statements always have non-null references to their then- and 713 // If-statements always have non-null references to their then- and
703 // else-parts. When parsing if-statements with no explicit else-part, 714 // else-parts. When parsing if-statements with no explicit else-part,
704 // the parser implicitly creates an empty statement. Use the 715 // the parser implicitly creates an empty statement. Use the
705 // HasThenStatement() and HasElseStatement() functions to check if a 716 // HasThenStatement() and HasElseStatement() functions to check if a
706 // given if-statement has a then- or an else-part containing code. 717 // given if-statement has a then- or an else-part containing code.
707 class IfStatement: public Statement { 718 class IfStatement: public Statement {
708 public: 719 public:
709 IfStatement(Expression* condition, 720 IfStatement(Isolate* isolate,
721 Expression* condition,
710 Statement* then_statement, 722 Statement* then_statement,
711 Statement* else_statement) 723 Statement* else_statement)
712 : condition_(condition), 724 : condition_(condition),
713 then_statement_(then_statement), 725 then_statement_(then_statement),
714 else_statement_(else_statement), 726 else_statement_(else_statement),
715 if_id_(GetNextId()), 727 if_id_(GetNextId(isolate)),
716 then_id_(GetNextId()), 728 then_id_(GetNextId(isolate)),
717 else_id_(GetNextId()) { 729 else_id_(GetNextId(isolate)) {
718 } 730 }
719 731
720 DECLARE_NODE_TYPE(IfStatement) 732 DECLARE_NODE_TYPE(IfStatement)
721 733
722 virtual bool IsInlineable() const; 734 virtual bool IsInlineable() const;
723 735
724 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } 736 bool HasThenStatement() const { return !then_statement()->IsEmpty(); }
725 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } 737 bool HasElseStatement() const { return !else_statement()->IsEmpty(); }
726 738
727 Expression* condition() const { return condition_; } 739 Expression* condition() const { return condition_; }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 class EmptyStatement: public Statement { 848 class EmptyStatement: public Statement {
837 public: 849 public:
838 DECLARE_NODE_TYPE(EmptyStatement) 850 DECLARE_NODE_TYPE(EmptyStatement)
839 851
840 virtual bool IsInlineable() const; 852 virtual bool IsInlineable() const;
841 }; 853 };
842 854
843 855
844 class Literal: public Expression { 856 class Literal: public Expression {
845 public: 857 public:
846 explicit Literal(Handle<Object> handle) : handle_(handle) { } 858 Literal(Isolate* isolate, Handle<Object> handle)
859 : Expression(isolate), handle_(handle) { }
847 860
848 DECLARE_NODE_TYPE(Literal) 861 DECLARE_NODE_TYPE(Literal)
849 862
850 virtual bool IsTrivial() { return true; } 863 virtual bool IsTrivial() { return true; }
851 virtual bool IsSmiLiteral() { return handle_->IsSmi(); } 864 virtual bool IsSmiLiteral() { return handle_->IsSmi(); }
852 865
853 // Check if this literal is identical to the other literal. 866 // Check if this literal is identical to the other literal.
854 bool IsIdenticalTo(const Literal* other) const { 867 bool IsIdenticalTo(const Literal* other) const {
855 return handle_.is_identical_to(other->handle_); 868 return handle_.is_identical_to(other->handle_);
856 } 869 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 virtual bool IsInlineable() const; 902 virtual bool IsInlineable() const;
890 903
891 private: 904 private:
892 Handle<Object> handle_; 905 Handle<Object> handle_;
893 }; 906 };
894 907
895 908
896 // Base class for literals that needs space in the corresponding JSFunction. 909 // Base class for literals that needs space in the corresponding JSFunction.
897 class MaterializedLiteral: public Expression { 910 class MaterializedLiteral: public Expression {
898 public: 911 public:
899 explicit MaterializedLiteral(int literal_index, bool is_simple, int depth) 912 MaterializedLiteral(Isolate* isolate,
900 : literal_index_(literal_index), is_simple_(is_simple), depth_(depth) {} 913 int literal_index,
914 bool is_simple,
915 int depth)
916 : Expression(isolate),
917 literal_index_(literal_index),
918 is_simple_(is_simple),
919 depth_(depth) {}
901 920
902 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } 921 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; }
903 922
904 int literal_index() { return literal_index_; } 923 int literal_index() { return literal_index_; }
905 924
906 // A materialized literal is simple if the values consist of only 925 // A materialized literal is simple if the values consist of only
907 // constants and simple object and array literals. 926 // constants and simple object and array literals.
908 bool is_simple() const { return is_simple_; } 927 bool is_simple() const { return is_simple_; }
909 928
910 int depth() const { return depth_; } 929 int depth() const { return depth_; }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 void set_emit_store(bool emit_store); 965 void set_emit_store(bool emit_store);
947 bool emit_store(); 966 bool emit_store();
948 967
949 private: 968 private:
950 Literal* key_; 969 Literal* key_;
951 Expression* value_; 970 Expression* value_;
952 Kind kind_; 971 Kind kind_;
953 bool emit_store_; 972 bool emit_store_;
954 }; 973 };
955 974
956 ObjectLiteral(Handle<FixedArray> constant_properties, 975 ObjectLiteral(Isolate* isolate,
976 Handle<FixedArray> constant_properties,
957 ZoneList<Property*>* properties, 977 ZoneList<Property*>* properties,
958 int literal_index, 978 int literal_index,
959 bool is_simple, 979 bool is_simple,
960 bool fast_elements, 980 bool fast_elements,
961 int depth, 981 int depth,
962 bool has_function) 982 bool has_function)
963 : MaterializedLiteral(literal_index, is_simple, depth), 983 : MaterializedLiteral(isolate, literal_index, is_simple, depth),
964 constant_properties_(constant_properties), 984 constant_properties_(constant_properties),
965 properties_(properties), 985 properties_(properties),
966 fast_elements_(fast_elements), 986 fast_elements_(fast_elements),
967 has_function_(has_function) {} 987 has_function_(has_function) {}
968 988
969 DECLARE_NODE_TYPE(ObjectLiteral) 989 DECLARE_NODE_TYPE(ObjectLiteral)
970 990
971 Handle<FixedArray> constant_properties() const { 991 Handle<FixedArray> constant_properties() const {
972 return constant_properties_; 992 return constant_properties_;
973 } 993 }
(...skipping 18 matching lines...) Expand all
992 Handle<FixedArray> constant_properties_; 1012 Handle<FixedArray> constant_properties_;
993 ZoneList<Property*>* properties_; 1013 ZoneList<Property*>* properties_;
994 bool fast_elements_; 1014 bool fast_elements_;
995 bool has_function_; 1015 bool has_function_;
996 }; 1016 };
997 1017
998 1018
999 // Node for capturing a regexp literal. 1019 // Node for capturing a regexp literal.
1000 class RegExpLiteral: public MaterializedLiteral { 1020 class RegExpLiteral: public MaterializedLiteral {
1001 public: 1021 public:
1002 RegExpLiteral(Handle<String> pattern, 1022 RegExpLiteral(Isolate* isolate,
1023 Handle<String> pattern,
1003 Handle<String> flags, 1024 Handle<String> flags,
1004 int literal_index) 1025 int literal_index)
1005 : MaterializedLiteral(literal_index, false, 1), 1026 : MaterializedLiteral(isolate, literal_index, false, 1),
1006 pattern_(pattern), 1027 pattern_(pattern),
1007 flags_(flags) {} 1028 flags_(flags) {}
1008 1029
1009 DECLARE_NODE_TYPE(RegExpLiteral) 1030 DECLARE_NODE_TYPE(RegExpLiteral)
1010 1031
1011 Handle<String> pattern() const { return pattern_; } 1032 Handle<String> pattern() const { return pattern_; }
1012 Handle<String> flags() const { return flags_; } 1033 Handle<String> flags() const { return flags_; }
1013 1034
1014 private: 1035 private:
1015 Handle<String> pattern_; 1036 Handle<String> pattern_;
1016 Handle<String> flags_; 1037 Handle<String> flags_;
1017 }; 1038 };
1018 1039
1019 // An array literal has a literals object that is used 1040 // An array literal has a literals object that is used
1020 // for minimizing the work when constructing it at runtime. 1041 // for minimizing the work when constructing it at runtime.
1021 class ArrayLiteral: public MaterializedLiteral { 1042 class ArrayLiteral: public MaterializedLiteral {
1022 public: 1043 public:
1023 ArrayLiteral(Handle<FixedArray> constant_elements, 1044 ArrayLiteral(Isolate* isolate,
1045 Handle<FixedArray> constant_elements,
1024 ZoneList<Expression*>* values, 1046 ZoneList<Expression*>* values,
1025 int literal_index, 1047 int literal_index,
1026 bool is_simple, 1048 bool is_simple,
1027 int depth) 1049 int depth)
1028 : MaterializedLiteral(literal_index, is_simple, depth), 1050 : MaterializedLiteral(isolate, literal_index, is_simple, depth),
1029 constant_elements_(constant_elements), 1051 constant_elements_(constant_elements),
1030 values_(values), 1052 values_(values),
1031 first_element_id_(ReserveIdRange(values->length())) {} 1053 first_element_id_(ReserveIdRange(isolate, values->length())) {}
1032 1054
1033 DECLARE_NODE_TYPE(ArrayLiteral) 1055 DECLARE_NODE_TYPE(ArrayLiteral)
1034 1056
1035 Handle<FixedArray> constant_elements() const { return constant_elements_; } 1057 Handle<FixedArray> constant_elements() const { return constant_elements_; }
1036 ZoneList<Expression*>* values() const { return values_; } 1058 ZoneList<Expression*>* values() const { return values_; }
1037 1059
1038 // Return an AST id for an element that is used in simulate instructions. 1060 // Return an AST id for an element that is used in simulate instructions.
1039 int GetIdForElement(int i) { return first_element_id_ + i; } 1061 int GetIdForElement(int i) { return first_element_id_ + i; }
1040 1062
1041 private: 1063 private:
1042 Handle<FixedArray> constant_elements_; 1064 Handle<FixedArray> constant_elements_;
1043 ZoneList<Expression*>* values_; 1065 ZoneList<Expression*>* values_;
1044 int first_element_id_; 1066 int first_element_id_;
1045 }; 1067 };
1046 1068
1047 1069
1048 class VariableProxy: public Expression { 1070 class VariableProxy: public Expression {
1049 public: 1071 public:
1050 explicit VariableProxy(Variable* var); 1072 VariableProxy(Isolate* isolate, Variable* var);
1051 1073
1052 DECLARE_NODE_TYPE(VariableProxy) 1074 DECLARE_NODE_TYPE(VariableProxy)
1053 1075
1054 // Type testing & conversion 1076 // Type testing & conversion
1055 Variable* AsVariable() { return (this == NULL) ? NULL : var_; } 1077 Variable* AsVariable() { return (this == NULL) ? NULL : var_; }
1056 1078
1057 virtual bool IsValidLeftHandSide() { 1079 virtual bool IsValidLeftHandSide() {
1058 return var_ == NULL ? true : var_->IsValidLeftHandSide(); 1080 return var_ == NULL ? true : var_->IsValidLeftHandSide();
1059 } 1081 }
1060 1082
(...skipping 26 matching lines...) Expand all
1087 void BindTo(Variable* var); 1109 void BindTo(Variable* var);
1088 1110
1089 protected: 1111 protected:
1090 Handle<String> name_; 1112 Handle<String> name_;
1091 Variable* var_; // resolved variable, or NULL 1113 Variable* var_; // resolved variable, or NULL
1092 bool is_this_; 1114 bool is_this_;
1093 bool inside_with_; 1115 bool inside_with_;
1094 bool is_trivial_; 1116 bool is_trivial_;
1095 int position_; 1117 int position_;
1096 1118
1097 VariableProxy(Handle<String> name, 1119 VariableProxy(Isolate* isolate,
1120 Handle<String> name,
1098 bool is_this, 1121 bool is_this,
1099 bool inside_with, 1122 bool inside_with,
1100 int position = RelocInfo::kNoPosition); 1123 int position = RelocInfo::kNoPosition);
1101 explicit VariableProxy(bool is_this); 1124 VariableProxy(Isolate* isolate, bool is_this);
1102 1125
1103 friend class Scope; 1126 friend class Scope;
1104 }; 1127 };
1105 1128
1106 1129
1107 class VariableProxySentinel: public VariableProxy { 1130 class VariableProxySentinel: public VariableProxy {
1108 public: 1131 public:
1109 virtual bool IsValidLeftHandSide() { return !is_this(); } 1132 virtual bool IsValidLeftHandSide() { return !is_this(); }
1110 1133
1111 private: 1134 private:
1112 explicit VariableProxySentinel(bool is_this) : VariableProxy(is_this) { } 1135 VariableProxySentinel(Isolate* isolate, bool is_this)
1136 : VariableProxy(isolate, is_this) { }
1113 1137
1114 friend class AstSentinels; 1138 friend class AstSentinels;
1115 }; 1139 };
1116 1140
1117 1141
1118 class Slot: public Expression { 1142 class Slot: public Expression {
1119 public: 1143 public:
1120 enum Type { 1144 enum Type {
1121 // A slot in the parameter section on the stack. index() is 1145 // A slot in the parameter section on the stack. index() is
1122 // the parameter index, counting left-to-right, starting at 0. 1146 // the parameter index, counting left-to-right, starting at 0.
1123 PARAMETER, 1147 PARAMETER,
1124 1148
1125 // A slot in the local section on the stack. index() is 1149 // A slot in the local section on the stack. index() is
1126 // the variable index in the stack frame, starting at 0. 1150 // the variable index in the stack frame, starting at 0.
1127 LOCAL, 1151 LOCAL,
1128 1152
1129 // An indexed slot in a heap context. index() is the 1153 // An indexed slot in a heap context. index() is the
1130 // variable index in the context object on the heap, 1154 // variable index in the context object on the heap,
1131 // starting at 0. var()->scope() is the corresponding 1155 // starting at 0. var()->scope() is the corresponding
1132 // scope. 1156 // scope.
1133 CONTEXT, 1157 CONTEXT,
1134 1158
1135 // A named slot in a heap context. var()->name() is the 1159 // A named slot in a heap context. var()->name() is the
1136 // variable name in the context object on the heap, 1160 // variable name in the context object on the heap,
1137 // with lookup starting at the current context. index() 1161 // with lookup starting at the current context. index()
1138 // is invalid. 1162 // is invalid.
1139 LOOKUP 1163 LOOKUP
1140 }; 1164 };
1141 1165
1142 Slot(Variable* var, Type type, int index) 1166 Slot(Isolate* isolate, Variable* var, Type type, int index)
1143 : var_(var), type_(type), index_(index) { 1167 : Expression(isolate), var_(var), type_(type), index_(index) {
1144 ASSERT(var != NULL); 1168 ASSERT(var != NULL);
1145 } 1169 }
1146 1170
1147 virtual void Accept(AstVisitor* v); 1171 virtual void Accept(AstVisitor* v);
1148 1172
1149 virtual Slot* AsSlot() { return this; } 1173 virtual Slot* AsSlot() { return this; }
1150 1174
1151 bool IsStackAllocated() { return type_ == PARAMETER || type_ == LOCAL; } 1175 bool IsStackAllocated() { return type_ == PARAMETER || type_ == LOCAL; }
1152 1176
1153 // Accessors 1177 // Accessors
(...skipping 10 matching lines...) Expand all
1164 }; 1188 };
1165 1189
1166 1190
1167 class Property: public Expression { 1191 class Property: public Expression {
1168 public: 1192 public:
1169 // Synthetic properties are property lookups introduced by the system, 1193 // Synthetic properties are property lookups introduced by the system,
1170 // to objects that aren't visible to the user. Function calls to synthetic 1194 // to objects that aren't visible to the user. Function calls to synthetic
1171 // properties should use the global object as receiver, not the base object 1195 // properties should use the global object as receiver, not the base object
1172 // of the resolved Reference. 1196 // of the resolved Reference.
1173 enum Type { NORMAL, SYNTHETIC }; 1197 enum Type { NORMAL, SYNTHETIC };
1174 Property(Expression* obj, Expression* key, int pos, Type type = NORMAL) 1198 Property(Isolate* isolate,
1175 : obj_(obj), 1199 Expression* obj,
1200 Expression* key,
1201 int pos,
1202 Type type = NORMAL)
1203 : Expression(isolate),
1204 obj_(obj),
1176 key_(key), 1205 key_(key),
1177 pos_(pos), 1206 pos_(pos),
1178 type_(type), 1207 type_(type),
1179 receiver_types_(NULL), 1208 receiver_types_(NULL),
1180 is_monomorphic_(false), 1209 is_monomorphic_(false),
1181 is_array_length_(false), 1210 is_array_length_(false),
1182 is_string_length_(false), 1211 is_string_length_(false),
1183 is_string_access_(false), 1212 is_string_access_(false),
1184 is_function_prototype_(false) { } 1213 is_function_prototype_(false) { }
1185 1214
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 bool is_array_length_ : 1; 1246 bool is_array_length_ : 1;
1218 bool is_string_length_ : 1; 1247 bool is_string_length_ : 1;
1219 bool is_string_access_ : 1; 1248 bool is_string_access_ : 1;
1220 bool is_function_prototype_ : 1; 1249 bool is_function_prototype_ : 1;
1221 Handle<Map> monomorphic_receiver_type_; 1250 Handle<Map> monomorphic_receiver_type_;
1222 }; 1251 };
1223 1252
1224 1253
1225 class Call: public Expression { 1254 class Call: public Expression {
1226 public: 1255 public:
1227 Call(Expression* expression, ZoneList<Expression*>* arguments, int pos) 1256 Call(Isolate* isolate,
1228 : expression_(expression), 1257 Expression* expression,
1258 ZoneList<Expression*>* arguments,
1259 int pos)
1260 : Expression(isolate),
1261 expression_(expression),
1229 arguments_(arguments), 1262 arguments_(arguments),
1230 pos_(pos), 1263 pos_(pos),
1231 is_monomorphic_(false), 1264 is_monomorphic_(false),
1232 check_type_(RECEIVER_MAP_CHECK), 1265 check_type_(RECEIVER_MAP_CHECK),
1233 receiver_types_(NULL), 1266 receiver_types_(NULL),
1234 return_id_(GetNextId()) { 1267 return_id_(GetNextId(isolate)) {
1235 } 1268 }
1236 1269
1237 DECLARE_NODE_TYPE(Call) 1270 DECLARE_NODE_TYPE(Call)
1238 1271
1239 virtual bool IsInlineable() const; 1272 virtual bool IsInlineable() const;
1240 1273
1241 Expression* expression() const { return expression_; } 1274 Expression* expression() const { return expression_; }
1242 ZoneList<Expression*>* arguments() const { return arguments_; } 1275 ZoneList<Expression*>* arguments() const { return arguments_; }
1243 virtual int position() const { return pos_; } 1276 virtual int position() const { return pos_; }
1244 1277
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 EmptyStatement empty_statement_; 1336 EmptyStatement empty_statement_;
1304 1337
1305 friend class Isolate; 1338 friend class Isolate;
1306 1339
1307 DISALLOW_COPY_AND_ASSIGN(AstSentinels); 1340 DISALLOW_COPY_AND_ASSIGN(AstSentinels);
1308 }; 1341 };
1309 1342
1310 1343
1311 class CallNew: public Expression { 1344 class CallNew: public Expression {
1312 public: 1345 public:
1313 CallNew(Expression* expression, ZoneList<Expression*>* arguments, int pos) 1346 CallNew(Isolate* isolate,
1314 : expression_(expression), arguments_(arguments), pos_(pos) { } 1347 Expression* expression,
1348 ZoneList<Expression*>* arguments,
1349 int pos)
1350 : Expression(isolate),
1351 expression_(expression),
1352 arguments_(arguments),
1353 pos_(pos) { }
1315 1354
1316 DECLARE_NODE_TYPE(CallNew) 1355 DECLARE_NODE_TYPE(CallNew)
1317 1356
1318 virtual bool IsInlineable() const; 1357 virtual bool IsInlineable() const;
1319 1358
1320 Expression* expression() const { return expression_; } 1359 Expression* expression() const { return expression_; }
1321 ZoneList<Expression*>* arguments() const { return arguments_; } 1360 ZoneList<Expression*>* arguments() const { return arguments_; }
1322 virtual int position() const { return pos_; } 1361 virtual int position() const { return pos_; }
1323 1362
1324 private: 1363 private:
1325 Expression* expression_; 1364 Expression* expression_;
1326 ZoneList<Expression*>* arguments_; 1365 ZoneList<Expression*>* arguments_;
1327 int pos_; 1366 int pos_;
1328 }; 1367 };
1329 1368
1330 1369
1331 // The CallRuntime class does not represent any official JavaScript 1370 // The CallRuntime class does not represent any official JavaScript
1332 // language construct. Instead it is used to call a C or JS function 1371 // language construct. Instead it is used to call a C or JS function
1333 // with a set of arguments. This is used from the builtins that are 1372 // with a set of arguments. This is used from the builtins that are
1334 // implemented in JavaScript (see "v8natives.js"). 1373 // implemented in JavaScript (see "v8natives.js").
1335 class CallRuntime: public Expression { 1374 class CallRuntime: public Expression {
1336 public: 1375 public:
1337 CallRuntime(Handle<String> name, 1376 CallRuntime(Isolate* isolate,
1377 Handle<String> name,
1338 const Runtime::Function* function, 1378 const Runtime::Function* function,
1339 ZoneList<Expression*>* arguments) 1379 ZoneList<Expression*>* arguments)
1340 : name_(name), function_(function), arguments_(arguments) { } 1380 : Expression(isolate),
1381 name_(name),
1382 function_(function),
1383 arguments_(arguments) { }
1341 1384
1342 DECLARE_NODE_TYPE(CallRuntime) 1385 DECLARE_NODE_TYPE(CallRuntime)
1343 1386
1344 virtual bool IsInlineable() const; 1387 virtual bool IsInlineable() const;
1345 1388
1346 Handle<String> name() const { return name_; } 1389 Handle<String> name() const { return name_; }
1347 const Runtime::Function* function() const { return function_; } 1390 const Runtime::Function* function() const { return function_; }
1348 ZoneList<Expression*>* arguments() const { return arguments_; } 1391 ZoneList<Expression*>* arguments() const { return arguments_; }
1349 bool is_jsruntime() const { return function_ == NULL; } 1392 bool is_jsruntime() const { return function_ == NULL; }
1350 1393
1351 private: 1394 private:
1352 Handle<String> name_; 1395 Handle<String> name_;
1353 const Runtime::Function* function_; 1396 const Runtime::Function* function_;
1354 ZoneList<Expression*>* arguments_; 1397 ZoneList<Expression*>* arguments_;
1355 }; 1398 };
1356 1399
1357 1400
1358 class UnaryOperation: public Expression { 1401 class UnaryOperation: public Expression {
1359 public: 1402 public:
1360 UnaryOperation(Token::Value op, Expression* expression, int pos) 1403 UnaryOperation(Isolate* isolate,
1361 : op_(op), expression_(expression), pos_(pos) { 1404 Token::Value op,
1405 Expression* expression,
1406 int pos)
1407 : Expression(isolate), op_(op), expression_(expression), pos_(pos) {
1362 ASSERT(Token::IsUnaryOp(op)); 1408 ASSERT(Token::IsUnaryOp(op));
1363 } 1409 }
1364 1410
1365 DECLARE_NODE_TYPE(UnaryOperation) 1411 DECLARE_NODE_TYPE(UnaryOperation)
1366 1412
1367 virtual bool IsInlineable() const; 1413 virtual bool IsInlineable() const;
1368 1414
1369 virtual bool ResultOverwriteAllowed(); 1415 virtual bool ResultOverwriteAllowed();
1370 1416
1371 Token::Value op() const { return op_; } 1417 Token::Value op() const { return op_; }
1372 Expression* expression() const { return expression_; } 1418 Expression* expression() const { return expression_; }
1373 virtual int position() const { return pos_; } 1419 virtual int position() const { return pos_; }
1374 1420
1375 private: 1421 private:
1376 Token::Value op_; 1422 Token::Value op_;
1377 Expression* expression_; 1423 Expression* expression_;
1378 int pos_; 1424 int pos_;
1379 }; 1425 };
1380 1426
1381 1427
1382 class BinaryOperation: public Expression { 1428 class BinaryOperation: public Expression {
1383 public: 1429 public:
1384 BinaryOperation(Token::Value op, 1430 BinaryOperation(Isolate* isolate,
1431 Token::Value op,
1385 Expression* left, 1432 Expression* left,
1386 Expression* right, 1433 Expression* right,
1387 int pos) 1434 int pos)
1388 : op_(op), left_(left), right_(right), pos_(pos) { 1435 : Expression(isolate), op_(op), left_(left), right_(right), pos_(pos) {
1389 ASSERT(Token::IsBinaryOp(op)); 1436 ASSERT(Token::IsBinaryOp(op));
1390 right_id_ = (op == Token::AND || op == Token::OR) 1437 right_id_ = (op == Token::AND || op == Token::OR)
1391 ? static_cast<int>(GetNextId()) 1438 ? static_cast<int>(GetNextId(isolate))
1392 : AstNode::kNoNumber; 1439 : AstNode::kNoNumber;
1393 } 1440 }
1394 1441
1395 DECLARE_NODE_TYPE(BinaryOperation) 1442 DECLARE_NODE_TYPE(BinaryOperation)
1396 1443
1397 virtual bool IsInlineable() const; 1444 virtual bool IsInlineable() const;
1398 1445
1399 virtual bool ResultOverwriteAllowed(); 1446 virtual bool ResultOverwriteAllowed();
1400 1447
1401 Token::Value op() const { return op_; } 1448 Token::Value op() const { return op_; }
(...skipping 10 matching lines...) Expand all
1412 Expression* right_; 1459 Expression* right_;
1413 int pos_; 1460 int pos_;
1414 // The short-circuit logical operations have an AST ID for their 1461 // The short-circuit logical operations have an AST ID for their
1415 // right-hand subexpression. 1462 // right-hand subexpression.
1416 int right_id_; 1463 int right_id_;
1417 }; 1464 };
1418 1465
1419 1466
1420 class CountOperation: public Expression { 1467 class CountOperation: public Expression {
1421 public: 1468 public:
1422 CountOperation(Token::Value op, bool is_prefix, Expression* expr, int pos) 1469 CountOperation(Isolate* isolate,
1423 : op_(op), 1470 Token::Value op,
1471 bool is_prefix,
1472 Expression* expr,
1473 int pos)
1474 : Expression(isolate),
1475 op_(op),
1424 is_prefix_(is_prefix), 1476 is_prefix_(is_prefix),
1425 expression_(expr), 1477 expression_(expr),
1426 pos_(pos), 1478 pos_(pos),
1427 assignment_id_(GetNextId()), 1479 assignment_id_(GetNextId(isolate)),
1428 count_id_(GetNextId()), 1480 count_id_(GetNextId(isolate)),
1429 receiver_types_(NULL) { } 1481 receiver_types_(NULL) { }
1430 1482
1431 DECLARE_NODE_TYPE(CountOperation) 1483 DECLARE_NODE_TYPE(CountOperation)
1432 1484
1433 bool is_prefix() const { return is_prefix_; } 1485 bool is_prefix() const { return is_prefix_; }
1434 bool is_postfix() const { return !is_prefix_; } 1486 bool is_postfix() const { return !is_prefix_; }
1435 1487
1436 Token::Value op() const { return op_; } 1488 Token::Value op() const { return op_; }
1437 Token::Value binary_op() { 1489 Token::Value binary_op() {
1438 return (op() == Token::INC) ? Token::ADD : Token::SUB; 1490 return (op() == Token::INC) ? Token::ADD : Token::SUB;
(...skipping 25 matching lines...) Expand all
1464 int pos_; 1516 int pos_;
1465 int assignment_id_; 1517 int assignment_id_;
1466 int count_id_; 1518 int count_id_;
1467 Handle<Map> monomorphic_receiver_type_; 1519 Handle<Map> monomorphic_receiver_type_;
1468 ZoneMapList* receiver_types_; 1520 ZoneMapList* receiver_types_;
1469 }; 1521 };
1470 1522
1471 1523
1472 class CompareOperation: public Expression { 1524 class CompareOperation: public Expression {
1473 public: 1525 public:
1474 CompareOperation(Token::Value op, 1526 CompareOperation(Isolate* isolate,
1527 Token::Value op,
1475 Expression* left, 1528 Expression* left,
1476 Expression* right, 1529 Expression* right,
1477 int pos) 1530 int pos)
1478 : op_(op), left_(left), right_(right), pos_(pos), compare_type_(NONE) { 1531 : Expression(isolate),
1532 op_(op),
1533 left_(left),
1534 right_(right),
1535 pos_(pos),
1536 compare_type_(NONE) {
1479 ASSERT(Token::IsCompareOp(op)); 1537 ASSERT(Token::IsCompareOp(op));
1480 } 1538 }
1481 1539
1482 DECLARE_NODE_TYPE(CompareOperation) 1540 DECLARE_NODE_TYPE(CompareOperation)
1483 1541
1484 Token::Value op() const { return op_; } 1542 Token::Value op() const { return op_; }
1485 Expression* left() const { return left_; } 1543 Expression* left() const { return left_; }
1486 Expression* right() const { return right_; } 1544 Expression* right() const { return right_; }
1487 virtual int position() const { return pos_; } 1545 virtual int position() const { return pos_; }
1488 1546
(...skipping 14 matching lines...) Expand all
1503 Expression* right_; 1561 Expression* right_;
1504 int pos_; 1562 int pos_;
1505 1563
1506 enum CompareTypeFeedback { NONE, SMI_ONLY, OBJECT_ONLY }; 1564 enum CompareTypeFeedback { NONE, SMI_ONLY, OBJECT_ONLY };
1507 CompareTypeFeedback compare_type_; 1565 CompareTypeFeedback compare_type_;
1508 }; 1566 };
1509 1567
1510 1568
1511 class CompareToNull: public Expression { 1569 class CompareToNull: public Expression {
1512 public: 1570 public:
1513 CompareToNull(bool is_strict, Expression* expression) 1571 CompareToNull(Isolate* isolate, bool is_strict, Expression* expression)
1514 : is_strict_(is_strict), expression_(expression) { } 1572 : Expression(isolate), is_strict_(is_strict), expression_(expression) { }
1515 1573
1516 DECLARE_NODE_TYPE(CompareToNull) 1574 DECLARE_NODE_TYPE(CompareToNull)
1517 1575
1518 virtual bool IsInlineable() const; 1576 virtual bool IsInlineable() const;
1519 1577
1520 bool is_strict() const { return is_strict_; } 1578 bool is_strict() const { return is_strict_; }
1521 Token::Value op() const { return is_strict_ ? Token::EQ_STRICT : Token::EQ; } 1579 Token::Value op() const { return is_strict_ ? Token::EQ_STRICT : Token::EQ; }
1522 Expression* expression() const { return expression_; } 1580 Expression* expression() const { return expression_; }
1523 1581
1524 private: 1582 private:
1525 bool is_strict_; 1583 bool is_strict_;
1526 Expression* expression_; 1584 Expression* expression_;
1527 }; 1585 };
1528 1586
1529 1587
1530 class Conditional: public Expression { 1588 class Conditional: public Expression {
1531 public: 1589 public:
1532 Conditional(Expression* condition, 1590 Conditional(Isolate* isolate,
1591 Expression* condition,
1533 Expression* then_expression, 1592 Expression* then_expression,
1534 Expression* else_expression, 1593 Expression* else_expression,
1535 int then_expression_position, 1594 int then_expression_position,
1536 int else_expression_position) 1595 int else_expression_position)
1537 : condition_(condition), 1596 : Expression(isolate),
1597 condition_(condition),
1538 then_expression_(then_expression), 1598 then_expression_(then_expression),
1539 else_expression_(else_expression), 1599 else_expression_(else_expression),
1540 then_expression_position_(then_expression_position), 1600 then_expression_position_(then_expression_position),
1541 else_expression_position_(else_expression_position), 1601 else_expression_position_(else_expression_position),
1542 then_id_(GetNextId()), 1602 then_id_(GetNextId(isolate)),
1543 else_id_(GetNextId()) { 1603 else_id_(GetNextId(isolate)) {
1544 } 1604 }
1545 1605
1546 DECLARE_NODE_TYPE(Conditional) 1606 DECLARE_NODE_TYPE(Conditional)
1547 1607
1548 virtual bool IsInlineable() const; 1608 virtual bool IsInlineable() const;
1549 1609
1550 Expression* condition() const { return condition_; } 1610 Expression* condition() const { return condition_; }
1551 Expression* then_expression() const { return then_expression_; } 1611 Expression* then_expression() const { return then_expression_; }
1552 Expression* else_expression() const { return else_expression_; } 1612 Expression* else_expression() const { return else_expression_; }
1553 1613
1554 int then_expression_position() const { return then_expression_position_; } 1614 int then_expression_position() const { return then_expression_position_; }
1555 int else_expression_position() const { return else_expression_position_; } 1615 int else_expression_position() const { return else_expression_position_; }
1556 1616
1557 int ThenId() const { return then_id_; } 1617 int ThenId() const { return then_id_; }
1558 int ElseId() const { return else_id_; } 1618 int ElseId() const { return else_id_; }
1559 1619
1560 private: 1620 private:
1561 Expression* condition_; 1621 Expression* condition_;
1562 Expression* then_expression_; 1622 Expression* then_expression_;
1563 Expression* else_expression_; 1623 Expression* else_expression_;
1564 int then_expression_position_; 1624 int then_expression_position_;
1565 int else_expression_position_; 1625 int else_expression_position_;
1566 int then_id_; 1626 int then_id_;
1567 int else_id_; 1627 int else_id_;
1568 }; 1628 };
1569 1629
1570 1630
1571 class Assignment: public Expression { 1631 class Assignment: public Expression {
1572 public: 1632 public:
1573 Assignment(Token::Value op, Expression* target, Expression* value, int pos); 1633 Assignment(Isolate* isolate,
1634 Token::Value op,
1635 Expression* target,
1636 Expression* value,
1637 int pos);
1574 1638
1575 DECLARE_NODE_TYPE(Assignment) 1639 DECLARE_NODE_TYPE(Assignment)
1576 1640
1577 virtual bool IsInlineable() const; 1641 virtual bool IsInlineable() const;
1578 1642
1579 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } 1643 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; }
1580 1644
1581 Token::Value binary_op() const; 1645 Token::Value binary_op() const;
1582 1646
1583 Token::Value op() const { return op_; } 1647 Token::Value op() const { return op_; }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1623 bool block_end_; 1687 bool block_end_;
1624 1688
1625 bool is_monomorphic_; 1689 bool is_monomorphic_;
1626 ZoneMapList* receiver_types_; 1690 ZoneMapList* receiver_types_;
1627 Handle<Map> monomorphic_receiver_type_; 1691 Handle<Map> monomorphic_receiver_type_;
1628 }; 1692 };
1629 1693
1630 1694
1631 class Throw: public Expression { 1695 class Throw: public Expression {
1632 public: 1696 public:
1633 Throw(Expression* exception, int pos) 1697 Throw(Isolate* isolate, Expression* exception, int pos)
1634 : exception_(exception), pos_(pos) {} 1698 : Expression(isolate), exception_(exception), pos_(pos) {}
1635 1699
1636 DECLARE_NODE_TYPE(Throw) 1700 DECLARE_NODE_TYPE(Throw)
1637 1701
1638 Expression* exception() const { return exception_; } 1702 Expression* exception() const { return exception_; }
1639 virtual int position() const { return pos_; } 1703 virtual int position() const { return pos_; }
1640 virtual bool IsInlineable() const; 1704 virtual bool IsInlineable() const;
1641 1705
1642 private: 1706 private:
1643 Expression* exception_; 1707 Expression* exception_;
1644 int pos_; 1708 int pos_;
1645 }; 1709 };
1646 1710
1647 1711
1648 class FunctionLiteral: public Expression { 1712 class FunctionLiteral: public Expression {
1649 public: 1713 public:
1650 FunctionLiteral(Handle<String> name, 1714 FunctionLiteral(Isolate* isolate,
1715 Handle<String> name,
1651 Scope* scope, 1716 Scope* scope,
1652 ZoneList<Statement*>* body, 1717 ZoneList<Statement*>* body,
1653 int materialized_literal_count, 1718 int materialized_literal_count,
1654 int expected_property_count, 1719 int expected_property_count,
1655 bool has_only_simple_this_property_assignments, 1720 bool has_only_simple_this_property_assignments,
1656 Handle<FixedArray> this_property_assignments, 1721 Handle<FixedArray> this_property_assignments,
1657 int num_parameters, 1722 int num_parameters,
1658 int start_position, 1723 int start_position,
1659 int end_position, 1724 int end_position,
1660 bool is_expression, 1725 bool is_expression,
1661 bool has_duplicate_parameters) 1726 bool has_duplicate_parameters)
1662 : name_(name), 1727 : Expression(isolate),
1728 name_(name),
1663 scope_(scope), 1729 scope_(scope),
1664 body_(body), 1730 body_(body),
1665 materialized_literal_count_(materialized_literal_count), 1731 materialized_literal_count_(materialized_literal_count),
1666 expected_property_count_(expected_property_count), 1732 expected_property_count_(expected_property_count),
1667 has_only_simple_this_property_assignments_( 1733 has_only_simple_this_property_assignments_(
1668 has_only_simple_this_property_assignments), 1734 has_only_simple_this_property_assignments),
1669 this_property_assignments_(this_property_assignments), 1735 this_property_assignments_(this_property_assignments),
1670 num_parameters_(num_parameters), 1736 num_parameters_(num_parameters),
1671 start_position_(start_position), 1737 start_position_(start_position),
1672 end_position_(end_position), 1738 end_position_(end_position),
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1731 int function_token_position_; 1797 int function_token_position_;
1732 Handle<String> inferred_name_; 1798 Handle<String> inferred_name_;
1733 bool is_expression_; 1799 bool is_expression_;
1734 bool pretenure_; 1800 bool pretenure_;
1735 bool has_duplicate_parameters_; 1801 bool has_duplicate_parameters_;
1736 }; 1802 };
1737 1803
1738 1804
1739 class SharedFunctionInfoLiteral: public Expression { 1805 class SharedFunctionInfoLiteral: public Expression {
1740 public: 1806 public:
1741 explicit SharedFunctionInfoLiteral( 1807 SharedFunctionInfoLiteral(
1808 Isolate* isolate,
1742 Handle<SharedFunctionInfo> shared_function_info) 1809 Handle<SharedFunctionInfo> shared_function_info)
1743 : shared_function_info_(shared_function_info) { } 1810 : Expression(isolate), shared_function_info_(shared_function_info) { }
1744 1811
1745 DECLARE_NODE_TYPE(SharedFunctionInfoLiteral) 1812 DECLARE_NODE_TYPE(SharedFunctionInfoLiteral)
1746 1813
1747 Handle<SharedFunctionInfo> shared_function_info() const { 1814 Handle<SharedFunctionInfo> shared_function_info() const {
1748 return shared_function_info_; 1815 return shared_function_info_;
1749 } 1816 }
1750 virtual bool IsInlineable() const; 1817 virtual bool IsInlineable() const;
1751 1818
1752 private: 1819 private:
1753 Handle<SharedFunctionInfo> shared_function_info_; 1820 Handle<SharedFunctionInfo> shared_function_info_;
1754 }; 1821 };
1755 1822
1756 1823
1757 class ThisFunction: public Expression { 1824 class ThisFunction: public Expression {
1758 public: 1825 public:
1826 explicit ThisFunction(Isolate* isolate) : Expression(isolate) {}
1759 DECLARE_NODE_TYPE(ThisFunction) 1827 DECLARE_NODE_TYPE(ThisFunction)
1760 virtual bool IsInlineable() const; 1828 virtual bool IsInlineable() const;
1761 }; 1829 };
1762 1830
1763 1831
1764 // ---------------------------------------------------------------------------- 1832 // ----------------------------------------------------------------------------
1765 // Regular expressions 1833 // Regular expressions
1766 1834
1767 1835
1768 class RegExpVisitor BASE_EMBEDDED { 1836 class RegExpVisitor BASE_EMBEDDED {
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
2159 2227
2160 private: 2228 private:
2161 Isolate* isolate_; 2229 Isolate* isolate_;
2162 bool stack_overflow_; 2230 bool stack_overflow_;
2163 }; 2231 };
2164 2232
2165 2233
2166 } } // namespace v8::internal 2234 } } // namespace v8::internal
2167 2235
2168 #endif // V8_AST_H_ 2236 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698