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