| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 Operand LCodeGen::ToOperand(LOperand* op) const { | 470 Operand LCodeGen::ToOperand(LOperand* op) const { |
| 471 // Does not handle registers. In X64 assembler, plain registers are not | 471 // Does not handle registers. In X64 assembler, plain registers are not |
| 472 // representable as an Operand. | 472 // representable as an Operand. |
| 473 ASSERT(op->IsStackSlot() || op->IsDoubleStackSlot()); | 473 ASSERT(op->IsStackSlot() || op->IsDoubleStackSlot()); |
| 474 return Operand(rbp, StackSlotOffset(op->index())); | 474 return Operand(rbp, StackSlotOffset(op->index())); |
| 475 } | 475 } |
| 476 | 476 |
| 477 | 477 |
| 478 void LCodeGen::WriteTranslation(LEnvironment* environment, | 478 void LCodeGen::WriteTranslation(LEnvironment* environment, |
| 479 Translation* translation, | 479 Translation* translation, |
| 480 int* arguments_index, | 480 int* pushed_arguments_index, |
| 481 int* arguments_count) { | 481 int* pushed_arguments_count) { |
| 482 if (environment == NULL) return; | 482 if (environment == NULL) return; |
| 483 | 483 |
| 484 // The translation includes one command per value in the environment. | 484 // The translation includes one command per value in the environment. |
| 485 int translation_size = environment->values()->length(); | 485 int translation_size = environment->values()->length(); |
| 486 // The output frame height does not include the parameters. | 486 // The output frame height does not include the parameters. |
| 487 int height = translation_size - environment->parameter_count(); | 487 int height = translation_size - environment->parameter_count(); |
| 488 | 488 |
| 489 // Function parameters are arguments to the outermost environment. The | 489 // Function parameters are arguments to the outermost environment. The |
| 490 // arguments index points to the first element of a sequence of tagged | 490 // arguments index points to the first element of a sequence of tagged |
| 491 // values on the stack that represent the arguments. This needs to be | 491 // values on the stack that represent the arguments. This needs to be |
| 492 // kept in sync with the LArgumentsElements implementation. | 492 // kept in sync with the LArgumentsElements implementation. |
| 493 *arguments_index = -environment->parameter_count(); | 493 *pushed_arguments_index = -environment->parameter_count(); |
| 494 *arguments_count = environment->parameter_count(); | 494 *pushed_arguments_count = environment->parameter_count(); |
| 495 | 495 |
| 496 WriteTranslation(environment->outer(), | 496 WriteTranslation(environment->outer(), |
| 497 translation, | 497 translation, |
| 498 arguments_index, | 498 pushed_arguments_index, |
| 499 arguments_count); | 499 pushed_arguments_count); |
| 500 bool has_closure_id = !info()->closure().is_null() && | 500 bool has_closure_id = !info()->closure().is_null() && |
| 501 *info()->closure() != *environment->closure(); | 501 *info()->closure() != *environment->closure(); |
| 502 int closure_id = has_closure_id | 502 int closure_id = has_closure_id |
| 503 ? DefineDeoptimizationLiteral(environment->closure()) | 503 ? DefineDeoptimizationLiteral(environment->closure()) |
| 504 : Translation::kSelfLiteralId; | 504 : Translation::kSelfLiteralId; |
| 505 | 505 |
| 506 switch (environment->frame_type()) { | 506 switch (environment->frame_type()) { |
| 507 case JS_FUNCTION: | 507 case JS_FUNCTION: |
| 508 translation->BeginJSFrame(environment->ast_id(), closure_id, height); | 508 translation->BeginJSFrame(environment->ast_id(), closure_id, height); |
| 509 break; | 509 break; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 522 break; | 522 break; |
| 523 case ARGUMENTS_ADAPTOR: | 523 case ARGUMENTS_ADAPTOR: |
| 524 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); | 524 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); |
| 525 break; | 525 break; |
| 526 case STUB: | 526 case STUB: |
| 527 translation->BeginCompiledStubFrame(); | 527 translation->BeginCompiledStubFrame(); |
| 528 break; | 528 break; |
| 529 } | 529 } |
| 530 | 530 |
| 531 // Inlined frames which push their arguments cause the index to be | 531 // Inlined frames which push their arguments cause the index to be |
| 532 // bumped and a new stack area to be used for materialization. | 532 // bumped and another stack area to be used for materialization, |
| 533 if (environment->entry() != NULL && | 533 // otherwise actual argument values are unknown for inlined frames. |
| 534 environment->entry()->arguments_pushed()) { | 534 bool arguments_known = true; |
| 535 *arguments_index = *arguments_index < 0 | 535 int arguments_index = *pushed_arguments_index; |
| 536 ? GetStackSlotCount() | 536 int arguments_count = *pushed_arguments_count; |
| 537 : *arguments_index + *arguments_count; | 537 if (environment->entry() != NULL) { |
| 538 *arguments_count = environment->entry()->arguments_count() + 1; | 538 arguments_known = environment->entry()->arguments_pushed(); |
| 539 arguments_index = arguments_index < 0 |
| 540 ? GetStackSlotCount() : arguments_index + arguments_count; |
| 541 arguments_count = environment->entry()->arguments_count() + 1; |
| 542 if (environment->entry()->arguments_pushed()) { |
| 543 *pushed_arguments_index = arguments_index; |
| 544 *pushed_arguments_count = arguments_count; |
| 545 } |
| 539 } | 546 } |
| 540 | 547 |
| 541 for (int i = 0; i < translation_size; ++i) { | 548 for (int i = 0; i < translation_size; ++i) { |
| 542 LOperand* value = environment->values()->at(i); | 549 LOperand* value = environment->values()->at(i); |
| 543 // spilled_registers_ and spilled_double_registers_ are either | 550 // spilled_registers_ and spilled_double_registers_ are either |
| 544 // both NULL or both set. | 551 // both NULL or both set. |
| 545 if (environment->spilled_registers() != NULL && value != NULL) { | 552 if (environment->spilled_registers() != NULL && value != NULL) { |
| 546 if (value->IsRegister() && | 553 if (value->IsRegister() && |
| 547 environment->spilled_registers()[value->index()] != NULL) { | 554 environment->spilled_registers()[value->index()] != NULL) { |
| 548 translation->MarkDuplicate(); | 555 translation->MarkDuplicate(); |
| 549 AddToTranslation(translation, | 556 AddToTranslation(translation, |
| 550 environment->spilled_registers()[value->index()], | 557 environment->spilled_registers()[value->index()], |
| 551 environment->HasTaggedValueAt(i), | 558 environment->HasTaggedValueAt(i), |
| 552 environment->HasUint32ValueAt(i), | 559 environment->HasUint32ValueAt(i), |
| 553 *arguments_index, | 560 arguments_known, |
| 554 *arguments_count); | 561 arguments_index, |
| 562 arguments_count); |
| 555 } else if ( | 563 } else if ( |
| 556 value->IsDoubleRegister() && | 564 value->IsDoubleRegister() && |
| 557 environment->spilled_double_registers()[value->index()] != NULL) { | 565 environment->spilled_double_registers()[value->index()] != NULL) { |
| 558 translation->MarkDuplicate(); | 566 translation->MarkDuplicate(); |
| 559 AddToTranslation( | 567 AddToTranslation( |
| 560 translation, | 568 translation, |
| 561 environment->spilled_double_registers()[value->index()], | 569 environment->spilled_double_registers()[value->index()], |
| 562 false, | 570 false, |
| 563 false, | 571 false, |
| 564 *arguments_index, | 572 arguments_known, |
| 565 *arguments_count); | 573 arguments_index, |
| 574 arguments_count); |
| 566 } | 575 } |
| 567 } | 576 } |
| 568 | 577 |
| 569 AddToTranslation(translation, | 578 AddToTranslation(translation, |
| 570 value, | 579 value, |
| 571 environment->HasTaggedValueAt(i), | 580 environment->HasTaggedValueAt(i), |
| 572 environment->HasUint32ValueAt(i), | 581 environment->HasUint32ValueAt(i), |
| 573 *arguments_index, | 582 arguments_known, |
| 574 *arguments_count); | 583 arguments_index, |
| 584 arguments_count); |
| 575 } | 585 } |
| 576 } | 586 } |
| 577 | 587 |
| 578 | 588 |
| 579 void LCodeGen::AddToTranslation(Translation* translation, | 589 void LCodeGen::AddToTranslation(Translation* translation, |
| 580 LOperand* op, | 590 LOperand* op, |
| 581 bool is_tagged, | 591 bool is_tagged, |
| 582 bool is_uint32, | 592 bool is_uint32, |
| 593 bool arguments_known, |
| 583 int arguments_index, | 594 int arguments_index, |
| 584 int arguments_count) { | 595 int arguments_count) { |
| 585 if (op == NULL) { | 596 if (op == NULL) { |
| 586 // TODO(twuerthinger): Introduce marker operands to indicate that this value | 597 // TODO(twuerthinger): Introduce marker operands to indicate that this value |
| 587 // is not present and must be reconstructed from the deoptimizer. Currently | 598 // is not present and must be reconstructed from the deoptimizer. Currently |
| 588 // this is only used for the arguments object. | 599 // this is only used for the arguments object. |
| 589 translation->StoreArgumentsObject(arguments_index, arguments_count); | 600 translation->StoreArgumentsObject( |
| 601 arguments_known, arguments_index, arguments_count); |
| 590 } else if (op->IsStackSlot()) { | 602 } else if (op->IsStackSlot()) { |
| 591 if (is_tagged) { | 603 if (is_tagged) { |
| 592 translation->StoreStackSlot(op->index()); | 604 translation->StoreStackSlot(op->index()); |
| 593 } else if (is_uint32) { | 605 } else if (is_uint32) { |
| 594 translation->StoreUint32StackSlot(op->index()); | 606 translation->StoreUint32StackSlot(op->index()); |
| 595 } else { | 607 } else { |
| 596 translation->StoreInt32StackSlot(op->index()); | 608 translation->StoreInt32StackSlot(op->index()); |
| 597 } | 609 } |
| 598 } else if (op->IsDoubleStackSlot()) { | 610 } else if (op->IsDoubleStackSlot()) { |
| 599 translation->StoreDoubleStackSlot(op->index()); | 611 translation->StoreDoubleStackSlot(op->index()); |
| (...skipping 5185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5785 FixedArray::kHeaderSize - kPointerSize)); | 5797 FixedArray::kHeaderSize - kPointerSize)); |
| 5786 __ bind(&done); | 5798 __ bind(&done); |
| 5787 } | 5799 } |
| 5788 | 5800 |
| 5789 | 5801 |
| 5790 #undef __ | 5802 #undef __ |
| 5791 | 5803 |
| 5792 } } // namespace v8::internal | 5804 } } // namespace v8::internal |
| 5793 | 5805 |
| 5794 #endif // V8_TARGET_ARCH_X64 | 5806 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |