OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 RUNTIME_VM_DART_ENTRY_H_ | 5 #ifndef RUNTIME_VM_DART_ENTRY_H_ |
6 #define RUNTIME_VM_DART_ENTRY_H_ | 6 #define RUNTIME_VM_DART_ENTRY_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 static intptr_t count_offset(); | 44 static intptr_t count_offset(); |
45 static intptr_t positional_count_offset(); | 45 static intptr_t positional_count_offset(); |
46 static intptr_t first_named_entry_offset(); | 46 static intptr_t first_named_entry_offset(); |
47 static intptr_t name_offset() { return kNameOffset * kWordSize; } | 47 static intptr_t name_offset() { return kNameOffset * kWordSize; } |
48 static intptr_t position_offset() { return kPositionOffset * kWordSize; } | 48 static intptr_t position_offset() { return kPositionOffset * kWordSize; } |
49 static intptr_t named_entry_size() { return kNamedEntrySize * kWordSize; } | 49 static intptr_t named_entry_size() { return kNamedEntrySize * kWordSize; } |
50 | 50 |
51 // Allocate and return an arguments descriptor. The first | 51 // Allocate and return an arguments descriptor. The first |
52 // (count - optional_arguments_names.Length()) arguments are | 52 // (count - optional_arguments_names.Length()) arguments are |
53 // positional and the remaining ones are named optional arguments. | 53 // positional and the remaining ones are named optional arguments. |
54 static RawArray* New(intptr_t count, | 54 static RawArray* New(intptr_t count, const Array& optional_arguments_names); |
55 const Array& optional_arguments_names); | |
56 | 55 |
57 // Allocate and return an arguments descriptor that has no optional | 56 // Allocate and return an arguments descriptor that has no optional |
58 // arguments. All arguments are positional. | 57 // arguments. All arguments are positional. |
59 static RawArray* New(intptr_t count); | 58 static RawArray* New(intptr_t count); |
60 | 59 |
61 // Initialize the preallocated fixed length arguments descriptors cache. | 60 // Initialize the preallocated fixed length arguments descriptors cache. |
62 static void InitOnce(); | 61 static void InitOnce(); |
63 | 62 |
64 enum { | 63 enum { kCachedDescriptorCount = 32 }; |
65 kCachedDescriptorCount = 32 | |
66 }; | |
67 | 64 |
68 private: | 65 private: |
69 // Absolute indexes into the array. | 66 // Absolute indexes into the array. |
70 enum { | 67 enum { |
71 kCountIndex, | 68 kCountIndex, |
72 kPositionalCountIndex, | 69 kPositionalCountIndex, |
73 kFirstNamedEntryIndex, | 70 kFirstNamedEntryIndex, |
74 }; | 71 }; |
75 | 72 |
76 // Relative indexes into each named argument entry. | 73 // Relative indexes into each named argument entry. |
77 enum { | 74 enum { |
78 kNameOffset, | 75 kNameOffset, |
79 kPositionOffset, | 76 kPositionOffset, |
80 kNamedEntrySize, | 77 kNamedEntrySize, |
81 }; | 78 }; |
82 | 79 |
83 static intptr_t LengthFor(intptr_t count) { | 80 static intptr_t LengthFor(intptr_t count) { |
84 // Add 1 for the terminating null. | 81 // Add 1 for the terminating null. |
85 return kFirstNamedEntryIndex + (kNamedEntrySize * count) + 1; | 82 return kFirstNamedEntryIndex + (kNamedEntrySize * count) + 1; |
86 } | 83 } |
87 | 84 |
88 static RawArray* NewNonCached(intptr_t count, bool canonicalize = true); | 85 static RawArray* NewNonCached(intptr_t count, bool canonicalize = true); |
89 | 86 |
90 // Used by Simulator to parse argument descriptors. | 87 // Used by Simulator to parse argument descriptors. |
91 static intptr_t name_index(intptr_t index) { | 88 static intptr_t name_index(intptr_t index) { |
92 return kFirstNamedEntryIndex + | 89 return kFirstNamedEntryIndex + (index * kNamedEntrySize) + kNameOffset; |
93 (index * kNamedEntrySize) + | |
94 kNameOffset; | |
95 } | 90 } |
96 | 91 |
97 static intptr_t position_index(intptr_t index) { | 92 static intptr_t position_index(intptr_t index) { |
98 return kFirstNamedEntryIndex + | 93 return kFirstNamedEntryIndex + (index * kNamedEntrySize) + kPositionOffset; |
99 (index * kNamedEntrySize) + | |
100 kPositionOffset; | |
101 } | 94 } |
102 | 95 |
103 const Array& array_; | 96 const Array& array_; |
104 | 97 |
105 // A cache of VM heap allocated arguments descriptors. | 98 // A cache of VM heap allocated arguments descriptors. |
106 static RawArray* cached_args_descriptors_[kCachedDescriptorCount]; | 99 static RawArray* cached_args_descriptors_[kCachedDescriptorCount]; |
107 | 100 |
108 friend class SnapshotReader; | 101 friend class SnapshotReader; |
109 friend class SnapshotWriter; | 102 friend class SnapshotWriter; |
110 friend class Serializer; | 103 friend class Serializer; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // | 182 // |
190 // Returns null on success, a RawError on failure. | 183 // Returns null on success, a RawError on failure. |
191 static RawObject* MapSetAt(const Instance& map, | 184 static RawObject* MapSetAt(const Instance& map, |
192 const Instance& key, | 185 const Instance& key, |
193 const Instance& value); | 186 const Instance& value); |
194 }; | 187 }; |
195 | 188 |
196 } // namespace dart | 189 } // namespace dart |
197 | 190 |
198 #endif // RUNTIME_VM_DART_ENTRY_H_ | 191 #endif // RUNTIME_VM_DART_ENTRY_H_ |
OLD | NEW |