Chromium Code Reviews| 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_[kCachedDescriptors]; |
| + |
| + |
| 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 < kCachedDescriptors) { |
| + 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. |
| @@ -285,12 +302,21 @@ |
| descriptor.SetAt((descriptor_len - 1), Object::Handle()); |
| // Share the immutable descriptor when possible by canonicalizing it. |
| - descriptor.MakeImmutable(); |
| - descriptor ^= descriptor.Canonicalize(); |
| + if (canonicalize) { |
|
regis
2013/01/05 01:05:29
I suppose you do not canonicalize the cached descr
Ivan Posva
2013/01/07 18:27:12
Making them immutable now. For this we need to mak
|
| + descriptor.MakeImmutable(); |
| + descriptor ^= descriptor.Canonicalize(); |
| + } |
| return descriptor.raw(); |
| } |
| +void ArgumentsDescriptor::InitOnce() { |
| + for (int i = 0; i < kCachedDescriptors; i++) { |
| + cached_args_descriptors_[i] = ArgumentsDescriptor::NewNonCached(i, false); |
| + } |
| +} |
| + |
| + |
| RawObject* DartLibraryCalls::ExceptionCreate(const Library& lib, |
| const String& class_name, |
| const Array& arguments) { |