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

Side by Side Diff: vm/flow_graph_compiler_x64.cc

Issue 10407082: Reland: Migrate {Closure,Instance,Static}Call to use location-based code generation templates. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « vm/flow_graph_compiler_x64.h ('k') | vm/intermediate_language.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/flow_graph_compiler.h" 8 #include "vm/flow_graph_compiler.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 comp->token_index(), 428 comp->token_index(),
429 comp->try_index(), 429 comp->try_index(),
430 kConditionTypeErrorRuntimeEntry); 430 kConditionTypeErrorRuntimeEntry);
431 // We should never return here. 431 // We should never return here.
432 __ int3(); 432 __ int3();
433 433
434 __ Bind(&done); 434 __ Bind(&done);
435 } 435 }
436 436
437 437
438 // True iff. the arguments to a call will be properly pushed and can
439 // be popped after the call.
440 template <typename T> static bool VerifyCallComputation(T* comp) {
441 // Argument values should be consecutive temps.
442 //
443 // TODO(kmillikin): implement stack height tracking so we can also assert
444 // they are on top of the stack.
445 intptr_t previous = -1;
446 for (int i = 0; i < comp->ArgumentCount(); ++i) {
447 Value* val = comp->ArgumentAt(i);
448 if (!val->IsUse()) return false;
449 intptr_t current = val->AsUse()->definition()->temp_index();
450 if (i != 0) {
451 if (current != (previous + 1)) return false;
452 }
453 previous = current;
454 }
455 return true;
456 }
457
458
459 // Truee iff. the v2 is above v1 on stack, or one of them is constant. 438 // Truee iff. the v2 is above v1 on stack, or one of them is constant.
460 static bool VerifyValues(Value* v1, Value* v2) { 439 static bool VerifyValues(Value* v1, Value* v2) {
461 if (v1->IsUse() && v2->IsUse()) { 440 if (v1->IsUse() && v2->IsUse()) {
462 return (v1->AsUse()->definition()->temp_index() + 1) == 441 return (v1->AsUse()->definition()->temp_index() + 1) ==
463 v2->AsUse()->definition()->temp_index(); 442 v2->AsUse()->definition()->temp_index();
464 } 443 }
465 return true; 444 return true;
466 } 445 }
467 446
468 447
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 __ movq(RAX, CTX); 502 __ movq(RAX, CTX);
524 } 503 }
525 504
526 505
527 void FlowGraphCompiler::VisitStoreContext(StoreContextComp* comp) { 506 void FlowGraphCompiler::VisitStoreContext(StoreContextComp* comp) {
528 LoadValue(CTX, comp->value()); 507 LoadValue(CTX, comp->value());
529 } 508 }
530 509
531 510
532 void FlowGraphCompiler::VisitClosureCall(ClosureCallComp* comp) { 511 void FlowGraphCompiler::VisitClosureCall(ClosureCallComp* comp) {
533 ASSERT(VerifyCallComputation(comp)); 512 // Moved to intermediate_language_x64.cc.
534 // The arguments to the stub include the closure. The arguments 513 UNREACHABLE();
535 // descriptor describes the closure's arguments (and so does not include
536 // the closure).
537 int argument_count = comp->ArgumentCount();
538 const Array& arguments_descriptor =
539 CodeGenerator::ArgumentsDescriptor(argument_count - 1,
540 comp->argument_names());
541 __ LoadObject(R10, arguments_descriptor);
542
543 GenerateCall(comp->token_index(),
544 comp->try_index(),
545 &StubCode::CallClosureFunctionLabel(),
546 PcDescriptors::kOther);
547 __ Drop(argument_count);
548 } 514 }
549 515
550 516
551 void FlowGraphCompiler::VisitInstanceCall(InstanceCallComp* comp) { 517 void FlowGraphCompiler::VisitInstanceCall(InstanceCallComp* comp) {
552 ASSERT(VerifyCallComputation(comp)); 518 // Moved to intermediate_language_x64.cc.
553 EmitInstanceCall(comp->cid(), 519 UNREACHABLE();
554 comp->token_index(),
555 comp->try_index(),
556 comp->function_name(),
557 comp->ArgumentCount(),
558 comp->argument_names(),
559 comp->checked_argument_count());
560 } 520 }
561 521
562 522
563 void FlowGraphCompiler::VisitStrictCompare(StrictCompareComp* comp) { 523 void FlowGraphCompiler::VisitStrictCompare(StrictCompareComp* comp) {
564 // Visitor should not be used to compile this instruction. 524 // Visitor should not be used to compile this instruction.
565 // Native code template for StrictCompareComp was moved to 525 // Native code template for StrictCompareComp was moved to
566 // StrictCompareComp::EmitNativeCode. 526 // StrictCompareComp::EmitNativeCode.
567 UNREACHABLE(); 527 UNREACHABLE();
568 } 528 }
569 529
(...skipping 30 matching lines...) Expand all
600 comp->try_index(), 560 comp->try_index(),
601 operator_name, 561 operator_name,
602 kNumberOfArguments, 562 kNumberOfArguments,
603 kNoArgumentNames, 563 kNoArgumentNames,
604 kNumArgumentsChecked); 564 kNumArgumentsChecked);
605 __ Bind(&done); 565 __ Bind(&done);
606 } 566 }
607 567
608 568
609 void FlowGraphCompiler::VisitStaticCall(StaticCallComp* comp) { 569 void FlowGraphCompiler::VisitStaticCall(StaticCallComp* comp) {
610 ASSERT(VerifyCallComputation(comp)); 570 // Moved to intermediate_language_x64.cc.
611 EmitStaticCall(comp->token_index(), 571 UNREACHABLE();
612 comp->try_index(),
613 comp->function(),
614 comp->ArgumentCount(),
615 comp->argument_names());
616 } 572 }
617 573
618 574
619 void FlowGraphCompiler::VisitLoadLocal(LoadLocalComp* comp) { 575 void FlowGraphCompiler::VisitLoadLocal(LoadLocalComp* comp) {
620 __ movq(RAX, Address(RBP, comp->local().index() * kWordSize)); 576 __ movq(RAX, Address(RBP, comp->local().index() * kWordSize));
621 } 577 }
622 578
623 579
624 void FlowGraphCompiler::VisitStoreLocal(StoreLocalComp* comp) { 580 void FlowGraphCompiler::VisitStoreLocal(StoreLocalComp* comp) {
625 LoadValue(RAX, comp->value()); 581 LoadValue(RAX, comp->value());
(...skipping 21 matching lines...) Expand all
647 } 603 }
648 604
649 605
650 void FlowGraphCompiler::VisitLoadInstanceField(LoadInstanceFieldComp* comp) { 606 void FlowGraphCompiler::VisitLoadInstanceField(LoadInstanceFieldComp* comp) {
651 LoadValue(RAX, comp->instance()); 607 LoadValue(RAX, comp->instance());
652 __ movq(RAX, FieldAddress(RAX, comp->field().Offset())); 608 __ movq(RAX, FieldAddress(RAX, comp->field().Offset()));
653 } 609 }
654 610
655 611
656 void FlowGraphCompiler::VisitStoreInstanceField(StoreInstanceFieldComp* comp) { 612 void FlowGraphCompiler::VisitStoreInstanceField(StoreInstanceFieldComp* comp) {
657 VerifyValues(comp->instance(), comp->value()); 613 ASSERT(VerifyValues(comp->instance(), comp->value()));
658 LoadValue(RDX, comp->value()); 614 LoadValue(RDX, comp->value());
659 LoadValue(RAX, comp->instance()); 615 LoadValue(RAX, comp->instance());
660 __ StoreIntoObject(RAX, FieldAddress(RAX, comp->field().Offset()), RDX); 616 __ StoreIntoObject(RAX, FieldAddress(RAX, comp->field().Offset()), RDX);
661 } 617 }
662 618
663 619
664 620
665 void FlowGraphCompiler::VisitLoadStaticField(LoadStaticFieldComp* comp) { 621 void FlowGraphCompiler::VisitLoadStaticField(LoadStaticFieldComp* comp) {
666 __ LoadObject(RDX, comp->field()); 622 __ LoadObject(RDX, comp->field());
667 __ movq(RAX, FieldAddress(RDX, Field::value_offset())); 623 __ movq(RAX, FieldAddress(RDX, Field::value_offset()));
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
1752 1708
1753 1709
1754 void FlowGraphCompiler::FinalizeComments(const Code& code) { 1710 void FlowGraphCompiler::FinalizeComments(const Code& code) {
1755 code.set_comments(assembler_->GetCodeComments()); 1711 code.set_comments(assembler_->GetCodeComments());
1756 } 1712 }
1757 1713
1758 1714
1759 } // namespace dart 1715 } // namespace dart
1760 1716
1761 #endif // defined TARGET_ARCH_X64 1717 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « vm/flow_graph_compiler_x64.h ('k') | vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698