| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_RAW_OBJECT_H_ | 5 #ifndef VM_RAW_OBJECT_H_ |
| 6 #define VM_RAW_OBJECT_H_ | 6 #define VM_RAW_OBJECT_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
| 10 #include "vm/token.h" | 10 #include "vm/token.h" |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 } | 535 } |
| 536 }; | 536 }; |
| 537 | 537 |
| 538 | 538 |
| 539 class RawFunction : public RawObject { | 539 class RawFunction : public RawObject { |
| 540 public: | 540 public: |
| 541 enum Kind { | 541 enum Kind { |
| 542 kRegularFunction, | 542 kRegularFunction, |
| 543 kClosureFunction, | 543 kClosureFunction, |
| 544 kSignatureFunction, // represents a signature only without actual code. | 544 kSignatureFunction, // represents a signature only without actual code. |
| 545 kGetterFunction, // represents getter functions e.g: get foo() { .. }. | 545 kGetterFunction, // represents getter functions e.g: get foo() { .. }. |
| 546 kSetterFunction, // represents setter functions e.g: set foo(..) { .. }. | 546 kSetterFunction, // represents setter functions e.g: set foo(..) { .. }. |
| 547 kAbstract, | |
| 548 kConstructor, | 547 kConstructor, |
| 549 kImplicitGetter, // represents an implicit getter for fields. | 548 kImplicitGetter, // represents an implicit getter for fields. |
| 550 kImplicitSetter, // represents an implicit setter for fields. | 549 kImplicitSetter, // represents an implicit setter for fields. |
| 551 kConstImplicitGetter, // represents an implicit const getter for fields. | 550 kConstImplicitGetter, // represents an implicit const getter for fields. |
| 552 }; | 551 }; |
| 553 | 552 |
| 554 private: | 553 private: |
| 555 RAW_HEAP_OBJECT_IMPLEMENTATION(Function); | 554 RAW_HEAP_OBJECT_IMPLEMENTATION(Function); |
| 556 | 555 |
| 556 enum KindTagBits { |
| 557 kStaticBit = 1, |
| 558 kConstBit = 2, |
| 559 kOptimizableBit = 3, |
| 560 kNativeBit = 4, |
| 561 kAbstractBit = 5, |
| 562 kExternalBit = 5, |
| 563 kKindTagBit = 6, |
| 564 kKindTagSize = 4, |
| 565 }; |
| 566 class StaticBit : public BitField<bool, kStaticBit, 1> {}; |
| 567 class ConstBit : public BitField<bool, kConstBit, 1> {}; |
| 568 class OptimizableBit : public BitField<bool, kOptimizableBit, 1> {}; |
| 569 class NativeBit : public BitField<bool, kNativeBit, 1> {}; |
| 570 class AbstractBit : public BitField<bool, kAbstractBit, 1> {}; |
| 571 class ExternalBit : public BitField<bool, kExternalBit, 1> {}; |
| 572 class KindBits : public BitField<Kind, kKindTagBit, kKindTagSize> {}; |
| 573 |
| 574 bool IsStatic() const { |
| 575 return StaticBit::decode(ptr()->kind_tag_); |
| 576 } |
| 577 void SetIsStatic(bool value) { |
| 578 uword bits = ptr()->kind_tag_; |
| 579 ptr()->kind_tag_ = StaticBit::update(value, bits); |
| 580 } |
| 581 bool IsConst() const { |
| 582 return ConstBit::decode(ptr()->kind_tag_); |
| 583 } |
| 584 void SetIsConst(bool value) { |
| 585 uword bits = ptr()->kind_tag_; |
| 586 ptr()->kind_tag_ = ConstBit::update(value, bits); |
| 587 } |
| 588 bool IsOptimizable() const { |
| 589 return OptimizableBit::decode(ptr()->kind_tag_); |
| 590 } |
| 591 void SetIsOptimizable(bool value) { |
| 592 uword bits = ptr()->kind_tag_; |
| 593 ptr()->kind_tag_ = OptimizableBit::update(value, bits); |
| 594 } |
| 595 bool IsNative() const { |
| 596 return NativeBit::decode(ptr()->kind_tag_); |
| 597 } |
| 598 void SetIsNative(bool value) { |
| 599 uword bits = ptr()->kind_tag_; |
| 600 ptr()->kind_tag_ = NativeBit::update(value, bits); |
| 601 } |
| 602 bool IsAbstract() const { |
| 603 return AbstractBit::decode(ptr()->kind_tag_); |
| 604 } |
| 605 void SetIsAbstract(bool value) { |
| 606 uword bits = ptr()->kind_tag_; |
| 607 ptr()->kind_tag_ = AbstractBit::update(value, bits); |
| 608 } |
| 609 bool IsExternal() const { |
| 610 return ExternalBit::decode(ptr()->kind_tag_); |
| 611 } |
| 612 void SetIsExternal(bool value) { |
| 613 uword bits = ptr()->kind_tag_; |
| 614 ptr()->kind_tag_ = ExternalBit::update(value, bits); |
| 615 } |
| 616 Kind GetKind() const { |
| 617 return KindBits::decode(ptr()->kind_tag_); |
| 618 } |
| 619 void SetKind(Kind value) { |
| 620 uword bits = ptr()->kind_tag_; |
| 621 ptr()->kind_tag_ = KindBits::update(value, bits); |
| 622 } |
| 623 |
| 557 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->name_); } | 624 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->name_); } |
| 558 RawString* name_; | 625 RawString* name_; |
| 559 RawClass* owner_; | 626 RawClass* owner_; |
| 560 RawAbstractType* result_type_; | 627 RawAbstractType* result_type_; |
| 561 RawArray* parameter_types_; | 628 RawArray* parameter_types_; |
| 562 RawArray* parameter_names_; | 629 RawArray* parameter_names_; |
| 563 RawCode* code_; // Compiled code for the function. | 630 RawCode* code_; // Compiled code for the function. |
| 564 RawCode* unoptimized_code_; // Unoptimized code, keep it after optimization. | 631 RawCode* unoptimized_code_; // Unoptimized code, keep it after optimization. |
| 565 RawContextScope* context_scope_; | 632 RawContextScope* context_scope_; |
| 566 RawFunction* parent_function_; // Enclosing function of this local function. | 633 RawFunction* parent_function_; // Enclosing function of this local function. |
| 567 RawClass* signature_class_; // Only for closure or signature function. | 634 RawClass* signature_class_; // Only for closure or signature function. |
| 568 RawCode* closure_allocation_stub_; // Stub code for allocation of closures. | 635 RawCode* closure_allocation_stub_; // Stub code for allocation of closures. |
| 569 RawFunction* implicit_closure_function_; // Implicit closure function. | 636 RawFunction* implicit_closure_function_; // Implicit closure function. |
| 570 RawObject** to() { | 637 RawObject** to() { |
| 571 return reinterpret_cast<RawObject**>(&ptr()->implicit_closure_function_); | 638 return reinterpret_cast<RawObject**>(&ptr()->implicit_closure_function_); |
| 572 } | 639 } |
| 573 | 640 |
| 574 intptr_t token_pos_; | 641 intptr_t token_pos_; |
| 575 intptr_t end_token_pos_; | 642 intptr_t end_token_pos_; |
| 576 intptr_t num_fixed_parameters_; | 643 intptr_t num_fixed_parameters_; |
| 577 intptr_t num_optional_parameters_; | 644 intptr_t num_optional_parameters_; |
| 578 intptr_t usage_counter_; // Incremented while function is running. | 645 intptr_t usage_counter_; // Incremented while function is running. |
| 579 intptr_t deoptimization_counter_; | 646 intptr_t deoptimization_counter_; |
| 580 Kind kind_; | 647 intptr_t kind_tag_; |
| 581 bool is_static_; | |
| 582 bool is_const_; | |
| 583 bool is_optimizable_; | |
| 584 bool is_native_; | |
| 585 bool is_external_; | |
| 586 }; | 648 }; |
| 587 | 649 |
| 588 | 650 |
| 589 class RawField : public RawObject { | 651 class RawField : public RawObject { |
| 590 RAW_HEAP_OBJECT_IMPLEMENTATION(Field); | 652 RAW_HEAP_OBJECT_IMPLEMENTATION(Field); |
| 591 | 653 |
| 592 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->name_); } | 654 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->name_); } |
| 593 RawString* name_; | 655 RawString* name_; |
| 594 RawClass* owner_; | 656 RawClass* owner_; |
| 595 RawAbstractType* type_; | 657 RawAbstractType* type_; |
| (...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1518 kExternalUint64Array == kByteArray + 18 && | 1580 kExternalUint64Array == kByteArray + 18 && |
| 1519 kExternalFloat32Array == kByteArray + 19 && | 1581 kExternalFloat32Array == kByteArray + 19 && |
| 1520 kExternalFloat64Array == kByteArray + 20 && | 1582 kExternalFloat64Array == kByteArray + 20 && |
| 1521 kClosure == kByteArray + 21); | 1583 kClosure == kByteArray + 21); |
| 1522 return (index >= kByteArray && index <= kClosure); | 1584 return (index >= kByteArray && index <= kClosure); |
| 1523 } | 1585 } |
| 1524 | 1586 |
| 1525 } // namespace dart | 1587 } // namespace dart |
| 1526 | 1588 |
| 1527 #endif // VM_RAW_OBJECT_H_ | 1589 #endif // VM_RAW_OBJECT_H_ |
| OLD | NEW |