| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/arm64/lithium-codegen-arm64.h" | 7 #include "src/arm64/lithium-codegen-arm64.h" |
| 8 #include "src/arm64/lithium-gap-resolver-arm64.h" | 8 #include "src/arm64/lithium-gap-resolver-arm64.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 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 int length = jump_table_.length(); | 837 int length = jump_table_.length(); |
| 838 for (int i = 0; i < length; i++) { | 838 for (int i = 0; i < length; i++) { |
| 839 Deoptimizer::JumpTableEntry* table_entry = jump_table_[i]; | 839 Deoptimizer::JumpTableEntry* table_entry = jump_table_[i]; |
| 840 __ Bind(&table_entry->label); | 840 __ Bind(&table_entry->label); |
| 841 | 841 |
| 842 Deoptimizer::BailoutType type = table_entry->bailout_type; | 842 Deoptimizer::BailoutType type = table_entry->bailout_type; |
| 843 Address entry = table_entry->address; | 843 Address entry = table_entry->address; |
| 844 int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type); | 844 int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type); |
| 845 DCHECK_NE(Deoptimizer::kNotDeoptimizationEntry, id); | 845 DCHECK_NE(Deoptimizer::kNotDeoptimizationEntry, id); |
| 846 Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id); | 846 Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id); |
| 847 DeoptComment(table_entry->mnemonic, table_entry->reason); | 847 DeoptComment(table_entry->reason); |
| 848 | 848 |
| 849 // Second-level deopt table entries are contiguous and small, so instead | 849 // Second-level deopt table entries are contiguous and small, so instead |
| 850 // of loading the full, absolute address of each one, load the base | 850 // of loading the full, absolute address of each one, load the base |
| 851 // address and add an immediate offset. | 851 // address and add an immediate offset. |
| 852 __ Mov(entry_offset, entry - base); | 852 __ Mov(entry_offset, entry - base); |
| 853 | 853 |
| 854 // The last entry can fall through into `call_deopt_entry`, avoiding a | 854 // The last entry can fall through into `call_deopt_entry`, avoiding a |
| 855 // branch. | 855 // branch. |
| 856 bool last_entry = (i + 1) == length; | 856 bool last_entry = (i + 1) == length; |
| 857 | 857 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 | 986 |
| 987 for (int i = 0, length = inlined_closures->length(); i < length; i++) { | 987 for (int i = 0, length = inlined_closures->length(); i < length; i++) { |
| 988 DefineDeoptimizationLiteral(inlined_closures->at(i)); | 988 DefineDeoptimizationLiteral(inlined_closures->at(i)); |
| 989 } | 989 } |
| 990 | 990 |
| 991 inlined_function_count_ = deoptimization_literals_.length(); | 991 inlined_function_count_ = deoptimization_literals_.length(); |
| 992 } | 992 } |
| 993 | 993 |
| 994 | 994 |
| 995 void LCodeGen::DeoptimizeBranch( | 995 void LCodeGen::DeoptimizeBranch( |
| 996 LInstruction* instr, const char* reason, BranchType branch_type, | 996 LInstruction* instr, const char* detail, BranchType branch_type, |
| 997 Register reg, int bit, Deoptimizer::BailoutType* override_bailout_type) { | 997 Register reg, int bit, Deoptimizer::BailoutType* override_bailout_type) { |
| 998 LEnvironment* environment = instr->environment(); | 998 LEnvironment* environment = instr->environment(); |
| 999 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 999 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
| 1000 Deoptimizer::BailoutType bailout_type = | 1000 Deoptimizer::BailoutType bailout_type = |
| 1001 info()->IsStub() ? Deoptimizer::LAZY : Deoptimizer::EAGER; | 1001 info()->IsStub() ? Deoptimizer::LAZY : Deoptimizer::EAGER; |
| 1002 | 1002 |
| 1003 if (override_bailout_type != NULL) { | 1003 if (override_bailout_type != NULL) { |
| 1004 bailout_type = *override_bailout_type; | 1004 bailout_type = *override_bailout_type; |
| 1005 } | 1005 } |
| 1006 | 1006 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1037 __ Pop(x2, x1, x0); | 1037 __ Pop(x2, x1, x0); |
| 1038 } | 1038 } |
| 1039 | 1039 |
| 1040 if (info()->ShouldTrapOnDeopt()) { | 1040 if (info()->ShouldTrapOnDeopt()) { |
| 1041 Label dont_trap; | 1041 Label dont_trap; |
| 1042 __ B(&dont_trap, InvertBranchType(branch_type), reg, bit); | 1042 __ B(&dont_trap, InvertBranchType(branch_type), reg, bit); |
| 1043 __ Debug("trap_on_deopt", __LINE__, BREAK); | 1043 __ Debug("trap_on_deopt", __LINE__, BREAK); |
| 1044 __ Bind(&dont_trap); | 1044 __ Bind(&dont_trap); |
| 1045 } | 1045 } |
| 1046 | 1046 |
| 1047 Deoptimizer::Reason reason(instr->Mnemonic(), detail); |
| 1047 DCHECK(info()->IsStub() || frame_is_built_); | 1048 DCHECK(info()->IsStub() || frame_is_built_); |
| 1048 // Go through jump table if we need to build frame, or restore caller doubles. | 1049 // Go through jump table if we need to build frame, or restore caller doubles. |
| 1049 if (branch_type == always && | 1050 if (branch_type == always && |
| 1050 frame_is_built_ && !info()->saves_caller_doubles()) { | 1051 frame_is_built_ && !info()->saves_caller_doubles()) { |
| 1051 DeoptComment(instr->Mnemonic(), reason); | 1052 DeoptComment(reason); |
| 1052 __ Call(entry, RelocInfo::RUNTIME_ENTRY); | 1053 __ Call(entry, RelocInfo::RUNTIME_ENTRY); |
| 1053 } else { | 1054 } else { |
| 1054 // We often have several deopts to the same entry, reuse the last | 1055 // We often have several deopts to the same entry, reuse the last |
| 1055 // jump entry if this is the case. | 1056 // jump entry if this is the case. |
| 1056 if (jump_table_.is_empty() || (jump_table_.last()->address != entry) || | 1057 if (jump_table_.is_empty() || (jump_table_.last()->address != entry) || |
| 1057 (jump_table_.last()->bailout_type != bailout_type) || | 1058 (jump_table_.last()->bailout_type != bailout_type) || |
| 1058 (jump_table_.last()->needs_frame != !frame_is_built_)) { | 1059 (jump_table_.last()->needs_frame != !frame_is_built_)) { |
| 1059 Deoptimizer::JumpTableEntry* table_entry = | 1060 Deoptimizer::JumpTableEntry* table_entry = |
| 1060 new (zone()) Deoptimizer::JumpTableEntry( | 1061 new (zone()) Deoptimizer::JumpTableEntry(entry, reason, bailout_type, |
| 1061 entry, instr->Mnemonic(), reason, bailout_type, !frame_is_built_); | 1062 !frame_is_built_); |
| 1062 jump_table_.Add(table_entry, zone()); | 1063 jump_table_.Add(table_entry, zone()); |
| 1063 } | 1064 } |
| 1064 __ B(&jump_table_.last()->label, branch_type, reg, bit); | 1065 __ B(&jump_table_.last()->label, branch_type, reg, bit); |
| 1065 } | 1066 } |
| 1066 } | 1067 } |
| 1067 | 1068 |
| 1068 | 1069 |
| 1069 void LCodeGen::Deoptimize(LInstruction* instr, | 1070 void LCodeGen::Deoptimize(LInstruction* instr, |
| 1070 Deoptimizer::BailoutType* override_bailout_type, | 1071 Deoptimizer::BailoutType* override_bailout_type, |
| 1071 const char* reason) { | 1072 const char* detail) { |
| 1072 DeoptimizeBranch(instr, reason, always, NoReg, -1, override_bailout_type); | 1073 DeoptimizeBranch(instr, detail, always, NoReg, -1, override_bailout_type); |
| 1073 } | 1074 } |
| 1074 | 1075 |
| 1075 | 1076 |
| 1076 void LCodeGen::DeoptimizeIf(Condition cond, LInstruction* instr, | 1077 void LCodeGen::DeoptimizeIf(Condition cond, LInstruction* instr, |
| 1077 const char* reason) { | 1078 const char* detail) { |
| 1078 DeoptimizeBranch(instr, reason, static_cast<BranchType>(cond)); | 1079 DeoptimizeBranch(instr, detail, static_cast<BranchType>(cond)); |
| 1079 } | 1080 } |
| 1080 | 1081 |
| 1081 | 1082 |
| 1082 void LCodeGen::DeoptimizeIfZero(Register rt, LInstruction* instr, | 1083 void LCodeGen::DeoptimizeIfZero(Register rt, LInstruction* instr, |
| 1083 const char* reason) { | 1084 const char* detail) { |
| 1084 DeoptimizeBranch(instr, reason, reg_zero, rt); | 1085 DeoptimizeBranch(instr, detail, reg_zero, rt); |
| 1085 } | 1086 } |
| 1086 | 1087 |
| 1087 | 1088 |
| 1088 void LCodeGen::DeoptimizeIfNotZero(Register rt, LInstruction* instr, | 1089 void LCodeGen::DeoptimizeIfNotZero(Register rt, LInstruction* instr, |
| 1089 const char* reason) { | 1090 const char* detail) { |
| 1090 DeoptimizeBranch(instr, reason, reg_not_zero, rt); | 1091 DeoptimizeBranch(instr, detail, reg_not_zero, rt); |
| 1091 } | 1092 } |
| 1092 | 1093 |
| 1093 | 1094 |
| 1094 void LCodeGen::DeoptimizeIfNegative(Register rt, LInstruction* instr, | 1095 void LCodeGen::DeoptimizeIfNegative(Register rt, LInstruction* instr, |
| 1095 const char* reason) { | 1096 const char* detail) { |
| 1096 int sign_bit = rt.Is64Bits() ? kXSignBit : kWSignBit; | 1097 int sign_bit = rt.Is64Bits() ? kXSignBit : kWSignBit; |
| 1097 DeoptimizeIfBitSet(rt, sign_bit, instr, reason); | 1098 DeoptimizeIfBitSet(rt, sign_bit, instr, detail); |
| 1098 } | 1099 } |
| 1099 | 1100 |
| 1100 | 1101 |
| 1101 void LCodeGen::DeoptimizeIfSmi(Register rt, LInstruction* instr, | 1102 void LCodeGen::DeoptimizeIfSmi(Register rt, LInstruction* instr, |
| 1102 const char* reason) { | 1103 const char* detail) { |
| 1103 DeoptimizeIfBitClear(rt, MaskToBit(kSmiTagMask), instr, reason); | 1104 DeoptimizeIfBitClear(rt, MaskToBit(kSmiTagMask), instr, detail); |
| 1104 } | 1105 } |
| 1105 | 1106 |
| 1106 | 1107 |
| 1107 void LCodeGen::DeoptimizeIfNotSmi(Register rt, LInstruction* instr, | 1108 void LCodeGen::DeoptimizeIfNotSmi(Register rt, LInstruction* instr, |
| 1108 const char* reason) { | 1109 const char* detail) { |
| 1109 DeoptimizeIfBitSet(rt, MaskToBit(kSmiTagMask), instr, reason); | 1110 DeoptimizeIfBitSet(rt, MaskToBit(kSmiTagMask), instr, detail); |
| 1110 } | 1111 } |
| 1111 | 1112 |
| 1112 | 1113 |
| 1113 void LCodeGen::DeoptimizeIfRoot(Register rt, Heap::RootListIndex index, | 1114 void LCodeGen::DeoptimizeIfRoot(Register rt, Heap::RootListIndex index, |
| 1114 LInstruction* instr, const char* reason) { | 1115 LInstruction* instr, const char* detail) { |
| 1115 __ CompareRoot(rt, index); | 1116 __ CompareRoot(rt, index); |
| 1116 DeoptimizeIf(eq, instr, reason); | 1117 DeoptimizeIf(eq, instr, detail); |
| 1117 } | 1118 } |
| 1118 | 1119 |
| 1119 | 1120 |
| 1120 void LCodeGen::DeoptimizeIfNotRoot(Register rt, Heap::RootListIndex index, | 1121 void LCodeGen::DeoptimizeIfNotRoot(Register rt, Heap::RootListIndex index, |
| 1121 LInstruction* instr, const char* reason) { | 1122 LInstruction* instr, const char* detail) { |
| 1122 __ CompareRoot(rt, index); | 1123 __ CompareRoot(rt, index); |
| 1123 DeoptimizeIf(ne, instr, reason); | 1124 DeoptimizeIf(ne, instr, detail); |
| 1124 } | 1125 } |
| 1125 | 1126 |
| 1126 | 1127 |
| 1127 void LCodeGen::DeoptimizeIfMinusZero(DoubleRegister input, LInstruction* instr, | 1128 void LCodeGen::DeoptimizeIfMinusZero(DoubleRegister input, LInstruction* instr, |
| 1128 const char* reason) { | 1129 const char* detail) { |
| 1129 __ TestForMinusZero(input); | 1130 __ TestForMinusZero(input); |
| 1130 DeoptimizeIf(vs, instr, reason); | 1131 DeoptimizeIf(vs, instr, detail); |
| 1131 } | 1132 } |
| 1132 | 1133 |
| 1133 | 1134 |
| 1134 void LCodeGen::DeoptimizeIfBitSet(Register rt, int bit, LInstruction* instr, | 1135 void LCodeGen::DeoptimizeIfBitSet(Register rt, int bit, LInstruction* instr, |
| 1135 const char* reason) { | 1136 const char* detail) { |
| 1136 DeoptimizeBranch(instr, reason, reg_bit_set, rt, bit); | 1137 DeoptimizeBranch(instr, detail, reg_bit_set, rt, bit); |
| 1137 } | 1138 } |
| 1138 | 1139 |
| 1139 | 1140 |
| 1140 void LCodeGen::DeoptimizeIfBitClear(Register rt, int bit, LInstruction* instr, | 1141 void LCodeGen::DeoptimizeIfBitClear(Register rt, int bit, LInstruction* instr, |
| 1141 const char* reason) { | 1142 const char* detail) { |
| 1142 DeoptimizeBranch(instr, reason, reg_bit_clear, rt, bit); | 1143 DeoptimizeBranch(instr, detail, reg_bit_clear, rt, bit); |
| 1143 } | 1144 } |
| 1144 | 1145 |
| 1145 | 1146 |
| 1146 void LCodeGen::EnsureSpaceForLazyDeopt(int space_needed) { | 1147 void LCodeGen::EnsureSpaceForLazyDeopt(int space_needed) { |
| 1147 if (!info()->IsStub()) { | 1148 if (!info()->IsStub()) { |
| 1148 // Ensure that we have enough space after the previous lazy-bailout | 1149 // Ensure that we have enough space after the previous lazy-bailout |
| 1149 // instruction for patching the code here. | 1150 // instruction for patching the code here. |
| 1150 intptr_t current_pc = masm()->pc_offset(); | 1151 intptr_t current_pc = masm()->pc_offset(); |
| 1151 | 1152 |
| 1152 if (current_pc < (last_lazy_deopt_pc_ + space_needed)) { | 1153 if (current_pc < (last_lazy_deopt_pc_ + space_needed)) { |
| (...skipping 4884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6037 Handle<ScopeInfo> scope_info = instr->scope_info(); | 6038 Handle<ScopeInfo> scope_info = instr->scope_info(); |
| 6038 __ Push(scope_info); | 6039 __ Push(scope_info); |
| 6039 __ Push(ToRegister(instr->function())); | 6040 __ Push(ToRegister(instr->function())); |
| 6040 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 6041 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
| 6041 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6042 RecordSafepoint(Safepoint::kNoLazyDeopt); |
| 6042 } | 6043 } |
| 6043 | 6044 |
| 6044 | 6045 |
| 6045 | 6046 |
| 6046 } } // namespace v8::internal | 6047 } } // namespace v8::internal |
| OLD | NEW |