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