OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 135 |
136 Scope* CodeGenerator::scope() { return info_->function()->scope(); } | 136 Scope* CodeGenerator::scope() { return info_->function()->scope(); } |
137 | 137 |
138 | 138 |
139 // Calling conventions: | 139 // Calling conventions: |
140 // fp: caller's frame pointer | 140 // fp: caller's frame pointer |
141 // sp: stack pointer | 141 // sp: stack pointer |
142 // r1: called JS function | 142 // r1: called JS function |
143 // cp: callee's context | 143 // cp: callee's context |
144 | 144 |
145 void CodeGenerator::Generate(CompilationInfo* info, Mode mode) { | 145 void CodeGenerator::Generate(CompilationInfo* info) { |
146 // Record the position for debugging purposes. | 146 // Record the position for debugging purposes. |
147 CodeForFunctionPosition(info->function()); | 147 CodeForFunctionPosition(info->function()); |
148 | 148 |
149 // Initialize state. | 149 // Initialize state. |
150 info_ = info; | 150 info_ = info; |
151 ASSERT(allocator_ == NULL); | 151 ASSERT(allocator_ == NULL); |
152 RegisterAllocator register_allocator(this); | 152 RegisterAllocator register_allocator(this); |
153 allocator_ = ®ister_allocator; | 153 allocator_ = ®ister_allocator; |
154 ASSERT(frame_ == NULL); | 154 ASSERT(frame_ == NULL); |
155 frame_ = new VirtualFrame(); | 155 frame_ = new VirtualFrame(); |
(...skipping 11 matching lines...) Expand all Loading... |
167 allocator_->Initialize(); | 167 allocator_->Initialize(); |
168 | 168 |
169 #ifdef DEBUG | 169 #ifdef DEBUG |
170 if (strlen(FLAG_stop_at) > 0 && | 170 if (strlen(FLAG_stop_at) > 0 && |
171 info->function()->name()->IsEqualTo(CStrVector(FLAG_stop_at))) { | 171 info->function()->name()->IsEqualTo(CStrVector(FLAG_stop_at))) { |
172 frame_->SpillAll(); | 172 frame_->SpillAll(); |
173 __ stop("stop-at"); | 173 __ stop("stop-at"); |
174 } | 174 } |
175 #endif | 175 #endif |
176 | 176 |
177 if (mode == PRIMARY) { | 177 if (info->mode() == CompilationInfo::PRIMARY) { |
178 frame_->Enter(); | 178 frame_->Enter(); |
179 // tos: code slot | 179 // tos: code slot |
180 | 180 |
181 // Allocate space for locals and initialize them. This also checks | 181 // Allocate space for locals and initialize them. This also checks |
182 // for stack overflow. | 182 // for stack overflow. |
183 frame_->AllocateStackSlots(); | 183 frame_->AllocateStackSlots(); |
184 | 184 |
185 VirtualFrame::SpilledScope spilled_scope; | 185 VirtualFrame::SpilledScope spilled_scope; |
186 int heap_slots = scope()->num_heap_slots(); | 186 int heap_slots = scope()->num_heap_slots(); |
187 if (heap_slots > 0) { | 187 if (heap_slots > 0) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 frame_->EmitPush(ip); | 270 frame_->EmitPush(ip); |
271 StoreToSlot(scope()->function()->slot(), NOT_CONST_INIT); | 271 StoreToSlot(scope()->function()->slot(), NOT_CONST_INIT); |
272 } | 272 } |
273 } else { | 273 } else { |
274 // When used as the secondary compiler for splitting, r1, cp, | 274 // When used as the secondary compiler for splitting, r1, cp, |
275 // fp, and lr have been pushed on the stack. Adjust the virtual | 275 // fp, and lr have been pushed on the stack. Adjust the virtual |
276 // frame to match this state. | 276 // frame to match this state. |
277 frame_->Adjust(4); | 277 frame_->Adjust(4); |
278 allocator_->Unuse(r1); | 278 allocator_->Unuse(r1); |
279 allocator_->Unuse(lr); | 279 allocator_->Unuse(lr); |
| 280 |
| 281 // Bind all the bailout labels to the beginning of the function. |
| 282 List<CompilationInfo::Bailout*>* bailouts = info->bailouts(); |
| 283 for (int i = 0; i < bailouts->length(); i++) { |
| 284 __ bind(bailouts->at(i)->label()); |
| 285 } |
280 } | 286 } |
281 | 287 |
282 // Initialize the function return target after the locals are set | 288 // Initialize the function return target after the locals are set |
283 // up, because it needs the expected frame height from the frame. | 289 // up, because it needs the expected frame height from the frame. |
284 function_return_.set_direction(JumpTarget::BIDIRECTIONAL); | 290 function_return_.set_direction(JumpTarget::BIDIRECTIONAL); |
285 function_return_is_shadowed_ = false; | 291 function_return_is_shadowed_ = false; |
286 | 292 |
287 // Generate code to 'execute' declarations and initialize functions | 293 // Generate code to 'execute' declarations and initialize functions |
288 // (source elements). In case of an illegal redeclaration we need to | 294 // (source elements). In case of an illegal redeclaration we need to |
289 // handle that instead of processing the declarations. | 295 // handle that instead of processing the declarations. |
(...skipping 7343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7633 | 7639 |
7634 // Just jump to runtime to add the two strings. | 7640 // Just jump to runtime to add the two strings. |
7635 __ bind(&string_add_runtime); | 7641 __ bind(&string_add_runtime); |
7636 __ TailCallRuntime(ExternalReference(Runtime::kStringAdd), 2, 1); | 7642 __ TailCallRuntime(ExternalReference(Runtime::kStringAdd), 2, 1); |
7637 } | 7643 } |
7638 | 7644 |
7639 | 7645 |
7640 #undef __ | 7646 #undef __ |
7641 | 7647 |
7642 } } // namespace v8::internal | 7648 } } // namespace v8::internal |
OLD | NEW |