Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: runtime/vm/dart_entry.h

Issue 2859673002: Pass type argument vector to generic functions (if --reify-generic-functions is (Closed)
Patch Set: address review comments and sync Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/dart_entry.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 namespace dart { 11 namespace dart {
12 12
13 // Forward declarations. 13 // Forward declarations.
14 class Array; 14 class Array;
15 class Closure; 15 class Closure;
16 class Function; 16 class Function;
17 class Instance; 17 class Instance;
18 class Integer; 18 class Integer;
19 class Library; 19 class Library;
20 class Object; 20 class Object;
21 class RawArray; 21 class RawArray;
22 class RawInstance; 22 class RawInstance;
23 class RawObject; 23 class RawObject;
24 class RawString; 24 class RawString;
25 class String; 25 class String;
26 26
27 // An arguments descriptor array consists of the total argument count; the 27 // An arguments descriptor array consists of the type argument vector length (0
28 // if none); total argument count (not counting type argument vector); the
28 // positional argument count; a sequence of (name, position) pairs, sorted 29 // positional argument count; a sequence of (name, position) pairs, sorted
29 // by name, for each named optional argument; and a terminating null to 30 // by name, for each named optional argument; and a terminating null to
30 // simplify iterating in generated code. 31 // simplify iterating in generated code.
31 class ArgumentsDescriptor : public ValueObject { 32 class ArgumentsDescriptor : public ValueObject {
32 public: 33 public:
33 explicit ArgumentsDescriptor(const Array& array); 34 explicit ArgumentsDescriptor(const Array& array);
34 35
35 // Accessors. 36 // Accessors.
37 intptr_t TypeArgsLen() const;
36 intptr_t Count() const; 38 intptr_t Count() const;
37 intptr_t PositionalCount() const; 39 intptr_t PositionalCount() const;
38 intptr_t NamedCount() const { return Count() - PositionalCount(); } 40 intptr_t NamedCount() const { return Count() - PositionalCount(); }
39 RawString* NameAt(intptr_t i) const; 41 RawString* NameAt(intptr_t i) const;
40 intptr_t PositionAt(intptr_t i) const; 42 intptr_t PositionAt(intptr_t i) const;
41 bool MatchesNameAt(intptr_t i, const String& other) const; 43 bool MatchesNameAt(intptr_t i, const String& other) const;
42 44
43 // Generated code support. 45 // Generated code support.
46 static intptr_t type_args_len_offset();
44 static intptr_t count_offset(); 47 static intptr_t count_offset();
45 static intptr_t positional_count_offset(); 48 static intptr_t positional_count_offset();
46 static intptr_t first_named_entry_offset(); 49 static intptr_t first_named_entry_offset();
47 static intptr_t name_offset() { return kNameOffset * kWordSize; } 50 static intptr_t name_offset() { return kNameOffset * kWordSize; }
48 static intptr_t position_offset() { return kPositionOffset * kWordSize; } 51 static intptr_t position_offset() { return kPositionOffset * kWordSize; }
49 static intptr_t named_entry_size() { return kNamedEntrySize * kWordSize; } 52 static intptr_t named_entry_size() { return kNamedEntrySize * kWordSize; }
50 53
51 // Allocate and return an arguments descriptor. The first 54 // Allocate and return an arguments descriptor. The first
52 // (count - optional_arguments_names.Length()) arguments are 55 // (num_arguments - optional_arguments_names.Length()) arguments are
53 // positional and the remaining ones are named optional arguments. 56 // positional and the remaining ones are named optional arguments.
54 static RawArray* New(intptr_t count, const Array& optional_arguments_names); 57 // The presence of a type argument vector as first argument (not counted in
58 // num_arguments) is indicated by a non-zero type_args_len.
59 static RawArray* New(intptr_t type_args_len,
60 intptr_t num_arguments,
61 const Array& optional_arguments_names);
55 62
56 // Allocate and return an arguments descriptor that has no optional 63 // Allocate and return an arguments descriptor that has no optional
57 // arguments. All arguments are positional. 64 // arguments. All arguments are positional. The presence of a type argument
58 static RawArray* New(intptr_t count); 65 // vector as first argument (not counted in num_arguments) is indicated
66 // by a non-zero type_args_len.
67 static RawArray* New(intptr_t type_args_len, intptr_t num_arguments);
59 68
60 // Initialize the preallocated fixed length arguments descriptors cache. 69 // Initialize the preallocated fixed length arguments descriptors cache.
61 static void InitOnce(); 70 static void InitOnce();
62 71
63 enum { kCachedDescriptorCount = 32 }; 72 enum { kCachedDescriptorCount = 32 };
64 73
65 private: 74 private:
66 // Absolute indexes into the array. 75 // Absolute indexes into the array.
76 // Keep these in sync with the constants in invocation_mirror_patch.dart.
67 enum { 77 enum {
78 kTypeArgsLenIndex,
68 kCountIndex, 79 kCountIndex,
69 kPositionalCountIndex, 80 kPositionalCountIndex,
70 kFirstNamedEntryIndex, 81 kFirstNamedEntryIndex,
71 }; 82 };
72 83
73 // Relative indexes into each named argument entry. 84 // Relative indexes into each named argument entry.
74 enum { 85 enum {
75 kNameOffset, 86 kNameOffset,
76 kPositionOffset, 87 kPositionOffset,
77 kNamedEntrySize, 88 kNamedEntrySize,
78 }; 89 };
79 90
80 static intptr_t LengthFor(intptr_t count) { 91 static intptr_t LengthFor(intptr_t num_named_arguments) {
81 // Add 1 for the terminating null. 92 // Add 1 for the terminating null.
82 return kFirstNamedEntryIndex + (kNamedEntrySize * count) + 1; 93 return kFirstNamedEntryIndex + (kNamedEntrySize * num_named_arguments) + 1;
83 } 94 }
84 95
85 static RawArray* NewNonCached(intptr_t count, bool canonicalize = true); 96 static RawArray* NewNonCached(intptr_t num_arguments,
97 bool canonicalize = true);
86 98
87 // Used by Simulator to parse argument descriptors. 99 // Used by Simulator to parse argument descriptors.
88 static intptr_t name_index(intptr_t index) { 100 static intptr_t name_index(intptr_t index) {
89 return kFirstNamedEntryIndex + (index * kNamedEntrySize) + kNameOffset; 101 return kFirstNamedEntryIndex + (index * kNamedEntrySize) + kNameOffset;
90 } 102 }
91 103
92 static intptr_t position_index(intptr_t index) { 104 static intptr_t position_index(intptr_t index) {
93 return kFirstNamedEntryIndex + (index * kNamedEntrySize) + kPositionOffset; 105 return kFirstNamedEntryIndex + (index * kNamedEntrySize) + kPositionOffset;
94 } 106 }
95 107
(...skipping 17 matching lines...) Expand all
113 public: 125 public:
114 // On success, returns a RawInstance. On failure, a RawError. 126 // On success, returns a RawInstance. On failure, a RawError.
115 typedef RawObject* (*invokestub)(const Code& target_code, 127 typedef RawObject* (*invokestub)(const Code& target_code,
116 const Array& arguments_descriptor, 128 const Array& arguments_descriptor,
117 const Array& arguments, 129 const Array& arguments,
118 Thread* thread); 130 Thread* thread);
119 131
120 // Invokes the specified instance function or static function. 132 // Invokes the specified instance function or static function.
121 // The first argument of an instance function is the receiver. 133 // The first argument of an instance function is the receiver.
122 // On success, returns a RawInstance. On failure, a RawError. 134 // On success, returns a RawInstance. On failure, a RawError.
123 // This is used when there are no named arguments in the call. 135 // This is used when there is no type argument vector and
136 // no named arguments in the call.
124 static RawObject* InvokeFunction(const Function& function, 137 static RawObject* InvokeFunction(const Function& function,
125 const Array& arguments); 138 const Array& arguments);
126 139
127 // Invokes the specified instance, static, or closure function. 140 // Invokes the specified instance, static, or closure function.
128 // On success, returns a RawInstance. On failure, a RawError. 141 // On success, returns a RawInstance. On failure, a RawError.
129 static RawObject* InvokeFunction( 142 static RawObject* InvokeFunction(
130 const Function& function, 143 const Function& function,
131 const Array& arguments, 144 const Array& arguments,
132 const Array& arguments_descriptor, 145 const Array& arguments_descriptor,
133 uword current_sp = Thread::GetCurrentStackPointer()); 146 uword current_sp = Thread::GetCurrentStackPointer());
134 147
135 // Invokes the closure object given as the first argument. 148 // Invokes the closure object given as the first argument.
136 // On success, returns a RawInstance. On failure, a RawError. 149 // On success, returns a RawInstance. On failure, a RawError.
137 // This is used when there are no named arguments in the call. 150 // This is used when there is no type argument vector and
151 // no named arguments in the call.
138 static RawObject* InvokeClosure(const Array& arguments); 152 static RawObject* InvokeClosure(const Array& arguments);
139 153
140 // Invokes the closure object given as the first argument. 154 // Invokes the closure object given as the first argument.
141 // On success, returns a RawInstance. On failure, a RawError. 155 // On success, returns a RawInstance. On failure, a RawError.
142 static RawObject* InvokeClosure(const Array& arguments, 156 static RawObject* InvokeClosure(const Array& arguments,
143 const Array& arguments_descriptor); 157 const Array& arguments_descriptor);
144 158
145 // Invokes the noSuchMethod instance function on the receiver. 159 // Invokes the noSuchMethod instance function on the receiver.
146 // On success, returns a RawInstance. On failure, a RawError. 160 // On success, returns a RawInstance. On failure, a RawError.
147 static RawObject* InvokeNoSuchMethod(const Instance& receiver, 161 static RawObject* InvokeNoSuchMethod(const Instance& receiver,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // 198 //
185 // Returns null on success, a RawError on failure. 199 // Returns null on success, a RawError on failure.
186 static RawObject* MapSetAt(const Instance& map, 200 static RawObject* MapSetAt(const Instance& map,
187 const Instance& key, 201 const Instance& key,
188 const Instance& value); 202 const Instance& value);
189 }; 203 };
190 204
191 } // namespace dart 205 } // namespace dart
192 206
193 #endif // RUNTIME_VM_DART_ENTRY_H_ 207 #endif // RUNTIME_VM_DART_ENTRY_H_
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/dart_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698