| Index: runtime/vm/flow_graph_compiler_x64.cc
|
| diff --git a/runtime/vm/flow_graph_compiler_x64.cc b/runtime/vm/flow_graph_compiler_x64.cc
|
| index 2c531a1af8cc5259a29d3cea3c227a2b1d39505b..59934cd1360ca8bbe5f9309aadcad9df9bc7c464 100644
|
| --- a/runtime/vm/flow_graph_compiler_x64.cc
|
| +++ b/runtime/vm/flow_graph_compiler_x64.cc
|
| @@ -100,6 +100,7 @@ RawTypedData* CompilerDeoptInfo::CreateDeoptInfo(FlowGraphCompiler* compiler,
|
|
|
| Zone* zone = compiler->zone();
|
|
|
| + // Current PP, FP, and PC.
|
| builder->AddPp(current->function(), slot_ix++);
|
| builder->AddPcMarker(Function::Handle(zone), slot_ix++);
|
| builder->AddCallerFp(slot_ix++);
|
| @@ -120,6 +121,7 @@ RawTypedData* CompilerDeoptInfo::CreateDeoptInfo(FlowGraphCompiler* compiler,
|
| Environment* previous = current;
|
| current = current->outer();
|
| while (current != NULL) {
|
| + // PP, FP, and PC.
|
| builder->AddPp(current->function(), slot_ix++);
|
| builder->AddPcMarker(previous->function(), slot_ix++);
|
| builder->AddCallerFp(slot_ix++);
|
| @@ -155,8 +157,9 @@ RawTypedData* CompilerDeoptInfo::CreateDeoptInfo(FlowGraphCompiler* compiler,
|
| // The previous pointer is now the outermost environment.
|
| ASSERT(previous != NULL);
|
|
|
| - // Set slots for the outermost environment.
|
| + // For the outermost environment, set caller PC, caller PP, and caller FP.
|
| builder->AddCallerPp(slot_ix++);
|
| + // PC marker.
|
| builder->AddPcMarker(previous->function(), slot_ix++);
|
| builder->AddCallerFp(slot_ix++);
|
| builder->AddCallerPc(slot_ix++);
|
| @@ -184,7 +187,6 @@ void CompilerDeoptInfoWithStub::GenerateCode(FlowGraphCompiler* compiler,
|
|
|
| ASSERT(deopt_env() != NULL);
|
|
|
| - __ pushq(CODE_REG);
|
| __ Call(*StubCode::Deoptimize_entry());
|
| set_pc_offset(assem->CodeSize());
|
| __ int3();
|
| @@ -923,8 +925,11 @@ void FlowGraphCompiler::CopyParameters() {
|
|
|
| __ Bind(&wrong_num_arguments);
|
| if (function.IsClosureFunction()) {
|
| - __ LeaveDartFrame(kKeepCalleePP); // The arguments are still on the stack.
|
| - __ Jmp(*StubCode::CallClosureNoSuchMethod_entry());
|
| + ASSERT(assembler()->constant_pool_allowed());
|
| + __ LeaveDartFrame(); // The arguments are still on the stack.
|
| + ASSERT(!assembler()->constant_pool_allowed());
|
| + __ jmp(*StubCode::CallClosureNoSuchMethod_entry());
|
| + __ set_constant_pool_allowed(true);
|
| // The noSuchMethod call may return to the caller, but not here.
|
| } else if (check_correct_named_args) {
|
| __ Stop("Wrong arguments");
|
| @@ -981,19 +986,30 @@ void FlowGraphCompiler::GenerateInlinedSetter(intptr_t offset) {
|
| // NOTE: If the entry code shape changes, ReturnAddressLocator in profiler.cc
|
| // needs to be updated to match.
|
| void FlowGraphCompiler::EmitFrameEntry() {
|
| + ASSERT(Assembler::EntryPointToPcMarkerOffset() == 0);
|
| +
|
| const Function& function = parsed_function().function();
|
| + const Register new_pp = R13;
|
| + const Register new_pc = R12;
|
| +
|
| + // Load PC marker.
|
| + const intptr_t kRIPRelativeLeaqSize = 7;
|
| + const intptr_t entry_to_rip_offset = __ CodeSize() + kRIPRelativeLeaqSize;
|
| + __ leaq(new_pc, Address::AddressRIPRelative(-entry_to_rip_offset));
|
| + ASSERT(__ CodeSize() == entry_to_rip_offset);
|
| +
|
| // Load pool pointer.
|
| + const intptr_t object_pool_pc_dist =
|
| + Instructions::HeaderSize() - Instructions::object_pool_offset();
|
| + __ movq(new_pp, Address(new_pc, -object_pool_pc_dist));
|
|
|
| if (flow_graph().IsCompiledForOsr()) {
|
| intptr_t extra_slots = StackSize()
|
| - flow_graph().num_stack_locals()
|
| - flow_graph().num_copied_params();
|
| ASSERT(extra_slots >= 0);
|
| - __ EnterOsrFrame(extra_slots * kWordSize);
|
| + __ EnterOsrFrame(extra_slots * kWordSize, new_pp, new_pc);
|
| } else {
|
| - const Register new_pp = R13;
|
| - __ LoadPoolPointer(new_pp);
|
| -
|
| if (CanOptimizeFunction() &&
|
| function.IsOptimizable() &&
|
| (!is_optimizing() || may_reoptimize())) {
|
| @@ -1001,6 +1017,9 @@ void FlowGraphCompiler::EmitFrameEntry() {
|
| // Load function object using the callee's pool pointer.
|
| __ LoadFunctionFromCalleePool(function_reg, function, new_pp);
|
|
|
| + // Patch point is after the eventually inlined function object.
|
| + entry_patch_pc_offset_ = assembler()->CodeSize();
|
| +
|
| // Reoptimization of an optimized function is triggered by counting in
|
| // IC stubs, but not at the entry of the function.
|
| if (!is_optimizing()) {
|
| @@ -1013,10 +1032,12 @@ void FlowGraphCompiler::EmitFrameEntry() {
|
| __ J(GREATER_EQUAL,
|
| *StubCode::OptimizeFunction_entry(),
|
| new_pp);
|
| + } else {
|
| + entry_patch_pc_offset_ = assembler()->CodeSize();
|
| }
|
| ASSERT(StackSize() >= 0);
|
| __ Comment("Enter frame");
|
| - __ EnterDartFrame(StackSize() * kWordSize, new_pp);
|
| + __ EnterDartFrame(StackSize() * kWordSize, new_pp, new_pc);
|
| }
|
| }
|
|
|
| @@ -1061,8 +1082,11 @@ void FlowGraphCompiler::CompileGraph() {
|
|
|
| __ Bind(&wrong_num_arguments);
|
| if (function.IsClosureFunction()) {
|
| - __ LeaveDartFrame(kKeepCalleePP); // Leave arguments on the stack.
|
| - __ Jmp(*StubCode::CallClosureNoSuchMethod_entry());
|
| + ASSERT(assembler()->constant_pool_allowed());
|
| + __ LeaveDartFrame(); // The arguments are still on the stack.
|
| + ASSERT(!assembler()->constant_pool_allowed());
|
| + __ jmp(*StubCode::CallClosureNoSuchMethod_entry());
|
| + __ set_constant_pool_allowed(true);
|
| // The noSuchMethod call may return to the caller, but not here.
|
| } else {
|
| __ Stop("Wrong number of arguments");
|
| @@ -1126,6 +1150,10 @@ void FlowGraphCompiler::CompileGraph() {
|
| GenerateDeferredCode();
|
| // Emit function patching code. This will be swapped with the first 13 bytes
|
| // at entry point.
|
| + patch_code_pc_offset_ = assembler()->CodeSize();
|
| + // This is patched up to a point in FrameEntry where the PP for the
|
| + // current function is in R13 instead of PP.
|
| + __ JmpPatchable(*StubCode::FixCallersTarget_entry(), R13);
|
|
|
| if (is_optimizing()) {
|
| lazy_deopt_pc_offset_ = assembler()->CodeSize();
|
|
|