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

Side by Side Diff: vm/flow_graph_compiler.cc

Issue 10632009: Make the parser agnostic to the TokenStream implementation. This is the first step towards compacti… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
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 | « vm/flow_graph_builder.cc ('k') | vm/flow_graph_compiler_ia32.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_XXX. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX.
6 6
7 #include "vm/flow_graph_compiler.h" 7 #include "vm/flow_graph_compiler.h"
8 8
9 #include "vm/debugger.h" 9 #include "vm/debugger.h"
10 #include "vm/il_printer.h" 10 #include "vm/il_printer.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 void FlowGraphCompiler::AddExceptionHandler(intptr_t try_index, 142 void FlowGraphCompiler::AddExceptionHandler(intptr_t try_index,
143 intptr_t pc_offset) { 143 intptr_t pc_offset) {
144 exception_handlers_list_->AddHandler(try_index, pc_offset); 144 exception_handlers_list_->AddHandler(try_index, pc_offset);
145 } 145 }
146 146
147 147
148 // Uses current pc position and try-index. 148 // Uses current pc position and try-index.
149 void FlowGraphCompiler::AddCurrentDescriptor(PcDescriptors::Kind kind, 149 void FlowGraphCompiler::AddCurrentDescriptor(PcDescriptors::Kind kind,
150 intptr_t cid, 150 intptr_t cid,
151 intptr_t token_index, 151 intptr_t token_pos,
152 intptr_t try_index) { 152 intptr_t try_index) {
153 ASSERT((kind != PcDescriptors::kDeopt) || 153 ASSERT((kind != PcDescriptors::kDeopt) ||
154 frame_register_allocator()->IsSpilled()); 154 frame_register_allocator()->IsSpilled());
155 pc_descriptors_list()->AddDescriptor(kind, 155 pc_descriptors_list()->AddDescriptor(kind,
156 assembler()->CodeSize(), 156 assembler()->CodeSize(),
157 cid, 157 cid,
158 token_index, 158 token_pos,
159 try_index); 159 try_index);
160 } 160 }
161 161
162 162
163 Label* FlowGraphCompiler::AddDeoptStub(intptr_t deopt_id, 163 Label* FlowGraphCompiler::AddDeoptStub(intptr_t deopt_id,
164 intptr_t deopt_token_index, 164 intptr_t deopt_token_pos,
165 intptr_t try_index, 165 intptr_t try_index,
166 DeoptReasonId reason, 166 DeoptReasonId reason,
167 Register reg1, 167 Register reg1,
168 Register reg2, 168 Register reg2,
169 Register reg3) { 169 Register reg3) {
170 DeoptimizationStub* stub = 170 DeoptimizationStub* stub =
171 new DeoptimizationStub(deopt_id, deopt_token_index, try_index, reason); 171 new DeoptimizationStub(deopt_id, deopt_token_pos, try_index, reason);
172 frame_register_allocator()->SpillInDeoptStub(stub); 172 frame_register_allocator()->SpillInDeoptStub(stub);
173 if (reg1 != kNoRegister) stub->Push(reg1); 173 if (reg1 != kNoRegister) stub->Push(reg1);
174 if (reg2 != kNoRegister) stub->Push(reg2); 174 if (reg2 != kNoRegister) stub->Push(reg2);
175 if (reg3 != kNoRegister) stub->Push(reg3); 175 if (reg3 != kNoRegister) stub->Push(reg3);
176 deopt_stubs_.Add(stub); 176 deopt_stubs_.Add(stub);
177 return stub->entry_label(); 177 return stub->entry_label();
178 } 178 }
179 179
180 180
181 void FlowGraphCompiler::FinalizeExceptionHandlers(const Code& code) { 181 void FlowGraphCompiler::FinalizeExceptionHandlers(const Code& code) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 // generated, it may fall through to the non-intrinsified method body. 263 // generated, it may fall through to the non-intrinsified method body.
264 if (!FLAG_trace_functions) { 264 if (!FLAG_trace_functions) {
265 return Intrinsifier::Intrinsify(parsed_function().function(), assembler()); 265 return Intrinsifier::Intrinsify(parsed_function().function(), assembler());
266 } 266 }
267 return false; 267 return false;
268 } 268 }
269 269
270 270
271 void FlowGraphCompiler::GenerateInstanceCall( 271 void FlowGraphCompiler::GenerateInstanceCall(
272 intptr_t cid, 272 intptr_t cid,
273 intptr_t token_index, 273 intptr_t token_pos,
274 intptr_t try_index, 274 intptr_t try_index,
275 const String& function_name, 275 const String& function_name,
276 intptr_t argument_count, 276 intptr_t argument_count,
277 const Array& argument_names, 277 const Array& argument_names,
278 intptr_t checked_argument_count) { 278 intptr_t checked_argument_count) {
279 ASSERT(frame_register_allocator()->IsSpilled()); 279 ASSERT(frame_register_allocator()->IsSpilled());
280 ICData& ic_data = 280 ICData& ic_data =
281 ICData::ZoneHandle(ICData::New(parsed_function().function(), 281 ICData::ZoneHandle(ICData::New(parsed_function().function(),
282 function_name, 282 function_name,
283 cid, 283 cid,
(...skipping 13 matching lines...) Expand all
297 } 297 }
298 ExternalLabel target_label("InlineCache", label_address); 298 ExternalLabel target_label("InlineCache", label_address);
299 299
300 const intptr_t descr_offset = EmitInstanceCall(&target_label, 300 const intptr_t descr_offset = EmitInstanceCall(&target_label,
301 ic_data, 301 ic_data,
302 arguments_descriptor, 302 arguments_descriptor,
303 argument_count); 303 argument_count);
304 pc_descriptors_list()->AddDescriptor(PcDescriptors::kIcCall, 304 pc_descriptors_list()->AddDescriptor(PcDescriptors::kIcCall,
305 descr_offset, 305 descr_offset,
306 cid, 306 cid,
307 token_index, 307 token_pos,
308 try_index); 308 try_index);
309 } 309 }
310 310
311 311
312 void FlowGraphCompiler::GenerateStaticCall(intptr_t cid, 312 void FlowGraphCompiler::GenerateStaticCall(intptr_t cid,
313 intptr_t token_index, 313 intptr_t token_pos,
314 intptr_t try_index, 314 intptr_t try_index,
315 const Function& function, 315 const Function& function,
316 intptr_t argument_count, 316 intptr_t argument_count,
317 const Array& argument_names) { 317 const Array& argument_names) {
318 ASSERT(frame_register_allocator()->IsSpilled()); 318 ASSERT(frame_register_allocator()->IsSpilled());
319 319
320 const Array& arguments_descriptor = 320 const Array& arguments_descriptor =
321 CodeGenerator::ArgumentsDescriptor(argument_count, argument_names); 321 CodeGenerator::ArgumentsDescriptor(argument_count, argument_names);
322 const intptr_t descr_offset = EmitStaticCall(function, 322 const intptr_t descr_offset = EmitStaticCall(function,
323 arguments_descriptor, 323 arguments_descriptor,
324 argument_count); 324 argument_count);
325 pc_descriptors_list()->AddDescriptor(PcDescriptors::kFuncCall, 325 pc_descriptors_list()->AddDescriptor(PcDescriptors::kFuncCall,
326 descr_offset, 326 descr_offset,
327 cid, 327 cid,
328 token_index, 328 token_pos,
329 try_index); 329 try_index);
330 } 330 }
331 331
332 332
333 void FlowGraphCompiler::GenerateNumberTypeCheck(Register kClassIdReg, 333 void FlowGraphCompiler::GenerateNumberTypeCheck(Register kClassIdReg,
334 const AbstractType& type, 334 const AbstractType& type,
335 Label* is_instance_lbl, 335 Label* is_instance_lbl,
336 Label* is_not_instance_lbl) { 336 Label* is_not_instance_lbl) {
337 GrowableArray<intptr_t> args; 337 GrowableArray<intptr_t> args;
338 if (type.IsNumberInterface()) { 338 if (type.IsNumberInterface()) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 assembler()->Comment("@%d: %s", instr->cid(), buffer); 382 assembler()->Comment("@%d: %s", instr->cid(), buffer);
383 } 383 }
384 384
385 385
386 void FlowGraphCompiler::EmitLoadIndexedGeneric(LoadIndexedComp* comp) { 386 void FlowGraphCompiler::EmitLoadIndexedGeneric(LoadIndexedComp* comp) {
387 const String& function_name = 387 const String& function_name =
388 String::ZoneHandle(String::NewSymbol(Token::Str(Token::kINDEX))); 388 String::ZoneHandle(String::NewSymbol(Token::Str(Token::kINDEX)));
389 389
390 AddCurrentDescriptor(PcDescriptors::kDeopt, 390 AddCurrentDescriptor(PcDescriptors::kDeopt,
391 comp->cid(), 391 comp->cid(),
392 comp->token_index(), 392 comp->token_pos(),
393 comp->try_index()); 393 comp->try_index());
394 394
395 const intptr_t kNumArguments = 2; 395 const intptr_t kNumArguments = 2;
396 const intptr_t kNumArgsChecked = 1; // Type-feedback. 396 const intptr_t kNumArgsChecked = 1; // Type-feedback.
397 GenerateInstanceCall(comp->cid(), 397 GenerateInstanceCall(comp->cid(),
398 comp->token_index(), 398 comp->token_pos(),
399 comp->try_index(), 399 comp->try_index(),
400 function_name, 400 function_name,
401 kNumArguments, 401 kNumArguments,
402 Array::ZoneHandle(), // No optional arguments. 402 Array::ZoneHandle(), // No optional arguments.
403 kNumArgsChecked); 403 kNumArgsChecked);
404 } 404 }
405 405
406 406
407 void FlowGraphCompiler::EmitTestAndCall(const ICData& ic_data, 407 void FlowGraphCompiler::EmitTestAndCall(const ICData& ic_data,
408 Register class_id_reg, 408 Register class_id_reg,
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 609
610 610
611 void FrameRegisterAllocator::SpillInDeoptStub(DeoptimizationStub* stub) { 611 void FrameRegisterAllocator::SpillInDeoptStub(DeoptimizationStub* stub) {
612 for (int i = 0; i < stack_.length(); i++) { 612 for (int i = 0; i < stack_.length(); i++) {
613 stub->Push(stack_[i]); 613 stub->Push(stack_[i]);
614 } 614 }
615 } 615 }
616 616
617 617
618 } // namespace dart 618 } // namespace dart
OLDNEW
« no previous file with comments | « vm/flow_graph_builder.cc ('k') | vm/flow_graph_compiler_ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698