| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
| 8 | 8 |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 } | 611 } |
| 612 } | 612 } |
| 613 | 613 |
| 614 | 614 |
| 615 void LCodeGen::WriteTranslation(LEnvironment* environment, | 615 void LCodeGen::WriteTranslation(LEnvironment* environment, |
| 616 Translation* translation) { | 616 Translation* translation) { |
| 617 if (environment == NULL) return; | 617 if (environment == NULL) return; |
| 618 | 618 |
| 619 // The translation includes one command per value in the environment. | 619 // The translation includes one command per value in the environment. |
| 620 int translation_size = environment->translation_size(); | 620 int translation_size = environment->translation_size(); |
| 621 // The output frame height does not include the parameters. | |
| 622 int height = translation_size - environment->parameter_count(); | |
| 623 | 621 |
| 624 WriteTranslation(environment->outer(), translation); | 622 WriteTranslation(environment->outer(), translation); |
| 625 | 623 WriteTranslationFrame(environment, translation); |
| 626 switch (environment->frame_type()) { | |
| 627 case JS_FUNCTION: { | |
| 628 int shared_id = DefineDeoptimizationLiteral( | |
| 629 environment->entry() ? environment->entry()->shared() | |
| 630 : info()->shared_info()); | |
| 631 translation->BeginJSFrame(environment->ast_id(), shared_id, height); | |
| 632 if (info()->closure().is_identical_to(environment->closure())) { | |
| 633 translation->StoreJSFrameFunction(); | |
| 634 } else { | |
| 635 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 636 translation->StoreLiteral(closure_id); | |
| 637 } | |
| 638 break; | |
| 639 } | |
| 640 case JS_CONSTRUCT: { | |
| 641 int shared_id = DefineDeoptimizationLiteral( | |
| 642 environment->entry() ? environment->entry()->shared() | |
| 643 : info()->shared_info()); | |
| 644 translation->BeginConstructStubFrame(shared_id, translation_size); | |
| 645 if (info()->closure().is_identical_to(environment->closure())) { | |
| 646 translation->StoreJSFrameFunction(); | |
| 647 } else { | |
| 648 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 649 translation->StoreLiteral(closure_id); | |
| 650 } | |
| 651 break; | |
| 652 } | |
| 653 case JS_GETTER: { | |
| 654 DCHECK(translation_size == 1); | |
| 655 DCHECK(height == 0); | |
| 656 int shared_id = DefineDeoptimizationLiteral( | |
| 657 environment->entry() ? environment->entry()->shared() | |
| 658 : info()->shared_info()); | |
| 659 translation->BeginGetterStubFrame(shared_id); | |
| 660 if (info()->closure().is_identical_to(environment->closure())) { | |
| 661 translation->StoreJSFrameFunction(); | |
| 662 } else { | |
| 663 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 664 translation->StoreLiteral(closure_id); | |
| 665 } | |
| 666 break; | |
| 667 } | |
| 668 case JS_SETTER: { | |
| 669 DCHECK(translation_size == 2); | |
| 670 DCHECK(height == 0); | |
| 671 int shared_id = DefineDeoptimizationLiteral( | |
| 672 environment->entry() ? environment->entry()->shared() | |
| 673 : info()->shared_info()); | |
| 674 translation->BeginSetterStubFrame(shared_id); | |
| 675 if (info()->closure().is_identical_to(environment->closure())) { | |
| 676 translation->StoreJSFrameFunction(); | |
| 677 } else { | |
| 678 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 679 translation->StoreLiteral(closure_id); | |
| 680 } | |
| 681 break; | |
| 682 } | |
| 683 case ARGUMENTS_ADAPTOR: { | |
| 684 int shared_id = DefineDeoptimizationLiteral( | |
| 685 environment->entry() ? environment->entry()->shared() | |
| 686 : info()->shared_info()); | |
| 687 translation->BeginArgumentsAdaptorFrame(shared_id, translation_size); | |
| 688 if (info()->closure().is_identical_to(environment->closure())) { | |
| 689 translation->StoreJSFrameFunction(); | |
| 690 } else { | |
| 691 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 692 translation->StoreLiteral(closure_id); | |
| 693 } | |
| 694 break; | |
| 695 } | |
| 696 case STUB: | |
| 697 translation->BeginCompiledStubFrame(translation_size); | |
| 698 break; | |
| 699 } | |
| 700 | 624 |
| 701 int object_index = 0; | 625 int object_index = 0; |
| 702 int dematerialized_index = 0; | 626 int dematerialized_index = 0; |
| 703 for (int i = 0; i < translation_size; ++i) { | 627 for (int i = 0; i < translation_size; ++i) { |
| 704 LOperand* value = environment->values()->at(i); | 628 LOperand* value = environment->values()->at(i); |
| 705 AddToTranslation( | 629 AddToTranslation( |
| 706 environment, translation, value, environment->HasTaggedValueAt(i), | 630 environment, translation, value, environment->HasTaggedValueAt(i), |
| 707 environment->HasUint32ValueAt(i), &object_index, &dematerialized_index); | 631 environment->HasUint32ValueAt(i), &object_index, &dematerialized_index); |
| 708 } | 632 } |
| 709 } | 633 } |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 data->SetAstId(i, env->ast_id()); | 923 data->SetAstId(i, env->ast_id()); |
| 1000 data->SetTranslationIndex(i, Smi::FromInt(env->translation_index())); | 924 data->SetTranslationIndex(i, Smi::FromInt(env->translation_index())); |
| 1001 data->SetArgumentsStackHeight(i, | 925 data->SetArgumentsStackHeight(i, |
| 1002 Smi::FromInt(env->arguments_stack_height())); | 926 Smi::FromInt(env->arguments_stack_height())); |
| 1003 data->SetPc(i, Smi::FromInt(env->pc_offset())); | 927 data->SetPc(i, Smi::FromInt(env->pc_offset())); |
| 1004 } | 928 } |
| 1005 code->set_deoptimization_data(*data); | 929 code->set_deoptimization_data(*data); |
| 1006 } | 930 } |
| 1007 | 931 |
| 1008 | 932 |
| 1009 int LCodeGen::DefineDeoptimizationLiteral(Handle<Object> literal) { | |
| 1010 int result = deoptimization_literals_.length(); | |
| 1011 for (int i = 0; i < deoptimization_literals_.length(); ++i) { | |
| 1012 if (deoptimization_literals_[i].is_identical_to(literal)) return i; | |
| 1013 } | |
| 1014 deoptimization_literals_.Add(literal, zone()); | |
| 1015 return result; | |
| 1016 } | |
| 1017 | |
| 1018 | |
| 1019 void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() { | 933 void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() { |
| 1020 DCHECK_EQ(0, deoptimization_literals_.length()); | 934 DCHECK_EQ(0, deoptimization_literals_.length()); |
| 1021 for (auto function : chunk()->inlined_functions()) { | 935 for (auto function : chunk()->inlined_functions()) { |
| 1022 DefineDeoptimizationLiteral(function); | 936 DefineDeoptimizationLiteral(function); |
| 1023 } | 937 } |
| 1024 inlined_function_count_ = deoptimization_literals_.length(); | 938 inlined_function_count_ = deoptimization_literals_.length(); |
| 1025 } | 939 } |
| 1026 | 940 |
| 1027 | 941 |
| 1028 void LCodeGen::RecordSafepointWithLazyDeopt( | 942 void LCodeGen::RecordSafepointWithLazyDeopt( |
| (...skipping 4840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5869 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5783 RecordSafepoint(Safepoint::kNoLazyDeopt); |
| 5870 } | 5784 } |
| 5871 | 5785 |
| 5872 | 5786 |
| 5873 #undef __ | 5787 #undef __ |
| 5874 | 5788 |
| 5875 } // namespace internal | 5789 } // namespace internal |
| 5876 } // namespace v8 | 5790 } // namespace v8 |
| 5877 | 5791 |
| 5878 #endif // V8_TARGET_ARCH_IA32 | 5792 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |