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

Unified Diff: runtime/vm/stub_code_x64.cc

Issue 600243002: Patchable AllocateArray stub, like instance allocation stubs. (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 40629)
+++ runtime/vm/stub_code_x64.cc (working copy)
@@ -367,6 +367,28 @@
}
+// Called from array allocate instruction when the allocation stub has been
+// disabled.
+// R10: length (preserved).
+// RBX: element type (preserved).
+void StubCode::GenerateFixAllocateArrayStubTargetStub(Assembler* assembler) {
+ __ EnterStubFrame();
+ __ pushq(R10); // Preserve length.
+ __ pushq(RBX); // Preserve element type.
+ // Setup space on stack for return value.
+ __ PushObject(Object::null_object(), PP);
+ __ CallRuntime(kFixAllocationStubTargetRuntimeEntry, 0);
+ __ popq(RAX); // Get Code object.
+ __ popq(RBX); // Restore element type.
+ __ popq(R10); // Restore length.
+ __ movq(RAX, FieldAddress(RAX, Code::instructions_offset()));
+ __ addq(RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
+ __ LeaveStubFrame();
+ __ jmp(RAX);
+ __ int3();
+}
+
+
// Input parameters:
// R10: smi-tagged argument count, may be zero.
// RBP[kParamEndSlotFromFp + 1]: last argument.
@@ -376,7 +398,9 @@
__ LoadObject(R12, Object::null_object(), PP);
// Allocate array to store arguments of caller.
__ movq(RBX, R12); // Null element type for raw Array.
- __ call(&stub_code->AllocateArrayLabel());
+ const Code& array_stub = Code::Handle(stub_code->GetAllocateArrayStub());
+ const ExternalLabel array_label(array_stub.EntryPoint());
+ __ call(&array_label);
__ SmiUntag(R10);
// RAX: newly allocated array.
// R10: length of the array (was preserved by the stub).
@@ -580,7 +604,12 @@
// RBX : array element type (either NULL or an instantiated type).
// NOTE: R10 cannot be clobbered here as the caller relies on it being saved.
// The newly allocated object is returned in RAX.
-void StubCode::GenerateAllocateArrayStub(Assembler* assembler) {
+void StubCode::GeneratePatchableAllocateArrayStub(Assembler* assembler,
+ uword* entry_patch_offset, uword* patch_code_pc_offset) {
+ // Must load pool pointer before being able to patch.
+ Register new_pp = R13;
+ __ LoadPoolPointer(new_pp);
+ *entry_patch_offset = assembler->CodeSize();
Label slow_case;
// Compute the size to be allocated, it is based on the array length
// and is computed as:
@@ -691,6 +720,9 @@
__ popq(RAX); // Pop return value from return slot.
__ LeaveStubFrame();
__ ret();
+ *patch_code_pc_offset = assembler->CodeSize();
+ StubCode* stub_code = Isolate::Current()->stub_code();
+ __ JmpPatchable(&stub_code->FixAllocateArrayStubTargetLabel(), 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