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

Unified Diff: vm/code_generator_ia32.cc

Issue 10375059: Use a reserved stack local variable to store the Code object so that it can be looked up easily whe… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 7 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
Index: vm/code_generator_ia32.cc
===================================================================
--- vm/code_generator_ia32.cc (revision 7576)
+++ vm/code_generator_ia32.cc (working copy)
@@ -185,7 +185,6 @@
// implemented by the AST based code generation and 'code_generation_finished'
// is false.
if (!code_generation_finished) {
- GeneratePreEntryCode();
GenerateEntryCode();
if (FLAG_print_scopes) {
// Print the function scope (again) after generating the prologue in order
@@ -396,7 +395,7 @@
const int stack_slot_count =
num_copied_params + parsed_function_.stack_local_count();
set_locals_space_size(stack_slot_count * kWordSize);
- __ EnterFrame(locals_space_size());
+ AssemblerMacros::EnterDartFrame(assembler_, locals_space_size());
// 2. Optionally check if the number of arguments matches. We check the
// number of passed arguments when we have to copy them due to the
@@ -430,11 +429,13 @@
__ Bind(&argc_in_range);
}
} else {
- 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 (EDX).
@@ -454,8 +455,9 @@
__ subl(EBX, ECX);
__ leal(EBX, Address(EBP, EBX, TIMES_2, 2 * kWordSize));
// Let EDI point to the last copied positional argument, i.e. to
- // fp[-1 - (num_pos_args - 1)].
- __ movl(EDI, EBP);
+ // fp[ParsedFunction::kFirstStackSlotIndex - (num_pos_args - 1)].
+ int index = ParsedFunction::kFirstStackSlotIndex + 1;
regis 2012/05/14 17:33:10 const
siva 2012/05/15 23:52:39 Done.
+ __ leal(EDI, Address(EBP, (index * kWordSize)));
__ subl(EDI, ECX); // ECX is a Smi, subtract twice for TIMES_4 scaling.
__ subl(EDI, ECX);
__ SmiUntag(ECX);
@@ -530,11 +532,12 @@
param_pos - num_fixed_params));
__ LoadObject(EAX, value);
__ Bind(&assign_optional_parameter);
- // Assign EAX to fp[-1 - param_pos].
+ // Assign EAX 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(EBP, (-1 - param_pos) * kWordSize);
+ const Address param_addr(
+ EBP, (ParsedFunction::kFirstStackSlotIndex - param_pos) * kWordSize);
__ movl(param_addr, EAX);
__ Bind(&next_parameter);
}
@@ -546,6 +549,12 @@
__ j(EQUAL, &all_arguments_processed, Assembler::kNearJump);
__ Bind(&wrong_num_arguments);
+ if (locals_space_size() != 0) {
+ // We need to unwind the space we reserved for locals/copied parms etc.
regis 2012/05/14 17:33:10 I add a comment here when reviewing your other ove
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.
+ __ addl(ESP, Immediate(locals_space_size()));
+ }
if (function.IsClosureFunction()) {
GenerateCallRuntime(AstNode::kNoId,
0,
@@ -559,6 +568,7 @@
AstNode::kNoId,
kNumArgsChecked);
__ LoadObject(ECX, ic_data);
+ // EBP - 4 : PC marker, allows easy identification of RawInstruction obj.
// EBP : points to previous frame pointer.
// EBP + 4 : points to return address.
// EBP + 8 : address of last argument (arg n-1).
@@ -640,7 +650,7 @@
}
#ifdef DEBUG
// Check that the entry stack size matches the exit stack size.
- __ movl(EDX, EBP);
+ __ leal(EDX, Address(EBP, kLocalsOffsetFromFP));
__ subl(EDX, ESP);
ASSERT(locals_space_size() >= 0);
__ cmpl(EDX, Immediate(locals_space_size()));
@@ -875,8 +885,8 @@
Immediate(reinterpret_cast<intptr_t>(Object::null()));
const Function& function = parsed_function_.function();
const int num_params = function.NumberOfParameters();
- int param_frame_index =
- (num_params == function.num_fixed_parameters()) ? 1 + num_params : -1;
+ int param_frame_index = (num_params == function.num_fixed_parameters()) ?
+ (1 + num_params) : ParsedFunction::kFirstStackSlotIndex;
for (int pos = 0; pos < num_params; param_frame_index--, pos++) {
LocalVariable* parameter = scope->VariableAt(pos);
ASSERT(parameter->owner() == scope);
@@ -2787,7 +2797,8 @@
if (!node->has_optional_parameters()) {
__ leal(EAX, Address(EBP, (1 + node->argument_count()) * kWordSize));
} else {
- __ leal(EAX, Address(EBP, -1 * kWordSize));
+ __ leal(EAX,
+ Address(EBP, ParsedFunction::kFirstStackSlotIndex * kWordSize));
}
__ movl(ECX, Immediate(reinterpret_cast<uword>(node->native_c_function())));
__ movl(EDX, Immediate(node->argument_count()));
@@ -2810,11 +2821,8 @@
// Restore ESP from EBP as we are coming from a throw and the code for
// popping arguments has not been run.
ASSERT(locals_space_size() >= 0);
- if (locals_space_size() == 0) {
- __ movl(ESP, EBP);
- } else {
- __ leal(ESP, Address(EBP, -locals_space_size()));
- }
+ intptr_t offset_size = -locals_space_size() + kLocalsOffsetFromFP;
+ __ leal(ESP, Address(EBP, offset_size));
// The JumpToExceptionHandler trampoline code sets up
// - the exception object in EAX (kExceptionObjectReg)

Powered by Google App Engine
This is Rietveld 408576698