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

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

Issue 10069042: Simplify code in code code generator, move checks to flow graph builder. We can assume that any typ… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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') | no next file » | 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"
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 void FlowGraphCompiler::GenerateInstanceOf(intptr_t node_id, 457 void FlowGraphCompiler::GenerateInstanceOf(intptr_t node_id,
458 intptr_t token_index, 458 intptr_t token_index,
459 intptr_t try_index, 459 intptr_t try_index,
460 Value* value, 460 Value* value,
461 const AbstractType& type, 461 const AbstractType& type,
462 bool negate_result) { 462 bool negate_result) {
463 ASSERT(type.IsFinalized() && !type.IsMalformed()); 463 ASSERT(type.IsFinalized() && !type.IsMalformed());
464 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); 464 const Bool& bool_true = Bool::ZoneHandle(Bool::True());
465 const Bool& bool_false = Bool::ZoneHandle(Bool::False()); 465 const Bool& bool_false = Bool::ZoneHandle(Bool::False());
466 466
467 // All objects are instances of type T if Object type is a subtype of type T.
468 const Type& object_type =
469 Type::Handle(Isolate::Current()->object_store()->object_type());
470 Error& malformed_error = Error::Handle();
471 if (type.IsInstantiated() &&
472 object_type.IsSubtypeOf(type, &malformed_error)) {
473 __ LoadObject(RAX, negate_result ? bool_false : bool_true);
474 return;
475 }
476
477 // Eliminate the test if it can be performed successfully at compile time.
478 if ((value != NULL) && value->IsConstant() && type.IsInstantiated()) {
479 // TODO(regis): A constant value should be an instance, not an object.
480 Instance& literal_value = Instance::Handle();
481 literal_value ^= value->AsConstant()->value().raw();
482 const Class& cls = Class::Handle(literal_value.clazz());
483 if (cls.IsNullClass()) {
484 ASSERT(literal_value.IsNull() ||
485 (literal_value.raw() == Object::sentinel()) ||
486 (literal_value.raw() == Object::transition_sentinel()));
487 // A null object is only an instance of Object and Dynamic, which has
488 // already been checked above (if the type is instantiated). So we can
489 // return false here if the instance is null (and if the type is
490 // instantiated).
491 __ PushObject(negate_result ? bool_true : bool_false);
492 } else {
493 Error& malformed_error = Error::Handle();
494 if (literal_value.IsInstanceOf(type,
495 TypeArguments::Handle(),
496 &malformed_error)) {
497 __ PushObject(negate_result ? bool_false : bool_true);
498 } else {
499 ASSERT(malformed_error.IsNull());
500 __ PushObject(negate_result ? bool_true : bool_false);
501 }
502 }
503 return;
504 }
505
506 const Immediate raw_null = 467 const Immediate raw_null =
507 Immediate(reinterpret_cast<intptr_t>(Object::null())); 468 Immediate(reinterpret_cast<intptr_t>(Object::null()));
508 Label done; 469 Label done;
509 // If type is instantiated and non-parameterized, we can inline code 470 // If type is instantiated and non-parameterized, we can inline code
510 // checking whether the tested instance is a Smi. 471 // checking whether the tested instance is a Smi.
511 if (type.IsInstantiated()) { 472 if (type.IsInstantiated()) {
512 // A null object is only an instance of Object and Dynamic, which has 473 // A null object is only an instance of Object and Dynamic, which has
513 // already been checked above (if the type is instantiated). So we can 474 // already been checked above (if the type is instantiated). So we can
514 // return false here if the instance is null (and if the type is 475 // return false here if the instance is null (and if the type is
515 // instantiated). 476 // instantiated).
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 ASSERT(exception_handlers_list_ != NULL); 1353 ASSERT(exception_handlers_list_ != NULL);
1393 const ExceptionHandlers& handlers = ExceptionHandlers::Handle( 1354 const ExceptionHandlers& handlers = ExceptionHandlers::Handle(
1394 exception_handlers_list_->FinalizeExceptionHandlers(code.EntryPoint())); 1355 exception_handlers_list_->FinalizeExceptionHandlers(code.EntryPoint()));
1395 code.set_exception_handlers(handlers); 1356 code.set_exception_handlers(handlers);
1396 } 1357 }
1397 1358
1398 1359
1399 } // namespace dart 1360 } // namespace dart
1400 1361
1401 #endif // defined TARGET_ARCH_X64 1362 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698