OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 return MemOperand(fp, -(index + 3) * kPointerSize + kPointerSize); | 425 return MemOperand(fp, -(index + 3) * kPointerSize + kPointerSize); |
426 } else { | 426 } else { |
427 // Incoming parameter. Skip the return address and the first word of | 427 // Incoming parameter. Skip the return address and the first word of |
428 // the double. | 428 // the double. |
429 return MemOperand(fp, -(index - 1) * kPointerSize + kPointerSize); | 429 return MemOperand(fp, -(index - 1) * kPointerSize + kPointerSize); |
430 } | 430 } |
431 } | 431 } |
432 | 432 |
433 | 433 |
434 void LCodeGen::WriteTranslation(LEnvironment* environment, | 434 void LCodeGen::WriteTranslation(LEnvironment* environment, |
435 Translation* translation, | 435 Translation* translation) { |
436 int* arguments_index, | |
437 int* arguments_count) { | |
438 if (environment == NULL) return; | 436 if (environment == NULL) return; |
439 | 437 |
440 // The translation includes one command per value in the environment. | 438 // The translation includes one command per value in the environment. |
441 int translation_size = environment->values()->length(); | 439 int translation_size = environment->values()->length(); |
442 // The output frame height does not include the parameters. | 440 // The output frame height does not include the parameters. |
443 int height = translation_size - environment->parameter_count(); | 441 int height = translation_size - environment->parameter_count(); |
444 | 442 |
445 // Function parameters are arguments to the outermost environment. The | 443 WriteTranslation(environment->outer(), translation); |
446 // arguments index points to the first element of a sequence of tagged | |
447 // values on the stack that represent the arguments. This needs to be | |
448 // kept in sync with the LArgumentsElements implementation. | |
449 *arguments_index = -environment->parameter_count(); | |
450 *arguments_count = environment->parameter_count(); | |
451 | |
452 WriteTranslation(environment->outer(), | |
453 translation, | |
454 arguments_index, | |
455 arguments_count); | |
456 int closure_id = *info()->closure() != *environment->closure() | 444 int closure_id = *info()->closure() != *environment->closure() |
457 ? DefineDeoptimizationLiteral(environment->closure()) | 445 ? DefineDeoptimizationLiteral(environment->closure()) |
458 : Translation::kSelfLiteralId; | 446 : Translation::kSelfLiteralId; |
459 | 447 |
460 switch (environment->frame_type()) { | 448 switch (environment->frame_type()) { |
461 case JS_FUNCTION: | 449 case JS_FUNCTION: |
462 translation->BeginJSFrame(environment->ast_id(), closure_id, height); | 450 translation->BeginJSFrame(environment->ast_id(), closure_id, height); |
463 break; | 451 break; |
464 case JS_CONSTRUCT: | 452 case JS_CONSTRUCT: |
465 translation->BeginConstructStubFrame(closure_id, translation_size); | 453 translation->BeginConstructStubFrame(closure_id, translation_size); |
466 break; | 454 break; |
467 case JS_GETTER: | 455 case JS_GETTER: |
468 ASSERT(translation_size == 1); | 456 ASSERT(translation_size == 1); |
469 ASSERT(height == 0); | 457 ASSERT(height == 0); |
470 translation->BeginGetterStubFrame(closure_id); | 458 translation->BeginGetterStubFrame(closure_id); |
471 break; | 459 break; |
472 case JS_SETTER: | 460 case JS_SETTER: |
473 ASSERT(translation_size == 2); | 461 ASSERT(translation_size == 2); |
474 ASSERT(height == 0); | 462 ASSERT(height == 0); |
475 translation->BeginSetterStubFrame(closure_id); | 463 translation->BeginSetterStubFrame(closure_id); |
476 break; | 464 break; |
477 case ARGUMENTS_ADAPTOR: | 465 case ARGUMENTS_ADAPTOR: |
478 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); | 466 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); |
479 break; | 467 break; |
480 } | 468 } |
481 | |
482 // Inlined frames which push their arguments cause the index to be | |
483 // bumped and a new stack area to be used for materialization. | |
484 if (environment->entry() != NULL && | |
485 environment->entry()->arguments_pushed()) { | |
486 *arguments_index = *arguments_index < 0 | |
487 ? GetStackSlotCount() | |
488 : *arguments_index + *arguments_count; | |
489 *arguments_count = environment->entry()->arguments_count() + 1; | |
490 } | |
491 | |
492 for (int i = 0; i < translation_size; ++i) { | 469 for (int i = 0; i < translation_size; ++i) { |
493 LOperand* value = environment->values()->at(i); | 470 LOperand* value = environment->values()->at(i); |
494 // spilled_registers_ and spilled_double_registers_ are either | 471 // spilled_registers_ and spilled_double_registers_ are either |
495 // both NULL or both set. | 472 // both NULL or both set. |
496 if (environment->spilled_registers() != NULL && value != NULL) { | 473 if (environment->spilled_registers() != NULL && value != NULL) { |
497 if (value->IsRegister() && | 474 if (value->IsRegister() && |
498 environment->spilled_registers()[value->index()] != NULL) { | 475 environment->spilled_registers()[value->index()] != NULL) { |
499 translation->MarkDuplicate(); | 476 translation->MarkDuplicate(); |
500 AddToTranslation(translation, | 477 AddToTranslation(translation, |
501 environment->spilled_registers()[value->index()], | 478 environment->spilled_registers()[value->index()], |
502 environment->HasTaggedValueAt(i), | 479 environment->HasTaggedValueAt(i), |
503 environment->HasUint32ValueAt(i), | 480 environment->HasUint32ValueAt(i)); |
504 *arguments_index, | |
505 *arguments_count); | |
506 } else if ( | 481 } else if ( |
507 value->IsDoubleRegister() && | 482 value->IsDoubleRegister() && |
508 environment->spilled_double_registers()[value->index()] != NULL) { | 483 environment->spilled_double_registers()[value->index()] != NULL) { |
509 translation->MarkDuplicate(); | 484 translation->MarkDuplicate(); |
510 AddToTranslation( | 485 AddToTranslation( |
511 translation, | 486 translation, |
512 environment->spilled_double_registers()[value->index()], | 487 environment->spilled_double_registers()[value->index()], |
513 false, | 488 false, |
514 false, | 489 false); |
515 *arguments_index, | |
516 *arguments_count); | |
517 } | 490 } |
518 } | 491 } |
519 | 492 |
520 AddToTranslation(translation, | 493 AddToTranslation(translation, |
521 value, | 494 value, |
522 environment->HasTaggedValueAt(i), | 495 environment->HasTaggedValueAt(i), |
523 environment->HasUint32ValueAt(i), | 496 environment->HasUint32ValueAt(i)); |
524 *arguments_index, | |
525 *arguments_count); | |
526 } | 497 } |
527 } | 498 } |
528 | 499 |
529 | 500 |
530 void LCodeGen::AddToTranslation(Translation* translation, | 501 void LCodeGen::AddToTranslation(Translation* translation, |
531 LOperand* op, | 502 LOperand* op, |
532 bool is_tagged, | 503 bool is_tagged, |
533 bool is_uint32, | 504 bool is_uint32) { |
534 int arguments_index, | |
535 int arguments_count) { | |
536 if (op == NULL) { | 505 if (op == NULL) { |
537 // TODO(twuerthinger): Introduce marker operands to indicate that this value | 506 // TODO(twuerthinger): Introduce marker operands to indicate that this value |
538 // is not present and must be reconstructed from the deoptimizer. Currently | 507 // is not present and must be reconstructed from the deoptimizer. Currently |
539 // this is only used for the arguments object. | 508 // this is only used for the arguments object. |
540 translation->StoreArgumentsObject(arguments_index, arguments_count); | 509 translation->StoreArgumentsObject(); |
541 } else if (op->IsStackSlot()) { | 510 } else if (op->IsStackSlot()) { |
542 if (is_tagged) { | 511 if (is_tagged) { |
543 translation->StoreStackSlot(op->index()); | 512 translation->StoreStackSlot(op->index()); |
544 } else if (is_uint32) { | 513 } else if (is_uint32) { |
545 translation->StoreUint32StackSlot(op->index()); | 514 translation->StoreUint32StackSlot(op->index()); |
546 } else { | 515 } else { |
547 translation->StoreInt32StackSlot(op->index()); | 516 translation->StoreInt32StackSlot(op->index()); |
548 } | 517 } |
549 } else if (op->IsDoubleStackSlot()) { | 518 } else if (op->IsDoubleStackSlot()) { |
550 translation->StoreDoubleStackSlot(op->index()); | 519 translation->StoreDoubleStackSlot(op->index()); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 // 0 ..................................................... size-1 | 595 // 0 ..................................................... size-1 |
627 // [parameters] [locals] [expression stack including arguments] | 596 // [parameters] [locals] [expression stack including arguments] |
628 | 597 |
629 // Layout of the translation: | 598 // Layout of the translation: |
630 // 0 ........................................................ size - 1 + 4 | 599 // 0 ........................................................ size - 1 + 4 |
631 // [expression stack including arguments] [locals] [4 words] [parameters] | 600 // [expression stack including arguments] [locals] [4 words] [parameters] |
632 // |>------------ translation_size ------------<| | 601 // |>------------ translation_size ------------<| |
633 | 602 |
634 int frame_count = 0; | 603 int frame_count = 0; |
635 int jsframe_count = 0; | 604 int jsframe_count = 0; |
636 int args_index = 0; | |
637 int args_count = 0; | |
638 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { | 605 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { |
639 ++frame_count; | 606 ++frame_count; |
640 if (e->frame_type() == JS_FUNCTION) { | 607 if (e->frame_type() == JS_FUNCTION) { |
641 ++jsframe_count; | 608 ++jsframe_count; |
642 } | 609 } |
643 } | 610 } |
644 Translation translation(&translations_, frame_count, jsframe_count, zone()); | 611 Translation translation(&translations_, frame_count, jsframe_count, zone()); |
645 WriteTranslation(environment, &translation, &args_index, &args_count); | 612 WriteTranslation(environment, &translation); |
646 int deoptimization_index = deoptimizations_.length(); | 613 int deoptimization_index = deoptimizations_.length(); |
647 int pc_offset = masm()->pc_offset(); | 614 int pc_offset = masm()->pc_offset(); |
648 environment->Register(deoptimization_index, | 615 environment->Register(deoptimization_index, |
649 translation.index(), | 616 translation.index(), |
650 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); | 617 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); |
651 deoptimizations_.Add(environment, zone()); | 618 deoptimizations_.Add(environment, zone()); |
652 } | 619 } |
653 } | 620 } |
654 | 621 |
655 | 622 |
(...skipping 4794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5450 __ Subu(scratch, result, scratch); | 5417 __ Subu(scratch, result, scratch); |
5451 __ lw(result, FieldMemOperand(scratch, | 5418 __ lw(result, FieldMemOperand(scratch, |
5452 FixedArray::kHeaderSize - kPointerSize)); | 5419 FixedArray::kHeaderSize - kPointerSize)); |
5453 __ bind(&done); | 5420 __ bind(&done); |
5454 } | 5421 } |
5455 | 5422 |
5456 | 5423 |
5457 #undef __ | 5424 #undef __ |
5458 | 5425 |
5459 } } // namespace v8::internal | 5426 } } // namespace v8::internal |
OLD | NEW |