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

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

Issue 6534022: Optimize functions needing a local context.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/x64/deoptimizer-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 const int kPageSize = 4 * KB; 156 const int kPageSize = 4 * KB;
157 for (int offset = slots * kPointerSize - kPageSize; 157 for (int offset = slots * kPointerSize - kPageSize;
158 offset > 0; 158 offset > 0;
159 offset -= kPageSize) { 159 offset -= kPageSize) {
160 __ mov(Operand(esp, offset), eax); 160 __ mov(Operand(esp, offset), eax);
161 } 161 }
162 #endif 162 #endif
163 } 163 }
164 } 164 }
165 165
166 // Possibly allocate a local context.
167 int heap_slots = scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
168 if (heap_slots > 0) {
169 Comment(";;; Allocate local context");
170 // Argument to NewContext is the function, which is still in edi.
171 __ push(edi);
172 if (heap_slots <= FastNewContextStub::kMaximumSlots) {
173 FastNewContextStub stub(heap_slots);
174 __ CallStub(&stub);
175 } else {
176 __ CallRuntime(Runtime::kNewContext, 1);
177 }
178 RecordSafepoint(Safepoint::kNoDeoptimizationIndex);
179 // Context is returned in both eax and esi. It replaces the context
180 // passed to us. It's saved in the stack and kept live in esi.
181 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), esi);
182
183 // Copy parameters into context if necessary.
184 int num_parameters = scope()->num_parameters();
185 for (int i = 0; i < num_parameters; i++) {
186 Slot* slot = scope()->parameter(i)->AsSlot();
187 if (slot != NULL && slot->type() == Slot::CONTEXT) {
188 int parameter_offset = StandardFrameConstants::kCallerSPOffset +
189 (num_parameters - 1 - i) * kPointerSize;
190 // Load parameter from stack.
191 __ mov(eax, Operand(ebp, parameter_offset));
192 // Store it in the context.
193 int context_offset = Context::SlotOffset(slot->index());
194 __ mov(Operand(esi, context_offset), eax);
195 // Update the write barrier. This clobbers all involved
196 // registers, so we have to use a third register to avoid
197 // clobbering esi.
198 __ mov(ecx, esi);
199 __ RecordWrite(ecx, context_offset, eax, ebx);
200 }
201 }
202 Comment(";;; End allocate local context");
203 }
204
166 // Trace the call. 205 // Trace the call.
167 if (FLAG_trace) { 206 if (FLAG_trace) {
168 // We have not executed any compiled code yet, so esi still holds the 207 // We have not executed any compiled code yet, so esi still holds the
169 // incoming context. 208 // incoming context.
170 __ CallRuntime(Runtime::kTraceEnter, 0); 209 __ CallRuntime(Runtime::kTraceEnter, 0);
171 } 210 }
172 return !is_aborted(); 211 return !is_aborted();
173 } 212 }
174 213
175 214
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 } 627 }
589 } 628 }
590 629
591 630
592 void LCodeGen::RecordSafepoint(LPointerMap* pointers, 631 void LCodeGen::RecordSafepoint(LPointerMap* pointers,
593 int deoptimization_index) { 632 int deoptimization_index) {
594 RecordSafepoint(pointers, Safepoint::kSimple, 0, deoptimization_index); 633 RecordSafepoint(pointers, Safepoint::kSimple, 0, deoptimization_index);
595 } 634 }
596 635
597 636
637 void LCodeGen::RecordSafepoint(int deoptimization_index) {
638 LPointerMap empty_pointers(RelocInfo::kNoPosition);
639 RecordSafepoint(&empty_pointers, deoptimization_index);
640 }
641
642
598 void LCodeGen::RecordSafepointWithRegisters(LPointerMap* pointers, 643 void LCodeGen::RecordSafepointWithRegisters(LPointerMap* pointers,
599 int arguments, 644 int arguments,
600 int deoptimization_index) { 645 int deoptimization_index) {
601 RecordSafepoint(pointers, Safepoint::kWithRegisters, arguments, 646 RecordSafepoint(pointers, Safepoint::kWithRegisters, arguments,
602 deoptimization_index); 647 deoptimization_index);
603 } 648 }
604 649
605 650
606 void LCodeGen::RecordPosition(int position) { 651 void LCodeGen::RecordPosition(int position) {
607 if (!FLAG_debug_info || position == RelocInfo::kNoPosition) return; 652 if (!FLAG_debug_info || position == RelocInfo::kNoPosition) return;
(...skipping 3192 matching lines...) Expand 10 before | Expand all | Expand 10 after
3800 ASSERT(osr_pc_offset_ == -1); 3845 ASSERT(osr_pc_offset_ == -1);
3801 osr_pc_offset_ = masm()->pc_offset(); 3846 osr_pc_offset_ = masm()->pc_offset();
3802 } 3847 }
3803 3848
3804 3849
3805 #undef __ 3850 #undef __
3806 3851
3807 } } // namespace v8::internal 3852 } } // namespace v8::internal
3808 3853
3809 #endif // V8_TARGET_ARCH_IA32 3854 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/x64/deoptimizer-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698