Fix array-put-object
Change CanPutArrayElementFromCode to take an object and a class, rather
than two classes. This allows the generated code to skip the null check
on the element (I believe this was the plan all along, but I must have
forgotten and the current codegen was dereferencing the element to find it's
class without checking for NULL).
Change-Id: I11865e0e625ab0e800718398fd911733718e6ce9
diff --git a/src/object.cc b/src/object.cc
index c54364f..8d3a94f 100644
--- a/src/object.cc
+++ b/src/object.cc
@@ -764,9 +764,12 @@
}
}
-void Class::CanPutArrayElementFromCode(const Class* object_class, const Class* array_class) {
- if (!CanPutArrayElement(object_class, array_class)) {
- LOG(ERROR) << "Can't put a " << PrettyClass(object_class)
+void Class::CanPutArrayElementFromCode(const Object* element, const Class* array_class) {
+ if (element == NULL) {
+ return;
+ }
+ if (!CanPutArrayElement(element->GetClass(), array_class)) {
+ LOG(ERROR) << "Can't put a " << PrettyClass(element->GetClass())
<< " into a " << PrettyClass(array_class);
UNIMPLEMENTED(FATAL) << "need to throw ArrayStoreException and unwind stack";
}