OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/cpu-profiler.h" | 10 #include "src/cpu-profiler.h" |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 } | 559 } |
560 } | 560 } |
561 | 561 |
562 | 562 |
563 void LCodeGen::WriteTranslation(LEnvironment* environment, | 563 void LCodeGen::WriteTranslation(LEnvironment* environment, |
564 Translation* translation) { | 564 Translation* translation) { |
565 if (environment == NULL) return; | 565 if (environment == NULL) return; |
566 | 566 |
567 // The translation includes one command per value in the environment. | 567 // The translation includes one command per value in the environment. |
568 int translation_size = environment->translation_size(); | 568 int translation_size = environment->translation_size(); |
569 // The output frame height does not include the parameters. | |
570 int height = translation_size - environment->parameter_count(); | |
571 | 569 |
572 WriteTranslation(environment->outer(), translation); | 570 WriteTranslation(environment->outer(), translation); |
573 | 571 WriteTranslationFrame(environment, translation); |
574 switch (environment->frame_type()) { | |
575 case JS_FUNCTION: { | |
576 int shared_id = DefineDeoptimizationLiteral( | |
577 environment->entry() ? environment->entry()->shared() | |
578 : info()->shared_info()); | |
579 translation->BeginJSFrame(environment->ast_id(), shared_id, height); | |
580 if (info()->closure().is_identical_to(environment->closure())) { | |
581 translation->StoreJSFrameFunction(); | |
582 } else { | |
583 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
584 translation->StoreLiteral(closure_id); | |
585 } | |
586 break; | |
587 } | |
588 case JS_CONSTRUCT: { | |
589 int shared_id = DefineDeoptimizationLiteral( | |
590 environment->entry() ? environment->entry()->shared() | |
591 : info()->shared_info()); | |
592 translation->BeginConstructStubFrame(shared_id, translation_size); | |
593 if (info()->closure().is_identical_to(environment->closure())) { | |
594 translation->StoreJSFrameFunction(); | |
595 } else { | |
596 int closure_id = DefineDeoptimizationLiteral(environment->closure()); | |
597 translation->StoreLiteral(closure_id); | |
598 } | |
599 break; | |
600 } | |
601 case JS_GETTER: { | |
602 DCHECK(translation_size == 1); | |
603 DCHECK(height == 0); | |
604 int shared_id = DefineDeoptimizationLiteral( | |
605 environment->entry() ? environment->entry()->shared() | |
606 : info()->shared_info()); | |
607 translation->BeginGetterStubFrame(shared_id); | |
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_SETTER: { | |
617 DCHECK(translation_size == 2); | |
618 DCHECK(height == 0); | |
619 int shared_id = DefineDeoptimizationLiteral( | |
620 environment->entry() ? environment->entry()->shared() | |
621 : info()->shared_info()); | |
622 translation->BeginSetterStubFrame(shared_id); | |
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 ARGUMENTS_ADAPTOR: { | |
632 int shared_id = DefineDeoptimizationLiteral( | |
633 environment->entry() ? environment->entry()->shared() | |
634 : info()->shared_info()); | |
635 translation->BeginArgumentsAdaptorFrame(shared_id, translation_size); | |
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 STUB: | |
645 translation->BeginCompiledStubFrame(translation_size); | |
646 break; | |
647 } | |
648 | 572 |
649 int object_index = 0; | 573 int object_index = 0; |
650 int dematerialized_index = 0; | 574 int dematerialized_index = 0; |
651 for (int i = 0; i < translation_size; ++i) { | 575 for (int i = 0; i < translation_size; ++i) { |
652 LOperand* value = environment->values()->at(i); | 576 LOperand* value = environment->values()->at(i); |
653 AddToTranslation( | 577 AddToTranslation( |
654 environment, translation, value, environment->HasTaggedValueAt(i), | 578 environment, translation, value, environment->HasTaggedValueAt(i), |
655 environment->HasUint32ValueAt(i), &object_index, &dematerialized_index); | 579 environment->HasUint32ValueAt(i), &object_index, &dematerialized_index); |
656 } | 580 } |
657 } | 581 } |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 data->SetAstId(i, env->ast_id()); | 849 data->SetAstId(i, env->ast_id()); |
926 data->SetTranslationIndex(i, Smi::FromInt(env->translation_index())); | 850 data->SetTranslationIndex(i, Smi::FromInt(env->translation_index())); |
927 data->SetArgumentsStackHeight(i, | 851 data->SetArgumentsStackHeight(i, |
928 Smi::FromInt(env->arguments_stack_height())); | 852 Smi::FromInt(env->arguments_stack_height())); |
929 data->SetPc(i, Smi::FromInt(env->pc_offset())); | 853 data->SetPc(i, Smi::FromInt(env->pc_offset())); |
930 } | 854 } |
931 code->set_deoptimization_data(*data); | 855 code->set_deoptimization_data(*data); |
932 } | 856 } |
933 | 857 |
934 | 858 |
935 int LCodeGen::DefineDeoptimizationLiteral(Handle<Object> literal) { | |
936 int result = deoptimization_literals_.length(); | |
937 for (int i = 0; i < deoptimization_literals_.length(); ++i) { | |
938 if (deoptimization_literals_[i].is_identical_to(literal)) return i; | |
939 } | |
940 deoptimization_literals_.Add(literal, zone()); | |
941 return result; | |
942 } | |
943 | |
944 | |
945 void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() { | 859 void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() { |
946 DCHECK_EQ(0, deoptimization_literals_.length()); | 860 DCHECK_EQ(0, deoptimization_literals_.length()); |
947 for (auto function : chunk()->inlined_functions()) { | 861 for (auto function : chunk()->inlined_functions()) { |
948 DefineDeoptimizationLiteral(function); | 862 DefineDeoptimizationLiteral(function); |
949 } | 863 } |
950 inlined_function_count_ = deoptimization_literals_.length(); | 864 inlined_function_count_ = deoptimization_literals_.length(); |
951 } | 865 } |
952 | 866 |
953 | 867 |
954 void LCodeGen::RecordSafepointWithLazyDeopt(LInstruction* instr, | 868 void LCodeGen::RecordSafepointWithLazyDeopt(LInstruction* instr, |
(...skipping 5364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6319 __ Push(scope_info); | 6233 __ Push(scope_info); |
6320 __ push(ToRegister(instr->function())); | 6234 __ push(ToRegister(instr->function())); |
6321 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 6235 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
6322 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6236 RecordSafepoint(Safepoint::kNoLazyDeopt); |
6323 } | 6237 } |
6324 | 6238 |
6325 | 6239 |
6326 #undef __ | 6240 #undef __ |
6327 } // namespace internal | 6241 } // namespace internal |
6328 } // namespace v8 | 6242 } // namespace v8 |
OLD | NEW |