| Index: runtime/vm/object.cc
|
| ===================================================================
|
| --- runtime/vm/object.cc (revision 40205)
|
| +++ runtime/vm/object.cc (working copy)
|
| @@ -3627,6 +3627,8 @@
|
|
|
|
|
| void Class::set_allocation_stub(const Code& value) const {
|
| + // Never clear the stub as it may still be a target, but will be GC-d if
|
| + // not referenced.
|
| ASSERT(!value.IsNull());
|
| ASSERT(raw_ptr()->allocation_stub_ == Code::null());
|
| StorePointer(&raw_ptr()->allocation_stub_, value.raw());
|
| @@ -3637,7 +3639,15 @@
|
| const Code& alloc_stub = Code::Handle(allocation_stub());
|
| if (!alloc_stub.IsNull()) {
|
| CodePatcher::PatchEntry(alloc_stub);
|
| - StorePointer(&raw_ptr()->allocation_stub_, Code::null());
|
| + const Code& spare_alloc_stub = Code::Handle(spare_allocation_stub());
|
| + if (spare_alloc_stub.IsNull()) {
|
| + StorePointer(&raw_ptr()->allocation_stub_, Code::null());
|
| + } else {
|
| + ASSERT(CodePatcher::IsEntryPatched(spare_alloc_stub));
|
| + CodePatcher::RestoreEntry(spare_alloc_stub);
|
| + StorePointer(&raw_ptr()->allocation_stub_, spare_alloc_stub.raw());
|
| + }
|
| + StorePointer(&raw_ptr()->spare_allocation_stub_, alloc_stub.raw());
|
| }
|
| }
|
|
|
|
|