OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 destination->reaching_frames_.Rewind(0); | 316 destination->reaching_frames_.Rewind(0); |
317 destination->reaching_frames_.AddAll(reaching_frames_); | 317 destination->reaching_frames_.AddAll(reaching_frames_); |
318 destination->merge_labels_.Rewind(0); | 318 destination->merge_labels_.Rewind(0); |
319 destination->merge_labels_.AddAll(merge_labels_); | 319 destination->merge_labels_.AddAll(merge_labels_); |
320 destination->entry_frame_ = entry_frame_; | 320 destination->entry_frame_ = entry_frame_; |
321 destination->entry_label_ = entry_label_; | 321 destination->entry_label_ = entry_label_; |
322 destination->expected_height_ = expected_height_; | 322 destination->expected_height_ = expected_height_; |
323 } | 323 } |
324 | 324 |
325 | 325 |
326 void BreakTarget::Jump() { | |
327 ASSERT(cgen()->has_valid_frame()); | |
328 | |
329 // Drop leftover statement state from the frame before merging. | |
330 cgen()->frame()->ForgetElements(cgen()->frame()->height() - expected_height_); | |
331 DoJump(); | |
332 } | |
333 | |
334 | |
335 void BreakTarget::Jump(Result* arg) { | |
336 ASSERT(cgen()->has_valid_frame()); | |
337 | |
338 // Drop leftover statement state from the frame before merging. | |
339 cgen()->frame()->ForgetElements(cgen()->frame()->height() - expected_height_); | |
340 cgen()->frame()->Push(arg); | |
341 DoJump(); | |
342 } | |
343 | |
344 | |
345 void BreakTarget::Branch(Condition cc, Hint hint) { | 326 void BreakTarget::Branch(Condition cc, Hint hint) { |
346 ASSERT(cgen()->has_valid_frame()); | 327 ASSERT(cgen()->has_valid_frame()); |
347 | 328 |
348 int count = cgen()->frame()->height() - expected_height_; | 329 int count = cgen()->frame()->height() - expected_height_; |
349 if (count > 0) { | 330 if (count > 0) { |
350 // We negate and branch here rather than using DoBranch's negate | 331 // We negate and branch here rather than using DoBranch's negate |
351 // and branch. This gives us a hook to remove statement state | 332 // and branch. This gives us a hook to remove statement state |
352 // from the frame. | 333 // from the frame. |
353 JumpTarget fall_through; | 334 JumpTarget fall_through; |
354 // Branch to fall through will not negate, because it is a | 335 // Branch to fall through will not negate, because it is a |
355 // forward-only target. | 336 // forward-only target. |
356 fall_through.Branch(NegateCondition(cc), NegateHint(hint)); | 337 fall_through.Branch(NegateCondition(cc), NegateHint(hint)); |
357 Jump(); // May emit merge code here. | 338 Jump(); // May emit merge code here. |
358 fall_through.Bind(); | 339 fall_through.Bind(); |
359 } else { | 340 } else { |
360 DoBranch(cc, hint); | 341 DoBranch(cc, hint); |
361 } | 342 } |
362 } | 343 } |
363 | 344 |
364 | 345 |
365 void BreakTarget::Bind() { | |
366 #ifdef DEBUG | |
367 // All the forward-reaching frames should have been adjusted at the | |
368 // jumps to this target. | |
369 for (int i = 0; i < reaching_frames_.length(); i++) { | |
370 ASSERT(reaching_frames_[i] == NULL || | |
371 reaching_frames_[i]->height() == expected_height_); | |
372 } | |
373 #endif | |
374 // Drop leftover statement state from the frame before merging, even | |
375 // on the fall through. This is so we can bind the return target | |
376 // with state on the frame. | |
377 if (cgen()->has_valid_frame()) { | |
378 int count = cgen()->frame()->height() - expected_height_; | |
379 cgen()->frame()->ForgetElements(count); | |
380 } | |
381 DoBind(); | |
382 } | |
383 | |
384 | |
385 void BreakTarget::Bind(Result* arg) { | |
386 #ifdef DEBUG | |
387 // All the forward-reaching frames should have been adjusted at the | |
388 // jumps to this target. | |
389 for (int i = 0; i < reaching_frames_.length(); i++) { | |
390 ASSERT(reaching_frames_[i] == NULL || | |
391 reaching_frames_[i]->height() == expected_height_ + 1); | |
392 } | |
393 #endif | |
394 // Drop leftover statement state from the frame before merging, even | |
395 // on the fall through. This is so we can bind the return target | |
396 // with state on the frame. | |
397 if (cgen()->has_valid_frame()) { | |
398 int count = cgen()->frame()->height() - expected_height_; | |
399 cgen()->frame()->ForgetElements(count); | |
400 cgen()->frame()->Push(arg); | |
401 } | |
402 DoBind(); | |
403 *arg = cgen()->frame()->Pop(); | |
404 } | |
405 | |
406 | |
407 // ------------------------------------------------------------------------- | 346 // ------------------------------------------------------------------------- |
408 // ShadowTarget implementation. | 347 // ShadowTarget implementation. |
409 | 348 |
410 ShadowTarget::ShadowTarget(BreakTarget* shadowed) { | 349 ShadowTarget::ShadowTarget(BreakTarget* shadowed) { |
411 ASSERT(shadowed != NULL); | 350 ASSERT(shadowed != NULL); |
412 other_target_ = shadowed; | 351 other_target_ = shadowed; |
413 | 352 |
414 #ifdef DEBUG | 353 #ifdef DEBUG |
415 is_shadowing_ = true; | 354 is_shadowing_ = true; |
416 #endif | 355 #endif |
(...skipping 18 matching lines...) Expand all Loading... |
435 temp.CopyTo(this); | 374 temp.CopyTo(this); |
436 temp.Unuse(); | 375 temp.Unuse(); |
437 | 376 |
438 #ifdef DEBUG | 377 #ifdef DEBUG |
439 is_shadowing_ = false; | 378 is_shadowing_ = false; |
440 #endif | 379 #endif |
441 } | 380 } |
442 | 381 |
443 | 382 |
444 } } // namespace v8::internal | 383 } } // namespace v8::internal |
OLD | NEW |