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

Unified Diff: runtime/vm/class_finalizer.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/class_finalizer.cc
diff --git a/runtime/vm/class_finalizer.cc b/runtime/vm/class_finalizer.cc
index 1db03051a164a076847afb7bb13c2a246216395d..cde45ccb5a1447cac552b7709d5e7315ee5ac011 100644
--- a/runtime/vm/class_finalizer.cc
+++ b/runtime/vm/class_finalizer.cc
@@ -2516,20 +2516,22 @@ void ClassFinalizer::FinalizeClass(const Class& cls) {
// values field. We also don't have to generate the code for these getters
// from thin air (no source code is available).
void ClassFinalizer::AllocateEnumValues(const Class &enum_cls) {
+ Thread* thread = Thread::Current();
+ Zone* zone = thread->zone();
const Field& index_field =
- Field::Handle(enum_cls.LookupInstanceField(Symbols::Index()));
+ Field::Handle(zone, enum_cls.LookupInstanceField(Symbols::Index()));
ASSERT(!index_field.IsNull());
const Field& values_field =
- Field::Handle(enum_cls.LookupStaticField(Symbols::Values()));
+ Field::Handle(zone, enum_cls.LookupStaticField(Symbols::Values()));
ASSERT(!values_field.IsNull());
- ASSERT(Instance::Handle(values_field.StaticValue()).IsArray());
+ ASSERT(Instance::Handle(zone, values_field.StaticValue()).IsArray());
Array& values_list = Array::Handle(
- Array::RawCast(values_field.StaticValue()));
+ zone, Array::RawCast(values_field.StaticValue()));
- const Array& fields = Array::Handle(enum_cls.fields());
- Field& field = Field::Handle();
- Instance& ordinal_value = Instance::Handle();
- Instance& enum_value = Instance::Handle();
+ const Array& fields = Array::Handle(zone, enum_cls.fields());
+ Field& field = Field::Handle(zone);
+ Instance& ordinal_value = Instance::Handle(zone);
+ Instance& enum_value = Instance::Handle(zone);
for (intptr_t i = 0; i < fields.Length(); i++) {
field = Field::RawCast(fields.At(i));
@@ -2542,7 +2544,7 @@ void ClassFinalizer::AllocateEnumValues(const Class &enum_cls) {
enum_value = Instance::New(enum_cls, Heap::kOld);
enum_value.SetField(index_field, ordinal_value);
const char* error_msg = "";
- enum_value = enum_value.CheckAndCanonicalize(&error_msg);
+ enum_value = enum_value.CheckAndCanonicalize(thread, &error_msg);
ASSERT(!enum_value.IsNull());
ASSERT(enum_value.IsCanonical());
field.SetStaticValue(enum_value, true);
@@ -2553,7 +2555,7 @@ void ClassFinalizer::AllocateEnumValues(const Class &enum_cls) {
}
values_list.MakeImmutable();
const char* error_msg = NULL;
- values_list ^= values_list.CheckAndCanonicalize(&error_msg);
+ values_list ^= values_list.CheckAndCanonicalize(thread, &error_msg);
ASSERT(!values_list.IsNull());
}
« no previous file with comments | « runtime/lib/integers.cc ('k') | runtime/vm/dart_entry.cc » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698