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

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

Issue 10538024: Implemented missing instructions in ia32, more sharing, removed bailouts, enable optimiziations on … (Closed) Base URL: http://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
« no previous file with comments | « runtime/vm/flow_graph_compiler_ia32.h ('k') | runtime/vm/flow_graph_compiler_shared.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_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
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"
11 #include "vm/ast_printer.h" 11 #include "vm/ast_printer.h"
12 #include "vm/compiler_stats.h" 12 #include "vm/compiler_stats.h"
13 #include "vm/il_printer.h" 13 #include "vm/il_printer.h"
14 #include "vm/locations.h" 14 #include "vm/locations.h"
15 #include "vm/object_store.h" 15 #include "vm/object_store.h"
16 #include "vm/stub_code.h" 16 #include "vm/stub_code.h"
17 17
18 namespace dart { 18 namespace dart {
19 19
20 DECLARE_FLAG(bool, code_comments);
21 DECLARE_FLAG(bool, compiler_stats); 20 DECLARE_FLAG(bool, compiler_stats);
22 DECLARE_FLAG(bool, enable_type_checks); 21 DECLARE_FLAG(bool, enable_type_checks);
23 DECLARE_FLAG(bool, print_ast); 22 DECLARE_FLAG(bool, print_ast);
24 DECLARE_FLAG(bool, print_scopes); 23 DECLARE_FLAG(bool, print_scopes);
25 DECLARE_FLAG(bool, trace_functions); 24 DECLARE_FLAG(bool, trace_functions);
26 25
27 26
28 void DeoptimizationStub::GenerateCode(FlowGraphCompilerShared* compiler) { 27 void DeoptimizationStub::GenerateCode(FlowGraphCompiler* compiler) {
29 Assembler* assem = compiler->assembler(); 28 Assembler* assem = compiler->assembler();
30 #define __ assem-> 29 #define __ assem->
31 __ Comment("Deopt stub for id %d", deopt_id_); 30 __ Comment("Deopt stub for id %d", deopt_id_);
32 __ Bind(entry_label()); 31 __ Bind(entry_label());
33 for (intptr_t i = 0; i < registers_.length(); i++) { 32 for (intptr_t i = 0; i < registers_.length(); i++) {
34 if (registers_[i] != kNoRegister) { 33 if (registers_[i] != kNoRegister) {
35 __ pushl(registers_[i]); 34 __ pushl(registers_[i]);
36 } 35 }
37 } 36 }
38 __ movl(EAX, Immediate(Smi::RawValue(reason_))); 37 __ movl(EAX, Immediate(Smi::RawValue(reason_)));
39 __ call(&StubCode::DeoptimizeLabel()); 38 __ call(&StubCode::DeoptimizeLabel());
40 compiler->AddCurrentDescriptor(PcDescriptors::kOther, 39 compiler->AddCurrentDescriptor(PcDescriptors::kOther,
41 deopt_id_, 40 deopt_id_,
42 deopt_token_index_, 41 deopt_token_index_,
43 try_index_); 42 try_index_);
44 #undef __ 43 #undef __
45 } 44 }
46 45
47 46
48 FlowGraphCompiler::FlowGraphCompiler(
49 Assembler* assembler,
50 const ParsedFunction& parsed_function,
51 const GrowableArray<BlockEntryInstr*>& block_order,
52 bool is_optimizing)
53 : FlowGraphCompilerShared(assembler,
54 parsed_function,
55 block_order,
56 is_optimizing) {}
57
58 47
59 #define __ assembler()-> 48 #define __ assembler()->
60 49
61 void FlowGraphCompiler::GenerateInlinedGetter(intptr_t offset) { 50 void FlowGraphCompiler::GenerateInlinedGetter(intptr_t offset) {
62 // TOS: return address. 51 // TOS: return address.
63 // +1 : receiver. 52 // +1 : receiver.
64 // Sequence node has one return node, its input is load field node. 53 // Sequence node has one return node, its input is load field node.
65 __ movl(EAX, Address(ESP, 1 * kWordSize)); 54 __ movl(EAX, Address(ESP, 1 * kWordSize));
66 __ movl(EAX, FieldAddress(EAX, offset)); 55 __ movl(EAX, FieldAddress(EAX, offset));
67 __ ret(); 56 __ ret();
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 // type check runtime call is the checked value. 939 // type check runtime call is the checked value.
951 __ Drop(8); 940 __ Drop(8);
952 __ popl(EAX); 941 __ popl(EAX);
953 942
954 __ Bind(&is_assignable); 943 __ Bind(&is_assignable);
955 __ popl(EDX); // Remove pushed instantiator type arguments.. 944 __ popl(EDX); // Remove pushed instantiator type arguments..
956 __ popl(ECX); // Remove pushed instantiator. 945 __ popl(ECX); // Remove pushed instantiator.
957 } 946 }
958 947
959 948
960 void FlowGraphCompiler::EmitComment(Instruction* instr) {
961 char buffer[80];
962 BufferFormatter f(buffer, sizeof(buffer));
963 instr->PrintTo(&f);
964 __ Comment("@%d: %s", instr->cid(), buffer);
965 }
966
967
968 void FlowGraphCompiler::BailoutOnInstruction(Instruction* instr) {
969 char buffer[80];
970 BufferFormatter f(buffer, sizeof(buffer));
971 instr->PrintTo(&f);
972 Bailout(buffer);
973 }
974
975
976 void FlowGraphCompiler::EmitInstructionPrologue(Instruction* instr) { 949 void FlowGraphCompiler::EmitInstructionPrologue(Instruction* instr) {
977 LocationSummary* locs = instr->locs(); 950 LocationSummary* locs = instr->locs();
978 ASSERT(locs != NULL); 951 ASSERT(locs != NULL);
979 952
980 locs->AllocateRegisters(); 953 locs->AllocateRegisters();
981 954
982 // Load instruction inputs into allocated registers. 955 // Load instruction inputs into allocated registers.
983 for (intptr_t i = locs->input_count() - 1; i >= 0; i--) { 956 for (intptr_t i = locs->input_count() - 1; i >= 0; i--) {
984 Location loc = locs->in(i); 957 Location loc = locs->in(i);
985 ASSERT(loc.kind() == Location::kRegister); 958 ASSERT(loc.kind() == Location::kRegister);
986 __ popl(loc.reg()); 959 __ popl(loc.reg());
987 } 960 }
988 } 961 }
989 962
990 963
991 void FlowGraphCompiler::VisitBlocks() {
992 for (intptr_t i = 0; i < block_order().length(); ++i) {
993 __ Comment("B%d", i);
994 // Compile the block entry.
995 set_current_block(block_order()[i]);
996 current_block()->PrepareEntry(this);
997 Instruction* instr = current_block()->StraightLineSuccessor();
998 // Compile all successors until an exit, branch, or a block entry.
999 while ((instr != NULL) && !instr->IsBlockEntry()) {
1000 if (FLAG_code_comments) EmitComment(instr);
1001 if (instr->locs() == NULL) {
1002 BailoutOnInstruction(instr);
1003 } else {
1004 EmitInstructionPrologue(instr);
1005 instr->EmitNativeCode(this);
1006 instr = instr->StraightLineSuccessor();
1007 }
1008 }
1009 BlockEntryInstr* successor =
1010 (instr == NULL) ? NULL : instr->AsBlockEntry();
1011 if (successor != NULL) {
1012 // Block ended with a "goto". We can fall through if it is the
1013 // next block in the list. Otherwise, we need a jump.
1014 if ((i == block_order().length() - 1) ||
1015 (block_order()[i + 1] != successor)) {
1016 __ jmp(GetBlockLabel(successor));
1017 }
1018 }
1019 }
1020 }
1021
1022 #undef __ 964 #undef __
1023 965
1024 } // namespace dart 966 } // namespace dart
1025 967
1026 #endif // defined TARGET_ARCH_IA32 968 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_ia32.h ('k') | runtime/vm/flow_graph_compiler_shared.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698