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

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

Issue 9479004: Add a stubbed-out implementation of FlowGraphCompiler for ia32 and arm. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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_x64.h ('k') | runtime/vm/vm_sources.gypi » ('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 "vm/ast_printer.h" 10 #include "vm/ast_printer.h"
11 #include "vm/code_generator.h" 11 #include "vm/code_generator.h"
12 #include "vm/disassembler.h" 12 #include "vm/disassembler.h"
13 #include "vm/longjump.h" 13 #include "vm/longjump.h"
14 #include "vm/parser.h" 14 #include "vm/parser.h"
15 #include "vm/stub_code.h" 15 #include "vm/stub_code.h"
16 16
17 namespace dart { 17 namespace dart {
18 18
19 DECLARE_FLAG(bool, print_ast); 19 DECLARE_FLAG(bool, print_ast);
20 DECLARE_FLAG(bool, print_scopes); 20 DECLARE_FLAG(bool, print_scopes);
21 DECLARE_FLAG(bool, trace_functions); 21 DECLARE_FLAG(bool, trace_functions);
22 DECLARE_FLAG(bool, disassemble);
23 22
24 void FlowGraphCompiler::Bailout(const char* reason) { 23 void FlowGraphCompiler::Bailout(const char* reason) {
25 const char* kFormat = "FlowGraphCompiler Bailout: %s."; 24 const char* kFormat = "FlowGraphCompiler Bailout: %s.";
26 intptr_t len = OS::SNPrint(NULL, 0, kFormat, reason) + 1; 25 intptr_t len = OS::SNPrint(NULL, 0, kFormat, reason) + 1;
27 char* chars = reinterpret_cast<char*>( 26 char* chars = reinterpret_cast<char*>(
28 Isolate::Current()->current_zone()->Allocate(len)); 27 Isolate::Current()->current_zone()->Allocate(len));
29 OS::SNPrint(chars, len, kFormat, reason); 28 OS::SNPrint(chars, len, kFormat, reason);
30 const Error& error = Error::Handle( 29 const Error& error = Error::Handle(
31 LanguageError::New(String::Handle(String::New(chars)))); 30 LanguageError::New(String::Handle(String::New(chars))));
32 Isolate::Current()->long_jump_base()->Jump(1, error); 31 Isolate::Current()->long_jump_base()->Jump(1, error);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 179
181 __ int3(); 180 __ int3();
182 // Emit function patching code. This will be swapped with the first 13 bytes 181 // Emit function patching code. This will be swapped with the first 13 bytes
183 // at entry point. 182 // at entry point.
184 pc_descriptors_list_->AddDescriptor(PcDescriptors::kPatchCode, 183 pc_descriptors_list_->AddDescriptor(PcDescriptors::kPatchCode,
185 assembler_->CodeSize(), 184 assembler_->CodeSize(),
186 AstNode::kNoId, 185 AstNode::kNoId,
187 0, 186 0,
188 -1); 187 -1);
189 __ jmp(&StubCode::FixCallersTargetLabel()); 188 __ jmp(&StubCode::FixCallersTargetLabel());
190
191 if (FLAG_disassemble) {
192 const char* function_fullname = function.ToFullyQualifiedCString();
193 OS::Print(";;; Function %s\n", function_fullname);
194 const Code& code = Code::Handle(Code::FinalizeCode("GRAPH", assembler_));
195 const Instructions& instructions =
196 Instructions::Handle(code.instructions());
197 uword start = instructions.EntryPoint();
198 Disassembler::Disassemble(start, start + assembler_->CodeSize());
199 OS::Print("\n");
200 }
201 } 189 }
202 190
203 191
204 // Infrastructure copied from class CodeGenerator. 192 // Infrastructure copied from class CodeGenerator.
205 void FlowGraphCompiler::GenerateCallRuntime(intptr_t node_id, 193 void FlowGraphCompiler::GenerateCallRuntime(intptr_t node_id,
206 intptr_t token_index, 194 intptr_t token_index,
207 const RuntimeEntry& entry) { 195 const RuntimeEntry& entry) {
208 __ CallRuntimeFromDart(entry); 196 __ CallRuntimeFromDart(entry);
209 AddCurrentDescriptor(PcDescriptors::kOther, node_id, token_index); 197 AddCurrentDescriptor(PcDescriptors::kOther, node_id, token_index);
210 } 198 }
211 199
212 200
213 // Uses current pc position and try-index. 201 // Uses current pc position and try-index.
214 void FlowGraphCompiler::AddCurrentDescriptor(PcDescriptors::Kind kind, 202 void FlowGraphCompiler::AddCurrentDescriptor(PcDescriptors::Kind kind,
215 intptr_t node_id, 203 intptr_t node_id,
216 intptr_t token_index) { 204 intptr_t token_index) {
217 pc_descriptors_list_->AddDescriptor(kind, 205 pc_descriptors_list_->AddDescriptor(kind,
218 assembler_->CodeSize(), 206 assembler_->CodeSize(),
219 node_id, 207 node_id,
220 token_index, 208 token_index,
221 CatchClauseNode::kInvalidTryIndex); 209 CatchClauseNode::kInvalidTryIndex);
222 } 210 }
223 211
224 212
213 void FlowGraphCompiler::FinalizePcDescriptors(const Code& code) {
214 ASSERT(pc_descriptors_list_ != NULL);
215 const PcDescriptors& descriptors = PcDescriptors::Handle(
216 pc_descriptors_list_->FinalizePcDescriptors(code.EntryPoint()));
217 CodeGenerator::VerifyPcDescriptors(
218 descriptors, parsed_function_.function().is_optimizable());
219 code.set_pc_descriptors(descriptors);
220 }
221
222
223 void FlowGraphCompiler::FinalizeVarDescriptors(const Code& code) {
224 const LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle(
225 parsed_function_.node_sequence()->scope()->GetVarDescriptors());
226 code.set_var_descriptors(var_descs);
227 }
228
229
230 void FlowGraphCompiler::FinalizeExceptionHandlers(const Code& code) {
231 // We don't compile exception handlers yet.
232 code.set_exception_handlers(
233 ExceptionHandlers::Handle(ExceptionHandlers::New(0)));
234 }
235
236
225 } // namespace dart 237 } // namespace dart
226 238
227 #endif // defined TARGET_ARCH_X64 239 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.h ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698