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

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

Issue 11773008: - Preallocate non-named ArgumentsDescriptors with a small amount of parameters. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/dart.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 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // Allocate and return an arguments descriptor. The first 50 // Allocate and return an arguments descriptor. The first
51 // (count - optional_arguments_names.Length()) arguments are 51 // (count - optional_arguments_names.Length()) arguments are
52 // positional and the remaining ones are named optional arguments. 52 // positional and the remaining ones are named optional arguments.
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.
61 static void InitOnce();
62
60 private: 63 private:
61 // Absolute indexes into the array. 64 // Absolute indexes into the array.
62 enum { 65 enum {
63 kCountIndex, 66 kCountIndex,
64 kPositionalCountIndex, 67 kPositionalCountIndex,
65 kFirstNamedEntryIndex, 68 kFirstNamedEntryIndex,
66 }; 69 };
67 70
68 // Relative indexes into each named argument entry. 71 // Relative indexes into each named argument entry.
69 enum { 72 enum {
70 kNameOffset, 73 kNameOffset,
71 kPositionOffset, 74 kPositionOffset,
72 kNamedEntrySize, 75 kNamedEntrySize,
73 }; 76 };
74 77
78 enum {
79 kCachedDescriptorCount = 32
80 };
81
75 static intptr_t LengthFor(intptr_t count) { 82 static intptr_t LengthFor(intptr_t count) {
76 // Add 1 for the terminating null. 83 // Add 1 for the terminating null.
77 return kFirstNamedEntryIndex + (kNamedEntrySize * count) + 1; 84 return kFirstNamedEntryIndex + (kNamedEntrySize * count) + 1;
78 } 85 }
79 86
87 static RawArray* NewNonCached(intptr_t count, bool canonicalize = true);
88
80 const Array& array_; 89 const Array& array_;
81 90
91 // A cache of VM heap allocated arguments descriptors.
92 static RawArray* cached_args_descriptors_[kCachedDescriptorCount];
93
82 DISALLOW_COPY_AND_ASSIGN(ArgumentsDescriptor); 94 DISALLOW_COPY_AND_ASSIGN(ArgumentsDescriptor);
83 }; 95 };
84 96
85 97
86 // DartEntry abstracts functionality needed to resolve dart functions 98 // DartEntry abstracts functionality needed to resolve dart functions
87 // and invoke them from C++. 99 // and invoke them from C++.
88 class DartEntry : public AllStatic { 100 class DartEntry : public AllStatic {
89 public: 101 public:
90 // On success, returns a RawInstance. On failure, a RawError. 102 // On success, returns a RawInstance. On failure, a RawError.
91 typedef RawObject* (*invokestub)(uword entry_point, 103 typedef RawObject* (*invokestub)(uword entry_point,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 186
175 // Gets the _id field of a SendPort/ReceivePort. 187 // Gets the _id field of a SendPort/ReceivePort.
176 // 188 //
177 // Returns the value of _id on success, a RawError on failure. 189 // Returns the value of _id on success, a RawError on failure.
178 static RawObject* PortGetId(const Instance& port); 190 static RawObject* PortGetId(const Instance& port);
179 }; 191 };
180 192
181 } // namespace dart 193 } // namespace dart
182 194
183 #endif // VM_DART_ENTRY_H_ 195 #endif // VM_DART_ENTRY_H_
OLDNEW
« no previous file with comments | « runtime/vm/dart.cc ('k') | runtime/vm/dart_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698