Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: src/compiler/code-generator.cc

Issue 1134713004: [turbofan] Pass closure as node to FrameState. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/ast-graph-builder.cc ('k') | src/compiler/common-operator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 419
420 420
421 FrameStateDescriptor* CodeGenerator::GetFrameStateDescriptor( 421 FrameStateDescriptor* CodeGenerator::GetFrameStateDescriptor(
422 Instruction* instr, size_t frame_state_offset) { 422 Instruction* instr, size_t frame_state_offset) {
423 InstructionOperandConverter i(this, instr); 423 InstructionOperandConverter i(this, instr);
424 InstructionSequence::StateId state_id = 424 InstructionSequence::StateId state_id =
425 InstructionSequence::StateId::FromInt(i.InputInt32(frame_state_offset)); 425 InstructionSequence::StateId::FromInt(i.InputInt32(frame_state_offset));
426 return code()->GetFrameStateDescriptor(state_id); 426 return code()->GetFrameStateDescriptor(state_id);
427 } 427 }
428 428
429
430 namespace {
431
429 struct OperandAndType { 432 struct OperandAndType {
430 OperandAndType(InstructionOperand* operand, MachineType type) 433 InstructionOperand* const operand;
431 : operand_(operand), type_(type) {} 434 MachineType const type;
432
433 InstructionOperand* operand_;
434 MachineType type_;
435 }; 435 };
436 436
437 static OperandAndType TypedOperandForFrameState( 437
438 FrameStateDescriptor* descriptor, Instruction* instr, 438 OperandAndType TypedOperandForFrameState(FrameStateDescriptor* descriptor,
439 size_t frame_state_offset, size_t index, OutputFrameStateCombine combine) { 439 Instruction* instr,
440 size_t frame_state_offset,
441 size_t index,
442 OutputFrameStateCombine combine) {
440 DCHECK(index < descriptor->GetSize(combine)); 443 DCHECK(index < descriptor->GetSize(combine));
441 switch (combine.kind()) { 444 switch (combine.kind()) {
442 case OutputFrameStateCombine::kPushOutput: { 445 case OutputFrameStateCombine::kPushOutput: {
443 DCHECK(combine.GetPushCount() <= instr->OutputCount()); 446 DCHECK(combine.GetPushCount() <= instr->OutputCount());
444 size_t size_without_output = 447 size_t size_without_output =
445 descriptor->GetSize(OutputFrameStateCombine::Ignore()); 448 descriptor->GetSize(OutputFrameStateCombine::Ignore());
446 // If the index is past the existing stack items, return the output. 449 // If the index is past the existing stack items, return the output.
447 if (index >= size_without_output) { 450 if (index >= size_without_output) {
448 return OperandAndType(instr->OutputAt(index - size_without_output), 451 return {instr->OutputAt(index - size_without_output), kMachAnyTagged};
449 kMachAnyTagged);
450 } 452 }
451 break; 453 break;
452 } 454 }
453 case OutputFrameStateCombine::kPokeAt: 455 case OutputFrameStateCombine::kPokeAt:
454 size_t index_from_top = 456 size_t index_from_top =
455 descriptor->GetSize(combine) - 1 - combine.GetOffsetToPokeAt(); 457 descriptor->GetSize(combine) - 1 - combine.GetOffsetToPokeAt();
456 if (index >= index_from_top && 458 if (index >= index_from_top &&
457 index < index_from_top + instr->OutputCount()) { 459 index < index_from_top + instr->OutputCount()) {
458 return OperandAndType(instr->OutputAt(index - index_from_top), 460 return {instr->OutputAt(index - index_from_top), kMachAnyTagged};
459 kMachAnyTagged);
460 } 461 }
461 break; 462 break;
462 } 463 }
463 return OperandAndType(instr->InputAt(frame_state_offset + index), 464 return {instr->InputAt(frame_state_offset + index),
464 descriptor->GetType(index)); 465 descriptor->GetType(index)};
465 } 466 }
466 467
468 } // namespace
469
467 470
468 void CodeGenerator::BuildTranslationForFrameStateDescriptor( 471 void CodeGenerator::BuildTranslationForFrameStateDescriptor(
469 FrameStateDescriptor* descriptor, Instruction* instr, 472 FrameStateDescriptor* descriptor, Instruction* instr,
470 Translation* translation, size_t frame_state_offset, 473 Translation* translation, size_t frame_state_offset,
471 OutputFrameStateCombine state_combine) { 474 OutputFrameStateCombine state_combine) {
472 // Outer-most state must be added to translation first. 475 // Outer-most state must be added to translation first.
473 if (descriptor->outer_state() != NULL) { 476 if (descriptor->outer_state() != nullptr) {
474 BuildTranslationForFrameStateDescriptor(descriptor->outer_state(), instr, 477 BuildTranslationForFrameStateDescriptor(descriptor->outer_state(), instr,
475 translation, frame_state_offset, 478 translation, frame_state_offset,
476 OutputFrameStateCombine::Ignore()); 479 OutputFrameStateCombine::Ignore());
477 } 480 }
481 frame_state_offset += descriptor->outer_state()->GetTotalSize();
478 482
483 // TODO(bmeurer): Fix this special case here.
479 int id = Translation::kSelfLiteralId; 484 int id = Translation::kSelfLiteralId;
480 if (!descriptor->jsfunction().is_null()) { 485 if (descriptor->outer_state() != nullptr) {
481 id = DefineDeoptimizationLiteral( 486 InstructionOperandConverter converter(this, instr);
482 Handle<Object>::cast(descriptor->jsfunction().ToHandleChecked())); 487 Handle<HeapObject> function(converter.InputHeapObject(frame_state_offset));
488 id = DefineDeoptimizationLiteral(function);
483 } 489 }
484 490
485 switch (descriptor->type()) { 491 switch (descriptor->type()) {
486 case JS_FRAME: 492 case JS_FRAME:
487 translation->BeginJSFrame( 493 translation->BeginJSFrame(
488 descriptor->bailout_id(), id, 494 descriptor->bailout_id(), id,
489 static_cast<unsigned int>(descriptor->GetSize(state_combine) - 495 static_cast<unsigned int>(descriptor->GetSize(state_combine) -
490 descriptor->parameters_count())); 496 (1 + descriptor->parameters_count())));
Jarin 2015/05/15 12:15:14 Maybe we want a TODO explaining the "1 +" here. An
Benedikt Meurer 2015/05/15 12:15:52 Covered by TODO above.
491 break; 497 break;
492 case ARGUMENTS_ADAPTOR: 498 case ARGUMENTS_ADAPTOR:
493 translation->BeginArgumentsAdaptorFrame( 499 translation->BeginArgumentsAdaptorFrame(
494 id, static_cast<unsigned int>(descriptor->parameters_count())); 500 id, static_cast<unsigned int>(descriptor->parameters_count()));
495 break; 501 break;
496 } 502 }
497 503
498 frame_state_offset += descriptor->outer_state()->GetTotalSize(); 504 for (size_t i = 1; i < descriptor->GetSize(state_combine); i++) {
499 for (size_t i = 0; i < descriptor->GetSize(state_combine); i++) {
500 OperandAndType op = TypedOperandForFrameState( 505 OperandAndType op = TypedOperandForFrameState(
501 descriptor, instr, frame_state_offset, i, state_combine); 506 descriptor, instr, frame_state_offset, i, state_combine);
502 AddTranslationForOperand(translation, instr, op.operand_, op.type_); 507 AddTranslationForOperand(translation, instr, op.operand, op.type);
503 } 508 }
504 } 509 }
505 510
506 511
507 int CodeGenerator::BuildTranslation(Instruction* instr, int pc_offset, 512 int CodeGenerator::BuildTranslation(Instruction* instr, int pc_offset,
508 size_t frame_state_offset, 513 size_t frame_state_offset,
509 OutputFrameStateCombine state_combine) { 514 OutputFrameStateCombine state_combine) {
510 FrameStateDescriptor* descriptor = 515 FrameStateDescriptor* descriptor =
511 GetFrameStateDescriptor(instr, frame_state_offset); 516 GetFrameStateDescriptor(instr, frame_state_offset);
512 frame_state_offset++; 517 frame_state_offset++;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 : masm_(gen->masm()), next_(gen->ools_) { 666 : masm_(gen->masm()), next_(gen->ools_) {
662 gen->ools_ = this; 667 gen->ools_ = this;
663 } 668 }
664 669
665 670
666 OutOfLineCode::~OutOfLineCode() {} 671 OutOfLineCode::~OutOfLineCode() {}
667 672
668 } // namespace compiler 673 } // namespace compiler
669 } // namespace internal 674 } // namespace internal
670 } // namespace v8 675 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.cc ('k') | src/compiler/common-operator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698