| OLD | NEW |
| 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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 | 435 |
| 436 static const Class* CoreClass(const char* c_name) { | 436 static const Class* CoreClass(const char* c_name) { |
| 437 const String& class_name = String::Handle(String::NewSymbol(c_name)); | 437 const String& class_name = String::Handle(String::NewSymbol(c_name)); |
| 438 const Class& cls = Class::ZoneHandle(Library::Handle( | 438 const Class& cls = Class::ZoneHandle(Library::Handle( |
| 439 Library::CoreImplLibrary()).LookupClass(class_name)); | 439 Library::CoreImplLibrary()).LookupClass(class_name)); |
| 440 ASSERT(!cls.IsNull()); | 440 ASSERT(!cls.IsNull()); |
| 441 return &cls; | 441 return &cls; |
| 442 } | 442 } |
| 443 | 443 |
| 444 | 444 |
| 445 void FlowGraphCompiler::GenerateInstantiatorTypeArguments( | |
| 446 intptr_t token_index) { | |
| 447 Bailout("FlowGraphCompiler::GenerateInstantiatorTypeArguments"); | |
| 448 } | |
| 449 | |
| 450 | |
| 451 // Copied from CodeGenerator. | 445 // Copied from CodeGenerator. |
| 452 // If instanceof type test cannot be performed successfully at compile time and | 446 // If instanceof type test cannot be performed successfully at compile time and |
| 453 // therefore eliminated, optimize it by adding inlined tests for: | 447 // therefore eliminated, optimize it by adding inlined tests for: |
| 454 // - NULL -> return false. | 448 // - NULL -> return false. |
| 455 // - Smi -> compile time subtype check (only if dst class is not parameterized). | 449 // - Smi -> compile time subtype check (only if dst class is not parameterized). |
| 456 // - Class equality (only if class is not parameterized). | 450 // - Class equality (only if class is not parameterized). |
| 457 // Inputs: | 451 // Inputs: |
| 458 // - RAX: object. | 452 // - RAX: object. |
| 453 // - RDX: optional type-arguments. |
| 459 // Destroys RCX. | 454 // Destroys RCX. |
| 460 // Returns: | 455 // Returns: |
| 461 // - true or false in RAX. | 456 // - true or false in RAX. |
| 462 void FlowGraphCompiler::GenerateInstanceOf(intptr_t node_id, | 457 void FlowGraphCompiler::GenerateInstanceOf(intptr_t node_id, |
| 463 intptr_t token_index, | 458 intptr_t token_index, |
| 464 intptr_t try_index, | 459 intptr_t try_index, |
| 465 Value* value, | 460 Value* value, |
| 466 const AbstractType& type, | 461 const AbstractType& type, |
| 467 bool negate_result) { | 462 bool negate_result) { |
| 468 ASSERT(type.IsFinalized() && !type.IsMalformed()); | 463 ASSERT(type.IsFinalized() && !type.IsMalformed()); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 __ PushObject(Object::ZoneHandle()); // Make room for the result. | 606 __ PushObject(Object::ZoneHandle()); // Make room for the result. |
| 612 const Immediate location = | 607 const Immediate location = |
| 613 Immediate(reinterpret_cast<int64_t>(Smi::New(token_index))); | 608 Immediate(reinterpret_cast<int64_t>(Smi::New(token_index))); |
| 614 const Immediate node_id_as_smi = | 609 const Immediate node_id_as_smi = |
| 615 Immediate(reinterpret_cast<int64_t>(Smi::New(node_id))); | 610 Immediate(reinterpret_cast<int64_t>(Smi::New(node_id))); |
| 616 __ pushq(location); // Push the source location. | 611 __ pushq(location); // Push the source location. |
| 617 __ pushq(node_id_as_smi); | 612 __ pushq(node_id_as_smi); |
| 618 __ pushq(RAX); // Push the instance. | 613 __ pushq(RAX); // Push the instance. |
| 619 __ PushObject(type); // Push the type. | 614 __ PushObject(type); // Push the type. |
| 620 if (!type.IsInstantiated()) { | 615 if (!type.IsInstantiated()) { |
| 621 GenerateInstantiatorTypeArguments(token_index); | 616 __ pushq(RDX); // Type arguments. |
| 622 } else { | 617 } else { |
| 623 __ pushq(raw_null); // Null instantiator. | 618 __ pushq(raw_null); // Null instantiator. |
| 624 } | 619 } |
| 625 GenerateCallRuntime(node_id, token_index, try_index, kInstanceofRuntimeEntry); | 620 GenerateCallRuntime(node_id, token_index, try_index, kInstanceofRuntimeEntry); |
| 626 // Pop the two parameters supplied to the runtime entry. The result of the | 621 // Pop the two parameters supplied to the runtime entry. The result of the |
| 627 // instanceof runtime call will be left as the result of the operation. | 622 // instanceof runtime call will be left as the result of the operation. |
| 628 __ addq(RSP, Immediate(5 * kWordSize)); | 623 __ addq(RSP, Immediate(5 * kWordSize)); |
| 629 if (negate_result) { | 624 if (negate_result) { |
| 630 Label negate_done; | 625 Label negate_done; |
| 631 __ popq(RDX); | 626 __ popq(RDX); |
| 632 __ LoadObject(RAX, bool_true); | 627 __ LoadObject(RAX, bool_true); |
| 633 __ cmpq(RDX, RAX); | 628 __ cmpq(RDX, RAX); |
| 634 __ j(NOT_EQUAL, &negate_done, Assembler::kNearJump); | 629 __ j(NOT_EQUAL, &negate_done, Assembler::kNearJump); |
| 635 __ LoadObject(RAX, bool_false); | 630 __ LoadObject(RAX, bool_false); |
| 636 __ Bind(&negate_done); | 631 __ Bind(&negate_done); |
| 637 __ pushq(RAX); | 632 __ pushq(RAX); |
| 638 } | 633 } |
| 639 __ Bind(&done); | 634 __ Bind(&done); |
| 640 __ popq(RAX); | 635 __ popq(RAX); |
| 641 } | 636 } |
| 642 | 637 |
| 643 | 638 |
| 644 void FlowGraphCompiler::VisitInstanceOf(InstanceOfComp* comp) { | 639 void FlowGraphCompiler::VisitInstanceOf(InstanceOfComp* comp) { |
| 640 if (comp->type_arguments() != NULL) { |
| 641 __ popq(RDX); |
| 642 } |
| 645 __ popq(RAX); | 643 __ popq(RAX); |
| 646 GenerateInstanceOf(comp->node_id(), | 644 GenerateInstanceOf(comp->node_id(), |
| 647 comp->token_index(), | 645 comp->token_index(), |
| 648 comp->try_index(), | 646 comp->try_index(), |
| 649 comp->value(), | 647 comp->value(), |
| 650 comp->type(), | 648 comp->type(), |
| 651 comp->negate_result()); | 649 comp->negate_result()); |
| 652 } | 650 } |
| 653 | 651 |
| 654 | 652 |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 void FlowGraphCompiler::VisitJoinEntry(JoinEntryInstr* instr) { | 935 void FlowGraphCompiler::VisitJoinEntry(JoinEntryInstr* instr) { |
| 938 __ Bind(&block_info_[instr->postorder_number()]->label); | 936 __ Bind(&block_info_[instr->postorder_number()]->label); |
| 939 } | 937 } |
| 940 | 938 |
| 941 | 939 |
| 942 void FlowGraphCompiler::VisitTargetEntry(TargetEntryInstr* instr) { | 940 void FlowGraphCompiler::VisitTargetEntry(TargetEntryInstr* instr) { |
| 943 __ Bind(&block_info_[instr->postorder_number()]->label); | 941 __ Bind(&block_info_[instr->postorder_number()]->label); |
| 944 if (instr->HasTryIndex()) { | 942 if (instr->HasTryIndex()) { |
| 945 exception_handlers_list_->AddHandler(instr->try_index(), | 943 exception_handlers_list_->AddHandler(instr->try_index(), |
| 946 assembler_->CodeSize()); | 944 assembler_->CodeSize()); |
| 947 // Bailout("Untested CatchEntry"); | |
| 948 } | 945 } |
| 949 } | 946 } |
| 950 | 947 |
| 951 | 948 |
| 952 void FlowGraphCompiler::VisitPickTemp(PickTempInstr* instr) { | 949 void FlowGraphCompiler::VisitPickTemp(PickTempInstr* instr) { |
| 953 // Semantics is to copy a stack-allocated temporary to the top of stack. | 950 // Semantics is to copy a stack-allocated temporary to the top of stack. |
| 954 // Destination index d is assumed the new top of stack after the | 951 // Destination index d is assumed the new top of stack after the |
| 955 // operation, so d-1 is the current top of stack and so d-s-1 is the | 952 // operation, so d-1 is the current top of stack and so d-s-1 is the |
| 956 // offset to source index s. | 953 // offset to source index s. |
| 957 intptr_t offset = instr->destination() - instr->source() - 1; | 954 intptr_t offset = instr->destination() - instr->source() - 1; |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 ASSERT(exception_handlers_list_ != NULL); | 1392 ASSERT(exception_handlers_list_ != NULL); |
| 1396 const ExceptionHandlers& handlers = ExceptionHandlers::Handle( | 1393 const ExceptionHandlers& handlers = ExceptionHandlers::Handle( |
| 1397 exception_handlers_list_->FinalizeExceptionHandlers(code.EntryPoint())); | 1394 exception_handlers_list_->FinalizeExceptionHandlers(code.EntryPoint())); |
| 1398 code.set_exception_handlers(handlers); | 1395 code.set_exception_handlers(handlers); |
| 1399 } | 1396 } |
| 1400 | 1397 |
| 1401 | 1398 |
| 1402 } // namespace dart | 1399 } // namespace dart |
| 1403 | 1400 |
| 1404 #endif // defined TARGET_ARCH_X64 | 1401 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |