| 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 #include "src/arm/lithium-codegen-arm.h" | 7 #include "src/arm/lithium-codegen-arm.h" |
| 8 #include "src/arm/lithium-gap-resolver-arm.h" | 8 #include "src/arm/lithium-gap-resolver-arm.h" |
| 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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 } | 589 } |
| 590 } | 590 } |
| 591 | 591 |
| 592 | 592 |
| 593 void LCodeGen::WriteTranslation(LEnvironment* environment, | 593 void LCodeGen::WriteTranslation(LEnvironment* environment, |
| 594 Translation* translation) { | 594 Translation* translation) { |
| 595 if (environment == NULL) return; | 595 if (environment == NULL) return; |
| 596 | 596 |
| 597 // The translation includes one command per value in the environment. | 597 // The translation includes one command per value in the environment. |
| 598 int translation_size = environment->translation_size(); | 598 int translation_size = environment->translation_size(); |
| 599 // The output frame height does not include the parameters. | |
| 600 int height = translation_size - environment->parameter_count(); | |
| 601 | 599 |
| 602 WriteTranslation(environment->outer(), translation); | 600 WriteTranslation(environment->outer(), translation); |
| 603 | 601 WriteTranslationFrame(environment, translation); |
| 604 switch (environment->frame_type()) { | |
| 605 case JS_FUNCTION: { | |
| 606 int shared_id = DefineDeoptimizationLiteral( | |
| 607 environment->entry() ? environment->entry()->shared() | |
| 608 : info()->shared_info()); | |
| 609 translation->BeginJSFrame(environment->ast_id(), shared_id, height); | |
| 610 if (info()->closure().is_identical_to(environment->closure())) { | |
| 611 translation->StoreJSFrameFunction(); | |
| 612 } else { | |
| 613 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 614 translation->StoreLiteral(closure_id); | |
| 615 } | |
| 616 break; | |
| 617 } | |
| 618 case JS_CONSTRUCT: { | |
| 619 int shared_id = DefineDeoptimizationLiteral( | |
| 620 environment->entry() ? environment->entry()->shared() | |
| 621 : info()->shared_info()); | |
| 622 translation->BeginConstructStubFrame(shared_id, translation_size); | |
| 623 if (info()->closure().is_identical_to(environment->closure())) { | |
| 624 translation->StoreJSFrameFunction(); | |
| 625 } else { | |
| 626 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 627 translation->StoreLiteral(closure_id); | |
| 628 } | |
| 629 break; | |
| 630 } | |
| 631 case JS_GETTER: { | |
| 632 DCHECK(translation_size == 1); | |
| 633 DCHECK(height == 0); | |
| 634 int shared_id = DefineDeoptimizationLiteral( | |
| 635 environment->entry() ? environment->entry()->shared() | |
| 636 : info()->shared_info()); | |
| 637 translation->BeginGetterStubFrame(shared_id); | |
| 638 if (info()->closure().is_identical_to(environment->closure())) { | |
| 639 translation->StoreJSFrameFunction(); | |
| 640 } else { | |
| 641 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 642 translation->StoreLiteral(closure_id); | |
| 643 } | |
| 644 break; | |
| 645 } | |
| 646 case JS_SETTER: { | |
| 647 DCHECK(translation_size == 2); | |
| 648 DCHECK(height == 0); | |
| 649 int shared_id = DefineDeoptimizationLiteral( | |
| 650 environment->entry() ? environment->entry()->shared() | |
| 651 : info()->shared_info()); | |
| 652 translation->BeginSetterStubFrame(shared_id); | |
| 653 if (info()->closure().is_identical_to(environment->closure())) { | |
| 654 translation->StoreJSFrameFunction(); | |
| 655 } else { | |
| 656 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 657 translation->StoreLiteral(closure_id); | |
| 658 } | |
| 659 break; | |
| 660 } | |
| 661 case ARGUMENTS_ADAPTOR: { | |
| 662 int shared_id = DefineDeoptimizationLiteral( | |
| 663 environment->entry() ? environment->entry()->shared() | |
| 664 : info()->shared_info()); | |
| 665 translation->BeginArgumentsAdaptorFrame(shared_id, translation_size); | |
| 666 if (info()->closure().is_identical_to(environment->closure())) { | |
| 667 translation->StoreJSFrameFunction(); | |
| 668 } else { | |
| 669 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 670 translation->StoreLiteral(closure_id); | |
| 671 } | |
| 672 break; | |
| 673 } | |
| 674 case STUB: | |
| 675 translation->BeginCompiledStubFrame(translation_size); | |
| 676 break; | |
| 677 } | |
| 678 | 602 |
| 679 int object_index = 0; | 603 int object_index = 0; |
| 680 int dematerialized_index = 0; | 604 int dematerialized_index = 0; |
| 681 for (int i = 0; i < translation_size; ++i) { | 605 for (int i = 0; i < translation_size; ++i) { |
| 682 LOperand* value = environment->values()->at(i); | 606 LOperand* value = environment->values()->at(i); |
| 683 AddToTranslation( | 607 AddToTranslation( |
| 684 environment, translation, value, environment->HasTaggedValueAt(i), | 608 environment, translation, value, environment->HasTaggedValueAt(i), |
| 685 environment->HasUint32ValueAt(i), &object_index, &dematerialized_index); | 609 environment->HasUint32ValueAt(i), &object_index, &dematerialized_index); |
| 686 } | 610 } |
| 687 } | 611 } |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 data->SetAstId(i, env->ast_id()); | 919 data->SetAstId(i, env->ast_id()); |
| 996 data->SetTranslationIndex(i, Smi::FromInt(env->translation_index())); | 920 data->SetTranslationIndex(i, Smi::FromInt(env->translation_index())); |
| 997 data->SetArgumentsStackHeight(i, | 921 data->SetArgumentsStackHeight(i, |
| 998 Smi::FromInt(env->arguments_stack_height())); | 922 Smi::FromInt(env->arguments_stack_height())); |
| 999 data->SetPc(i, Smi::FromInt(env->pc_offset())); | 923 data->SetPc(i, Smi::FromInt(env->pc_offset())); |
| 1000 } | 924 } |
| 1001 code->set_deoptimization_data(*data); | 925 code->set_deoptimization_data(*data); |
| 1002 } | 926 } |
| 1003 | 927 |
| 1004 | 928 |
| 1005 int LCodeGen::DefineDeoptimizationLiteral(Handle<Object> literal) { | |
| 1006 int result = deoptimization_literals_.length(); | |
| 1007 for (int i = 0; i < deoptimization_literals_.length(); ++i) { | |
| 1008 if (deoptimization_literals_[i].is_identical_to(literal)) return i; | |
| 1009 } | |
| 1010 deoptimization_literals_.Add(literal, zone()); | |
| 1011 return result; | |
| 1012 } | |
| 1013 | |
| 1014 | |
| 1015 void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() { | 929 void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() { |
| 1016 DCHECK_EQ(0, deoptimization_literals_.length()); | 930 DCHECK_EQ(0, deoptimization_literals_.length()); |
| 1017 for (auto function : chunk()->inlined_functions()) { | 931 for (auto function : chunk()->inlined_functions()) { |
| 1018 DefineDeoptimizationLiteral(function); | 932 DefineDeoptimizationLiteral(function); |
| 1019 } | 933 } |
| 1020 inlined_function_count_ = deoptimization_literals_.length(); | 934 inlined_function_count_ = deoptimization_literals_.length(); |
| 1021 } | 935 } |
| 1022 | 936 |
| 1023 | 937 |
| 1024 void LCodeGen::RecordSafepointWithLazyDeopt( | 938 void LCodeGen::RecordSafepointWithLazyDeopt( |
| (...skipping 5021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6046 __ push(ToRegister(instr->function())); | 5960 __ push(ToRegister(instr->function())); |
| 6047 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5961 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
| 6048 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5962 RecordSafepoint(Safepoint::kNoLazyDeopt); |
| 6049 } | 5963 } |
| 6050 | 5964 |
| 6051 | 5965 |
| 6052 #undef __ | 5966 #undef __ |
| 6053 | 5967 |
| 6054 } // namespace internal | 5968 } // namespace internal |
| 6055 } // namespace v8 | 5969 } // namespace v8 |
| OLD | NEW |