| 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/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/cpu-profiler.h" | 9 #include "src/cpu-profiler.h" |
| 10 #include "src/hydrogen-osr.h" | 10 #include "src/hydrogen-osr.h" |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 } | 575 } |
| 576 } | 576 } |
| 577 | 577 |
| 578 | 578 |
| 579 void LCodeGen::WriteTranslation(LEnvironment* environment, | 579 void LCodeGen::WriteTranslation(LEnvironment* environment, |
| 580 Translation* translation) { | 580 Translation* translation) { |
| 581 if (environment == NULL) return; | 581 if (environment == NULL) return; |
| 582 | 582 |
| 583 // The translation includes one command per value in the environment. | 583 // The translation includes one command per value in the environment. |
| 584 int translation_size = environment->translation_size(); | 584 int translation_size = environment->translation_size(); |
| 585 // The output frame height does not include the parameters. | |
| 586 int height = translation_size - environment->parameter_count(); | |
| 587 | 585 |
| 588 WriteTranslation(environment->outer(), translation); | 586 WriteTranslation(environment->outer(), translation); |
| 589 | 587 WriteTranslationFrame(environment, translation); |
| 590 switch (environment->frame_type()) { | |
| 591 case JS_FUNCTION: { | |
| 592 int shared_id = DefineDeoptimizationLiteral( | |
| 593 environment->entry() ? environment->entry()->shared() | |
| 594 : info()->shared_info()); | |
| 595 translation->BeginJSFrame(environment->ast_id(), shared_id, height); | |
| 596 if (info()->closure().is_identical_to(environment->closure())) { | |
| 597 translation->StoreJSFrameFunction(); | |
| 598 } else { | |
| 599 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 600 translation->StoreLiteral(closure_id); | |
| 601 } | |
| 602 break; | |
| 603 } | |
| 604 case JS_CONSTRUCT: { | |
| 605 int shared_id = DefineDeoptimizationLiteral( | |
| 606 environment->entry() ? environment->entry()->shared() | |
| 607 : info()->shared_info()); | |
| 608 translation->BeginConstructStubFrame(shared_id, translation_size); | |
| 609 if (info()->closure().is_identical_to(environment->closure())) { | |
| 610 translation->StoreJSFrameFunction(); | |
| 611 } else { | |
| 612 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 613 translation->StoreLiteral(closure_id); | |
| 614 } | |
| 615 break; | |
| 616 } | |
| 617 case JS_GETTER: { | |
| 618 DCHECK(translation_size == 1); | |
| 619 DCHECK(height == 0); | |
| 620 int shared_id = DefineDeoptimizationLiteral( | |
| 621 environment->entry() ? environment->entry()->shared() | |
| 622 : info()->shared_info()); | |
| 623 translation->BeginGetterStubFrame(shared_id); | |
| 624 if (info()->closure().is_identical_to(environment->closure())) { | |
| 625 translation->StoreJSFrameFunction(); | |
| 626 } else { | |
| 627 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 628 translation->StoreLiteral(closure_id); | |
| 629 } | |
| 630 break; | |
| 631 } | |
| 632 case JS_SETTER: { | |
| 633 DCHECK(translation_size == 2); | |
| 634 DCHECK(height == 0); | |
| 635 int shared_id = DefineDeoptimizationLiteral( | |
| 636 environment->entry() ? environment->entry()->shared() | |
| 637 : info()->shared_info()); | |
| 638 translation->BeginSetterStubFrame(shared_id); | |
| 639 if (info()->closure().is_identical_to(environment->closure())) { | |
| 640 translation->StoreJSFrameFunction(); | |
| 641 } else { | |
| 642 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 643 translation->StoreLiteral(closure_id); | |
| 644 } | |
| 645 break; | |
| 646 } | |
| 647 case ARGUMENTS_ADAPTOR: { | |
| 648 int shared_id = DefineDeoptimizationLiteral( | |
| 649 environment->entry() ? environment->entry()->shared() | |
| 650 : info()->shared_info()); | |
| 651 translation->BeginArgumentsAdaptorFrame(shared_id, translation_size); | |
| 652 if (info()->closure().is_identical_to(environment->closure())) { | |
| 653 translation->StoreJSFrameFunction(); | |
| 654 } else { | |
| 655 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
| 656 translation->StoreLiteral(closure_id); | |
| 657 } | |
| 658 break; | |
| 659 } | |
| 660 case STUB: | |
| 661 translation->BeginCompiledStubFrame(translation_size); | |
| 662 break; | |
| 663 } | |
| 664 | 588 |
| 665 int object_index = 0; | 589 int object_index = 0; |
| 666 int dematerialized_index = 0; | 590 int dematerialized_index = 0; |
| 667 for (int i = 0; i < translation_size; ++i) { | 591 for (int i = 0; i < translation_size; ++i) { |
| 668 LOperand* value = environment->values()->at(i); | 592 LOperand* value = environment->values()->at(i); |
| 669 AddToTranslation( | 593 AddToTranslation( |
| 670 environment, translation, value, environment->HasTaggedValueAt(i), | 594 environment, translation, value, environment->HasTaggedValueAt(i), |
| 671 environment->HasUint32ValueAt(i), &object_index, &dematerialized_index); | 595 environment->HasUint32ValueAt(i), &object_index, &dematerialized_index); |
| 672 } | 596 } |
| 673 } | 597 } |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 data->SetAstId(i, env->ast_id()); | 875 data->SetAstId(i, env->ast_id()); |
| 952 data->SetTranslationIndex(i, Smi::FromInt(env->translation_index())); | 876 data->SetTranslationIndex(i, Smi::FromInt(env->translation_index())); |
| 953 data->SetArgumentsStackHeight(i, | 877 data->SetArgumentsStackHeight(i, |
| 954 Smi::FromInt(env->arguments_stack_height())); | 878 Smi::FromInt(env->arguments_stack_height())); |
| 955 data->SetPc(i, Smi::FromInt(env->pc_offset())); | 879 data->SetPc(i, Smi::FromInt(env->pc_offset())); |
| 956 } | 880 } |
| 957 code->set_deoptimization_data(*data); | 881 code->set_deoptimization_data(*data); |
| 958 } | 882 } |
| 959 | 883 |
| 960 | 884 |
| 961 int LCodeGen::DefineDeoptimizationLiteral(Handle<Object> literal) { | |
| 962 int result = deoptimization_literals_.length(); | |
| 963 for (int i = 0; i < deoptimization_literals_.length(); ++i) { | |
| 964 if (deoptimization_literals_[i].is_identical_to(literal)) return i; | |
| 965 } | |
| 966 deoptimization_literals_.Add(literal, zone()); | |
| 967 return result; | |
| 968 } | |
| 969 | |
| 970 | |
| 971 void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() { | 885 void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() { |
| 972 DCHECK_EQ(0, deoptimization_literals_.length()); | 886 DCHECK_EQ(0, deoptimization_literals_.length()); |
| 973 for (auto function : chunk()->inlined_functions()) { | 887 for (auto function : chunk()->inlined_functions()) { |
| 974 DefineDeoptimizationLiteral(function); | 888 DefineDeoptimizationLiteral(function); |
| 975 } | 889 } |
| 976 inlined_function_count_ = deoptimization_literals_.length(); | 890 inlined_function_count_ = deoptimization_literals_.length(); |
| 977 } | 891 } |
| 978 | 892 |
| 979 | 893 |
| 980 void LCodeGen::RecordSafepointWithLazyDeopt( | 894 void LCodeGen::RecordSafepointWithLazyDeopt( |
| (...skipping 5183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6164 __ Push(at, ToRegister(instr->function())); | 6078 __ Push(at, ToRegister(instr->function())); |
| 6165 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 6079 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
| 6166 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6080 RecordSafepoint(Safepoint::kNoLazyDeopt); |
| 6167 } | 6081 } |
| 6168 | 6082 |
| 6169 | 6083 |
| 6170 #undef __ | 6084 #undef __ |
| 6171 | 6085 |
| 6172 } // namespace internal | 6086 } // namespace internal |
| 6173 } // namespace v8 | 6087 } // namespace v8 |
| OLD | NEW |