| OLD | NEW |
| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // enumerated here. | 53 // enumerated here. |
| 54 | 54 |
| 55 #define STATEMENT_NODE_LIST(V) \ | 55 #define STATEMENT_NODE_LIST(V) \ |
| 56 V(Block) \ | 56 V(Block) \ |
| 57 V(ExpressionStatement) \ | 57 V(ExpressionStatement) \ |
| 58 V(EmptyStatement) \ | 58 V(EmptyStatement) \ |
| 59 V(IfStatement) \ | 59 V(IfStatement) \ |
| 60 V(ContinueStatement) \ | 60 V(ContinueStatement) \ |
| 61 V(BreakStatement) \ | 61 V(BreakStatement) \ |
| 62 V(ReturnStatement) \ | 62 V(ReturnStatement) \ |
| 63 V(WithEnterStatement) \ | 63 V(EnterWithContextStatement) \ |
| 64 V(WithExitStatement) \ | 64 V(ExitContextStatement) \ |
| 65 V(SwitchStatement) \ | 65 V(SwitchStatement) \ |
| 66 V(DoWhileStatement) \ | 66 V(DoWhileStatement) \ |
| 67 V(WhileStatement) \ | 67 V(WhileStatement) \ |
| 68 V(ForStatement) \ | 68 V(ForStatement) \ |
| 69 V(ForInStatement) \ | 69 V(ForInStatement) \ |
| 70 V(TryCatchStatement) \ | 70 V(TryCatchStatement) \ |
| 71 V(TryFinallyStatement) \ | 71 V(TryFinallyStatement) \ |
| 72 V(DebuggerStatement) | 72 V(DebuggerStatement) |
| 73 | 73 |
| 74 #define EXPRESSION_NODE_LIST(V) \ | 74 #define EXPRESSION_NODE_LIST(V) \ |
| 75 V(FunctionLiteral) \ | 75 V(FunctionLiteral) \ |
| 76 V(SharedFunctionInfoLiteral) \ | 76 V(SharedFunctionInfoLiteral) \ |
| 77 V(Conditional) \ | 77 V(Conditional) \ |
| 78 V(VariableProxy) \ | 78 V(VariableProxy) \ |
| 79 V(Literal) \ | 79 V(Literal) \ |
| 80 V(RegExpLiteral) \ | 80 V(RegExpLiteral) \ |
| 81 V(ObjectLiteral) \ | 81 V(ObjectLiteral) \ |
| 82 V(ArrayLiteral) \ | 82 V(ArrayLiteral) \ |
| 83 V(CatchExtensionObject) \ | |
| 84 V(Assignment) \ | 83 V(Assignment) \ |
| 85 V(Throw) \ | 84 V(Throw) \ |
| 86 V(Property) \ | 85 V(Property) \ |
| 87 V(Call) \ | 86 V(Call) \ |
| 88 V(CallNew) \ | 87 V(CallNew) \ |
| 89 V(CallRuntime) \ | 88 V(CallRuntime) \ |
| 90 V(UnaryOperation) \ | 89 V(UnaryOperation) \ |
| 91 V(CountOperation) \ | 90 V(CountOperation) \ |
| 92 V(BinaryOperation) \ | 91 V(BinaryOperation) \ |
| 93 V(CompareOperation) \ | 92 V(CompareOperation) \ |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 #define DECLARE_TYPE_ENUM(type) k##type, | 127 #define DECLARE_TYPE_ENUM(type) k##type, |
| 129 enum Type { | 128 enum Type { |
| 130 AST_NODE_LIST(DECLARE_TYPE_ENUM) | 129 AST_NODE_LIST(DECLARE_TYPE_ENUM) |
| 131 kInvalid = -1 | 130 kInvalid = -1 |
| 132 }; | 131 }; |
| 133 #undef DECLARE_TYPE_ENUM | 132 #undef DECLARE_TYPE_ENUM |
| 134 | 133 |
| 135 static const int kNoNumber = -1; | 134 static const int kNoNumber = -1; |
| 136 static const int kFunctionEntryId = 2; // Using 0 could disguise errors. | 135 static const int kFunctionEntryId = 2; // Using 0 could disguise errors. |
| 137 | 136 |
| 138 AstNode() : id_(GetNextId()) { | 137 AstNode() { |
| 139 Isolate* isolate = Isolate::Current(); | 138 Isolate* isolate = Isolate::Current(); |
| 140 isolate->set_ast_node_count(isolate->ast_node_count() + 1); | 139 isolate->set_ast_node_count(isolate->ast_node_count() + 1); |
| 141 } | 140 } |
| 142 | 141 |
| 143 virtual ~AstNode() { } | 142 virtual ~AstNode() { } |
| 144 | 143 |
| 145 virtual void Accept(AstVisitor* v) = 0; | 144 virtual void Accept(AstVisitor* v) = 0; |
| 146 virtual Type node_type() const { return kInvalid; } | 145 virtual Type node_type() const { return kInvalid; } |
| 147 | 146 |
| 148 // Type testing & conversion functions overridden by concrete subclasses. | 147 // Type testing & conversion functions overridden by concrete subclasses. |
| 149 #define DECLARE_NODE_FUNCTIONS(type) \ | 148 #define DECLARE_NODE_FUNCTIONS(type) \ |
| 150 virtual type* As##type() { return NULL; } | 149 virtual type* As##type() { return NULL; } |
| 151 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 150 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
| 152 #undef DECLARE_NODE_FUNCTIONS | 151 #undef DECLARE_NODE_FUNCTIONS |
| 153 | 152 |
| 154 virtual Statement* AsStatement() { return NULL; } | 153 virtual Statement* AsStatement() { return NULL; } |
| 155 virtual Expression* AsExpression() { return NULL; } | 154 virtual Expression* AsExpression() { return NULL; } |
| 156 virtual TargetCollector* AsTargetCollector() { return NULL; } | 155 virtual TargetCollector* AsTargetCollector() { return NULL; } |
| 157 virtual BreakableStatement* AsBreakableStatement() { return NULL; } | 156 virtual BreakableStatement* AsBreakableStatement() { return NULL; } |
| 158 virtual IterationStatement* AsIterationStatement() { return NULL; } | 157 virtual IterationStatement* AsIterationStatement() { return NULL; } |
| 159 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } | 158 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } |
| 160 virtual Slot* AsSlot() { return NULL; } | 159 virtual Slot* AsSlot() { return NULL; } |
| 161 | 160 |
| 162 // True if the node is simple enough for us to inline calls containing it. | 161 // True if the node is simple enough for us to inline calls containing it. |
| 163 virtual bool IsInlineable() const = 0; | 162 virtual bool IsInlineable() const = 0; |
| 164 | 163 |
| 165 static int Count() { return Isolate::Current()->ast_node_count(); } | 164 static int Count() { return Isolate::Current()->ast_node_count(); } |
| 166 static void ResetIds() { Isolate::Current()->set_ast_node_id(0); } | 165 static void ResetIds() { Isolate::Current()->set_ast_node_id(0); } |
| 167 unsigned id() const { return id_; } | |
| 168 | 166 |
| 169 protected: | 167 protected: |
| 170 static unsigned GetNextId() { | 168 static unsigned GetNextId() { return ReserveIdRange(1); } |
| 171 Isolate* isolate = Isolate::Current(); | |
| 172 unsigned tmp = isolate->ast_node_id(); | |
| 173 isolate->set_ast_node_id(tmp + 1); | |
| 174 return tmp; | |
| 175 } | |
| 176 static unsigned ReserveIdRange(int n) { | 169 static unsigned ReserveIdRange(int n) { |
| 177 Isolate* isolate = Isolate::Current(); | 170 Isolate* isolate = Isolate::Current(); |
| 178 unsigned tmp = isolate->ast_node_id(); | 171 unsigned tmp = isolate->ast_node_id(); |
| 179 isolate->set_ast_node_id(tmp + n); | 172 isolate->set_ast_node_id(tmp + n); |
| 180 return tmp; | 173 return tmp; |
| 181 } | 174 } |
| 182 | 175 |
| 183 private: | |
| 184 unsigned id_; | |
| 185 | |
| 186 friend class CaseClause; // Generates AST IDs. | 176 friend class CaseClause; // Generates AST IDs. |
| 187 }; | 177 }; |
| 188 | 178 |
| 189 | 179 |
| 190 class Statement: public AstNode { | 180 class Statement: public AstNode { |
| 191 public: | 181 public: |
| 192 Statement() : statement_pos_(RelocInfo::kNoPosition) {} | 182 Statement() : statement_pos_(RelocInfo::kNoPosition) {} |
| 193 | 183 |
| 194 virtual Statement* AsStatement() { return this; } | 184 virtual Statement* AsStatement() { return this; } |
| 195 | 185 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 213 // code generation. | 203 // code generation. |
| 214 kUninitialized, | 204 kUninitialized, |
| 215 // Evaluated for its side effects. | 205 // Evaluated for its side effects. |
| 216 kEffect, | 206 kEffect, |
| 217 // Evaluated for its value (and side effects). | 207 // Evaluated for its value (and side effects). |
| 218 kValue, | 208 kValue, |
| 219 // Evaluated for control flow (and side effects). | 209 // Evaluated for control flow (and side effects). |
| 220 kTest | 210 kTest |
| 221 }; | 211 }; |
| 222 | 212 |
| 223 Expression() {} | 213 Expression() : id_(GetNextId()), test_id_(GetNextId()) {} |
| 224 | 214 |
| 225 virtual int position() const { | 215 virtual int position() const { |
| 226 UNREACHABLE(); | 216 UNREACHABLE(); |
| 227 return 0; | 217 return 0; |
| 228 } | 218 } |
| 229 | 219 |
| 230 virtual Expression* AsExpression() { return this; } | 220 virtual Expression* AsExpression() { return this; } |
| 231 | 221 |
| 232 virtual bool IsTrivial() { return false; } | 222 virtual bool IsTrivial() { return false; } |
| 233 virtual bool IsValidLeftHandSide() { return false; } | 223 virtual bool IsValidLeftHandSide() { return false; } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 264 } | 254 } |
| 265 virtual ZoneMapList* GetReceiverTypes() { | 255 virtual ZoneMapList* GetReceiverTypes() { |
| 266 UNREACHABLE(); | 256 UNREACHABLE(); |
| 267 return NULL; | 257 return NULL; |
| 268 } | 258 } |
| 269 virtual Handle<Map> GetMonomorphicReceiverType() { | 259 virtual Handle<Map> GetMonomorphicReceiverType() { |
| 270 UNREACHABLE(); | 260 UNREACHABLE(); |
| 271 return Handle<Map>(); | 261 return Handle<Map>(); |
| 272 } | 262 } |
| 273 | 263 |
| 274 ExternalArrayType external_array_type() const { | 264 unsigned id() const { return id_; } |
| 275 return external_array_type_; | 265 unsigned test_id() const { return test_id_; } |
| 276 } | |
| 277 void set_external_array_type(ExternalArrayType array_type) { | |
| 278 external_array_type_ = array_type; | |
| 279 } | |
| 280 | 266 |
| 281 private: | 267 private: |
| 282 ExternalArrayType external_array_type_; | 268 unsigned id_; |
| 269 unsigned test_id_; |
| 283 }; | 270 }; |
| 284 | 271 |
| 285 | 272 |
| 286 /** | 273 /** |
| 287 * A sentinel used during pre parsing that represents some expression | 274 * A sentinel used during pre parsing that represents some expression |
| 288 * that is a valid left hand side without having to actually build | 275 * that is a valid left hand side without having to actually build |
| 289 * the expression. | 276 * the expression. |
| 290 */ | 277 */ |
| 291 class ValidLeftHandSideSentinel: public Expression { | 278 class ValidLeftHandSideSentinel: public Expression { |
| 292 public: | 279 public: |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 class IterationStatement: public BreakableStatement { | 376 class IterationStatement: public BreakableStatement { |
| 390 public: | 377 public: |
| 391 // Type testing & conversion. | 378 // Type testing & conversion. |
| 392 virtual IterationStatement* AsIterationStatement() { return this; } | 379 virtual IterationStatement* AsIterationStatement() { return this; } |
| 393 | 380 |
| 394 Statement* body() const { return body_; } | 381 Statement* body() const { return body_; } |
| 395 | 382 |
| 396 // Bailout support. | 383 // Bailout support. |
| 397 int OsrEntryId() const { return osr_entry_id_; } | 384 int OsrEntryId() const { return osr_entry_id_; } |
| 398 virtual int ContinueId() const = 0; | 385 virtual int ContinueId() const = 0; |
| 386 virtual int StackCheckId() const = 0; |
| 399 | 387 |
| 400 // Code generation | 388 // Code generation |
| 401 Label* continue_target() { return &continue_target_; } | 389 Label* continue_target() { return &continue_target_; } |
| 402 | 390 |
| 403 protected: | 391 protected: |
| 404 explicit inline IterationStatement(ZoneStringList* labels); | 392 explicit inline IterationStatement(ZoneStringList* labels); |
| 405 | 393 |
| 406 void Initialize(Statement* body) { | 394 void Initialize(Statement* body) { |
| 407 body_ = body; | 395 body_ = body; |
| 408 } | 396 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 427 | 415 |
| 428 Expression* cond() const { return cond_; } | 416 Expression* cond() const { return cond_; } |
| 429 | 417 |
| 430 // Position where condition expression starts. We need it to make | 418 // Position where condition expression starts. We need it to make |
| 431 // the loop's condition a breakable location. | 419 // the loop's condition a breakable location. |
| 432 int condition_position() { return condition_position_; } | 420 int condition_position() { return condition_position_; } |
| 433 void set_condition_position(int pos) { condition_position_ = pos; } | 421 void set_condition_position(int pos) { condition_position_ = pos; } |
| 434 | 422 |
| 435 // Bailout support. | 423 // Bailout support. |
| 436 virtual int ContinueId() const { return continue_id_; } | 424 virtual int ContinueId() const { return continue_id_; } |
| 425 virtual int StackCheckId() const { return back_edge_id_; } |
| 437 int BackEdgeId() const { return back_edge_id_; } | 426 int BackEdgeId() const { return back_edge_id_; } |
| 438 | 427 |
| 439 virtual bool IsInlineable() const; | 428 virtual bool IsInlineable() const; |
| 440 | 429 |
| 441 private: | 430 private: |
| 442 Expression* cond_; | 431 Expression* cond_; |
| 443 int condition_position_; | 432 int condition_position_; |
| 444 int continue_id_; | 433 int continue_id_; |
| 445 int back_edge_id_; | 434 int back_edge_id_; |
| 446 }; | 435 }; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 461 bool may_have_function_literal() const { | 450 bool may_have_function_literal() const { |
| 462 return may_have_function_literal_; | 451 return may_have_function_literal_; |
| 463 } | 452 } |
| 464 void set_may_have_function_literal(bool value) { | 453 void set_may_have_function_literal(bool value) { |
| 465 may_have_function_literal_ = value; | 454 may_have_function_literal_ = value; |
| 466 } | 455 } |
| 467 virtual bool IsInlineable() const; | 456 virtual bool IsInlineable() const; |
| 468 | 457 |
| 469 // Bailout support. | 458 // Bailout support. |
| 470 virtual int ContinueId() const { return EntryId(); } | 459 virtual int ContinueId() const { return EntryId(); } |
| 460 virtual int StackCheckId() const { return body_id_; } |
| 471 int BodyId() const { return body_id_; } | 461 int BodyId() const { return body_id_; } |
| 472 | 462 |
| 473 private: | 463 private: |
| 474 Expression* cond_; | 464 Expression* cond_; |
| 475 // True if there is a function literal subexpression in the condition. | 465 // True if there is a function literal subexpression in the condition. |
| 476 bool may_have_function_literal_; | 466 bool may_have_function_literal_; |
| 477 int body_id_; | 467 int body_id_; |
| 478 }; | 468 }; |
| 479 | 469 |
| 480 | 470 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 500 | 490 |
| 501 bool may_have_function_literal() const { | 491 bool may_have_function_literal() const { |
| 502 return may_have_function_literal_; | 492 return may_have_function_literal_; |
| 503 } | 493 } |
| 504 void set_may_have_function_literal(bool value) { | 494 void set_may_have_function_literal(bool value) { |
| 505 may_have_function_literal_ = value; | 495 may_have_function_literal_ = value; |
| 506 } | 496 } |
| 507 | 497 |
| 508 // Bailout support. | 498 // Bailout support. |
| 509 virtual int ContinueId() const { return continue_id_; } | 499 virtual int ContinueId() const { return continue_id_; } |
| 500 virtual int StackCheckId() const { return body_id_; } |
| 510 int BodyId() const { return body_id_; } | 501 int BodyId() const { return body_id_; } |
| 511 | 502 |
| 512 bool is_fast_smi_loop() { return loop_variable_ != NULL; } | 503 bool is_fast_smi_loop() { return loop_variable_ != NULL; } |
| 513 Variable* loop_variable() { return loop_variable_; } | 504 Variable* loop_variable() { return loop_variable_; } |
| 514 void set_loop_variable(Variable* var) { loop_variable_ = var; } | 505 void set_loop_variable(Variable* var) { loop_variable_ = var; } |
| 515 virtual bool IsInlineable() const; | 506 virtual bool IsInlineable() const; |
| 516 | 507 |
| 517 private: | 508 private: |
| 518 Statement* init_; | 509 Statement* init_; |
| 519 Expression* cond_; | 510 Expression* cond_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 538 enumerable_ = enumerable; | 529 enumerable_ = enumerable; |
| 539 } | 530 } |
| 540 | 531 |
| 541 Expression* each() const { return each_; } | 532 Expression* each() const { return each_; } |
| 542 Expression* enumerable() const { return enumerable_; } | 533 Expression* enumerable() const { return enumerable_; } |
| 543 virtual bool IsInlineable() const; | 534 virtual bool IsInlineable() const; |
| 544 | 535 |
| 545 // Bailout support. | 536 // Bailout support. |
| 546 int AssignmentId() const { return assignment_id_; } | 537 int AssignmentId() const { return assignment_id_; } |
| 547 virtual int ContinueId() const { return EntryId(); } | 538 virtual int ContinueId() const { return EntryId(); } |
| 539 virtual int StackCheckId() const { return EntryId(); } |
| 548 | 540 |
| 549 private: | 541 private: |
| 550 Expression* each_; | 542 Expression* each_; |
| 551 Expression* enumerable_; | 543 Expression* enumerable_; |
| 552 int assignment_id_; | 544 int assignment_id_; |
| 553 }; | 545 }; |
| 554 | 546 |
| 555 | 547 |
| 556 class ExpressionStatement: public Statement { | 548 class ExpressionStatement: public Statement { |
| 557 public: | 549 public: |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 DECLARE_NODE_TYPE(ReturnStatement) | 603 DECLARE_NODE_TYPE(ReturnStatement) |
| 612 | 604 |
| 613 Expression* expression() const { return expression_; } | 605 Expression* expression() const { return expression_; } |
| 614 virtual bool IsInlineable() const; | 606 virtual bool IsInlineable() const; |
| 615 | 607 |
| 616 private: | 608 private: |
| 617 Expression* expression_; | 609 Expression* expression_; |
| 618 }; | 610 }; |
| 619 | 611 |
| 620 | 612 |
| 621 class WithEnterStatement: public Statement { | 613 class EnterWithContextStatement: public Statement { |
| 622 public: | 614 public: |
| 623 explicit WithEnterStatement(Expression* expression, bool is_catch_block) | 615 explicit EnterWithContextStatement(Expression* expression) |
| 624 : expression_(expression), is_catch_block_(is_catch_block) { } | 616 : expression_(expression) { } |
| 625 | 617 |
| 626 DECLARE_NODE_TYPE(WithEnterStatement) | 618 DECLARE_NODE_TYPE(EnterWithContextStatement) |
| 627 | 619 |
| 628 Expression* expression() const { return expression_; } | 620 Expression* expression() const { return expression_; } |
| 629 | 621 |
| 630 bool is_catch_block() const { return is_catch_block_; } | |
| 631 virtual bool IsInlineable() const; | 622 virtual bool IsInlineable() const; |
| 632 | 623 |
| 633 private: | 624 private: |
| 634 Expression* expression_; | 625 Expression* expression_; |
| 635 bool is_catch_block_; | |
| 636 }; | 626 }; |
| 637 | 627 |
| 638 | 628 |
| 639 class WithExitStatement: public Statement { | 629 class ExitContextStatement: public Statement { |
| 640 public: | 630 public: |
| 641 WithExitStatement() { } | |
| 642 | |
| 643 virtual bool IsInlineable() const; | 631 virtual bool IsInlineable() const; |
| 644 | 632 |
| 645 DECLARE_NODE_TYPE(WithExitStatement) | 633 DECLARE_NODE_TYPE(ExitContextStatement) |
| 646 }; | 634 }; |
| 647 | 635 |
| 648 | 636 |
| 649 class CaseClause: public ZoneObject { | 637 class CaseClause: public ZoneObject { |
| 650 public: | 638 public: |
| 651 CaseClause(Expression* label, ZoneList<Statement*>* statements, int pos); | 639 CaseClause(Expression* label, ZoneList<Statement*>* statements, int pos); |
| 652 | 640 |
| 653 bool is_default() const { return label_ == NULL; } | 641 bool is_default() const { return label_ == NULL; } |
| 654 Expression* label() const { | 642 Expression* label() const { |
| 655 CHECK(!is_default()); | 643 CHECK(!is_default()); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 // HasThenStatement() and HasElseStatement() functions to check if a | 696 // HasThenStatement() and HasElseStatement() functions to check if a |
| 709 // given if-statement has a then- or an else-part containing code. | 697 // given if-statement has a then- or an else-part containing code. |
| 710 class IfStatement: public Statement { | 698 class IfStatement: public Statement { |
| 711 public: | 699 public: |
| 712 IfStatement(Expression* condition, | 700 IfStatement(Expression* condition, |
| 713 Statement* then_statement, | 701 Statement* then_statement, |
| 714 Statement* else_statement) | 702 Statement* else_statement) |
| 715 : condition_(condition), | 703 : condition_(condition), |
| 716 then_statement_(then_statement), | 704 then_statement_(then_statement), |
| 717 else_statement_(else_statement), | 705 else_statement_(else_statement), |
| 706 if_id_(GetNextId()), |
| 718 then_id_(GetNextId()), | 707 then_id_(GetNextId()), |
| 719 else_id_(GetNextId()) { | 708 else_id_(GetNextId()) { |
| 720 } | 709 } |
| 721 | 710 |
| 722 DECLARE_NODE_TYPE(IfStatement) | 711 DECLARE_NODE_TYPE(IfStatement) |
| 723 | 712 |
| 724 virtual bool IsInlineable() const; | 713 virtual bool IsInlineable() const; |
| 725 | 714 |
| 726 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } | 715 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } |
| 727 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } | 716 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } |
| 728 | 717 |
| 729 Expression* condition() const { return condition_; } | 718 Expression* condition() const { return condition_; } |
| 730 Statement* then_statement() const { return then_statement_; } | 719 Statement* then_statement() const { return then_statement_; } |
| 731 Statement* else_statement() const { return else_statement_; } | 720 Statement* else_statement() const { return else_statement_; } |
| 732 | 721 |
| 722 int IfId() const { return if_id_; } |
| 733 int ThenId() const { return then_id_; } | 723 int ThenId() const { return then_id_; } |
| 734 int ElseId() const { return else_id_; } | 724 int ElseId() const { return else_id_; } |
| 735 | 725 |
| 736 private: | 726 private: |
| 737 Expression* condition_; | 727 Expression* condition_; |
| 738 Statement* then_statement_; | 728 Statement* then_statement_; |
| 739 Statement* else_statement_; | 729 Statement* else_statement_; |
| 730 int if_id_; |
| 740 int then_id_; | 731 int then_id_; |
| 741 int else_id_; | 732 int else_id_; |
| 742 }; | 733 }; |
| 743 | 734 |
| 744 | 735 |
| 745 // NOTE: TargetCollectors are represented as nodes to fit in the target | 736 // NOTE: TargetCollectors are represented as nodes to fit in the target |
| 746 // stack in the compiler; this should probably be reworked. | 737 // stack in the compiler; this should probably be reworked. |
| 747 class TargetCollector: public AstNode { | 738 class TargetCollector: public AstNode { |
| 748 public: | 739 public: |
| 749 explicit TargetCollector(ZoneList<Label*>* targets) | 740 TargetCollector(): targets_(0) { } |
| 750 : targets_(targets) { | |
| 751 } | |
| 752 | 741 |
| 753 // Adds a jump target to the collector. The collector stores a pointer not | 742 // Adds a jump target to the collector. The collector stores a pointer not |
| 754 // a copy of the target to make binding work, so make sure not to pass in | 743 // a copy of the target to make binding work, so make sure not to pass in |
| 755 // references to something on the stack. | 744 // references to something on the stack. |
| 756 void AddTarget(Label* target); | 745 void AddTarget(Label* target); |
| 757 | 746 |
| 758 // Virtual behaviour. TargetCollectors are never part of the AST. | 747 // Virtual behaviour. TargetCollectors are never part of the AST. |
| 759 virtual void Accept(AstVisitor* v) { UNREACHABLE(); } | 748 virtual void Accept(AstVisitor* v) { UNREACHABLE(); } |
| 760 virtual TargetCollector* AsTargetCollector() { return this; } | 749 virtual TargetCollector* AsTargetCollector() { return this; } |
| 761 | 750 |
| 762 ZoneList<Label*>* targets() { return targets_; } | 751 ZoneList<Label*>* targets() { return &targets_; } |
| 763 virtual bool IsInlineable() const; | 752 virtual bool IsInlineable() const; |
| 764 | 753 |
| 765 private: | 754 private: |
| 766 ZoneList<Label*>* targets_; | 755 ZoneList<Label*> targets_; |
| 767 }; | 756 }; |
| 768 | 757 |
| 769 | 758 |
| 770 class TryStatement: public Statement { | 759 class TryStatement: public Statement { |
| 771 public: | 760 public: |
| 772 explicit TryStatement(Block* try_block) | 761 explicit TryStatement(Block* try_block) |
| 773 : try_block_(try_block), escaping_targets_(NULL) { } | 762 : try_block_(try_block), escaping_targets_(NULL) { } |
| 774 | 763 |
| 775 void set_escaping_targets(ZoneList<Label*>* targets) { | 764 void set_escaping_targets(ZoneList<Label*>* targets) { |
| 776 escaping_targets_ = targets; | 765 escaping_targets_ = targets; |
| 777 } | 766 } |
| 778 | 767 |
| 779 Block* try_block() const { return try_block_; } | 768 Block* try_block() const { return try_block_; } |
| 780 ZoneList<Label*>* escaping_targets() const { return escaping_targets_; } | 769 ZoneList<Label*>* escaping_targets() const { return escaping_targets_; } |
| 781 virtual bool IsInlineable() const; | 770 virtual bool IsInlineable() const; |
| 782 | 771 |
| 783 private: | 772 private: |
| 784 Block* try_block_; | 773 Block* try_block_; |
| 785 ZoneList<Label*>* escaping_targets_; | 774 ZoneList<Label*>* escaping_targets_; |
| 786 }; | 775 }; |
| 787 | 776 |
| 788 | 777 |
| 789 class TryCatchStatement: public TryStatement { | 778 class TryCatchStatement: public TryStatement { |
| 790 public: | 779 public: |
| 791 TryCatchStatement(Block* try_block, | 780 TryCatchStatement(Block* try_block, |
| 792 VariableProxy* catch_var, | 781 Scope* scope, |
| 782 Variable* variable, |
| 793 Block* catch_block) | 783 Block* catch_block) |
| 794 : TryStatement(try_block), | 784 : TryStatement(try_block), |
| 795 catch_var_(catch_var), | 785 scope_(scope), |
| 786 variable_(variable), |
| 796 catch_block_(catch_block) { | 787 catch_block_(catch_block) { |
| 797 } | 788 } |
| 798 | 789 |
| 799 DECLARE_NODE_TYPE(TryCatchStatement) | 790 DECLARE_NODE_TYPE(TryCatchStatement) |
| 800 | 791 |
| 801 VariableProxy* catch_var() const { return catch_var_; } | 792 Scope* scope() { return scope_; } |
| 793 Variable* variable() { return variable_; } |
| 802 Block* catch_block() const { return catch_block_; } | 794 Block* catch_block() const { return catch_block_; } |
| 803 virtual bool IsInlineable() const; | 795 virtual bool IsInlineable() const; |
| 804 | 796 |
| 805 private: | 797 private: |
| 806 VariableProxy* catch_var_; | 798 Scope* scope_; |
| 799 Variable* variable_; |
| 807 Block* catch_block_; | 800 Block* catch_block_; |
| 808 }; | 801 }; |
| 809 | 802 |
| 810 | 803 |
| 811 class TryFinallyStatement: public TryStatement { | 804 class TryFinallyStatement: public TryStatement { |
| 812 public: | 805 public: |
| 813 TryFinallyStatement(Block* try_block, Block* finally_block) | 806 TryFinallyStatement(Block* try_block, Block* finally_block) |
| 814 : TryStatement(try_block), | 807 : TryStatement(try_block), |
| 815 finally_block_(finally_block) { } | 808 finally_block_(finally_block) { } |
| 816 | 809 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 // Return an AST id for an element that is used in simulate instructions. | 1029 // Return an AST id for an element that is used in simulate instructions. |
| 1037 int GetIdForElement(int i) { return first_element_id_ + i; } | 1030 int GetIdForElement(int i) { return first_element_id_ + i; } |
| 1038 | 1031 |
| 1039 private: | 1032 private: |
| 1040 Handle<FixedArray> constant_elements_; | 1033 Handle<FixedArray> constant_elements_; |
| 1041 ZoneList<Expression*>* values_; | 1034 ZoneList<Expression*>* values_; |
| 1042 int first_element_id_; | 1035 int first_element_id_; |
| 1043 }; | 1036 }; |
| 1044 | 1037 |
| 1045 | 1038 |
| 1046 // Node for constructing a context extension object for a catch block. | |
| 1047 // The catch context extension object has one property, the catch | |
| 1048 // variable, which should be DontDelete. | |
| 1049 class CatchExtensionObject: public Expression { | |
| 1050 public: | |
| 1051 CatchExtensionObject(Literal* key, VariableProxy* value) | |
| 1052 : key_(key), value_(value) { | |
| 1053 } | |
| 1054 | |
| 1055 DECLARE_NODE_TYPE(CatchExtensionObject) | |
| 1056 | |
| 1057 Literal* key() const { return key_; } | |
| 1058 VariableProxy* value() const { return value_; } | |
| 1059 virtual bool IsInlineable() const; | |
| 1060 | |
| 1061 private: | |
| 1062 Literal* key_; | |
| 1063 VariableProxy* value_; | |
| 1064 }; | |
| 1065 | |
| 1066 | |
| 1067 class VariableProxy: public Expression { | 1039 class VariableProxy: public Expression { |
| 1068 public: | 1040 public: |
| 1069 explicit VariableProxy(Variable* var); | 1041 explicit VariableProxy(Variable* var); |
| 1070 | 1042 |
| 1071 DECLARE_NODE_TYPE(VariableProxy) | 1043 DECLARE_NODE_TYPE(VariableProxy) |
| 1072 | 1044 |
| 1073 // Type testing & conversion | 1045 // Type testing & conversion |
| 1074 virtual Property* AsProperty() { | 1046 Variable* AsVariable() { return (this == NULL) ? NULL : var_; } |
| 1075 return var_ == NULL ? NULL : var_->AsProperty(); | |
| 1076 } | |
| 1077 | |
| 1078 Variable* AsVariable() { | |
| 1079 if (this == NULL || var_ == NULL) return NULL; | |
| 1080 Expression* rewrite = var_->rewrite(); | |
| 1081 if (rewrite == NULL || rewrite->AsSlot() != NULL) return var_; | |
| 1082 return NULL; | |
| 1083 } | |
| 1084 | 1047 |
| 1085 virtual bool IsValidLeftHandSide() { | 1048 virtual bool IsValidLeftHandSide() { |
| 1086 return var_ == NULL ? true : var_->IsValidLeftHandSide(); | 1049 return var_ == NULL ? true : var_->IsValidLeftHandSide(); |
| 1087 } | 1050 } |
| 1088 | 1051 |
| 1089 virtual bool IsTrivial() { | 1052 virtual bool IsTrivial() { |
| 1090 // Reading from a mutable variable is a side effect, but the | 1053 // Reading from a mutable variable is a side effect, but the |
| 1091 // variable for 'this' is immutable. | 1054 // variable for 'this' is immutable. |
| 1092 return is_this_ || is_trivial_; | 1055 return is_this_ || is_trivial_; |
| 1093 } | 1056 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 Property(Expression* obj, Expression* key, int pos, Type type = NORMAL) | 1165 Property(Expression* obj, Expression* key, int pos, Type type = NORMAL) |
| 1203 : obj_(obj), | 1166 : obj_(obj), |
| 1204 key_(key), | 1167 key_(key), |
| 1205 pos_(pos), | 1168 pos_(pos), |
| 1206 type_(type), | 1169 type_(type), |
| 1207 receiver_types_(NULL), | 1170 receiver_types_(NULL), |
| 1208 is_monomorphic_(false), | 1171 is_monomorphic_(false), |
| 1209 is_array_length_(false), | 1172 is_array_length_(false), |
| 1210 is_string_length_(false), | 1173 is_string_length_(false), |
| 1211 is_string_access_(false), | 1174 is_string_access_(false), |
| 1212 is_function_prototype_(false), | 1175 is_function_prototype_(false) { } |
| 1213 is_arguments_access_(false) { } | |
| 1214 | 1176 |
| 1215 DECLARE_NODE_TYPE(Property) | 1177 DECLARE_NODE_TYPE(Property) |
| 1216 | 1178 |
| 1217 virtual bool IsValidLeftHandSide() { return true; } | 1179 virtual bool IsValidLeftHandSide() { return true; } |
| 1218 virtual bool IsInlineable() const; | 1180 virtual bool IsInlineable() const; |
| 1219 | 1181 |
| 1220 Expression* obj() const { return obj_; } | 1182 Expression* obj() const { return obj_; } |
| 1221 Expression* key() const { return key_; } | 1183 Expression* key() const { return key_; } |
| 1222 virtual int position() const { return pos_; } | 1184 virtual int position() const { return pos_; } |
| 1223 bool is_synthetic() const { return type_ == SYNTHETIC; } | 1185 bool is_synthetic() const { return type_ == SYNTHETIC; } |
| 1224 | 1186 |
| 1225 bool IsStringLength() const { return is_string_length_; } | 1187 bool IsStringLength() const { return is_string_length_; } |
| 1226 bool IsStringAccess() const { return is_string_access_; } | 1188 bool IsStringAccess() const { return is_string_access_; } |
| 1227 bool IsFunctionPrototype() const { return is_function_prototype_; } | 1189 bool IsFunctionPrototype() const { return is_function_prototype_; } |
| 1228 | 1190 |
| 1229 // Marks that this is actually an argument rewritten to a keyed property | |
| 1230 // accessing the argument through the arguments shadow object. | |
| 1231 void set_is_arguments_access(bool is_arguments_access) { | |
| 1232 is_arguments_access_ = is_arguments_access; | |
| 1233 } | |
| 1234 bool is_arguments_access() const { return is_arguments_access_; } | |
| 1235 | |
| 1236 // Type feedback information. | 1191 // Type feedback information. |
| 1237 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1192 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
| 1238 virtual bool IsMonomorphic() { return is_monomorphic_; } | 1193 virtual bool IsMonomorphic() { return is_monomorphic_; } |
| 1239 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } | 1194 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } |
| 1240 virtual bool IsArrayLength() { return is_array_length_; } | 1195 virtual bool IsArrayLength() { return is_array_length_; } |
| 1241 virtual Handle<Map> GetMonomorphicReceiverType() { | 1196 virtual Handle<Map> GetMonomorphicReceiverType() { |
| 1242 return monomorphic_receiver_type_; | 1197 return monomorphic_receiver_type_; |
| 1243 } | 1198 } |
| 1244 | 1199 |
| 1245 private: | 1200 private: |
| 1246 Expression* obj_; | 1201 Expression* obj_; |
| 1247 Expression* key_; | 1202 Expression* key_; |
| 1248 int pos_; | 1203 int pos_; |
| 1249 Type type_; | 1204 Type type_; |
| 1250 | 1205 |
| 1251 ZoneMapList* receiver_types_; | 1206 ZoneMapList* receiver_types_; |
| 1252 bool is_monomorphic_ : 1; | 1207 bool is_monomorphic_ : 1; |
| 1253 bool is_array_length_ : 1; | 1208 bool is_array_length_ : 1; |
| 1254 bool is_string_length_ : 1; | 1209 bool is_string_length_ : 1; |
| 1255 bool is_string_access_ : 1; | 1210 bool is_string_access_ : 1; |
| 1256 bool is_function_prototype_ : 1; | 1211 bool is_function_prototype_ : 1; |
| 1257 bool is_arguments_access_ : 1; | |
| 1258 Handle<Map> monomorphic_receiver_type_; | 1212 Handle<Map> monomorphic_receiver_type_; |
| 1259 }; | 1213 }; |
| 1260 | 1214 |
| 1261 | 1215 |
| 1262 class Call: public Expression { | 1216 class Call: public Expression { |
| 1263 public: | 1217 public: |
| 1264 Call(Expression* expression, ZoneList<Expression*>* arguments, int pos) | 1218 Call(Expression* expression, ZoneList<Expression*>* arguments, int pos) |
| 1265 : expression_(expression), | 1219 : expression_(expression), |
| 1266 arguments_(arguments), | 1220 arguments_(arguments), |
| 1267 pos_(pos), | 1221 pos_(pos), |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1455 | 1409 |
| 1456 | 1410 |
| 1457 class CountOperation: public Expression { | 1411 class CountOperation: public Expression { |
| 1458 public: | 1412 public: |
| 1459 CountOperation(Token::Value op, bool is_prefix, Expression* expr, int pos) | 1413 CountOperation(Token::Value op, bool is_prefix, Expression* expr, int pos) |
| 1460 : op_(op), | 1414 : op_(op), |
| 1461 is_prefix_(is_prefix), | 1415 is_prefix_(is_prefix), |
| 1462 expression_(expr), | 1416 expression_(expr), |
| 1463 pos_(pos), | 1417 pos_(pos), |
| 1464 assignment_id_(GetNextId()), | 1418 assignment_id_(GetNextId()), |
| 1465 count_id_(GetNextId()) { } | 1419 count_id_(GetNextId()), |
| 1420 receiver_types_(NULL) { } |
| 1466 | 1421 |
| 1467 DECLARE_NODE_TYPE(CountOperation) | 1422 DECLARE_NODE_TYPE(CountOperation) |
| 1468 | 1423 |
| 1469 bool is_prefix() const { return is_prefix_; } | 1424 bool is_prefix() const { return is_prefix_; } |
| 1470 bool is_postfix() const { return !is_prefix_; } | 1425 bool is_postfix() const { return !is_prefix_; } |
| 1471 | 1426 |
| 1472 Token::Value op() const { return op_; } | 1427 Token::Value op() const { return op_; } |
| 1473 Token::Value binary_op() { | 1428 Token::Value binary_op() { |
| 1474 return (op() == Token::INC) ? Token::ADD : Token::SUB; | 1429 return (op() == Token::INC) ? Token::ADD : Token::SUB; |
| 1475 } | 1430 } |
| 1476 | 1431 |
| 1477 Expression* expression() const { return expression_; } | 1432 Expression* expression() const { return expression_; } |
| 1478 virtual int position() const { return pos_; } | 1433 virtual int position() const { return pos_; } |
| 1479 | 1434 |
| 1480 virtual void MarkAsStatement() { is_prefix_ = true; } | 1435 virtual void MarkAsStatement() { is_prefix_ = true; } |
| 1481 | 1436 |
| 1482 virtual bool IsInlineable() const; | 1437 virtual bool IsInlineable() const; |
| 1483 | 1438 |
| 1484 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1439 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
| 1485 virtual bool IsMonomorphic() { return is_monomorphic_; } | 1440 virtual bool IsMonomorphic() { return is_monomorphic_; } |
| 1486 virtual Handle<Map> GetMonomorphicReceiverType() { | 1441 virtual Handle<Map> GetMonomorphicReceiverType() { |
| 1487 return monomorphic_receiver_type_; | 1442 return monomorphic_receiver_type_; |
| 1488 } | 1443 } |
| 1444 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } |
| 1489 | 1445 |
| 1490 // Bailout support. | 1446 // Bailout support. |
| 1491 int AssignmentId() const { return assignment_id_; } | 1447 int AssignmentId() const { return assignment_id_; } |
| 1492 int CountId() const { return count_id_; } | 1448 int CountId() const { return count_id_; } |
| 1493 | 1449 |
| 1494 private: | 1450 private: |
| 1495 Token::Value op_; | 1451 Token::Value op_; |
| 1496 bool is_prefix_; | 1452 bool is_prefix_; |
| 1497 bool is_monomorphic_; | 1453 bool is_monomorphic_; |
| 1498 Expression* expression_; | 1454 Expression* expression_; |
| 1499 int pos_; | 1455 int pos_; |
| 1500 int assignment_id_; | 1456 int assignment_id_; |
| 1501 int count_id_; | 1457 int count_id_; |
| 1502 Handle<Map> monomorphic_receiver_type_; | 1458 Handle<Map> monomorphic_receiver_type_; |
| 1459 ZoneMapList* receiver_types_; |
| 1503 }; | 1460 }; |
| 1504 | 1461 |
| 1505 | 1462 |
| 1506 class CompareOperation: public Expression { | 1463 class CompareOperation: public Expression { |
| 1507 public: | 1464 public: |
| 1508 CompareOperation(Token::Value op, | 1465 CompareOperation(Token::Value op, |
| 1509 Expression* left, | 1466 Expression* left, |
| 1510 Expression* right, | 1467 Expression* right, |
| 1511 int pos) | 1468 int pos) |
| 1512 : op_(op), left_(left), right_(right), pos_(pos), compare_type_(NONE) { | 1469 : op_(op), left_(left), right_(right), pos_(pos), compare_type_(NONE) { |
| 1513 ASSERT(Token::IsCompareOp(op)); | 1470 ASSERT(Token::IsCompareOp(op)); |
| 1514 } | 1471 } |
| 1515 | 1472 |
| 1516 DECLARE_NODE_TYPE(CompareOperation) | 1473 DECLARE_NODE_TYPE(CompareOperation) |
| 1517 | 1474 |
| 1518 Token::Value op() const { return op_; } | 1475 Token::Value op() const { return op_; } |
| 1519 Expression* left() const { return left_; } | 1476 Expression* left() const { return left_; } |
| 1520 Expression* right() const { return right_; } | 1477 Expression* right() const { return right_; } |
| 1521 virtual int position() const { return pos_; } | 1478 virtual int position() const { return pos_; } |
| 1522 | 1479 |
| 1523 virtual bool IsInlineable() const; | 1480 virtual bool IsInlineable() const; |
| 1524 | 1481 |
| 1525 // Type feedback information. | 1482 // Type feedback information. |
| 1526 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1483 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
| 1527 bool IsSmiCompare() { return compare_type_ == SMI_ONLY; } | 1484 bool IsSmiCompare() { return compare_type_ == SMI_ONLY; } |
| 1528 bool IsObjectCompare() { return compare_type_ == OBJECT_ONLY; } | 1485 bool IsObjectCompare() { return compare_type_ == OBJECT_ONLY; } |
| 1529 | 1486 |
| 1487 // Match special cases. |
| 1488 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); |
| 1489 bool IsLiteralCompareUndefined(Expression** expr); |
| 1490 |
| 1530 private: | 1491 private: |
| 1531 Token::Value op_; | 1492 Token::Value op_; |
| 1532 Expression* left_; | 1493 Expression* left_; |
| 1533 Expression* right_; | 1494 Expression* right_; |
| 1534 int pos_; | 1495 int pos_; |
| 1535 | 1496 |
| 1536 enum CompareTypeFeedback { NONE, SMI_ONLY, OBJECT_ONLY }; | 1497 enum CompareTypeFeedback { NONE, SMI_ONLY, OBJECT_ONLY }; |
| 1537 CompareTypeFeedback compare_type_; | 1498 CompareTypeFeedback compare_type_; |
| 1538 }; | 1499 }; |
| 1539 | 1500 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1680 FunctionLiteral(Handle<String> name, | 1641 FunctionLiteral(Handle<String> name, |
| 1681 Scope* scope, | 1642 Scope* scope, |
| 1682 ZoneList<Statement*>* body, | 1643 ZoneList<Statement*>* body, |
| 1683 int materialized_literal_count, | 1644 int materialized_literal_count, |
| 1684 int expected_property_count, | 1645 int expected_property_count, |
| 1685 bool has_only_simple_this_property_assignments, | 1646 bool has_only_simple_this_property_assignments, |
| 1686 Handle<FixedArray> this_property_assignments, | 1647 Handle<FixedArray> this_property_assignments, |
| 1687 int num_parameters, | 1648 int num_parameters, |
| 1688 int start_position, | 1649 int start_position, |
| 1689 int end_position, | 1650 int end_position, |
| 1690 bool is_expression) | 1651 bool is_expression, |
| 1652 bool has_duplicate_parameters) |
| 1691 : name_(name), | 1653 : name_(name), |
| 1692 scope_(scope), | 1654 scope_(scope), |
| 1693 body_(body), | 1655 body_(body), |
| 1694 materialized_literal_count_(materialized_literal_count), | 1656 materialized_literal_count_(materialized_literal_count), |
| 1695 expected_property_count_(expected_property_count), | 1657 expected_property_count_(expected_property_count), |
| 1696 has_only_simple_this_property_assignments_( | 1658 has_only_simple_this_property_assignments_( |
| 1697 has_only_simple_this_property_assignments), | 1659 has_only_simple_this_property_assignments), |
| 1698 this_property_assignments_(this_property_assignments), | 1660 this_property_assignments_(this_property_assignments), |
| 1699 num_parameters_(num_parameters), | 1661 num_parameters_(num_parameters), |
| 1700 start_position_(start_position), | 1662 start_position_(start_position), |
| 1701 end_position_(end_position), | 1663 end_position_(end_position), |
| 1702 is_expression_(is_expression), | |
| 1703 function_token_position_(RelocInfo::kNoPosition), | 1664 function_token_position_(RelocInfo::kNoPosition), |
| 1704 inferred_name_(HEAP->empty_string()), | 1665 inferred_name_(HEAP->empty_string()), |
| 1705 pretenure_(false) { } | 1666 is_expression_(is_expression), |
| 1667 pretenure_(false), |
| 1668 has_duplicate_parameters_(has_duplicate_parameters) { |
| 1669 } |
| 1706 | 1670 |
| 1707 DECLARE_NODE_TYPE(FunctionLiteral) | 1671 DECLARE_NODE_TYPE(FunctionLiteral) |
| 1708 | 1672 |
| 1709 Handle<String> name() const { return name_; } | 1673 Handle<String> name() const { return name_; } |
| 1710 Scope* scope() const { return scope_; } | 1674 Scope* scope() const { return scope_; } |
| 1711 ZoneList<Statement*>* body() const { return body_; } | 1675 ZoneList<Statement*>* body() const { return body_; } |
| 1712 void set_function_token_position(int pos) { function_token_position_ = pos; } | 1676 void set_function_token_position(int pos) { function_token_position_ = pos; } |
| 1713 int function_token_position() const { return function_token_position_; } | 1677 int function_token_position() const { return function_token_position_; } |
| 1714 int start_position() const { return start_position_; } | 1678 int start_position() const { return start_position_; } |
| 1715 int end_position() const { return end_position_; } | 1679 int end_position() const { return end_position_; } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1735 | 1699 |
| 1736 Handle<String> inferred_name() const { return inferred_name_; } | 1700 Handle<String> inferred_name() const { return inferred_name_; } |
| 1737 void set_inferred_name(Handle<String> inferred_name) { | 1701 void set_inferred_name(Handle<String> inferred_name) { |
| 1738 inferred_name_ = inferred_name; | 1702 inferred_name_ = inferred_name; |
| 1739 } | 1703 } |
| 1740 | 1704 |
| 1741 bool pretenure() { return pretenure_; } | 1705 bool pretenure() { return pretenure_; } |
| 1742 void set_pretenure(bool value) { pretenure_ = value; } | 1706 void set_pretenure(bool value) { pretenure_ = value; } |
| 1743 virtual bool IsInlineable() const; | 1707 virtual bool IsInlineable() const; |
| 1744 | 1708 |
| 1709 bool has_duplicate_parameters() { return has_duplicate_parameters_; } |
| 1710 |
| 1745 private: | 1711 private: |
| 1746 Handle<String> name_; | 1712 Handle<String> name_; |
| 1747 Scope* scope_; | 1713 Scope* scope_; |
| 1748 ZoneList<Statement*>* body_; | 1714 ZoneList<Statement*>* body_; |
| 1749 int materialized_literal_count_; | 1715 int materialized_literal_count_; |
| 1750 int expected_property_count_; | 1716 int expected_property_count_; |
| 1751 bool has_only_simple_this_property_assignments_; | 1717 bool has_only_simple_this_property_assignments_; |
| 1752 Handle<FixedArray> this_property_assignments_; | 1718 Handle<FixedArray> this_property_assignments_; |
| 1753 int num_parameters_; | 1719 int num_parameters_; |
| 1754 int start_position_; | 1720 int start_position_; |
| 1755 int end_position_; | 1721 int end_position_; |
| 1756 bool is_expression_; | |
| 1757 int function_token_position_; | 1722 int function_token_position_; |
| 1758 Handle<String> inferred_name_; | 1723 Handle<String> inferred_name_; |
| 1724 bool is_expression_; |
| 1759 bool pretenure_; | 1725 bool pretenure_; |
| 1726 bool has_duplicate_parameters_; |
| 1760 }; | 1727 }; |
| 1761 | 1728 |
| 1762 | 1729 |
| 1763 class SharedFunctionInfoLiteral: public Expression { | 1730 class SharedFunctionInfoLiteral: public Expression { |
| 1764 public: | 1731 public: |
| 1765 explicit SharedFunctionInfoLiteral( | 1732 explicit SharedFunctionInfoLiteral( |
| 1766 Handle<SharedFunctionInfo> shared_function_info) | 1733 Handle<SharedFunctionInfo> shared_function_info) |
| 1767 : shared_function_info_(shared_function_info) { } | 1734 : shared_function_info_(shared_function_info) { } |
| 1768 | 1735 |
| 1769 DECLARE_NODE_TYPE(SharedFunctionInfoLiteral) | 1736 DECLARE_NODE_TYPE(SharedFunctionInfoLiteral) |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1943 // S : unicode non-whitespace | 1910 // S : unicode non-whitespace |
| 1944 // w : ASCII word character (digit, letter, underscore) | 1911 // w : ASCII word character (digit, letter, underscore) |
| 1945 // W : non-ASCII word character | 1912 // W : non-ASCII word character |
| 1946 // d : ASCII digit | 1913 // d : ASCII digit |
| 1947 // D : non-ASCII digit | 1914 // D : non-ASCII digit |
| 1948 // . : non-unicode non-newline | 1915 // . : non-unicode non-newline |
| 1949 // * : All characters | 1916 // * : All characters |
| 1950 uc16 standard_type() { return set_.standard_set_type(); } | 1917 uc16 standard_type() { return set_.standard_set_type(); } |
| 1951 ZoneList<CharacterRange>* ranges() { return set_.ranges(); } | 1918 ZoneList<CharacterRange>* ranges() { return set_.ranges(); } |
| 1952 bool is_negated() { return is_negated_; } | 1919 bool is_negated() { return is_negated_; } |
| 1920 |
| 1953 private: | 1921 private: |
| 1954 CharacterSet set_; | 1922 CharacterSet set_; |
| 1955 bool is_negated_; | 1923 bool is_negated_; |
| 1956 }; | 1924 }; |
| 1957 | 1925 |
| 1958 | 1926 |
| 1959 class RegExpAtom: public RegExpTree { | 1927 class RegExpAtom: public RegExpTree { |
| 1960 public: | 1928 public: |
| 1961 explicit RegExpAtom(Vector<const uc16> data) : data_(data) { } | 1929 explicit RegExpAtom(Vector<const uc16> data) : data_(data) { } |
| 1962 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1930 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2027 virtual Interval CaptureRegisters(); | 1995 virtual Interval CaptureRegisters(); |
| 2028 virtual bool IsQuantifier(); | 1996 virtual bool IsQuantifier(); |
| 2029 virtual int min_match() { return min_match_; } | 1997 virtual int min_match() { return min_match_; } |
| 2030 virtual int max_match() { return max_match_; } | 1998 virtual int max_match() { return max_match_; } |
| 2031 int min() { return min_; } | 1999 int min() { return min_; } |
| 2032 int max() { return max_; } | 2000 int max() { return max_; } |
| 2033 bool is_possessive() { return type_ == POSSESSIVE; } | 2001 bool is_possessive() { return type_ == POSSESSIVE; } |
| 2034 bool is_non_greedy() { return type_ == NON_GREEDY; } | 2002 bool is_non_greedy() { return type_ == NON_GREEDY; } |
| 2035 bool is_greedy() { return type_ == GREEDY; } | 2003 bool is_greedy() { return type_ == GREEDY; } |
| 2036 RegExpTree* body() { return body_; } | 2004 RegExpTree* body() { return body_; } |
| 2005 |
| 2037 private: | 2006 private: |
| 2038 RegExpTree* body_; | 2007 RegExpTree* body_; |
| 2039 int min_; | 2008 int min_; |
| 2040 int max_; | 2009 int max_; |
| 2041 int min_match_; | 2010 int min_match_; |
| 2042 int max_match_; | 2011 int max_match_; |
| 2043 Type type_; | 2012 Type type_; |
| 2044 }; | 2013 }; |
| 2045 | 2014 |
| 2046 | 2015 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2059 virtual bool IsAnchoredAtStart(); | 2028 virtual bool IsAnchoredAtStart(); |
| 2060 virtual bool IsAnchoredAtEnd(); | 2029 virtual bool IsAnchoredAtEnd(); |
| 2061 virtual Interval CaptureRegisters(); | 2030 virtual Interval CaptureRegisters(); |
| 2062 virtual bool IsCapture(); | 2031 virtual bool IsCapture(); |
| 2063 virtual int min_match() { return body_->min_match(); } | 2032 virtual int min_match() { return body_->min_match(); } |
| 2064 virtual int max_match() { return body_->max_match(); } | 2033 virtual int max_match() { return body_->max_match(); } |
| 2065 RegExpTree* body() { return body_; } | 2034 RegExpTree* body() { return body_; } |
| 2066 int index() { return index_; } | 2035 int index() { return index_; } |
| 2067 static int StartRegister(int index) { return index * 2; } | 2036 static int StartRegister(int index) { return index * 2; } |
| 2068 static int EndRegister(int index) { return index * 2 + 1; } | 2037 static int EndRegister(int index) { return index * 2 + 1; } |
| 2038 |
| 2069 private: | 2039 private: |
| 2070 RegExpTree* body_; | 2040 RegExpTree* body_; |
| 2071 int index_; | 2041 int index_; |
| 2072 }; | 2042 }; |
| 2073 | 2043 |
| 2074 | 2044 |
| 2075 class RegExpLookahead: public RegExpTree { | 2045 class RegExpLookahead: public RegExpTree { |
| 2076 public: | 2046 public: |
| 2077 RegExpLookahead(RegExpTree* body, | 2047 RegExpLookahead(RegExpTree* body, |
| 2078 bool is_positive, | 2048 bool is_positive, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2089 virtual RegExpLookahead* AsLookahead(); | 2059 virtual RegExpLookahead* AsLookahead(); |
| 2090 virtual Interval CaptureRegisters(); | 2060 virtual Interval CaptureRegisters(); |
| 2091 virtual bool IsLookahead(); | 2061 virtual bool IsLookahead(); |
| 2092 virtual bool IsAnchoredAtStart(); | 2062 virtual bool IsAnchoredAtStart(); |
| 2093 virtual int min_match() { return 0; } | 2063 virtual int min_match() { return 0; } |
| 2094 virtual int max_match() { return 0; } | 2064 virtual int max_match() { return 0; } |
| 2095 RegExpTree* body() { return body_; } | 2065 RegExpTree* body() { return body_; } |
| 2096 bool is_positive() { return is_positive_; } | 2066 bool is_positive() { return is_positive_; } |
| 2097 int capture_count() { return capture_count_; } | 2067 int capture_count() { return capture_count_; } |
| 2098 int capture_from() { return capture_from_; } | 2068 int capture_from() { return capture_from_; } |
| 2069 |
| 2099 private: | 2070 private: |
| 2100 RegExpTree* body_; | 2071 RegExpTree* body_; |
| 2101 bool is_positive_; | 2072 bool is_positive_; |
| 2102 int capture_count_; | 2073 int capture_count_; |
| 2103 int capture_from_; | 2074 int capture_from_; |
| 2104 }; | 2075 }; |
| 2105 | 2076 |
| 2106 | 2077 |
| 2107 class RegExpBackReference: public RegExpTree { | 2078 class RegExpBackReference: public RegExpTree { |
| 2108 public: | 2079 public: |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2179 | 2150 |
| 2180 private: | 2151 private: |
| 2181 Isolate* isolate_; | 2152 Isolate* isolate_; |
| 2182 bool stack_overflow_; | 2153 bool stack_overflow_; |
| 2183 }; | 2154 }; |
| 2184 | 2155 |
| 2185 | 2156 |
| 2186 } } // namespace v8::internal | 2157 } } // namespace v8::internal |
| 2187 | 2158 |
| 2188 #endif // V8_AST_H_ | 2159 #endif // V8_AST_H_ |
| OLD | NEW |