| 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);
|
| }
|
|
|
|
|
|
|