Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 // Take ownership of the entry frame. | 188 // Take ownership of the entry frame. |
| 189 cgen_->SetFrame(entry_frame_, &reserved); | 189 cgen_->SetFrame(entry_frame_, &reserved); |
| 190 entry_frame_ = NULL; | 190 entry_frame_ = NULL; |
| 191 } | 191 } |
| 192 __ bind(&entry_label_); | 192 __ bind(&entry_label_); |
| 193 is_linked_ = false; | 193 is_linked_ = false; |
| 194 is_bound_ = true; | 194 is_bound_ = true; |
| 195 return; | 195 return; |
| 196 } | 196 } |
| 197 | 197 |
| 198 if (direction_ == FORWARD_ONLY) { | 198 if (!is_linked()) { |
| 199 // A simple case: no forward jumps and no possible backward jumps. | 199 ASSERT(cgen_->has_valid_frame()); |
| 200 if (!is_linked()) { | 200 if (direction_ == FORWARD_ONLY) { |
| 201 // Fast case: no forward jumps and no possible backward jumps. | |
| 201 // The stack pointer can be floating above the top of the | 202 // The stack pointer can be floating above the top of the |
| 202 // virtual frame before the bind. Afterward, it should not. | 203 // virtual frame before the bind. Afterward, it should not. |
| 203 ASSERT(cgen_->has_valid_frame()); | |
| 204 VirtualFrame* frame = cgen_->frame(); | 204 VirtualFrame* frame = cgen_->frame(); |
| 205 int difference = | 205 int difference = |
| 206 frame->stack_pointer_ - (frame->elements_.length() - 1); | 206 frame->stack_pointer_ - (frame->elements_.length() - 1); |
| 207 if (difference > 0) { | 207 if (difference > 0) { |
| 208 frame->stack_pointer_ -= difference; | 208 frame->stack_pointer_ -= difference; |
| 209 __ add(Operand(esp), Immediate(difference * kPointerSize)); | 209 __ add(Operand(esp), Immediate(difference * kPointerSize)); |
| 210 } | 210 } |
| 211 | 211 |
| 212 is_bound_ = true; | 212 } else { |
| 213 return; | 213 ASSERT(direction_ == BIDIRECTIONAL); |
| 214 // Fast case: no forward jumps, possible backward ones. Remove | |
| 215 // constants and copies above the watermark on the fall-through | |
| 216 // frame and use it as the entry frame. | |
| 217 cgen_->frame()->MakeMergable(mergable_elements); | |
| 218 entry_frame_ = new VirtualFrame(cgen_->frame()); | |
| 219 __ bind(&entry_label_); | |
| 220 } | |
| 221 is_bound_ = true; | |
| 222 return; | |
| 223 } | |
| 224 | |
| 225 | |
|
Kasper Lund
2009/05/15 06:26:51
Too much spacing?
Kevin Millikin (Chromium)
2009/05/15 08:03:35
Done.
| |
| 226 if (direction_ == FORWARD_ONLY && | |
| 227 !cgen_->has_valid_frame() && | |
| 228 reaching_frames_.length() == 1) { | |
|
William Hesse
2009/05/15 07:45:51
Can't this case be reduced to the previous case (1
Kevin Millikin (Chromium)
2009/05/15 08:03:35
Of course. I planned on doing that as another cha
| |
| 229 // Fast case: no fall-through, a single forward jump, and no | |
| 230 // possible backward jumps. Pick up the only reaching frame, take | |
| 231 // ownership of it, and use it for the block about to be emitted. | |
| 232 VirtualFrame* frame = reaching_frames_[0]; | |
| 233 RegisterFile reserved = RegisterAllocator::Reserved(); | |
| 234 cgen_->SetFrame(frame, &reserved); | |
| 235 reaching_frames_[0] = NULL; | |
| 236 __ bind(&merge_labels_[0]); | |
| 237 | |
| 238 // The stack pointer can be floating above the top of the | |
| 239 // virtual frame before the bind. Afterward, it should not. | |
| 240 int difference = | |
| 241 frame->stack_pointer_ - (frame->elements_.length() - 1); | |
| 242 if (difference > 0) { | |
| 243 frame->stack_pointer_ -= difference; | |
| 244 __ add(Operand(esp), Immediate(difference * kPointerSize)); | |
| 214 } | 245 } |
| 215 | 246 |
| 216 // Another simple case: no fall through, a single forward jump, | 247 is_linked_ = false; |
| 217 // and no possible backward jumps. | 248 is_bound_ = true; |
| 218 if (!cgen_->has_valid_frame() && reaching_frames_.length() == 1) { | 249 return; |
| 219 // Pick up the only reaching frame, take ownership of it, and | |
| 220 // use it for the block about to be emitted. | |
| 221 VirtualFrame* frame = reaching_frames_[0]; | |
| 222 RegisterFile reserved = RegisterAllocator::Reserved(); | |
| 223 cgen_->SetFrame(frame, &reserved); | |
| 224 reaching_frames_[0] = NULL; | |
| 225 __ bind(&merge_labels_[0]); | |
| 226 | |
| 227 // The stack pointer can be floating above the top of the | |
| 228 // virtual frame before the bind. Afterward, it should not. | |
| 229 int difference = | |
| 230 frame->stack_pointer_ - (frame->elements_.length() - 1); | |
| 231 if (difference > 0) { | |
| 232 frame->stack_pointer_ -= difference; | |
| 233 __ add(Operand(esp), Immediate(difference * kPointerSize)); | |
| 234 } | |
| 235 | |
| 236 is_linked_ = false; | |
| 237 is_bound_ = true; | |
| 238 return; | |
| 239 } | |
| 240 } | 250 } |
| 241 | 251 |
| 242 // If there is a current frame, record it as the fall-through. It | 252 // If there is a current frame, record it as the fall-through. It |
| 243 // is owned by the reaching frames for now. | 253 // is owned by the reaching frames for now. |
| 244 bool had_fall_through = false; | 254 bool had_fall_through = false; |
| 245 if (cgen_->has_valid_frame()) { | 255 if (cgen_->has_valid_frame()) { |
| 246 had_fall_through = true; | 256 had_fall_through = true; |
| 247 AddReachingFrame(cgen_->frame()); // Return value ignored. | 257 AddReachingFrame(cgen_->frame()); // Return value ignored. |
| 248 RegisterFile empty; | 258 RegisterFile empty; |
| 249 cgen_->SetFrame(NULL, &empty); | 259 cgen_->SetFrame(NULL, &empty); |
| 250 } | 260 } |
| 251 | 261 |
| 252 // Compute the frame to use for entry to the block. | 262 // Compute the frame to use for entry to the block. |
| 253 if (entry_frame_ == NULL) { | 263 ComputeEntryFrame(mergable_elements); |
| 254 ComputeEntryFrame(mergable_elements); | |
| 255 } | |
| 256 | 264 |
| 257 // Some moves required to merge to an expected frame require purely | 265 // Some moves required to merge to an expected frame require purely |
| 258 // frame state changes, and do not require any code generation. | 266 // frame state changes, and do not require any code generation. |
| 259 // Perform those first to increase the possibility of finding equal | 267 // Perform those first to increase the possibility of finding equal |
| 260 // frames below. | 268 // frames below. |
| 261 for (int i = 0; i < reaching_frames_.length(); i++) { | 269 for (int i = 0; i < reaching_frames_.length(); i++) { |
| 262 if (reaching_frames_[i] != NULL) { | 270 if (reaching_frames_[i] != NULL) { |
| 263 reaching_frames_[i]->PrepareMergeTo(entry_frame_); | 271 reaching_frames_[i]->PrepareMergeTo(entry_frame_); |
| 264 } | 272 } |
| 265 } | 273 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 } | 373 } |
| 366 | 374 |
| 367 is_linked_ = false; | 375 is_linked_ = false; |
| 368 is_bound_ = true; | 376 is_bound_ = true; |
| 369 } | 377 } |
| 370 | 378 |
| 371 #undef __ | 379 #undef __ |
| 372 | 380 |
| 373 | 381 |
| 374 } } // namespace v8::internal | 382 } } // namespace v8::internal |
| OLD | NEW |