| 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/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
| 6 | 6 |
| 7 #include "src/compiler/code-generator-impl.h" | 7 #include "src/compiler/code-generator-impl.h" |
| 8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
| 9 #include "src/compiler/pipeline.h" | 9 #include "src/compiler/pipeline.h" |
| 10 | 10 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 for (int i = 0; i < patch_count; ++i) { | 226 for (int i = 0; i < patch_count; ++i) { |
| 227 LazyDeoptimizationEntry entry = lazy_deoptimization_entries_[i]; | 227 LazyDeoptimizationEntry entry = lazy_deoptimization_entries_[i]; |
| 228 data->SetReturnAddressPc(i, Smi::FromInt(entry.position_after_call())); | 228 data->SetReturnAddressPc(i, Smi::FromInt(entry.position_after_call())); |
| 229 data->SetPatchedAddressPc(i, Smi::FromInt(entry.deoptimization()->pos())); | 229 data->SetPatchedAddressPc(i, Smi::FromInt(entry.deoptimization()->pos())); |
| 230 } | 230 } |
| 231 | 231 |
| 232 code_object->set_deoptimization_data(*data); | 232 code_object->set_deoptimization_data(*data); |
| 233 } | 233 } |
| 234 | 234 |
| 235 | 235 |
| 236 void CodeGenerator::AddSafepointAndDeopt(Instruction* instr) { |
| 237 CallDescriptor::DeoptimizationSupport deopt = |
| 238 static_cast<CallDescriptor::DeoptimizationSupport>( |
| 239 MiscField::decode(instr->opcode())); |
| 240 |
| 241 |
| 242 if ((deopt & CallDescriptor::kLazyDeoptimization) != 0) { |
| 243 RecordLazyDeoptimizationEntry(instr); |
| 244 } |
| 245 |
| 246 bool needs_frame_state = (deopt & CallDescriptor::kNeedsFrameState) != 0; |
| 247 |
| 248 RecordSafepoint( |
| 249 instr->pointer_map(), Safepoint::kSimple, 0, |
| 250 needs_frame_state ? Safepoint::kLazyDeopt : Safepoint::kNoLazyDeopt); |
| 251 |
| 252 if ((deopt & CallDescriptor::kNeedsFrameState) != 0) { |
| 253 // The frame state starts at argument 1 (just after the code address). |
| 254 InstructionOperandConverter converter(this, instr); |
| 255 int deoptimization_id = converter.ToConstant(instr->InputAt(1)).ToInt32(); |
| 256 // The actual frame state values start at offset 2. |
| 257 BuildTranslation(instr, 2, deoptimization_id); |
| 258 safepoints()->RecordLazyDeoptimizationIndex(deoptimization_id); |
| 259 } |
| 260 } |
| 261 |
| 262 |
| 236 void CodeGenerator::RecordLazyDeoptimizationEntry(Instruction* instr) { | 263 void CodeGenerator::RecordLazyDeoptimizationEntry(Instruction* instr) { |
| 237 InstructionOperandConverter i(this, instr); | 264 InstructionOperandConverter i(this, instr); |
| 238 | 265 |
| 239 Label after_call; | 266 Label after_call; |
| 240 masm()->bind(&after_call); | 267 masm()->bind(&after_call); |
| 241 | 268 |
| 242 // The continuation and deoptimization are the last two inputs: | 269 // The continuation and deoptimization are the last two inputs: |
| 243 BasicBlock* cont_block = | 270 BasicBlock* cont_block = |
| 244 i.InputBlock(static_cast<int>(instr->InputCount()) - 2); | 271 i.InputBlock(static_cast<int>(instr->InputCount()) - 2); |
| 245 BasicBlock* deopt_block = | 272 BasicBlock* deopt_block = |
| (...skipping 11 matching lines...) Expand all Loading... |
| 257 int result = static_cast<int>(deoptimization_literals_.size()); | 284 int result = static_cast<int>(deoptimization_literals_.size()); |
| 258 for (unsigned i = 0; i < deoptimization_literals_.size(); ++i) { | 285 for (unsigned i = 0; i < deoptimization_literals_.size(); ++i) { |
| 259 if (deoptimization_literals_[i].is_identical_to(literal)) return i; | 286 if (deoptimization_literals_[i].is_identical_to(literal)) return i; |
| 260 } | 287 } |
| 261 deoptimization_literals_.push_back(literal); | 288 deoptimization_literals_.push_back(literal); |
| 262 return result; | 289 return result; |
| 263 } | 290 } |
| 264 | 291 |
| 265 | 292 |
| 266 void CodeGenerator::BuildTranslation(Instruction* instr, | 293 void CodeGenerator::BuildTranslation(Instruction* instr, |
| 294 int first_argument_index, |
| 267 int deoptimization_id) { | 295 int deoptimization_id) { |
| 268 // We should build translation only once. | 296 // We should build translation only once. |
| 269 DCHECK_EQ(NULL, deoptimization_states_[deoptimization_id]); | 297 DCHECK_EQ(NULL, deoptimization_states_[deoptimization_id]); |
| 270 | 298 |
| 271 FrameStateDescriptor* descriptor = | 299 FrameStateDescriptor* descriptor = |
| 272 code()->GetDeoptimizationEntry(deoptimization_id); | 300 code()->GetDeoptimizationEntry(deoptimization_id); |
| 273 Translation translation(&translations_, 1, 1, zone()); | 301 Translation translation(&translations_, 1, 1, zone()); |
| 274 translation.BeginJSFrame(descriptor->bailout_id(), | 302 translation.BeginJSFrame(descriptor->bailout_id(), |
| 275 Translation::kSelfLiteralId, | 303 Translation::kSelfLiteralId, |
| 276 descriptor->size() - descriptor->parameters_count()); | 304 descriptor->size() - descriptor->parameters_count()); |
| 277 | 305 |
| 278 for (int i = 0; i < descriptor->size(); i++) { | 306 for (int i = 0; i < descriptor->size(); i++) { |
| 279 AddTranslationForOperand(&translation, instr, instr->InputAt(i)); | 307 AddTranslationForOperand(&translation, instr, |
| 308 instr->InputAt(i + first_argument_index)); |
| 280 } | 309 } |
| 281 | 310 |
| 282 deoptimization_states_[deoptimization_id] = | 311 deoptimization_states_[deoptimization_id] = |
| 283 new (zone()) DeoptimizationState(translation.index()); | 312 new (zone()) DeoptimizationState(translation.index()); |
| 284 } | 313 } |
| 285 | 314 |
| 286 | 315 |
| 287 void CodeGenerator::AddTranslationForOperand(Translation* translation, | 316 void CodeGenerator::AddTranslationForOperand(Translation* translation, |
| 288 Instruction* instr, | 317 Instruction* instr, |
| 289 InstructionOperand* op) { | 318 InstructionOperand* op) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 } | 389 } |
| 361 | 390 |
| 362 | 391 |
| 363 void CodeGenerator::AddNopForSmiCodeInlining() { UNIMPLEMENTED(); } | 392 void CodeGenerator::AddNopForSmiCodeInlining() { UNIMPLEMENTED(); } |
| 364 | 393 |
| 365 #endif // !V8_TURBOFAN_BACKEND | 394 #endif // !V8_TURBOFAN_BACKEND |
| 366 | 395 |
| 367 } // namespace compiler | 396 } // namespace compiler |
| 368 } // namespace internal | 397 } // namespace internal |
| 369 } // namespace v8 | 398 } // namespace v8 |
| OLD | NEW |