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

Unified Diff: runtime/vm/code_generator.cc

Issue 557913002: Allow invalidation and recompilation of instance allocation stubs. Requested in order to implement… (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
Index: runtime/vm/code_generator.cc
===================================================================
--- runtime/vm/code_generator.cc (revision 40064)
+++ runtime/vm/code_generator.cc (working copy)
@@ -1341,6 +1341,50 @@
}
+// The caller tried to allocate an instance via an invalidated allocation
+// stub.
+DEFINE_RUNTIME_ENTRY(FixAllocationStubTarget, 0) {
+ StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames);
+ StackFrame* frame = iterator.NextFrame();
+ while (frame != NULL && (frame->IsStubFrame() || frame->IsExitFrame())) {
koda 2014/09/10 15:33:21 This explicit null-check looks strange, since null
zra 2014/09/10 16:07:39 parens around (frame != NULL)
srdjan 2014/09/11 16:22:35 Done, also for FixCallersTarget above.
srdjan 2014/09/11 16:22:36 Removed that test
+ frame = iterator.NextFrame();
+ }
+ ASSERT(frame != NULL);
+ if (frame->IsEntryFrame()) {
+ // There must be a valid Dart frame.
+ UNREACHABLE();
+ }
+ ASSERT(frame->IsDartFrame());
+ const Code& caller_code = Code::Handle(isolate, frame->LookupDartCode());
+ ASSERT(!caller_code.IsNull());
+ const uword target =
+ CodePatcher::GetStaticCallTargetAt(frame->pc(), caller_code);
+ const Code& stub = Code::Handle(isolate, Code::LookupCode(target));
+ Class& alloc_class = Class::ZoneHandle(isolate);
+ alloc_class ^= stub.owner();
+ Code& alloc_stub = Code::Handle(isolate, alloc_class.allocation_stub());
+ if (alloc_stub.IsNull()) {
+ alloc_stub = isolate->stub_code()->GetAllocationStubForClass(alloc_class);
+ ASSERT(!CodePatcher::IsEntryPatched(alloc_stub));
+ }
+ const Instructions& instrs =
+ Instructions::Handle(isolate, caller_code.instructions());
+ {
+ WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size());
+ CodePatcher::PatchStaticCallAt(frame->pc(),
+ caller_code,
+ alloc_stub.EntryPoint());
+ }
+ if (FLAG_trace_patching) {
+ OS::PrintErr("FixAllocationStubTarget: caller %#" Px " "
+ " -> %#" Px "\n",
+ frame->pc(),
+ alloc_stub.EntryPoint());
+ }
+ arguments.SetReturn(alloc_stub);
+}
+
+
const char* DeoptReasonToCString(ICData::DeoptReasonId deopt_reason) {
switch (deopt_reason) {
#define DEOPT_REASON_TO_TEXT(name) case ICData::kDeopt##name: return #name;

Powered by Google App Engine
This is Rietveld 408576698