| 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 VM_DART_ENTRY_H_ | 5 #ifndef VM_DART_ENTRY_H_ |
| 6 #define VM_DART_ENTRY_H_ | 6 #define 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 static RawArray* New(intptr_t count, | 53 static RawArray* New(intptr_t count, |
| 54 const Array& optional_arguments_names); | 54 const Array& optional_arguments_names); |
| 55 | 55 |
| 56 // Allocate and return an arguments descriptor that has no optional | 56 // Allocate and return an arguments descriptor that has no optional |
| 57 // arguments. All arguments are positional. | 57 // arguments. All arguments are positional. |
| 58 static RawArray* New(intptr_t count); | 58 static RawArray* New(intptr_t count); |
| 59 | 59 |
| 60 // Initialize the preallocated fixed length arguments descriptors cache. | 60 // Initialize the preallocated fixed length arguments descriptors cache. |
| 61 static void InitOnce(); | 61 static void InitOnce(); |
| 62 | 62 |
| 63 enum { |
| 64 kCachedDescriptorCount = 32 |
| 65 }; |
| 66 |
| 63 private: | 67 private: |
| 64 // Absolute indexes into the array. | 68 // Absolute indexes into the array. |
| 65 enum { | 69 enum { |
| 66 kCountIndex, | 70 kCountIndex, |
| 67 kPositionalCountIndex, | 71 kPositionalCountIndex, |
| 68 kFirstNamedEntryIndex, | 72 kFirstNamedEntryIndex, |
| 69 }; | 73 }; |
| 70 | 74 |
| 71 // Relative indexes into each named argument entry. | 75 // Relative indexes into each named argument entry. |
| 72 enum { | 76 enum { |
| 73 kNameOffset, | 77 kNameOffset, |
| 74 kPositionOffset, | 78 kPositionOffset, |
| 75 kNamedEntrySize, | 79 kNamedEntrySize, |
| 76 }; | 80 }; |
| 77 | 81 |
| 78 enum { | |
| 79 kCachedDescriptorCount = 32 | |
| 80 }; | |
| 81 | |
| 82 static intptr_t LengthFor(intptr_t count) { | 82 static intptr_t LengthFor(intptr_t count) { |
| 83 // Add 1 for the terminating null. | 83 // Add 1 for the terminating null. |
| 84 return kFirstNamedEntryIndex + (kNamedEntrySize * count) + 1; | 84 return kFirstNamedEntryIndex + (kNamedEntrySize * count) + 1; |
| 85 } | 85 } |
| 86 | 86 |
| 87 static RawArray* NewNonCached(intptr_t count, bool canonicalize = true); | 87 static RawArray* NewNonCached(intptr_t count, bool canonicalize = true); |
| 88 | 88 |
| 89 const Array& array_; | 89 const Array& array_; |
| 90 | 90 |
| 91 // A cache of VM heap allocated arguments descriptors. | 91 // A cache of VM heap allocated arguments descriptors. |
| 92 static RawArray* cached_args_descriptors_[kCachedDescriptorCount]; | 92 static RawArray* cached_args_descriptors_[kCachedDescriptorCount]; |
| 93 | 93 |
| 94 friend class FullSnapshotWriter; | 94 friend class SnapshotReader; |
| 95 friend class VmIsolateSnapshotReader; | 95 friend class SnapshotWriter; |
| 96 DISALLOW_COPY_AND_ASSIGN(ArgumentsDescriptor); | 96 DISALLOW_COPY_AND_ASSIGN(ArgumentsDescriptor); |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 | 99 |
| 100 // DartEntry abstracts functionality needed to resolve dart functions | 100 // DartEntry abstracts functionality needed to resolve dart functions |
| 101 // and invoke them from C++. | 101 // and invoke them from C++. |
| 102 class DartEntry : public AllStatic { | 102 class DartEntry : public AllStatic { |
| 103 public: | 103 public: |
| 104 // On success, returns a RawInstance. On failure, a RawError. | 104 // On success, returns a RawInstance. On failure, a RawError. |
| 105 typedef RawObject* (*invokestub)(uword entry_point, | 105 typedef RawObject* (*invokestub)(uword entry_point, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 // | 172 // |
| 173 // Returns null on success, a RawError on failure. | 173 // Returns null on success, a RawError on failure. |
| 174 static RawObject* MapSetAt(const Instance& map, | 174 static RawObject* MapSetAt(const Instance& map, |
| 175 const Instance& key, | 175 const Instance& key, |
| 176 const Instance& value); | 176 const Instance& value); |
| 177 }; | 177 }; |
| 178 | 178 |
| 179 } // namespace dart | 179 } // namespace dart |
| 180 | 180 |
| 181 #endif // VM_DART_ENTRY_H_ | 181 #endif // VM_DART_ENTRY_H_ |
| OLD | NEW |