Chromium Code Reviews| Index: src/ia32/lithium-codegen-ia32.cc |
| =================================================================== |
| --- src/ia32/lithium-codegen-ia32.cc (revision 6838) |
| +++ src/ia32/lithium-codegen-ia32.cc (working copy) |
| @@ -137,6 +137,46 @@ |
| __ push(esi); // Callee's context. |
| __ push(edi); // Callee's JS function. |
| + // Possibly allocate a local context. |
| + int heap_slots = scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
|
Vyacheslav Egorov (Chromium)
2011/02/18 10:23:49
Drive by question: this code is basically shared w
rossberg
2011/02/21 16:40:42
According to Kevin, there unfortunately is no good
|
| + if (heap_slots > 0) { |
| + Comment(";;; Allocate local context"); |
| + // Argument to NewContext is the function, which is still in edi. |
| + __ push(edi); |
| + if (heap_slots <= FastNewContextStub::kMaximumSlots) { |
| + FastNewContextStub stub(heap_slots); |
| + __ CallStub(&stub); |
|
Mads Ager (chromium)
2011/02/17 15:49:07
Is there a reason for not using CallCode here whic
rossberg
2011/02/21 16:40:42
Yes: that function needs an explicit LInstruction,
|
| + } else { |
| + __ CallRuntime(Runtime::kNewContext, 1); |
|
Mads Ager (chromium)
2011/02/17 15:49:07
Ditto, is there a reason for not using CallRuntime
rossberg
2011/02/21 16:40:42
Same here.
|
| + } |
| + safepoints_.DefineSafepoint(masm(), Safepoint::kSimple, 0, |
|
Mads Ager (chromium)
2011/02/17 15:49:07
If you cannot use the function above, could you us
rossberg
2011/02/21 16:40:42
Same problem, we'd need an LPointerMap to use that
|
| + Safepoint::kNoDeoptimizationIndex); |
| + // Context is returned in both eax and esi. It replaces the context |
| + // passed to us. It's saved in the stack and kept live in esi. |
| + __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), esi); |
| + |
| + // Copy parameters into context if necessary. |
| + int num_parameters = scope()->num_parameters(); |
| + for (int i = 0; i < num_parameters; i++) { |
| + Slot* slot = scope()->parameter(i)->AsSlot(); |
| + if (slot != NULL && slot->type() == Slot::CONTEXT) { |
| + int parameter_offset = StandardFrameConstants::kCallerSPOffset + |
| + (num_parameters - 1 - i) * kPointerSize; |
| + // Load parameter from stack. |
| + __ mov(eax, Operand(ebp, parameter_offset)); |
| + // Store it in the context. |
| + int context_offset = Context::SlotOffset(slot->index()); |
| + __ mov(Operand(esi, context_offset), eax); |
| + // Update the write barrier. This clobbers all involved |
| + // registers, so we have use a third register to avoid |
|
Mads Ager (chromium)
2011/02/17 15:49:07
we have use -> we have to use
rossberg
2011/02/21 16:40:42
Done.
|
| + // clobbering esi. |
| + __ mov(ecx, esi); |
| + __ RecordWrite(ecx, context_offset, eax, ebx); |
| + } |
| + } |
| + Comment(";;; End allocate local context"); |
| + } |
| + |
| // Reserve space for the stack slots needed by the code. |
| int slots = StackSlotCount(); |
| if (slots > 0) { |