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

Unified Diff: runtime/vm/dart_entry.cc

Issue 1873143003: - Use a hash table to canonicalize instances/arrays to avoid having to iterate over a linear list a… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address-code-review Created 4 years, 8 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
Index: runtime/vm/dart_entry.cc
diff --git a/runtime/vm/dart_entry.cc b/runtime/vm/dart_entry.cc
index ea55b49e9f7eeaa6d5ca9d714ebfddeb2cd9617f..ec881ea7f9813f075909d0164089fa729e395dcf 100644
--- a/runtime/vm/dart_entry.cc
+++ b/runtime/vm/dart_entry.cc
@@ -322,23 +322,26 @@ RawArray* ArgumentsDescriptor::New(intptr_t num_arguments,
// argument count; the positional argument count; a sequence of (name,
// position) pairs, sorted by name, for each named optional argument; and
// a terminating null to simplify iterating in generated code.
+ Thread* thread = Thread::Current();
+ Zone* zone = thread->zone();
const intptr_t descriptor_len = LengthFor(num_named_args);
- Array& descriptor = Array::Handle(Array::New(descriptor_len, Heap::kOld));
+ Array& descriptor = Array::Handle(
+ zone, Array::New(descriptor_len, Heap::kOld));
// Set total number of passed arguments.
descriptor.SetAt(kCountIndex, Smi::Handle(Smi::New(num_arguments)));
// Set number of positional arguments.
descriptor.SetAt(kPositionalCountIndex, Smi::Handle(Smi::New(num_pos_args)));
// Set alphabetically sorted entries for named arguments.
- String& name = String::Handle();
- Smi& pos = Smi::Handle();
+ String& name = String::Handle(zone);
+ Smi& pos = Smi::Handle(zone);
+ String& previous_name = String::Handle(zone);
+ Smi& previous_pos = Smi::Handle(zone);
for (intptr_t i = 0; i < num_named_args; i++) {
name ^= optional_arguments_names.At(i);
pos = Smi::New(num_pos_args + i);
intptr_t insert_index = kFirstNamedEntryIndex + (kNamedEntrySize * i);
// Shift already inserted pairs with "larger" names.
- String& previous_name = String::Handle();
- Smi& previous_pos = Smi::Handle();
while (insert_index > kFirstNamedEntryIndex) {
intptr_t previous_index = insert_index - kNamedEntrySize;
previous_name ^= descriptor.At(previous_index + kNameOffset);
@@ -359,7 +362,7 @@ RawArray* ArgumentsDescriptor::New(intptr_t num_arguments,
// Share the immutable descriptor when possible by canonicalizing it.
descriptor.MakeImmutable();
- descriptor ^= descriptor.CheckAndCanonicalize(NULL);
+ descriptor ^= descriptor.CheckAndCanonicalize(thread, NULL);
ASSERT(!descriptor.IsNull());
return descriptor.raw();
}
@@ -379,9 +382,12 @@ RawArray* ArgumentsDescriptor::NewNonCached(intptr_t num_arguments,
// 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.
+ Thread* thread = Thread::Current();
+ Zone* zone = thread->zone();
const intptr_t descriptor_len = LengthFor(0);
- Array& descriptor = Array::Handle(Array::New(descriptor_len, Heap::kOld));
- const Smi& arg_count = Smi::Handle(Smi::New(num_arguments));
+ Array& descriptor = Array::Handle(
+ zone, Array::New(descriptor_len, Heap::kOld));
+ const Smi& arg_count = Smi::Handle(zone, Smi::New(num_arguments));
// Set total number of passed arguments.
descriptor.SetAt(kCountIndex, arg_count);
@@ -395,7 +401,7 @@ RawArray* ArgumentsDescriptor::NewNonCached(intptr_t num_arguments,
// Share the immutable descriptor when possible by canonicalizing it.
descriptor.MakeImmutable();
if (canonicalize) {
- descriptor ^= descriptor.CheckAndCanonicalize(NULL);
+ descriptor ^= descriptor.CheckAndCanonicalize(thread, NULL);
}
ASSERT(!descriptor.IsNull());
return descriptor.raw();

Powered by Google App Engine
This is Rietveld 408576698