Chromium Code Reviews| Index: src/ia32/code-stubs-ia32.cc |
| diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc |
| index 0707234fccead5740e976665b36bfedb9c33a172..090957976abc21c3706a28840adade49ed9e2b61 100644 |
| --- a/src/ia32/code-stubs-ia32.cc |
| +++ b/src/ia32/code-stubs-ia32.cc |
| @@ -159,6 +159,61 @@ void FastNewContextStub::Generate(MacroAssembler* masm) { |
| } |
| +void FastNewBlockContextStub::Generate(MacroAssembler* masm) { |
| + // Stack layout on entry: |
| + // |
| + // [esp + (1 * kPointerSize)]: function |
| + // [esp + (2 * kPointerSize)]: serialized scope info |
| + |
| + // Try to allocate the context in new space. |
| + Label gc; |
| + int length = slots_ + Context::MIN_CONTEXT_SLOTS; |
| + __ AllocateInNewSpace(FixedArray::SizeFor(length), |
| + eax, ebx, ecx, &gc, TAG_OBJECT); |
| + |
| + // Get the function from the stack. |
| + __ mov(ecx, Operand(esp, 1 * kPointerSize)); |
| + |
| + // Get the serialized scope info from the stack. |
| + __ mov(ebx, Operand(esp, 2 * kPointerSize)); |
| + |
| + // Setup the object header. |
| + Factory* factory = masm->isolate()->factory(); |
| + __ mov(FieldOperand(eax, HeapObject::kMapOffset), |
| + factory->block_context_map()); |
| + __ mov(FieldOperand(eax, Context::kLengthOffset), |
| + Immediate(Smi::FromInt(length))); |
| + |
| + // Setup the fixed slots. |
| + __ mov(ContextOperand(eax, Context::CLOSURE_INDEX), ecx); |
| + __ mov(ContextOperand(eax, Context::PREVIOUS_INDEX), esi); |
| + __ mov(ContextOperand(eax, Context::EXTENSION_INDEX), ebx); |
| + |
| + // Copy the global object from the previous context. |
| + __ mov(ebx, ContextOperand(esi, Context::GLOBAL_INDEX)); |
| + __ mov(ContextOperand(eax, Context::GLOBAL_INDEX), ebx); |
| + |
| + // Initialize the rest of the slots to the hole value. |
| + if (slots_ == 1) { |
| + __ mov(ContextOperand(eax, Context::MIN_CONTEXT_SLOTS), |
| + factory->the_hole_value()); |
| + } else { |
| + __ mov(ebx, factory->the_hole_value()); |
| + for (int i = Context::MIN_CONTEXT_SLOTS; i < length; i++) { |
|
danno
2011/10/05 12:30:09
Maybe it's clearer to iterate from 0 to slots_ and
Steven
2011/10/05 15:40:03
Done.
|
| + __ mov(ContextOperand(eax, i), ebx); |
| + } |
| + } |
| + |
| + // Return and remove the on-stack parameters. |
| + __ mov(esi, Operand(eax)); |
|
danno
2011/10/05 12:30:09
just use eax, not Operand(eax)
Steven
2011/10/05 15:40:03
Done.
|
| + __ ret(2 * kPointerSize); |
| + |
| + // Need to collect. Call into runtime system. |
| + __ bind(&gc); |
| + __ TailCallRuntime(Runtime::kPushBlockContext, 2, 1); |
| +} |
| + |
| + |
| void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) { |
| // Stack layout on entry: |
| // |