| 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 // f.arguments), and those are the same in the pre-call and post-call | 259 // f.arguments), and those are the same in the pre-call and post-call |
| 260 // states. | 260 // states. |
| 261 if (descriptor->state_combine() != kIgnoreOutput) { | 261 if (descriptor->state_combine() != kIgnoreOutput) { |
| 262 deopt_state_id = | 262 deopt_state_id = |
| 263 BuildTranslation(instr, -1, frame_state_offset, kIgnoreOutput); | 263 BuildTranslation(instr, -1, frame_state_offset, kIgnoreOutput); |
| 264 } | 264 } |
| 265 #if DEBUG | 265 #if DEBUG |
| 266 // Make sure all the values live in stack slots or they are immediates. | 266 // Make sure all the values live in stack slots or they are immediates. |
| 267 // (The values should not live in register because registers are clobbered | 267 // (The values should not live in register because registers are clobbered |
| 268 // by calls.) | 268 // by calls.) |
| 269 for (int i = 0; i < descriptor->size(); i++) { | 269 for (size_t i = 0; i < descriptor->size(); i++) { |
| 270 InstructionOperand* op = instr->InputAt(frame_state_offset + 1 + i); | 270 InstructionOperand* op = instr->InputAt(frame_state_offset + 1 + i); |
| 271 CHECK(op->IsStackSlot() || op->IsImmediate()); | 271 CHECK(op->IsStackSlot() || op->IsImmediate()); |
| 272 } | 272 } |
| 273 #endif | 273 #endif |
| 274 safepoints()->RecordLazyDeoptimizationIndex(deopt_state_id); | 274 safepoints()->RecordLazyDeoptimizationIndex(deopt_state_id); |
| 275 } | 275 } |
| 276 } | 276 } |
| 277 | 277 |
| 278 | 278 |
| 279 int CodeGenerator::DefineDeoptimizationLiteral(Handle<Object> literal) { | 279 int CodeGenerator::DefineDeoptimizationLiteral(Handle<Object> literal) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 294 return code()->GetFrameStateDescriptor(state_id); | 294 return code()->GetFrameStateDescriptor(state_id); |
| 295 } | 295 } |
| 296 | 296 |
| 297 | 297 |
| 298 void CodeGenerator::BuildTranslationForFrameStateDescriptor( | 298 void CodeGenerator::BuildTranslationForFrameStateDescriptor( |
| 299 FrameStateDescriptor* descriptor, Instruction* instr, | 299 FrameStateDescriptor* descriptor, Instruction* instr, |
| 300 Translation* translation, int frame_state_offset, | 300 Translation* translation, int frame_state_offset, |
| 301 OutputFrameStateCombine state_combine) { | 301 OutputFrameStateCombine state_combine) { |
| 302 // Outer-most state must be added to translation first. | 302 // Outer-most state must be added to translation first. |
| 303 if (descriptor->outer_state() != NULL) { | 303 if (descriptor->outer_state() != NULL) { |
| 304 BuildTranslationForFrameStateDescriptor( | 304 BuildTranslationForFrameStateDescriptor(descriptor->outer_state(), instr, |
| 305 descriptor->outer_state(), instr, translation, | 305 translation, frame_state_offset, |
| 306 frame_state_offset + descriptor->size(), kIgnoreOutput); | 306 kIgnoreOutput); |
| 307 } | 307 } |
| 308 | 308 |
| 309 int height = descriptor->size() - descriptor->parameters_count(); | 309 int id = Translation::kSelfLiteralId; |
| 310 switch (state_combine) { | 310 if (!descriptor->jsfunction().IsNull()) { |
| 311 case kPushOutput: | 311 id = DefineDeoptimizationLiteral( |
| 312 height++; | 312 Handle<Object>::cast(descriptor->jsfunction().handle())); |
| 313 } |
| 314 |
| 315 switch (descriptor->type()) { |
| 316 case JS_FRAME: |
| 317 translation->BeginJSFrame(descriptor->bailout_id(), id, |
| 318 descriptor->GetHeight(state_combine)); |
| 313 break; | 319 break; |
| 314 case kIgnoreOutput: | 320 case ARGUMENTS_ADAPTOR: |
| 321 translation->BeginArgumentsAdaptorFrame(id, |
| 322 descriptor->parameters_count()); |
| 315 break; | 323 break; |
| 316 } | 324 } |
| 317 | 325 |
| 318 translation->BeginJSFrame(descriptor->bailout_id(), | 326 frame_state_offset += descriptor->outer_state()->GetTotalSize(); |
| 319 Translation::kSelfLiteralId, height); | 327 for (size_t i = 0; i < descriptor->size(); i++) { |
| 320 | |
| 321 for (int i = 0; i < descriptor->size(); i++) { | |
| 322 AddTranslationForOperand(translation, instr, | 328 AddTranslationForOperand(translation, instr, |
| 323 instr->InputAt(i + frame_state_offset)); | 329 instr->InputAt(frame_state_offset + i)); |
| 324 } | 330 } |
| 325 | 331 |
| 326 switch (state_combine) { | 332 switch (state_combine) { |
| 327 case kPushOutput: | 333 case kPushOutput: |
| 328 DCHECK(instr->OutputCount() == 1); | 334 DCHECK(instr->OutputCount() == 1); |
| 329 AddTranslationForOperand(translation, instr, instr->OutputAt(0)); | 335 AddTranslationForOperand(translation, instr, instr->OutputAt(0)); |
| 330 break; | 336 break; |
| 331 case kIgnoreOutput: | 337 case kIgnoreOutput: |
| 332 break; | 338 break; |
| 333 } | 339 } |
| 334 } | 340 } |
| 335 | 341 |
| 336 | 342 |
| 337 int CodeGenerator::BuildTranslation(Instruction* instr, int pc_offset, | 343 int CodeGenerator::BuildTranslation(Instruction* instr, int pc_offset, |
| 338 int frame_state_offset, | 344 int frame_state_offset, |
| 339 OutputFrameStateCombine state_combine) { | 345 OutputFrameStateCombine state_combine) { |
| 340 FrameStateDescriptor* descriptor = | 346 FrameStateDescriptor* descriptor = |
| 341 GetFrameStateDescriptor(instr, frame_state_offset); | 347 GetFrameStateDescriptor(instr, frame_state_offset); |
| 342 frame_state_offset++; | 348 frame_state_offset++; |
| 343 | 349 |
| 344 int frame_count = descriptor->GetFrameCount(); | 350 Translation translation(&translations_, descriptor->GetFrameCount(), |
| 345 Translation translation(&translations_, frame_count, frame_count, zone()); | 351 descriptor->GetJSFrameCount(), zone()); |
| 346 BuildTranslationForFrameStateDescriptor(descriptor, instr, &translation, | 352 BuildTranslationForFrameStateDescriptor(descriptor, instr, &translation, |
| 347 frame_state_offset, state_combine); | 353 frame_state_offset, state_combine); |
| 348 | 354 |
| 349 int deoptimization_id = static_cast<int>(deoptimization_states_.size()); | 355 int deoptimization_id = static_cast<int>(deoptimization_states_.size()); |
| 350 | 356 |
| 351 deoptimization_states_.push_back(new (zone()) DeoptimizationState( | 357 deoptimization_states_.push_back(new (zone()) DeoptimizationState( |
| 352 descriptor->bailout_id(), translation.index(), pc_offset)); | 358 descriptor->bailout_id(), translation.index(), pc_offset)); |
| 353 | 359 |
| 354 return deoptimization_id; | 360 return deoptimization_id; |
| 355 } | 361 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 } | 442 } |
| 437 | 443 |
| 438 | 444 |
| 439 void CodeGenerator::AddNopForSmiCodeInlining() { UNIMPLEMENTED(); } | 445 void CodeGenerator::AddNopForSmiCodeInlining() { UNIMPLEMENTED(); } |
| 440 | 446 |
| 441 #endif // !V8_TURBOFAN_BACKEND | 447 #endif // !V8_TURBOFAN_BACKEND |
| 442 | 448 |
| 443 } // namespace compiler | 449 } // namespace compiler |
| 444 } // namespace internal | 450 } // namespace internal |
| 445 } // namespace v8 | 451 } // namespace v8 |
| OLD | NEW |