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_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
7 | 7 |
8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // Forward declarations. | 24 // Forward declarations. |
25 #define DEFINE_FORWARD_DECLARATION(clazz) \ | 25 #define DEFINE_FORWARD_DECLARATION(clazz) \ |
26 class clazz; | 26 class clazz; |
27 CLASS_LIST(DEFINE_FORWARD_DECLARATION) | 27 CLASS_LIST(DEFINE_FORWARD_DECLARATION) |
28 #undef DEFINE_FORWARD_DECLARATION | 28 #undef DEFINE_FORWARD_DECLARATION |
29 class Api; | 29 class Api; |
30 class ArgumentsDescriptor; | 30 class ArgumentsDescriptor; |
31 class Assembler; | 31 class Assembler; |
32 class Closure; | 32 class Closure; |
33 class Code; | 33 class Code; |
| 34 class DisassemblyFormatter; |
34 class DeoptInstr; | 35 class DeoptInstr; |
35 class FinalizablePersistentHandle; | 36 class FinalizablePersistentHandle; |
36 class LocalScope; | 37 class LocalScope; |
37 class ReusableHandleScope; | 38 class ReusableHandleScope; |
38 class ReusableObjectHandleScope; | 39 class ReusableObjectHandleScope; |
39 class Symbols; | 40 class Symbols; |
40 | 41 |
41 #if defined(DEBUG) | 42 #if defined(DEBUG) |
42 #define CHECK_HANDLE() CheckHandle(); | 43 #define CHECK_HANDLE() CheckHandle(); |
43 #else | 44 #else |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 other_type_arguments, | 873 other_type_arguments, |
873 bound_error); | 874 bound_error); |
874 } | 875 } |
875 | 876 |
876 // Check if this is the top level class. | 877 // Check if this is the top level class. |
877 bool IsTopLevel() const; | 878 bool IsTopLevel() const; |
878 | 879 |
879 RawArray* fields() const { return raw_ptr()->fields_; } | 880 RawArray* fields() const { return raw_ptr()->fields_; } |
880 void SetFields(const Array& value) const; | 881 void SetFields(const Array& value) const; |
881 intptr_t FindFieldIndex(const Field& field) const; | 882 intptr_t FindFieldIndex(const Field& field) const; |
| 883 RawField* FieldFromIndex(intptr_t idx) const; |
882 | 884 |
883 // Returns an array of all fields of this class and its superclasses indexed | 885 // Returns an array of all fields of this class and its superclasses indexed |
884 // by offset in words. | 886 // by offset in words. |
885 RawArray* OffsetToFieldMap() const; | 887 RawArray* OffsetToFieldMap() const; |
886 | 888 |
887 // Returns true if non-static fields are defined. | 889 // Returns true if non-static fields are defined. |
888 bool HasInstanceFields() const; | 890 bool HasInstanceFields() const; |
889 | 891 |
890 RawArray* functions() const { return raw_ptr()->functions_; } | 892 RawArray* functions() const { return raw_ptr()->functions_; } |
891 void SetFunctions(const Array& value) const; | 893 void SetFunctions(const Array& value) const; |
892 void AddFunction(const Function& function) const; | 894 void AddFunction(const Function& function) const; |
893 intptr_t FindFunctionIndex(const Function& function) const; | 895 intptr_t FindFunctionIndex(const Function& function) const; |
| 896 RawFunction* FunctionFromIndex(intptr_t idx) const; |
| 897 intptr_t FindImplicitClosureFunctionIndex(const Function& needle) const; |
| 898 RawFunction* ImplicitClosureFunctionFromIndex(intptr_t idx) const; |
894 | 899 |
895 RawGrowableObjectArray* closures() const { | 900 RawGrowableObjectArray* closures() const { |
896 return raw_ptr()->closure_functions_; | 901 return raw_ptr()->closure_functions_; |
897 } | 902 } |
898 void AddClosureFunction(const Function& function) const; | 903 void AddClosureFunction(const Function& function) const; |
899 RawFunction* LookupClosureFunction(intptr_t token_pos) const; | 904 RawFunction* LookupClosureFunction(intptr_t token_pos) const; |
900 intptr_t FindClosureIndex(intptr_t token_pos) const; | 905 intptr_t FindClosureIndex(const Function& function) const; |
| 906 RawFunction* ClosureFunctionFromIndex(intptr_t idx) const; |
901 | 907 |
902 RawFunction* LookupDynamicFunction(const String& name) const; | 908 RawFunction* LookupDynamicFunction(const String& name) const; |
903 RawFunction* LookupDynamicFunctionAllowPrivate(const String& name) const; | 909 RawFunction* LookupDynamicFunctionAllowPrivate(const String& name) const; |
904 RawFunction* LookupStaticFunction(const String& name) const; | 910 RawFunction* LookupStaticFunction(const String& name) const; |
905 RawFunction* LookupStaticFunctionAllowPrivate(const String& name) const; | 911 RawFunction* LookupStaticFunctionAllowPrivate(const String& name) const; |
906 RawFunction* LookupConstructor(const String& name) const; | 912 RawFunction* LookupConstructor(const String& name) const; |
907 RawFunction* LookupConstructorAllowPrivate(const String& name) const; | 913 RawFunction* LookupConstructorAllowPrivate(const String& name) const; |
908 RawFunction* LookupFactory(const String& name) const; | 914 RawFunction* LookupFactory(const String& name) const; |
909 RawFunction* LookupFunction(const String& name) const; | 915 RawFunction* LookupFunction(const String& name) const; |
910 RawFunction* LookupFunctionAllowPrivate(const String& name) const; | 916 RawFunction* LookupFunctionAllowPrivate(const String& name) const; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
987 raw_ptr()->num_native_fields_ = value; | 993 raw_ptr()->num_native_fields_ = value; |
988 } | 994 } |
989 | 995 |
990 RawCode* allocation_stub() const { | 996 RawCode* allocation_stub() const { |
991 return raw_ptr()->allocation_stub_; | 997 return raw_ptr()->allocation_stub_; |
992 } | 998 } |
993 void set_allocation_stub(const Code& value) const; | 999 void set_allocation_stub(const Code& value) const; |
994 | 1000 |
995 RawArray* constants() const; | 1001 RawArray* constants() const; |
996 | 1002 |
| 1003 intptr_t FindInvocationDispatcherFunctionIndex(const Function& needle) const; |
| 1004 RawFunction* InvocationDispatcherFunctionFromIndex(intptr_t idx) const; |
| 1005 |
997 RawFunction* GetInvocationDispatcher(const String& target_name, | 1006 RawFunction* GetInvocationDispatcher(const String& target_name, |
998 const Array& args_desc, | 1007 const Array& args_desc, |
999 RawFunction::Kind kind) const; | 1008 RawFunction::Kind kind) const; |
1000 | 1009 |
1001 void Finalize() const; | 1010 void Finalize() const; |
1002 | 1011 |
1003 // Apply given patch class to this class. | 1012 // Apply given patch class to this class. |
1004 // Return true on success, or false and error otherwise. | 1013 // Return true on success, or false and error otherwise. |
1005 bool ApplyPatch(const Class& patch, Error* error) const; | 1014 bool ApplyPatch(const Class& patch, Error* error) const; |
1006 | 1015 |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1592 void SetRedirectionType(const Type& type) const; | 1601 void SetRedirectionType(const Type& type) const; |
1593 RawString* RedirectionIdentifier() const; | 1602 RawString* RedirectionIdentifier() const; |
1594 void SetRedirectionIdentifier(const String& identifier) const; | 1603 void SetRedirectionIdentifier(const String& identifier) const; |
1595 RawFunction* RedirectionTarget() const; | 1604 RawFunction* RedirectionTarget() const; |
1596 void SetRedirectionTarget(const Function& target) const; | 1605 void SetRedirectionTarget(const Function& target) const; |
1597 | 1606 |
1598 RawFunction::Kind kind() const { | 1607 RawFunction::Kind kind() const { |
1599 return KindBits::decode(raw_ptr()->kind_tag_); | 1608 return KindBits::decode(raw_ptr()->kind_tag_); |
1600 } | 1609 } |
1601 | 1610 |
| 1611 static const char* KindToCString(RawFunction::Kind kind); |
| 1612 |
1602 bool is_static() const { return StaticBit::decode(raw_ptr()->kind_tag_); } | 1613 bool is_static() const { return StaticBit::decode(raw_ptr()->kind_tag_); } |
1603 bool is_const() const { return ConstBit::decode(raw_ptr()->kind_tag_); } | 1614 bool is_const() const { return ConstBit::decode(raw_ptr()->kind_tag_); } |
1604 bool is_external() const { return ExternalBit::decode(raw_ptr()->kind_tag_); } | 1615 bool is_external() const { return ExternalBit::decode(raw_ptr()->kind_tag_); } |
1605 bool IsConstructor() const { | 1616 bool IsConstructor() const { |
1606 return (kind() == RawFunction::kConstructor) && !is_static(); | 1617 return (kind() == RawFunction::kConstructor) && !is_static(); |
1607 } | 1618 } |
1608 bool IsImplicitConstructor() const; | 1619 bool IsImplicitConstructor() const; |
1609 bool IsFactory() const { | 1620 bool IsFactory() const { |
1610 return (kind() == RawFunction::kConstructor) && is_static(); | 1621 return (kind() == RawFunction::kConstructor) && is_static(); |
1611 } | 1622 } |
(...skipping 1623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3235 | 3246 |
3236 RawDeoptInfo* GetDeoptInfoAtPc(uword pc, intptr_t* deopt_reason) const; | 3247 RawDeoptInfo* GetDeoptInfoAtPc(uword pc, intptr_t* deopt_reason) const; |
3237 | 3248 |
3238 // Returns null if there is no static call at 'pc'. | 3249 // Returns null if there is no static call at 'pc'. |
3239 RawFunction* GetStaticCallTargetFunctionAt(uword pc) const; | 3250 RawFunction* GetStaticCallTargetFunctionAt(uword pc) const; |
3240 // Returns null if there is no static call at 'pc'. | 3251 // Returns null if there is no static call at 'pc'. |
3241 RawCode* GetStaticCallTargetCodeAt(uword pc) const; | 3252 RawCode* GetStaticCallTargetCodeAt(uword pc) const; |
3242 // Aborts if there is no static call at 'pc'. | 3253 // Aborts if there is no static call at 'pc'. |
3243 void SetStaticCallTargetCodeAt(uword pc, const Code& code) const; | 3254 void SetStaticCallTargetCodeAt(uword pc, const Code& code) const; |
3244 | 3255 |
3245 void Disassemble() const; | 3256 void Disassemble(DisassemblyFormatter* formatter = NULL) const; |
3246 | 3257 |
3247 class Comments : public ZoneAllocated { | 3258 class Comments : public ZoneAllocated { |
3248 public: | 3259 public: |
3249 static Comments& New(intptr_t count); | 3260 static Comments& New(intptr_t count); |
3250 | 3261 |
3251 intptr_t Length() const; | 3262 intptr_t Length() const; |
3252 | 3263 |
3253 void SetPCOffsetAt(intptr_t idx, intptr_t pc_offset); | 3264 void SetPCOffsetAt(intptr_t idx, intptr_t pc_offset); |
3254 void SetCommentAt(intptr_t idx, const String& comment); | 3265 void SetCommentAt(intptr_t idx, const String& comment); |
3255 | 3266 |
(...skipping 3315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6571 | 6582 |
6572 | 6583 |
6573 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6584 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
6574 intptr_t index) { | 6585 intptr_t index) { |
6575 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6586 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
6576 } | 6587 } |
6577 | 6588 |
6578 } // namespace dart | 6589 } // namespace dart |
6579 | 6590 |
6580 #endif // VM_OBJECT_H_ | 6591 #endif // VM_OBJECT_H_ |
OLD | NEW |