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