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

Unified Diff: runtime/vm/object.cc

Issue 566853005: Fix to allocation stub invalidation: we cannot just remove it as it will be collected even though c… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 40325)
+++ runtime/vm/object.cc (working copy)
@@ -3642,17 +3642,27 @@
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());
}
-void Class::DisableAllocationStub() const {
+void Class::SwitchAllocationStub() const {
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());
}
}
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698