Chromium Code Reviews| Index: vm/flow_graph_compiler_x64.cc |
| =================================================================== |
| --- vm/flow_graph_compiler_x64.cc (revision 7576) |
| +++ vm/flow_graph_compiler_x64.cc (working copy) |
| @@ -664,7 +664,8 @@ |
| if (!comp->has_optional_parameters()) { |
| __ leaq(RAX, Address(RBP, (1 + comp->argument_count()) * kWordSize)); |
| } else { |
| - __ leaq(RAX, Address(RBP, -1 * kWordSize)); |
| + __ leaq(RAX, |
| + Address(RBP, ParsedFunction::kFirstStackSlotIndex * kWordSize)); |
| } |
| __ movq(RBX, Immediate(reinterpret_cast<uword>(comp->native_c_function()))); |
| __ movq(R10, Immediate(comp->argument_count())); |
| @@ -1137,11 +1138,8 @@ |
| // popping arguments has not been run. |
| const intptr_t locals_space_size = StackSize() * kWordSize; |
| ASSERT(locals_space_size >= 0); |
| - if (locals_space_size == 0) { |
| - __ movq(RSP, RBP); |
| - } else { |
| - __ leaq(RSP, Address(RBP, -locals_space_size)); |
| - } |
| + intptr_t offset_size = -locals_space_size + kLocalsOffsetFromFP; |
| + __ leaq(RSP, Address(RBP, offset_size)); |
| ASSERT(!comp->exception_var().is_captured()); |
| ASSERT(!comp->stacktrace_var().is_captured()); |
| @@ -1332,11 +1330,13 @@ |
| LocalScope* scope = parsed_function_.node_sequence()->scope(); |
| const int num_fixed_params = function.num_fixed_parameters(); |
| const int num_opt_params = function.num_optional_parameters(); |
| - ASSERT(parsed_function_.first_parameter_index() == -1); |
| + ASSERT(parsed_function_.first_parameter_index() == |
| + ParsedFunction::kFirstStackSlotIndex); |
| // Copy positional arguments. |
| // Check that no fewer than num_fixed_params positional arguments are passed |
| // in and that no more than num_params arguments are passed in. |
| - // Passed argument i at fp[1 + argc - i] copied to fp[-1 - i]. |
| + // Passed argument i at fp[1 + argc - i] |
| + // copied to fp[ParsedFunction::kFirstStackSlotIndex - i]. |
| const int num_params = num_fixed_params + num_opt_params; |
| // Total number of args is the first Smi in args descriptor array (R10). |
| @@ -1356,11 +1356,14 @@ |
| __ subq(RBX, RCX); |
| __ leaq(RBX, Address(RBP, RBX, TIMES_4, 2 * kWordSize)); |
| // Let RDI point to the last copied positional argument, i.e. to |
| - // fp[-1 - (num_pos_args - 1)]. |
| + // fp[ParsedFunction::kFirstStackSlotIndex - (num_pos_args - 1)]. |
| __ SmiUntag(RCX); |
| __ movq(RAX, RCX); |
| __ negq(RAX); |
| - __ leaq(RDI, Address(RBP, RAX, TIMES_8, 0)); |
| + int index = ParsedFunction::kFirstStackSlotIndex + 1; |
|
regis
2012/05/14 17:33:10
const
siva
2012/05/15 23:52:39
Done.
|
| + // -num_pos_args is in RAX. |
| + // (ParsedFunction::kFirstStackSlotIndex + 1) is in index. |
| + __ leaq(RDI, Address(RBP, RAX, TIMES_8, (index * kWordSize))); |
| Label loop, loop_condition; |
| __ jmp(&loop_condition, Assembler::kNearJump); |
| // We do not use the final allocation index of the variable here, i.e. |
| @@ -1432,11 +1435,12 @@ |
| param_pos - num_fixed_params)); |
| __ LoadObject(RAX, value); |
| __ Bind(&assign_optional_parameter); |
| - // Assign RAX to fp[-1 - param_pos]. |
| + // Assign RAX to fp[ParsedFunction::kFirstStackSlotIndex - param_pos]. |
| // We do not use the final allocation index of the variable here, i.e. |
| // scope->VariableAt(i)->index(), because captured variables still need |
| // to be copied to the context that is not yet allocated. |
| - const Address param_addr(RBP, (-1 - param_pos) * kWordSize); |
| + const Address param_addr( |
| + RBP, (ParsedFunction::kFirstStackSlotIndex - param_pos) * kWordSize); |
| __ movq(param_addr, RAX); |
| __ Bind(&next_parameter); |
| } |
| @@ -1450,6 +1454,12 @@ |
| __ j(EQUAL, &all_arguments_processed, Assembler::kNearJump); |
| __ Bind(&wrong_num_arguments); |
| + if (StackSize() != 0) { |
| + // We need to unwind the space we reserved for locals/copied parms etc. |
|
regis
2012/05/14 17:33:10
ditto
siva
2012/05/15 23:52:39
Yes, I incorporated your comment into the other CL
|
| + // as the NoSuchMethodFunction stub does not expect to see that area on |
| + // the stack. |
| + __ addq(RSP, Immediate(StackSize() * kWordSize)); |
| + } |
| if (function.IsClosureFunction()) { |
| GenerateCallRuntime(AstNode::kNoId, |
| 0, |
| @@ -1464,6 +1474,7 @@ |
| AstNode::kNoId, |
| kNumArgsChecked); |
| __ LoadObject(RBX, ic_data); |
| + // RBP - 8 : PC marker, allows easy identification of RawInstruction obj. |
| // RBP : points to previous frame pointer. |
| // RBP + 8 : points to return address. |
| // RBP + 16 : address of last argument (arg n-1). |
| @@ -1597,7 +1608,7 @@ |
| const int parameter_count = function.num_fixed_parameters(); |
| const int num_copied_params = parsed_function_.copied_parameter_count(); |
| const int local_count = parsed_function_.stack_local_count(); |
| - __ EnterFrame(StackSize() * kWordSize); |
| + AssemblerMacros::EnterDartFrame(assembler_, (StackSize() * kWordSize)); |
| // We check the number of passed arguments when we have to copy them due to |
| // the presence of optional named parameters. |