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_X87 | 7 #if V8_TARGET_ARCH_X87 |
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 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 int pc_offset = masm()->pc_offset(); | 1073 int pc_offset = masm()->pc_offset(); |
1074 environment->Register(deoptimization_index, | 1074 environment->Register(deoptimization_index, |
1075 translation.index(), | 1075 translation.index(), |
1076 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); | 1076 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); |
1077 deoptimizations_.Add(environment, zone()); | 1077 deoptimizations_.Add(environment, zone()); |
1078 } | 1078 } |
1079 } | 1079 } |
1080 | 1080 |
1081 | 1081 |
1082 void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr, | 1082 void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr, |
1083 const char* detail, | 1083 Deoptimizer::DeoptReason deopt_reason, |
1084 Deoptimizer::BailoutType bailout_type) { | 1084 Deoptimizer::BailoutType bailout_type) { |
1085 LEnvironment* environment = instr->environment(); | 1085 LEnvironment* environment = instr->environment(); |
1086 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 1086 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
1087 DCHECK(environment->HasBeenRegistered()); | 1087 DCHECK(environment->HasBeenRegistered()); |
1088 int id = environment->deoptimization_index(); | 1088 int id = environment->deoptimization_index(); |
1089 DCHECK(info()->IsOptimizing() || info()->IsStub()); | 1089 DCHECK(info()->IsOptimizing() || info()->IsStub()); |
1090 Address entry = | 1090 Address entry = |
1091 Deoptimizer::GetDeoptimizationEntry(isolate(), id, bailout_type); | 1091 Deoptimizer::GetDeoptimizationEntry(isolate(), id, bailout_type); |
1092 if (entry == NULL) { | 1092 if (entry == NULL) { |
1093 Abort(kBailoutWasNotPrepared); | 1093 Abort(kBailoutWasNotPrepared); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 } | 1137 } |
1138 | 1138 |
1139 if (info()->ShouldTrapOnDeopt()) { | 1139 if (info()->ShouldTrapOnDeopt()) { |
1140 Label done; | 1140 Label done; |
1141 if (cc != no_condition) __ j(NegateCondition(cc), &done, Label::kNear); | 1141 if (cc != no_condition) __ j(NegateCondition(cc), &done, Label::kNear); |
1142 __ int3(); | 1142 __ int3(); |
1143 __ bind(&done); | 1143 __ bind(&done); |
1144 } | 1144 } |
1145 | 1145 |
1146 Deoptimizer::Reason reason(instr->hydrogen_value()->position().raw(), | 1146 Deoptimizer::Reason reason(instr->hydrogen_value()->position().raw(), |
1147 instr->Mnemonic(), detail); | 1147 instr->Mnemonic(), deopt_reason); |
1148 DCHECK(info()->IsStub() || frame_is_built_); | 1148 DCHECK(info()->IsStub() || frame_is_built_); |
1149 if (cc == no_condition && frame_is_built_) { | 1149 if (cc == no_condition && frame_is_built_) { |
1150 DeoptComment(reason); | 1150 DeoptComment(reason); |
1151 __ call(entry, RelocInfo::RUNTIME_ENTRY); | 1151 __ call(entry, RelocInfo::RUNTIME_ENTRY); |
1152 } else { | 1152 } else { |
1153 Deoptimizer::JumpTableEntry table_entry(entry, reason, bailout_type, | 1153 Deoptimizer::JumpTableEntry table_entry(entry, reason, bailout_type, |
1154 !frame_is_built_); | 1154 !frame_is_built_); |
1155 // We often have several deopts to the same entry, reuse the last | 1155 // We often have several deopts to the same entry, reuse the last |
1156 // jump entry if this is the case. | 1156 // jump entry if this is the case. |
1157 if (jump_table_.is_empty() || | 1157 if (jump_table_.is_empty() || |
1158 !table_entry.IsEquivalentTo(jump_table_.last())) { | 1158 !table_entry.IsEquivalentTo(jump_table_.last())) { |
1159 jump_table_.Add(table_entry, zone()); | 1159 jump_table_.Add(table_entry, zone()); |
1160 } | 1160 } |
1161 if (cc == no_condition) { | 1161 if (cc == no_condition) { |
1162 __ jmp(&jump_table_.last().label); | 1162 __ jmp(&jump_table_.last().label); |
1163 } else { | 1163 } else { |
1164 __ j(cc, &jump_table_.last().label); | 1164 __ j(cc, &jump_table_.last().label); |
1165 } | 1165 } |
1166 } | 1166 } |
1167 } | 1167 } |
1168 | 1168 |
1169 | 1169 |
1170 void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr, | 1170 void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr, |
1171 const char* detail) { | 1171 Deoptimizer::DeoptReason deopt_reason) { |
1172 Deoptimizer::BailoutType bailout_type = info()->IsStub() | 1172 Deoptimizer::BailoutType bailout_type = info()->IsStub() |
1173 ? Deoptimizer::LAZY | 1173 ? Deoptimizer::LAZY |
1174 : Deoptimizer::EAGER; | 1174 : Deoptimizer::EAGER; |
1175 DeoptimizeIf(cc, instr, detail, bailout_type); | 1175 DeoptimizeIf(cc, instr, deopt_reason, bailout_type); |
1176 } | 1176 } |
1177 | 1177 |
1178 | 1178 |
1179 void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) { | 1179 void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) { |
1180 int length = deoptimizations_.length(); | 1180 int length = deoptimizations_.length(); |
1181 if (length == 0) return; | 1181 if (length == 0) return; |
1182 Handle<DeoptimizationInputData> data = | 1182 Handle<DeoptimizationInputData> data = |
1183 DeoptimizationInputData::New(isolate(), length, TENURED); | 1183 DeoptimizationInputData::New(isolate(), length, TENURED); |
1184 | 1184 |
1185 Handle<ByteArray> translations = | 1185 Handle<ByteArray> translations = |
(...skipping 4118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5304 | 5304 |
5305 __ bind(&check_bools); | 5305 __ bind(&check_bools); |
5306 __ cmp(input_reg, factory()->true_value()); | 5306 __ cmp(input_reg, factory()->true_value()); |
5307 __ j(not_equal, &check_false, Label::kNear); | 5307 __ j(not_equal, &check_false, Label::kNear); |
5308 __ Move(input_reg, Immediate(1)); | 5308 __ Move(input_reg, Immediate(1)); |
5309 __ jmp(done); | 5309 __ jmp(done); |
5310 | 5310 |
5311 __ bind(&check_false); | 5311 __ bind(&check_false); |
5312 __ cmp(input_reg, factory()->false_value()); | 5312 __ cmp(input_reg, factory()->false_value()); |
5313 DeoptimizeIf(not_equal, instr, | 5313 DeoptimizeIf(not_equal, instr, |
5314 Deoptimizer::kNotAHeapNumberUndefinedTrueFalse); | 5314 Deoptimizer::kNotAHeapNumberUndefinedBoolean); |
5315 __ Move(input_reg, Immediate(0)); | 5315 __ Move(input_reg, Immediate(0)); |
5316 } else { | 5316 } else { |
5317 // TODO(olivf) Converting a number on the fpu is actually quite slow. We | 5317 // TODO(olivf) Converting a number on the fpu is actually quite slow. We |
5318 // should first try a fast conversion and then bailout to this slow case. | 5318 // should first try a fast conversion and then bailout to this slow case. |
5319 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), | 5319 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), |
5320 isolate()->factory()->heap_number_map()); | 5320 isolate()->factory()->heap_number_map()); |
5321 DeoptimizeIf(not_equal, instr, Deoptimizer::kNotAHeapNumber); | 5321 DeoptimizeIf(not_equal, instr, Deoptimizer::kNotAHeapNumber); |
5322 | 5322 |
5323 __ sub(esp, Immediate(kPointerSize)); | 5323 __ sub(esp, Immediate(kPointerSize)); |
5324 __ fld_d(FieldOperand(input_reg, HeapNumber::kValueOffset)); | 5324 __ fld_d(FieldOperand(input_reg, HeapNumber::kValueOffset)); |
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6378 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 6378 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
6379 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6379 RecordSafepoint(Safepoint::kNoLazyDeopt); |
6380 } | 6380 } |
6381 | 6381 |
6382 | 6382 |
6383 #undef __ | 6383 #undef __ |
6384 | 6384 |
6385 } } // namespace v8::internal | 6385 } } // namespace v8::internal |
6386 | 6386 |
6387 #endif // V8_TARGET_ARCH_X87 | 6387 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |