| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved.7 | 1 // Copyright 2012 the V8 project authors. All rights reserved.7 |
| 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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 } | 587 } |
| 588 } | 588 } |
| 589 | 589 |
| 590 | 590 |
| 591 void LCodeGen::WriteTranslation(LEnvironment* environment, | 591 void LCodeGen::WriteTranslation(LEnvironment* environment, |
| 592 Translation* translation) { | 592 Translation* translation) { |
| 593 if (environment == NULL) return; | 593 if (environment == NULL) return; |
| 594 | 594 |
| 595 // The translation includes one command per value in the environment. | 595 // The translation includes one command per value in the environment. |
| 596 int translation_size = environment->translation_size(); | 596 int translation_size = environment->translation_size(); |
| 597 // The output frame height does not include the parameters. | |
| 598 int height = translation_size - environment->parameter_count(); | |
| 599 | 597 |
| 600 WriteTranslation(environment->outer(), translation); | 598 WriteTranslation(environment->outer(), translation); |
| 601 | 599 WriteTranslationFrame(environment, translation); |
| 602 switch (environment->frame_type()) { | |
| 603 case JS_FUNCTION: { | |
| 604 int shared_id = DefineDeoptimizationLiteral( | |
| 605 environment->entry() ? environment->entry()->shared() | |
| 606 : info()->shared_info()); | |
| 607 translation->BeginJSFrame(environment->ast_id(), shared_id, height); | |
| 608 if (info()->closure().is_identical_to(environment->closure())) { | |
| 609 translation->StoreJSFrameFunction(); | |
| 610 } else { | |
| 611 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 612 translation->StoreLiteral(closure_id); | |
| 613 } | |
| 614 break; | |
| 615 } | |
| 616 case JS_CONSTRUCT: { | |
| 617 int shared_id = DefineDeoptimizationLiteral( | |
| 618 environment->entry() ? environment->entry()->shared() | |
| 619 : info()->shared_info()); | |
| 620 translation->BeginConstructStubFrame(shared_id, translation_size); | |
| 621 if (info()->closure().is_identical_to(environment->closure())) { | |
| 622 translation->StoreJSFrameFunction(); | |
| 623 } else { | |
| 624 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 625 translation->StoreLiteral(closure_id); | |
| 626 } | |
| 627 break; | |
| 628 } | |
| 629 case JS_GETTER: { | |
| 630 DCHECK(translation_size == 1); | |
| 631 DCHECK(height == 0); | |
| 632 int shared_id = DefineDeoptimizationLiteral( | |
| 633 environment->entry() ? environment->entry()->shared() | |
| 634 : info()->shared_info()); | |
| 635 translation->BeginGetterStubFrame(shared_id); | |
| 636 if (info()->closure().is_identical_to(environment->closure())) { | |
| 637 translation->StoreJSFrameFunction(); | |
| 638 } else { | |
| 639 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 640 translation->StoreLiteral(closure_id); | |
| 641 } | |
| 642 break; | |
| 643 } | |
| 644 case JS_SETTER: { | |
| 645 DCHECK(translation_size == 2); | |
| 646 DCHECK(height == 0); | |
| 647 int shared_id = DefineDeoptimizationLiteral( | |
| 648 environment->entry() ? environment->entry()->shared() | |
| 649 : info()->shared_info()); | |
| 650 translation->BeginSetterStubFrame(shared_id); | |
| 651 if (info()->closure().is_identical_to(environment->closure())) { | |
| 652 translation->StoreJSFrameFunction(); | |
| 653 } else { | |
| 654 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 655 translation->StoreLiteral(closure_id); | |
| 656 } | |
| 657 break; | |
| 658 } | |
| 659 case ARGUMENTS_ADAPTOR: { | |
| 660 int shared_id = DefineDeoptimizationLiteral( | |
| 661 environment->entry() ? environment->entry()->shared() | |
| 662 : info()->shared_info()); | |
| 663 translation->BeginArgumentsAdaptorFrame(shared_id, translation_size); | |
| 664 if (info()->closure().is_identical_to(environment->closure())) { | |
| 665 translation->StoreJSFrameFunction(); | |
| 666 } else { | |
| 667 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 668 translation->StoreLiteral(closure_id); | |
| 669 } | |
| 670 break; | |
| 671 } | |
| 672 case STUB: | |
| 673 translation->BeginCompiledStubFrame(translation_size); | |
| 674 break; | |
| 675 } | |
| 676 | 600 |
| 677 int object_index = 0; | 601 int object_index = 0; |
| 678 int dematerialized_index = 0; | 602 int dematerialized_index = 0; |
| 679 for (int i = 0; i < translation_size; ++i) { | 603 for (int i = 0; i < translation_size; ++i) { |
| 680 LOperand* value = environment->values()->at(i); | 604 LOperand* value = environment->values()->at(i); |
| 681 AddToTranslation( | 605 AddToTranslation( |
| 682 environment, translation, value, environment->HasTaggedValueAt(i), | 606 environment, translation, value, environment->HasTaggedValueAt(i), |
| 683 environment->HasUint32ValueAt(i), &object_index, &dematerialized_index); | 607 environment->HasUint32ValueAt(i), &object_index, &dematerialized_index); |
| 684 } | 608 } |
| 685 } | 609 } |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 data->SetAstId(i, env->ast_id()); | 886 data->SetAstId(i, env->ast_id()); |
| 963 data->SetTranslationIndex(i, Smi::FromInt(env->translation_index())); | 887 data->SetTranslationIndex(i, Smi::FromInt(env->translation_index())); |
| 964 data->SetArgumentsStackHeight(i, | 888 data->SetArgumentsStackHeight(i, |
| 965 Smi::FromInt(env->arguments_stack_height())); | 889 Smi::FromInt(env->arguments_stack_height())); |
| 966 data->SetPc(i, Smi::FromInt(env->pc_offset())); | 890 data->SetPc(i, Smi::FromInt(env->pc_offset())); |
| 967 } | 891 } |
| 968 code->set_deoptimization_data(*data); | 892 code->set_deoptimization_data(*data); |
| 969 } | 893 } |
| 970 | 894 |
| 971 | 895 |
| 972 int LCodeGen::DefineDeoptimizationLiteral(Handle<Object> literal) { | |
| 973 int result = deoptimization_literals_.length(); | |
| 974 for (int i = 0; i < deoptimization_literals_.length(); ++i) { | |
| 975 if (deoptimization_literals_[i].is_identical_to(literal)) return i; | |
| 976 } | |
| 977 deoptimization_literals_.Add(literal, zone()); | |
| 978 return result; | |
| 979 } | |
| 980 | |
| 981 | |
| 982 void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() { | 896 void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() { |
| 983 DCHECK_EQ(0, deoptimization_literals_.length()); | 897 DCHECK_EQ(0, deoptimization_literals_.length()); |
| 984 for (auto function : chunk()->inlined_functions()) { | 898 for (auto function : chunk()->inlined_functions()) { |
| 985 DefineDeoptimizationLiteral(function); | 899 DefineDeoptimizationLiteral(function); |
| 986 } | 900 } |
| 987 inlined_function_count_ = deoptimization_literals_.length(); | 901 inlined_function_count_ = deoptimization_literals_.length(); |
| 988 } | 902 } |
| 989 | 903 |
| 990 | 904 |
| 991 void LCodeGen::RecordSafepointWithLazyDeopt( | 905 void LCodeGen::RecordSafepointWithLazyDeopt( |
| (...skipping 5106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6098 __ Push(at, ToRegister(instr->function())); | 6012 __ Push(at, ToRegister(instr->function())); |
| 6099 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 6013 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
| 6100 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6014 RecordSafepoint(Safepoint::kNoLazyDeopt); |
| 6101 } | 6015 } |
| 6102 | 6016 |
| 6103 | 6017 |
| 6104 #undef __ | 6018 #undef __ |
| 6105 | 6019 |
| 6106 } // namespace internal | 6020 } // namespace internal |
| 6107 } // namespace v8 | 6021 } // namespace v8 |
| OLD | NEW |