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/stub_code_x64.cc

Issue 574843002: Fix x64 patching of asllocation stub: the pool pointer must be set-up before patching jump is execu… (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/stub_code_mips.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/stub_code_x64.cc
===================================================================
--- runtime/vm/stub_code_x64.cc (revision 40325)
+++ runtime/vm/stub_code_x64.cc (working copy)
@@ -1067,8 +1067,32 @@
// Input parameters:
// RSP + 8 : type arguments object (only if class is parameterized).
// RSP : points to return address.
-uword StubCode::GenerateAllocationStubForClass(Assembler* assembler,
- const Class& cls) {
+void StubCode::GenerateAllocationStubForClass(
+ Assembler* assembler, const Class& cls,
+ uword* entry_patch_offset, uword* patch_code_pc_offset) {
+ // Must set-up a PP before being able to patch.
+ Register new_pp = R13;
+ Register new_pc = R12;
+
+ Label next;
+ __ nop(4); // Need a fixed size sequence on frame entry.
+ __ call(&next);
+ __ Bind(&next);
+
+ const intptr_t object_pool_pc_dist =
+ Instructions::HeaderSize() - Instructions::object_pool_offset() +
+ __ CodeSize();
+ const intptr_t offset =
+ Assembler::EntryPointToPcMarkerOffset() - __ CodeSize();
+ __ popq(new_pc);
+ if (offset != 0) {
+ __ addq(new_pc, Immediate(offset));
+ }
+
+ // Load pool pointer.
+ __ movq(new_pp, Address(new_pc, -object_pool_pc_dist - offset));
+ *entry_patch_offset = assembler->CodeSize();
zra 2014/09/16 20:55:58 Since this is a delicate bit of code, I'd recommen
srdjan 2014/09/16 21:54:50 Good suggestion! Done.
+
const intptr_t kObjectTypeArgumentsOffset = 1 * kWordSize;
// The generated code is different if the class is parameterized.
const bool is_cls_parameterized = cls.NumTypeArguments() > 0;
@@ -1180,10 +1204,9 @@
// Restore the frame pointer.
__ LeaveStubFrame();
__ ret();
- uword patch_code_pc_offset = assembler->CodeSize();
+ *patch_code_pc_offset = assembler->CodeSize();
StubCode* stub_code = Isolate::Current()->stub_code();
- __ JmpPatchable(&stub_code->FixAllocationStubTargetLabel(), R13);
- return patch_code_pc_offset;
+ __ JmpPatchable(&stub_code->FixAllocationStubTargetLabel(), new_pp);
}
« no previous file with comments | « runtime/vm/stub_code_mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698