| 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 Comment(";;; -------------------- Jump table --------------------"); | 383 Comment(";;; -------------------- Jump table --------------------"); |
| 384 } | 384 } |
| 385 for (int i = 0; i < jump_table_.length(); i++) { | 385 for (int i = 0; i < jump_table_.length(); i++) { |
| 386 Deoptimizer::JumpTableEntry* table_entry = &jump_table_[i]; | 386 Deoptimizer::JumpTableEntry* table_entry = &jump_table_[i]; |
| 387 __ bind(&table_entry->label); | 387 __ bind(&table_entry->label); |
| 388 Address entry = table_entry->address; | 388 Address entry = table_entry->address; |
| 389 Deoptimizer::BailoutType type = table_entry->bailout_type; | 389 Deoptimizer::BailoutType type = table_entry->bailout_type; |
| 390 int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type); | 390 int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type); |
| 391 DCHECK_NE(Deoptimizer::kNotDeoptimizationEntry, id); | 391 DCHECK_NE(Deoptimizer::kNotDeoptimizationEntry, id); |
| 392 Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id); | 392 Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id); |
| 393 DeoptComment(table_entry->mnemonic, table_entry->reason); | 393 DeoptComment(table_entry->reason); |
| 394 if (table_entry->needs_frame) { | 394 if (table_entry->needs_frame) { |
| 395 DCHECK(!info()->saves_caller_doubles()); | 395 DCHECK(!info()->saves_caller_doubles()); |
| 396 __ push(Immediate(ExternalReference::ForDeoptEntry(entry))); | 396 __ push(Immediate(ExternalReference::ForDeoptEntry(entry))); |
| 397 if (needs_frame.is_bound()) { | 397 if (needs_frame.is_bound()) { |
| 398 __ jmp(&needs_frame); | 398 __ jmp(&needs_frame); |
| 399 } else { | 399 } else { |
| 400 __ bind(&needs_frame); | 400 __ bind(&needs_frame); |
| 401 __ push(MemOperand(ebp, StandardFrameConstants::kContextOffset)); | 401 __ push(MemOperand(ebp, StandardFrameConstants::kContextOffset)); |
| 402 // This variant of deopt can only be used with stubs. Since we don't | 402 // This variant of deopt can only be used with stubs. Since we don't |
| 403 // have a function pointer to install in the stack frame that we're | 403 // have a function pointer to install in the stack frame that we're |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 int pc_offset = masm()->pc_offset(); | 818 int pc_offset = masm()->pc_offset(); |
| 819 environment->Register(deoptimization_index, | 819 environment->Register(deoptimization_index, |
| 820 translation.index(), | 820 translation.index(), |
| 821 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); | 821 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); |
| 822 deoptimizations_.Add(environment, zone()); | 822 deoptimizations_.Add(environment, zone()); |
| 823 } | 823 } |
| 824 } | 824 } |
| 825 | 825 |
| 826 | 826 |
| 827 void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr, | 827 void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr, |
| 828 const char* reason, | 828 const char* detail, |
| 829 Deoptimizer::BailoutType bailout_type) { | 829 Deoptimizer::BailoutType bailout_type) { |
| 830 LEnvironment* environment = instr->environment(); | 830 LEnvironment* environment = instr->environment(); |
| 831 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 831 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
| 832 DCHECK(environment->HasBeenRegistered()); | 832 DCHECK(environment->HasBeenRegistered()); |
| 833 int id = environment->deoptimization_index(); | 833 int id = environment->deoptimization_index(); |
| 834 DCHECK(info()->IsOptimizing() || info()->IsStub()); | 834 DCHECK(info()->IsOptimizing() || info()->IsStub()); |
| 835 Address entry = | 835 Address entry = |
| 836 Deoptimizer::GetDeoptimizationEntry(isolate(), id, bailout_type); | 836 Deoptimizer::GetDeoptimizationEntry(isolate(), id, bailout_type); |
| 837 if (entry == NULL) { | 837 if (entry == NULL) { |
| 838 Abort(kBailoutWasNotPrepared); | 838 Abort(kBailoutWasNotPrepared); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 860 __ popfd(); | 860 __ popfd(); |
| 861 } | 861 } |
| 862 | 862 |
| 863 if (info()->ShouldTrapOnDeopt()) { | 863 if (info()->ShouldTrapOnDeopt()) { |
| 864 Label done; | 864 Label done; |
| 865 if (cc != no_condition) __ j(NegateCondition(cc), &done, Label::kNear); | 865 if (cc != no_condition) __ j(NegateCondition(cc), &done, Label::kNear); |
| 866 __ int3(); | 866 __ int3(); |
| 867 __ bind(&done); | 867 __ bind(&done); |
| 868 } | 868 } |
| 869 | 869 |
| 870 Deoptimizer::Reason reason(instr->Mnemonic(), detail); |
| 870 DCHECK(info()->IsStub() || frame_is_built_); | 871 DCHECK(info()->IsStub() || frame_is_built_); |
| 871 if (cc == no_condition && frame_is_built_) { | 872 if (cc == no_condition && frame_is_built_) { |
| 872 DeoptComment(instr->Mnemonic(), reason); | 873 DeoptComment(reason); |
| 873 __ call(entry, RelocInfo::RUNTIME_ENTRY); | 874 __ call(entry, RelocInfo::RUNTIME_ENTRY); |
| 874 } else { | 875 } else { |
| 875 // We often have several deopts to the same entry, reuse the last | 876 // We often have several deopts to the same entry, reuse the last |
| 876 // jump entry if this is the case. | 877 // jump entry if this is the case. |
| 877 if (jump_table_.is_empty() || | 878 if (jump_table_.is_empty() || |
| 878 jump_table_.last().address != entry || | 879 jump_table_.last().address != entry || |
| 879 jump_table_.last().needs_frame != !frame_is_built_ || | 880 jump_table_.last().needs_frame != !frame_is_built_ || |
| 880 jump_table_.last().bailout_type != bailout_type) { | 881 jump_table_.last().bailout_type != bailout_type) { |
| 881 Deoptimizer::JumpTableEntry table_entry(entry, instr->Mnemonic(), reason, | 882 Deoptimizer::JumpTableEntry table_entry(entry, reason, bailout_type, |
| 882 bailout_type, !frame_is_built_); | 883 !frame_is_built_); |
| 883 jump_table_.Add(table_entry, zone()); | 884 jump_table_.Add(table_entry, zone()); |
| 884 } | 885 } |
| 885 if (cc == no_condition) { | 886 if (cc == no_condition) { |
| 886 __ jmp(&jump_table_.last().label); | 887 __ jmp(&jump_table_.last().label); |
| 887 } else { | 888 } else { |
| 888 __ j(cc, &jump_table_.last().label); | 889 __ j(cc, &jump_table_.last().label); |
| 889 } | 890 } |
| 890 } | 891 } |
| 891 } | 892 } |
| 892 | 893 |
| 893 | 894 |
| 894 void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr, | 895 void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr, |
| 895 const char* reason) { | 896 const char* detail) { |
| 896 Deoptimizer::BailoutType bailout_type = info()->IsStub() | 897 Deoptimizer::BailoutType bailout_type = info()->IsStub() |
| 897 ? Deoptimizer::LAZY | 898 ? Deoptimizer::LAZY |
| 898 : Deoptimizer::EAGER; | 899 : Deoptimizer::EAGER; |
| 899 DeoptimizeIf(cc, instr, reason, bailout_type); | 900 DeoptimizeIf(cc, instr, detail, bailout_type); |
| 900 } | 901 } |
| 901 | 902 |
| 902 | 903 |
| 903 void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) { | 904 void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) { |
| 904 int length = deoptimizations_.length(); | 905 int length = deoptimizations_.length(); |
| 905 if (length == 0) return; | 906 if (length == 0) return; |
| 906 Handle<DeoptimizationInputData> data = | 907 Handle<DeoptimizationInputData> data = |
| 907 DeoptimizationInputData::New(isolate(), length, TENURED); | 908 DeoptimizationInputData::New(isolate(), length, TENURED); |
| 908 | 909 |
| 909 Handle<ByteArray> translations = | 910 Handle<ByteArray> translations = |
| (...skipping 4792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5702 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5703 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
| 5703 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5704 RecordSafepoint(Safepoint::kNoLazyDeopt); |
| 5704 } | 5705 } |
| 5705 | 5706 |
| 5706 | 5707 |
| 5707 #undef __ | 5708 #undef __ |
| 5708 | 5709 |
| 5709 } } // namespace v8::internal | 5710 } } // namespace v8::internal |
| 5710 | 5711 |
| 5711 #endif // V8_TARGET_ARCH_IA32 | 5712 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |