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

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

Issue 10559035: Implement a simple register allocator that tries to keep instruction results in registers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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
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 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 __ Bind(&done); 627 __ Bind(&done);
628 __ popq(RDX); // Remove pushed instantiator type arguments. 628 __ popq(RDX); // Remove pushed instantiator type arguments.
629 __ popq(RCX); // Remove pushed instantiator. 629 __ popq(RCX); // Remove pushed instantiator.
630 } 630 }
631 631
632 632
633 void FlowGraphCompiler::EmitInstructionPrologue(Instruction* instr) { 633 void FlowGraphCompiler::EmitInstructionPrologue(Instruction* instr) {
634 LocationSummary* locs = instr->locs(); 634 LocationSummary* locs = instr->locs();
635 ASSERT(locs != NULL); 635 ASSERT(locs != NULL);
636 636
637 locs->AllocateRegisters(); 637 frame_register_allocator()->AllocateRegisters(instr);
638 638
639 // Load instruction inputs into allocated registers. 639 // TODO(vegorov): adjust assertion when we start removing comparison from the
640 for (intptr_t i = locs->input_count() - 1; i >= 0; i--) { 640 // graph when it is merged with a branch.
641 Location loc = locs->in(i); 641 ASSERT(locs->is_call() ||
642 ASSERT(loc.kind() == Location::kRegister); 642 (instr->IsBranch() && instr->AsBranch()->is_fused_with_comparison()) ||
643 __ popq(loc.reg()); 643 (locs->input_count() == instr->InputCount()));
644 }
645 } 644 }
646 645
647 646
648 // Copied from CodeGenerator::CopyParameters (CodeGenerator will be deprecated). 647 // Copied from CodeGenerator::CopyParameters (CodeGenerator will be deprecated).
649 void FlowGraphCompiler::CopyParameters() { 648 void FlowGraphCompiler::CopyParameters() {
650 const Function& function = parsed_function().function(); 649 const Function& function = parsed_function().function();
651 LocalScope* scope = parsed_function().node_sequence()->scope(); 650 LocalScope* scope = parsed_function().node_sequence()->scope();
652 const int num_fixed_params = function.num_fixed_parameters(); 651 const int num_fixed_params = function.num_fixed_parameters();
653 const int num_opt_params = function.num_optional_parameters(); 652 const int num_opt_params = function.num_optional_parameters();
654 ASSERT(parsed_function().first_parameter_index() == 653 ASSERT(parsed_function().first_parameter_index() ==
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 -1); 981 -1);
983 __ jmp(&StubCode::FixCallersTargetLabel()); 982 __ jmp(&StubCode::FixCallersTargetLabel());
984 } 983 }
985 984
986 985
987 // Infrastructure copied from class CodeGenerator. 986 // Infrastructure copied from class CodeGenerator.
988 void FlowGraphCompiler::GenerateCall(intptr_t token_index, 987 void FlowGraphCompiler::GenerateCall(intptr_t token_index,
989 intptr_t try_index, 988 intptr_t try_index,
990 const ExternalLabel* label, 989 const ExternalLabel* label,
991 PcDescriptors::Kind kind) { 990 PcDescriptors::Kind kind) {
991 ASSERT(frame_register_allocator()->IsSpilled());
992 __ call(label); 992 __ call(label);
993 AddCurrentDescriptor(kind, AstNode::kNoId, token_index, try_index); 993 AddCurrentDescriptor(kind, AstNode::kNoId, token_index, try_index);
994 } 994 }
995 995
996 996
997 void FlowGraphCompiler::GenerateCallRuntime(intptr_t cid, 997 void FlowGraphCompiler::GenerateCallRuntime(intptr_t cid,
998 intptr_t token_index, 998 intptr_t token_index,
999 intptr_t try_index, 999 intptr_t try_index,
1000 const RuntimeEntry& entry) { 1000 const RuntimeEntry& entry) {
1001 ASSERT(frame_register_allocator()->IsSpilled());
1001 __ CallRuntime(entry); 1002 __ CallRuntime(entry);
1002 AddCurrentDescriptor(PcDescriptors::kOther, cid, token_index, try_index); 1003 AddCurrentDescriptor(PcDescriptors::kOther, cid, token_index, try_index);
1003 } 1004 }
1004 1005
1005 1006
1006 // Checks class id of instance against all 'class_ids'. Jump to 'deopt' label 1007 // Checks class id of instance against all 'class_ids'. Jump to 'deopt' label
1007 // if no match or instance is Smi. 1008 // if no match or instance is Smi.
1008 void FlowGraphCompiler::EmitClassChecksNoSmi( 1009 void FlowGraphCompiler::EmitClassChecksNoSmi(
1009 const ZoneGrowableArray<intptr_t>& class_ids, 1010 const ZoneGrowableArray<intptr_t>& class_ids,
1010 Register instance_reg, 1011 Register instance_reg,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 __ cvtsi2sd(result, temp); 1051 __ cvtsi2sd(result, temp);
1051 __ Bind(&done); 1052 __ Bind(&done);
1052 } 1053 }
1053 1054
1054 1055
1055 #undef __ 1056 #undef __
1056 1057
1057 } // namespace dart 1058 } // namespace dart
1058 1059
1059 #endif // defined TARGET_ARCH_X64 1060 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698