Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(609)

Side by Side Diff: src/arm/lithium-codegen-arm.cc

Issue 10908194: Fix arguments object materialization during deopt. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Ported to other architectures. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 return MemOperand(fp, -(index + 3) * kPointerSize + kPointerSize); 457 return MemOperand(fp, -(index + 3) * kPointerSize + kPointerSize);
458 } else { 458 } else {
459 // Incoming parameter. Skip the return address and the first word of 459 // Incoming parameter. Skip the return address and the first word of
460 // the double. 460 // the double.
461 return MemOperand(fp, -(index - 1) * kPointerSize + kPointerSize); 461 return MemOperand(fp, -(index - 1) * kPointerSize + kPointerSize);
462 } 462 }
463 } 463 }
464 464
465 465
466 void LCodeGen::WriteTranslation(LEnvironment* environment, 466 void LCodeGen::WriteTranslation(LEnvironment* environment,
467 Translation* translation) { 467 Translation* translation,
468 int* args_index,
Sven Panne 2012/09/12 07:14:22 Nit: args_foo => arguments_foo for consistency her
Michael Starzinger 2012/09/12 10:07:28 Done.
469 int* args_count) {
468 if (environment == NULL) return; 470 if (environment == NULL) return;
469 471
470 // The translation includes one command per value in the environment. 472 // The translation includes one command per value in the environment.
471 int translation_size = environment->values()->length(); 473 int translation_size = environment->values()->length();
472 // The output frame height does not include the parameters. 474 // The output frame height does not include the parameters.
473 int height = translation_size - environment->parameter_count(); 475 int height = translation_size - environment->parameter_count();
474 476
475 WriteTranslation(environment->outer(), translation); 477 // Function parameters are arguments to the outermost environment.
478 *args_index = -environment->parameter_count();
479 *args_count = environment->parameter_count();
480
481 WriteTranslation(environment->outer(), translation, args_index, args_count);
476 int closure_id = *info()->closure() != *environment->closure() 482 int closure_id = *info()->closure() != *environment->closure()
477 ? DefineDeoptimizationLiteral(environment->closure()) 483 ? DefineDeoptimizationLiteral(environment->closure())
478 : Translation::kSelfLiteralId; 484 : Translation::kSelfLiteralId;
479 485
480 switch (environment->frame_type()) { 486 switch (environment->frame_type()) {
481 case JS_FUNCTION: 487 case JS_FUNCTION:
482 translation->BeginJSFrame(environment->ast_id(), closure_id, height); 488 translation->BeginJSFrame(environment->ast_id(), closure_id, height);
483 break; 489 break;
484 case JS_CONSTRUCT: 490 case JS_CONSTRUCT:
485 translation->BeginConstructStubFrame(closure_id, translation_size); 491 translation->BeginConstructStubFrame(closure_id, translation_size);
486 break; 492 break;
487 case JS_GETTER: 493 case JS_GETTER:
488 ASSERT(translation_size == 1); 494 ASSERT(translation_size == 1);
489 ASSERT(height == 0); 495 ASSERT(height == 0);
490 translation->BeginGetterStubFrame(closure_id); 496 translation->BeginGetterStubFrame(closure_id);
491 break; 497 break;
492 case JS_SETTER: 498 case JS_SETTER:
493 ASSERT(translation_size == 2); 499 ASSERT(translation_size == 2);
494 ASSERT(height == 0); 500 ASSERT(height == 0);
495 translation->BeginSetterStubFrame(closure_id); 501 translation->BeginSetterStubFrame(closure_id);
496 break; 502 break;
497 case ARGUMENTS_ADAPTOR: 503 case ARGUMENTS_ADAPTOR:
498 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); 504 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size);
499 break; 505 break;
500 } 506 }
507
508 // Inlined frames which push their arguments cause the index to be
509 // bumped and a new stack area to be used for materialization.
510 if (environment->entry() != NULL &&
511 environment->entry()->arguments_pushed()) {
512 bool outermost = *args_index < 0;
513 *args_index = outermost ? GetStackSlotCount() : *args_index + *args_count;
514 *args_count = environment->entry()->arguments_count() + 1;
515 }
516
501 for (int i = 0; i < translation_size; ++i) { 517 for (int i = 0; i < translation_size; ++i) {
502 LOperand* value = environment->values()->at(i); 518 LOperand* value = environment->values()->at(i);
503 // spilled_registers_ and spilled_double_registers_ are either 519 // spilled_registers_ and spilled_double_registers_ are either
504 // both NULL or both set. 520 // both NULL or both set.
505 if (environment->spilled_registers() != NULL && value != NULL) { 521 if (environment->spilled_registers() != NULL && value != NULL) {
506 if (value->IsRegister() && 522 if (value->IsRegister() &&
507 environment->spilled_registers()[value->index()] != NULL) { 523 environment->spilled_registers()[value->index()] != NULL) {
508 translation->MarkDuplicate(); 524 translation->MarkDuplicate();
509 AddToTranslation(translation, 525 AddToTranslation(translation,
510 environment->spilled_registers()[value->index()], 526 environment->spilled_registers()[value->index()],
511 environment->HasTaggedValueAt(i), 527 environment->HasTaggedValueAt(i),
512 environment->HasUint32ValueAt(i)); 528 environment->HasUint32ValueAt(i),
529 *args_index,
530 *args_count);
513 } else if ( 531 } else if (
514 value->IsDoubleRegister() && 532 value->IsDoubleRegister() &&
515 environment->spilled_double_registers()[value->index()] != NULL) { 533 environment->spilled_double_registers()[value->index()] != NULL) {
516 translation->MarkDuplicate(); 534 translation->MarkDuplicate();
517 AddToTranslation( 535 AddToTranslation(
518 translation, 536 translation,
519 environment->spilled_double_registers()[value->index()], 537 environment->spilled_double_registers()[value->index()],
520 false, 538 false,
521 false); 539 false,
540 *args_index,
541 *args_count);
522 } 542 }
523 } 543 }
524 544
525 AddToTranslation(translation, 545 AddToTranslation(translation,
526 value, 546 value,
527 environment->HasTaggedValueAt(i), 547 environment->HasTaggedValueAt(i),
528 environment->HasUint32ValueAt(i)); 548 environment->HasUint32ValueAt(i),
549 *args_index,
550 *args_count);
529 } 551 }
530 } 552 }
531 553
532 554
533 void LCodeGen::AddToTranslation(Translation* translation, 555 void LCodeGen::AddToTranslation(Translation* translation,
534 LOperand* op, 556 LOperand* op,
535 bool is_tagged, 557 bool is_tagged,
536 bool is_uint32) { 558 bool is_uint32,
559 int arguments_index,
560 int arguments_count) {
537 if (op == NULL) { 561 if (op == NULL) {
538 // TODO(twuerthinger): Introduce marker operands to indicate that this value 562 // TODO(twuerthinger): Introduce marker operands to indicate that this value
539 // is not present and must be reconstructed from the deoptimizer. Currently 563 // is not present and must be reconstructed from the deoptimizer. Currently
540 // this is only used for the arguments object. 564 // this is only used for the arguments object.
541 translation->StoreArgumentsObject(); 565 translation->StoreArgumentsObject(arguments_index, arguments_count);
542 } else if (op->IsStackSlot()) { 566 } else if (op->IsStackSlot()) {
543 if (is_tagged) { 567 if (is_tagged) {
544 translation->StoreStackSlot(op->index()); 568 translation->StoreStackSlot(op->index());
545 } else if (is_uint32) { 569 } else if (is_uint32) {
546 translation->StoreUint32StackSlot(op->index()); 570 translation->StoreUint32StackSlot(op->index());
547 } else { 571 } else {
548 translation->StoreInt32StackSlot(op->index()); 572 translation->StoreInt32StackSlot(op->index());
549 } 573 }
550 } else if (op->IsDoubleStackSlot()) { 574 } else if (op->IsDoubleStackSlot()) {
551 translation->StoreDoubleStackSlot(op->index()); 575 translation->StoreDoubleStackSlot(op->index());
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 // 0 ..................................................... size-1 661 // 0 ..................................................... size-1
638 // [parameters] [locals] [expression stack including arguments] 662 // [parameters] [locals] [expression stack including arguments]
639 663
640 // Layout of the translation: 664 // Layout of the translation:
641 // 0 ........................................................ size - 1 + 4 665 // 0 ........................................................ size - 1 + 4
642 // [expression stack including arguments] [locals] [4 words] [parameters] 666 // [expression stack including arguments] [locals] [4 words] [parameters]
643 // |>------------ translation_size ------------<| 667 // |>------------ translation_size ------------<|
644 668
645 int frame_count = 0; 669 int frame_count = 0;
646 int jsframe_count = 0; 670 int jsframe_count = 0;
671 int args_index = 0;
672 int args_count = 0;
647 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { 673 for (LEnvironment* e = environment; e != NULL; e = e->outer()) {
648 ++frame_count; 674 ++frame_count;
649 if (e->frame_type() == JS_FUNCTION) { 675 if (e->frame_type() == JS_FUNCTION) {
650 ++jsframe_count; 676 ++jsframe_count;
651 } 677 }
652 } 678 }
653 Translation translation(&translations_, frame_count, jsframe_count, 679 Translation translation(&translations_, frame_count, jsframe_count, zone());
654 zone()); 680 WriteTranslation(environment, &translation, &args_index, &args_count);
655 WriteTranslation(environment, &translation);
656 int deoptimization_index = deoptimizations_.length(); 681 int deoptimization_index = deoptimizations_.length();
657 int pc_offset = masm()->pc_offset(); 682 int pc_offset = masm()->pc_offset();
658 environment->Register(deoptimization_index, 683 environment->Register(deoptimization_index,
659 translation.index(), 684 translation.index(),
660 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); 685 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1);
661 deoptimizations_.Add(environment, zone()); 686 deoptimizations_.Add(environment, zone());
662 } 687 }
663 } 688 }
664 689
665 690
(...skipping 4952 matching lines...) Expand 10 before | Expand all | Expand 10 after
5618 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize)); 5643 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize));
5619 __ ldr(result, FieldMemOperand(scratch, 5644 __ ldr(result, FieldMemOperand(scratch,
5620 FixedArray::kHeaderSize - kPointerSize)); 5645 FixedArray::kHeaderSize - kPointerSize));
5621 __ bind(&done); 5646 __ bind(&done);
5622 } 5647 }
5623 5648
5624 5649
5625 #undef __ 5650 #undef __
5626 5651
5627 } } // namespace v8::internal 5652 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698