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

Side by Side Diff: runtime/vm/flow_graph_compiler_x64.cc

Issue 10398046: Move code for accessing captured variables into the IL. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
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 | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/il_printer.cc » ('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 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 ASSERT(VerifyCallComputation(comp)); 606 ASSERT(VerifyCallComputation(comp));
607 EmitStaticCall(comp->token_index(), 607 EmitStaticCall(comp->token_index(),
608 comp->try_index(), 608 comp->try_index(),
609 comp->function(), 609 comp->function(),
610 comp->ArgumentCount(), 610 comp->ArgumentCount(),
611 comp->argument_names()); 611 comp->argument_names());
612 } 612 }
613 613
614 614
615 void FlowGraphCompiler::VisitLoadLocal(LoadLocalComp* comp) { 615 void FlowGraphCompiler::VisitLoadLocal(LoadLocalComp* comp) {
616 if (comp->local().is_captured()) { 616 __ movq(RAX, Address(RBP, comp->local().index() * kWordSize));
617 // The variable lives in the context.
618 intptr_t delta = comp->context_level() -
619 comp->local().owner()->context_level();
620 ASSERT(delta >= 0);
621 Register base = CTX;
622 while (delta-- > 0) {
623 __ movq(RAX, FieldAddress(base, Context::parent_offset()));
624 base = RAX;
625 }
626 __ movq(RAX,
627 FieldAddress(base,
628 Context::variable_offset(comp->local().index())));
629 } else {
630 // The variable lives in the current stack frame.
631 __ movq(RAX, Address(RBP, comp->local().index() * kWordSize));
632 }
633 } 617 }
634 618
635 619
636 void FlowGraphCompiler::VisitStoreLocal(StoreLocalComp* comp) { 620 void FlowGraphCompiler::VisitStoreLocal(StoreLocalComp* comp) {
637 LoadValue(RAX, comp->value()); 621 LoadValue(RAX, comp->value());
638 if (comp->local().is_captured()) { 622 __ movq(Address(RBP, comp->local().index() * kWordSize), RAX);
639 // The variable lives in the context.
640 Register scratch = R10;
641 intptr_t delta = comp->context_level() -
642 comp->local().owner()->context_level();
643 ASSERT(delta >= 0);
644 Register base = CTX;
645 while (delta-- > 0) {
646 __ movq(scratch, FieldAddress(base, Context::parent_offset()));
647 base = scratch;
648 }
649 __ StoreIntoObject(
650 base,
651 FieldAddress(base, Context::variable_offset(comp->local().index())),
652 RAX);
653 } else {
654 // The variable lives in the current stack frame.
655 __ movq(Address(RBP, comp->local().index() * kWordSize), RAX);
656 }
657 } 623 }
658 624
659 625
660 void FlowGraphCompiler::VisitNativeCall(NativeCallComp* comp) { 626 void FlowGraphCompiler::VisitNativeCall(NativeCallComp* comp) {
661 // Push the result place holder initialized to NULL. 627 // Push the result place holder initialized to NULL.
662 __ PushObject(Object::ZoneHandle()); 628 __ PushObject(Object::ZoneHandle());
663 // Pass a pointer to the first argument in RAX. 629 // Pass a pointer to the first argument in RAX.
664 if (!comp->has_optional_parameters()) { 630 if (!comp->has_optional_parameters()) {
665 __ leaq(RAX, Address(RBP, (1 + comp->argument_count()) * kWordSize)); 631 __ leaq(RAX, Address(RBP, (1 + comp->argument_count()) * kWordSize));
666 } else { 632 } else {
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 if (cls.HasTypeArguments()) { 905 if (cls.HasTypeArguments()) {
940 __ popq(RCX); // Discard type arguments. 906 __ popq(RCX); // Discard type arguments.
941 } 907 }
942 if (function.IsImplicitInstanceClosureFunction()) { 908 if (function.IsImplicitInstanceClosureFunction()) {
943 __ popq(RCX); // Discard receiver. 909 __ popq(RCX); // Discard receiver.
944 } 910 }
945 } 911 }
946 912
947 913
948 void FlowGraphCompiler::VisitNativeLoadField(NativeLoadFieldComp* comp) { 914 void FlowGraphCompiler::VisitNativeLoadField(NativeLoadFieldComp* comp) {
949 __ popq(RAX); 915 LoadValue(RAX, comp->value());
950 __ movq(RAX, FieldAddress(RAX, comp->offset_in_bytes())); 916 __ movq(RAX, FieldAddress(RAX, comp->offset_in_bytes()));
951 } 917 }
952 918
953 919
920 void FlowGraphCompiler::VisitNativeStoreField(NativeStoreFieldComp* comp) {
921 LoadValue(RBX, comp->dest());
922 LoadValue(RAX, comp->value());
923 __ StoreIntoObject(RBX, FieldAddress(RBX, comp->offset_in_bytes()), RAX);
924 }
925
926
954 void FlowGraphCompiler::VisitInstantiateTypeArguments( 927 void FlowGraphCompiler::VisitInstantiateTypeArguments(
955 InstantiateTypeArgumentsComp* comp) { 928 InstantiateTypeArgumentsComp* comp) {
956 __ popq(RAX); // Instantiator. 929 __ popq(RAX); // Instantiator.
957 930
958 // RAX is the instantiator AbstractTypeArguments object (or null). 931 // RAX is the instantiator AbstractTypeArguments object (or null).
959 // If the instantiator is null and if the type argument vector 932 // If the instantiator is null and if the type argument vector
960 // instantiated from null becomes a vector of Dynamic, then use null as 933 // instantiated from null becomes a vector of Dynamic, then use null as
961 // the type arguments. 934 // the type arguments.
962 Label type_arguments_instantiated; 935 Label type_arguments_instantiated;
963 const intptr_t len = comp->type_arguments().Length(); 936 const intptr_t len = comp->type_arguments().Length();
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 ASSERT(exception_handlers_list_ != NULL); 1687 ASSERT(exception_handlers_list_ != NULL);
1715 const ExceptionHandlers& handlers = ExceptionHandlers::Handle( 1688 const ExceptionHandlers& handlers = ExceptionHandlers::Handle(
1716 exception_handlers_list_->FinalizeExceptionHandlers(code.EntryPoint())); 1689 exception_handlers_list_->FinalizeExceptionHandlers(code.EntryPoint()));
1717 code.set_exception_handlers(handlers); 1690 code.set_exception_handlers(handlers);
1718 } 1691 }
1719 1692
1720 1693
1721 } // namespace dart 1694 } // namespace dart
1722 1695
1723 #endif // defined TARGET_ARCH_X64 1696 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/il_printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698