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

Unified Diff: runtime/vm/parser.cc

Issue 16780009: When canonicalize instances check if all fields are canonical. If a field is a non-canonical number… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 23823)
+++ runtime/vm/parser.cc (working copy)
@@ -6801,8 +6801,8 @@
arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle()));
} else {
const int total_num_parameters = function.NumParameters();
- Array& array = Array::ZoneHandle(Array::New(total_num_parameters));
- array ^= array.Canonicalize();
+ Array& array =
+ Array::ZoneHandle(Array::New(total_num_parameters, Heap::kOld));
// Skip receiver.
for (int i = 0; i < total_num_parameters; i++) {
array.SetAt(i, String::Handle(function.ParameterNameAt(i)));
@@ -8057,6 +8057,20 @@
}
+RawInstance* Parser::TryCanonicalize(const Instance& instance) {
+ if (instance.IsNull()) {
+ return instance.raw();
+ }
+ const char* error_str = NULL;
+ Instance& result =
+ Instance::Handle(instance.CheckAndCanonicalize(&error_str));
+ if (result.IsNull()) {
+ ErrorMsg("Invalid const object %s", error_str);
hausner 2013/06/11 23:29:24 The error position is not necessarily the current
srdjan 2013/06/12 00:22:22 Done.
+ }
+ return result.raw();
+}
+
+
// If the field is already initialized, return no ast (NULL).
// Otherwise, if the field is constant, initialize the field and return no ast.
// If the field is not initialized and not const, return the ast for the getter.
@@ -8116,9 +8130,7 @@
ASSERT(const_value.IsNull() || const_value.IsInstance());
Instance& instance = Instance::Handle();
instance ^= const_value.raw();
- if (!instance.IsNull()) {
- instance ^= instance.Canonicalize();
- }
+ instance = TryCanonicalize(instance);
field.set_value(instance);
} else {
return new StaticGetterNode(TokenPos(),
@@ -8142,7 +8154,7 @@
const Array& arg_values = Array::Handle(Array::New(num_arguments));
Instance& instance = Instance::Handle();
ASSERT(!constructor.IsFactory());
- instance = Instance::New(type_class, Heap::kOld);
+ instance ^= Instance::New(type_class, Heap::kOld);
hausner 2013/06/11 23:29:24 Why ^= ?
srdjan 2013/06/12 00:22:22 Weird ... removed.
if (!type_arguments.IsNull()) {
if (!type_arguments.IsInstantiated()) {
ErrorMsg("type must be constant in const constructor");
@@ -8178,10 +8190,7 @@
return Object::null();
}
} else {
- if (!instance.IsNull()) {
- instance ^= instance.Canonicalize();
- }
- return instance.raw();
+ return TryCanonicalize(instance);
}
}
@@ -8821,7 +8830,7 @@
}
const_list.SetAt(i, elem->AsLiteralNode()->literal());
}
- const_list ^= const_list.Canonicalize();
+ const_list ^= TryCanonicalize(const_list);
const_list.MakeImmutable();
return new LiteralNode(literal_pos, const_list);
} else {
@@ -9018,7 +9027,7 @@
}
key_value_array.SetAt(i, arg->AsLiteralNode()->literal());
}
- key_value_array ^= key_value_array.Canonicalize();
+ key_value_array ^= TryCanonicalize(key_value_array);
key_value_array.MakeImmutable();
// Construct the map object.
@@ -9691,9 +9700,7 @@
ASSERT(result.IsInstance());
Instance& value = Instance::ZoneHandle();
value ^= result.raw();
- if (!value.IsNull()) {
- value ^= value.Canonicalize();
- }
+ value = TryCanonicalize(value);
return value;
}
}

Powered by Google App Engine
This is Rietveld 408576698