| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_AST_H_ | 5 #ifndef V8_AST_H_ |
| 6 #define V8_AST_H_ | 6 #define V8_AST_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/assembler.h" | 10 #include "src/assembler.h" |
| (...skipping 2521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2532 } | 2532 } |
| 2533 const ZoneFeedbackVectorSpec* feedback_vector_spec() const { | 2533 const ZoneFeedbackVectorSpec* feedback_vector_spec() const { |
| 2534 return ast_properties_.get_spec(); | 2534 return ast_properties_.get_spec(); |
| 2535 } | 2535 } |
| 2536 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } | 2536 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } |
| 2537 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } | 2537 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } |
| 2538 void set_dont_optimize_reason(BailoutReason reason) { | 2538 void set_dont_optimize_reason(BailoutReason reason) { |
| 2539 dont_optimize_reason_ = reason; | 2539 dont_optimize_reason_ = reason; |
| 2540 } | 2540 } |
| 2541 | 2541 |
| 2542 static int num_ids() { return parent_num_ids() + 1; } |
| 2543 TypeFeedbackId HomeObjectFeedbackId() { return TypeFeedbackId(local_id(0)); } |
| 2544 |
| 2545 // Type feedback information. |
| 2546 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( |
| 2547 Isolate* isolate, const ICSlotCache* cache) override { |
| 2548 return FeedbackVectorRequirements(0, 1); |
| 2549 } |
| 2550 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot, |
| 2551 ICSlotCache* cache) override { |
| 2552 DCHECK(!slot.IsInvalid()); |
| 2553 home_object_feedback_slot_ = slot; |
| 2554 } |
| 2555 Code::Kind FeedbackICSlotKind(int index) override { return Code::LOAD_IC; } |
| 2556 |
| 2557 FeedbackVectorICSlot HomeObjectFeedbackSlot() { |
| 2558 DCHECK(!home_object_feedback_slot_.IsInvalid()); |
| 2559 return home_object_feedback_slot_; |
| 2560 } |
| 2561 |
| 2542 protected: | 2562 protected: |
| 2543 FunctionLiteral(Zone* zone, const AstRawString* name, | 2563 FunctionLiteral(Zone* zone, const AstRawString* name, |
| 2544 AstValueFactory* ast_value_factory, Scope* scope, | 2564 AstValueFactory* ast_value_factory, Scope* scope, |
| 2545 ZoneList<Statement*>* body, int materialized_literal_count, | 2565 ZoneList<Statement*>* body, int materialized_literal_count, |
| 2546 int expected_property_count, int handler_count, | 2566 int expected_property_count, int handler_count, |
| 2547 int parameter_count, FunctionType function_type, | 2567 int parameter_count, FunctionType function_type, |
| 2548 ParameterFlag has_duplicate_parameters, | 2568 ParameterFlag has_duplicate_parameters, |
| 2549 IsFunctionFlag is_function, | 2569 IsFunctionFlag is_function, |
| 2550 EagerCompileHint eager_compile_hint, FunctionKind kind, | 2570 EagerCompileHint eager_compile_hint, FunctionKind kind, |
| 2551 int position) | 2571 int position) |
| 2552 : Expression(zone, position), | 2572 : Expression(zone, position), |
| 2553 raw_name_(name), | 2573 raw_name_(name), |
| 2554 scope_(scope), | 2574 scope_(scope), |
| 2555 body_(body), | 2575 body_(body), |
| 2556 raw_inferred_name_(ast_value_factory->empty_string()), | 2576 raw_inferred_name_(ast_value_factory->empty_string()), |
| 2557 ast_properties_(zone), | 2577 ast_properties_(zone), |
| 2558 dont_optimize_reason_(kNoReason), | 2578 dont_optimize_reason_(kNoReason), |
| 2559 materialized_literal_count_(materialized_literal_count), | 2579 materialized_literal_count_(materialized_literal_count), |
| 2560 expected_property_count_(expected_property_count), | 2580 expected_property_count_(expected_property_count), |
| 2561 handler_count_(handler_count), | 2581 handler_count_(handler_count), |
| 2562 parameter_count_(parameter_count), | 2582 parameter_count_(parameter_count), |
| 2563 function_token_position_(RelocInfo::kNoPosition) { | 2583 function_token_position_(RelocInfo::kNoPosition), |
| 2584 home_object_feedback_slot_(FeedbackVectorICSlot::Invalid()) { |
| 2564 bitfield_ = IsExpression::encode(function_type != DECLARATION) | | 2585 bitfield_ = IsExpression::encode(function_type != DECLARATION) | |
| 2565 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) | | 2586 IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) | |
| 2566 Pretenure::encode(false) | | 2587 Pretenure::encode(false) | |
| 2567 HasDuplicateParameters::encode(has_duplicate_parameters) | | 2588 HasDuplicateParameters::encode(has_duplicate_parameters) | |
| 2568 IsFunction::encode(is_function) | | 2589 IsFunction::encode(is_function) | |
| 2569 EagerCompileHintBit::encode(eager_compile_hint) | | 2590 EagerCompileHintBit::encode(eager_compile_hint) | |
| 2570 FunctionKindBits::encode(kind) | | 2591 FunctionKindBits::encode(kind) | |
| 2571 ShouldBeUsedOnceHintBit::encode(kDontKnowIfShouldBeUsedOnce); | 2592 ShouldBeUsedOnceHintBit::encode(kDontKnowIfShouldBeUsedOnce); |
| 2572 DCHECK(IsValidFunctionKind(kind)); | 2593 DCHECK(IsValidFunctionKind(kind)); |
| 2573 } | 2594 } |
| 2574 | 2595 |
| 2596 static int parent_num_ids() { return Expression::num_ids(); } |
| 2597 |
| 2575 private: | 2598 private: |
| 2576 const AstRawString* raw_name_; | 2599 const AstRawString* raw_name_; |
| 2577 Handle<String> name_; | 2600 Handle<String> name_; |
| 2578 Handle<SharedFunctionInfo> shared_info_; | 2601 Handle<SharedFunctionInfo> shared_info_; |
| 2579 Scope* scope_; | 2602 Scope* scope_; |
| 2580 ZoneList<Statement*>* body_; | 2603 ZoneList<Statement*>* body_; |
| 2581 const AstString* raw_inferred_name_; | 2604 const AstString* raw_inferred_name_; |
| 2582 Handle<String> inferred_name_; | 2605 Handle<String> inferred_name_; |
| 2583 AstProperties ast_properties_; | 2606 AstProperties ast_properties_; |
| 2584 BailoutReason dont_optimize_reason_; | 2607 BailoutReason dont_optimize_reason_; |
| 2585 | 2608 |
| 2586 int materialized_literal_count_; | 2609 int materialized_literal_count_; |
| 2587 int expected_property_count_; | 2610 int expected_property_count_; |
| 2588 int handler_count_; | 2611 int handler_count_; |
| 2589 int parameter_count_; | 2612 int parameter_count_; |
| 2590 int function_token_position_; | 2613 int function_token_position_; |
| 2591 | 2614 |
| 2615 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 2616 FeedbackVectorICSlot home_object_feedback_slot_; |
| 2617 |
| 2592 unsigned bitfield_; | 2618 unsigned bitfield_; |
| 2593 class IsExpression : public BitField<bool, 0, 1> {}; | 2619 class IsExpression : public BitField<bool, 0, 1> {}; |
| 2594 class IsAnonymous : public BitField<bool, 1, 1> {}; | 2620 class IsAnonymous : public BitField<bool, 1, 1> {}; |
| 2595 class Pretenure : public BitField<bool, 2, 1> {}; | 2621 class Pretenure : public BitField<bool, 2, 1> {}; |
| 2596 class HasDuplicateParameters : public BitField<ParameterFlag, 3, 1> {}; | 2622 class HasDuplicateParameters : public BitField<ParameterFlag, 3, 1> {}; |
| 2597 class IsFunction : public BitField<IsFunctionFlag, 4, 1> {}; | 2623 class IsFunction : public BitField<IsFunctionFlag, 4, 1> {}; |
| 2598 class EagerCompileHintBit : public BitField<EagerCompileHint, 5, 1> {}; | 2624 class EagerCompileHintBit : public BitField<EagerCompileHint, 5, 1> {}; |
| 2599 class FunctionKindBits : public BitField<FunctionKind, 6, 8> {}; | 2625 class FunctionKindBits : public BitField<FunctionKind, 6, 8> {}; |
| 2600 class ShouldBeUsedOnceHintBit : public BitField<ShouldBeUsedOnceHint, 15, 1> { | 2626 class ShouldBeUsedOnceHintBit : public BitField<ShouldBeUsedOnceHint, 15, 1> { |
| 2601 }; | 2627 }; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2683 protected: | 2709 protected: |
| 2684 ThisFunction(Zone* zone, int pos) : Expression(zone, pos) {} | 2710 ThisFunction(Zone* zone, int pos) : Expression(zone, pos) {} |
| 2685 }; | 2711 }; |
| 2686 | 2712 |
| 2687 | 2713 |
| 2688 class SuperReference final : public Expression { | 2714 class SuperReference final : public Expression { |
| 2689 public: | 2715 public: |
| 2690 DECLARE_NODE_TYPE(SuperReference) | 2716 DECLARE_NODE_TYPE(SuperReference) |
| 2691 | 2717 |
| 2692 VariableProxy* this_var() const { return this_var_; } | 2718 VariableProxy* this_var() const { return this_var_; } |
| 2693 | 2719 VariableProxy* home_object_var() const { return home_object_var_; } |
| 2694 static int num_ids() { return parent_num_ids(); } | |
| 2695 | |
| 2696 // Type feedback information. | |
| 2697 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( | |
| 2698 Isolate* isolate, const ICSlotCache* cache) override { | |
| 2699 return FeedbackVectorRequirements(0, 1); | |
| 2700 } | |
| 2701 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot, | |
| 2702 ICSlotCache* cache) override { | |
| 2703 homeobject_feedback_slot_ = slot; | |
| 2704 } | |
| 2705 Code::Kind FeedbackICSlotKind(int index) override { return Code::LOAD_IC; } | |
| 2706 | |
| 2707 FeedbackVectorICSlot HomeObjectFeedbackSlot() { | |
| 2708 DCHECK(!homeobject_feedback_slot_.IsInvalid()); | |
| 2709 return homeobject_feedback_slot_; | |
| 2710 } | |
| 2711 | 2720 |
| 2712 protected: | 2721 protected: |
| 2713 SuperReference(Zone* zone, VariableProxy* this_var, int pos) | 2722 SuperReference(Zone* zone, VariableProxy* this_var, |
| 2723 VariableProxy* home_object_var, int pos) |
| 2714 : Expression(zone, pos), | 2724 : Expression(zone, pos), |
| 2715 this_var_(this_var), | 2725 this_var_(this_var), |
| 2716 homeobject_feedback_slot_(FeedbackVectorICSlot::Invalid()) { | 2726 home_object_var_(home_object_var) { |
| 2717 DCHECK(this_var->is_this()); | 2727 DCHECK(this_var->is_this()); |
| 2728 DCHECK(home_object_var->raw_name()->IsOneByteEqualTo(".home_object")); |
| 2718 } | 2729 } |
| 2719 static int parent_num_ids() { return Expression::num_ids(); } | |
| 2720 | 2730 |
| 2721 private: | 2731 private: |
| 2722 VariableProxy* this_var_; | 2732 VariableProxy* this_var_; |
| 2723 FeedbackVectorICSlot homeobject_feedback_slot_; | 2733 VariableProxy* home_object_var_; |
| 2724 }; | 2734 }; |
| 2725 | 2735 |
| 2726 | 2736 |
| 2727 #undef DECLARE_NODE_TYPE | 2737 #undef DECLARE_NODE_TYPE |
| 2728 | 2738 |
| 2729 | 2739 |
| 2730 // ---------------------------------------------------------------------------- | 2740 // ---------------------------------------------------------------------------- |
| 2731 // Regular expressions | 2741 // Regular expressions |
| 2732 | 2742 |
| 2733 | 2743 |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3484 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, | 3494 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, |
| 3485 v8::Extension* extension, | 3495 v8::Extension* extension, |
| 3486 int pos) { | 3496 int pos) { |
| 3487 return new (zone_) NativeFunctionLiteral(zone_, name, extension, pos); | 3497 return new (zone_) NativeFunctionLiteral(zone_, name, extension, pos); |
| 3488 } | 3498 } |
| 3489 | 3499 |
| 3490 ThisFunction* NewThisFunction(int pos) { | 3500 ThisFunction* NewThisFunction(int pos) { |
| 3491 return new (zone_) ThisFunction(zone_, pos); | 3501 return new (zone_) ThisFunction(zone_, pos); |
| 3492 } | 3502 } |
| 3493 | 3503 |
| 3494 SuperReference* NewSuperReference(VariableProxy* this_var, int pos) { | 3504 SuperReference* NewSuperReference(VariableProxy* this_var, |
| 3495 return new (zone_) SuperReference(zone_, this_var, pos); | 3505 VariableProxy* home_object_var, int pos) { |
| 3506 return new (zone_) SuperReference(zone_, this_var, home_object_var, pos); |
| 3496 } | 3507 } |
| 3497 | 3508 |
| 3498 private: | 3509 private: |
| 3499 Zone* zone_; | 3510 Zone* zone_; |
| 3500 AstValueFactory* ast_value_factory_; | 3511 AstValueFactory* ast_value_factory_; |
| 3501 }; | 3512 }; |
| 3502 | 3513 |
| 3503 | 3514 |
| 3504 } } // namespace v8::internal | 3515 } } // namespace v8::internal |
| 3505 | 3516 |
| 3506 #endif // V8_AST_H_ | 3517 #endif // V8_AST_H_ |
| OLD | NEW |