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

Unified Diff: runtime/vm/dart_entry.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/dart_entry.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_entry.cc
===================================================================
--- runtime/vm/dart_entry.cc (revision 16642)
+++ runtime/vm/dart_entry.cc (working copy)
@@ -13,6 +13,10 @@
namespace dart {
+// A cache of VM heap allocated arguments descriptors.
+RawArray* ArgumentsDescriptor::cached_args_descriptors_[kCachedDescriptorCount];
+
+
RawObject* DartEntry::InvokeDynamic(const Function& function,
const Array& arguments) {
const Array& arg_desc =
@@ -219,6 +223,9 @@
const Array& optional_arguments_names) {
const intptr_t num_named_args =
optional_arguments_names.IsNull() ? 0 : optional_arguments_names.Length();
+ if (num_named_args == 0) {
+ return ArgumentsDescriptor::New(num_arguments);
+ }
const intptr_t num_pos_args = num_arguments - num_named_args;
// Build the arguments descriptor array, which consists of the total
@@ -268,6 +275,16 @@
RawArray* ArgumentsDescriptor::New(intptr_t num_arguments) {
+ ASSERT(num_arguments >= 0);
+ if (num_arguments < kCachedDescriptorCount) {
+ return cached_args_descriptors_[num_arguments];
+ }
+ return NewNonCached(num_arguments);
+}
+
+
+RawArray* ArgumentsDescriptor::NewNonCached(intptr_t num_arguments,
+ bool canonicalize) {
// Build the arguments descriptor array, which consists of the total
// argument count; the positional argument count; and
// a terminating null to simplify iterating in generated code.
@@ -286,11 +303,20 @@
// Share the immutable descriptor when possible by canonicalizing it.
descriptor.MakeImmutable();
- descriptor ^= descriptor.Canonicalize();
+ if (canonicalize) {
+ descriptor ^= descriptor.Canonicalize();
+ }
return descriptor.raw();
}
+void ArgumentsDescriptor::InitOnce() {
+ for (int i = 0; i < kCachedDescriptorCount; i++) {
+ cached_args_descriptors_[i] = ArgumentsDescriptor::NewNonCached(i, false);
+ }
+}
+
+
RawObject* DartLibraryCalls::ExceptionCreate(const Library& lib,
const String& class_name,
const Array& arguments) {
« no previous file with comments | « runtime/vm/dart_entry.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698