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

Side by Side Diff: be2/src/ia32/codegen-ia32.cc

Issue 507035: Enable fast allocation of context objects on IA-32. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « be2/src/codegen.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 frame_->Enter(); 167 frame_->Enter();
168 168
169 // Allocate space for locals and initialize them. 169 // Allocate space for locals and initialize them.
170 frame_->AllocateStackSlots(); 170 frame_->AllocateStackSlots();
171 // Initialize the function return target after the locals are set 171 // Initialize the function return target after the locals are set
172 // up, because it needs the expected frame height from the frame. 172 // up, because it needs the expected frame height from the frame.
173 function_return_.set_direction(JumpTarget::BIDIRECTIONAL); 173 function_return_.set_direction(JumpTarget::BIDIRECTIONAL);
174 function_return_is_shadowed_ = false; 174 function_return_is_shadowed_ = false;
175 175
176 // Allocate the local context if needed. 176 // Allocate the local context if needed.
177 if (scope_->num_heap_slots() > 0) { 177 int heap_slots = scope_->num_heap_slots();
178 if (heap_slots > 0) {
178 Comment cmnt(masm_, "[ allocate local context"); 179 Comment cmnt(masm_, "[ allocate local context");
179 // Allocate local context. 180 // Allocate local context.
180 // Get outer context and create a new context based on it. 181 // Get outer context and create a new context based on it.
181 frame_->PushFunction(); 182 frame_->PushFunction();
182 Result context = frame_->CallRuntime(Runtime::kNewContext, 1); 183 Result context;
184 if (heap_slots <= FastNewContextStub::kMaximumSlots) {
185 FastNewContextStub stub(heap_slots);
186 context = frame_->CallStub(&stub, 1);
187 } else {
188 context = frame_->CallRuntime(Runtime::kNewContext, 1);
189 }
183 190
184 // Update context local. 191 // Update context local.
185 frame_->SaveContextRegister(); 192 frame_->SaveContextRegister();
186 193
187 // Verify that the runtime call result and esi agree. 194 // Verify that the runtime call result and esi agree.
188 if (FLAG_debug_code) { 195 if (FLAG_debug_code) {
189 __ cmp(context.reg(), Operand(esi)); 196 __ cmp(context.reg(), Operand(esi));
190 __ Assert(equal, "Runtime::NewContext should end up in esi"); 197 __ Assert(equal, "Runtime::NewContext should end up in esi");
191 } 198 }
192 } 199 }
(...skipping 6390 matching lines...) Expand 10 before | Expand all | Expand 10 after
6583 __ bind(&gc); 6590 __ bind(&gc);
6584 __ pop(ecx); // Temporarily remove return address. 6591 __ pop(ecx); // Temporarily remove return address.
6585 __ pop(edx); 6592 __ pop(edx);
6586 __ push(esi); 6593 __ push(esi);
6587 __ push(edx); 6594 __ push(edx);
6588 __ push(ecx); // Restore return address. 6595 __ push(ecx); // Restore return address.
6589 __ TailCallRuntime(ExternalReference(Runtime::kNewClosure), 2, 1); 6596 __ TailCallRuntime(ExternalReference(Runtime::kNewClosure), 2, 1);
6590 } 6597 }
6591 6598
6592 6599
6600 void FastNewContextStub::Generate(MacroAssembler* masm) {
6601 // Try to allocate the context in new space.
6602 Label gc;
6603 int length = slots_ + Context::MIN_CONTEXT_SLOTS;
6604 __ AllocateInNewSpace((length * kPointerSize) + FixedArray::kHeaderSize,
6605 eax, ebx, ecx, &gc, TAG_OBJECT);
6606
6607 // Get the function from the stack.
6608 __ mov(ecx, Operand(esp, 1 * kPointerSize));
6609
6610 // Setup the object header.
6611 __ mov(FieldOperand(eax, HeapObject::kMapOffset), Factory::context_map());
6612 __ mov(FieldOperand(eax, Array::kLengthOffset), Immediate(length));
6613
6614 // Setup the fixed slots.
6615 __ xor_(ebx, Operand(ebx)); // Set to NULL.
6616 __ mov(Operand(eax, Context::SlotOffset(Context::CLOSURE_INDEX)), ecx);
6617 __ mov(Operand(eax, Context::SlotOffset(Context::FCONTEXT_INDEX)), eax);
6618 __ mov(Operand(eax, Context::SlotOffset(Context::PREVIOUS_INDEX)), ebx);
6619 __ mov(Operand(eax, Context::SlotOffset(Context::EXTENSION_INDEX)), ebx);
6620
6621 // Copy the global object from the surrounding context.
6622 __ mov(ebx, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX)));
6623 __ mov(Operand(eax, Context::SlotOffset(Context::GLOBAL_INDEX)), ebx);
6624
6625 // Initialize the rest of the slots to undefined.
6626 __ mov(ebx, Factory::undefined_value());
6627 for (int i = Context::MIN_CONTEXT_SLOTS; i < length; i++) {
6628 __ mov(Operand(eax, Context::SlotOffset(i)), ebx);
6629 }
6630
6631 // Return and remove the on-stack parameter.
6632 __ mov(esi, Operand(eax));
6633 __ ret(1 * kPointerSize);
6634
6635 // Need to collect. Call into runtime system.
6636 __ bind(&gc);
6637 __ TailCallRuntime(ExternalReference(Runtime::kNewContext), 1, 1);
6638 }
6639
6640
6593 // NOTE: The stub does not handle the inlined cases (Smis, Booleans, undefined). 6641 // NOTE: The stub does not handle the inlined cases (Smis, Booleans, undefined).
6594 void ToBooleanStub::Generate(MacroAssembler* masm) { 6642 void ToBooleanStub::Generate(MacroAssembler* masm) {
6595 Label false_result, true_result, not_string; 6643 Label false_result, true_result, not_string;
6596 __ mov(eax, Operand(esp, 1 * kPointerSize)); 6644 __ mov(eax, Operand(esp, 1 * kPointerSize));
6597 6645
6598 // 'null' => false. 6646 // 'null' => false.
6599 __ cmp(eax, Factory::null_value()); 6647 __ cmp(eax, Factory::null_value());
6600 __ j(equal, &false_result); 6648 __ j(equal, &false_result);
6601 6649
6602 // Get the map and type of the heap object. 6650 // Get the map and type of the heap object.
(...skipping 1908 matching lines...) Expand 10 before | Expand all | Expand 10 after
8511 __ add(Operand(dest), Immediate(2)); 8559 __ add(Operand(dest), Immediate(2));
8512 } 8560 }
8513 __ sub(Operand(count), Immediate(1)); 8561 __ sub(Operand(count), Immediate(1));
8514 __ j(not_zero, &loop); 8562 __ j(not_zero, &loop);
8515 } 8563 }
8516 8564
8517 8565
8518 #undef __ 8566 #undef __
8519 8567
8520 } } // namespace v8::internal 8568 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « be2/src/codegen.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698