| 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 "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 __ popq(RCX); // Pop type arguments. | 916 __ popq(RCX); // Pop type arguments. |
| 917 __ popq(RCX); // Pop class. | 917 __ popq(RCX); // Pop class. |
| 918 __ popq(RCX); // Pop source location. | 918 __ popq(RCX); // Pop source location. |
| 919 __ popq(RAX); // Pop new instance. | 919 __ popq(RAX); // Pop new instance. |
| 920 } | 920 } |
| 921 | 921 |
| 922 | 922 |
| 923 void FlowGraphCompiler::VisitCreateArray(CreateArrayComp* comp) { | 923 void FlowGraphCompiler::VisitCreateArray(CreateArrayComp* comp) { |
| 924 // 1. Allocate the array. R10 = length, RBX = element type. | 924 // 1. Allocate the array. R10 = length, RBX = element type. |
| 925 __ movq(R10, Immediate(Smi::RawValue(comp->ElementCount()))); | 925 __ movq(R10, Immediate(Smi::RawValue(comp->ElementCount()))); |
| 926 const AbstractTypeArguments& element_type = comp->type_arguments(); | 926 LoadValue(RBX, comp->element_type()); |
| 927 ASSERT(element_type.IsNull() || element_type.IsInstantiated()); | |
| 928 __ LoadObject(RBX, element_type); | |
| 929 GenerateCall(comp->token_index(), | 927 GenerateCall(comp->token_index(), |
| 930 comp->try_index(), | 928 comp->try_index(), |
| 931 &StubCode::AllocateArrayLabel(), | 929 &StubCode::AllocateArrayLabel(), |
| 932 PcDescriptors::kOther); | 930 PcDescriptors::kOther); |
| 933 | 931 |
| 934 // 2. Initialize the array in RAX with the element values. | 932 // 2. Initialize the array in RAX with the element values. |
| 935 __ leaq(RCX, FieldAddress(RAX, Array::data_offset())); | 933 __ leaq(RCX, FieldAddress(RAX, Array::data_offset())); |
| 936 for (int i = comp->ElementCount() - 1; i >= 0; --i) { | 934 for (int i = comp->ElementCount() - 1; i >= 0; --i) { |
| 937 if (comp->ElementAt(i)->IsTemp()) { | 935 if (comp->ElementAt(i)->IsTemp()) { |
| 938 __ popq(Address(RCX, i * kWordSize)); | 936 __ popq(Address(RCX, i * kWordSize)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 961 } | 959 } |
| 962 } | 960 } |
| 963 | 961 |
| 964 | 962 |
| 965 void FlowGraphCompiler::VisitNativeLoadField(NativeLoadFieldComp* comp) { | 963 void FlowGraphCompiler::VisitNativeLoadField(NativeLoadFieldComp* comp) { |
| 966 __ popq(RAX); | 964 __ popq(RAX); |
| 967 __ movq(RAX, FieldAddress(RAX, comp->offset_in_bytes())); | 965 __ movq(RAX, FieldAddress(RAX, comp->offset_in_bytes())); |
| 968 } | 966 } |
| 969 | 967 |
| 970 | 968 |
| 971 void FlowGraphCompiler::VisitExtractFactoryTypeArguments( | 969 void FlowGraphCompiler::VisitInstantiateTypeArguments( |
| 972 ExtractFactoryTypeArgumentsComp* comp) { | 970 InstantiateTypeArgumentsComp* comp) { |
| 973 __ popq(RAX); // Instantiator. | 971 __ popq(RAX); // Instantiator. |
| 974 | 972 |
| 975 // RAX is the instantiator AbstractTypeArguments object (or null). | 973 // RAX is the instantiator AbstractTypeArguments object (or null). |
| 976 // If the instantiator is null and if the type argument vector | 974 // If the instantiator is null and if the type argument vector |
| 977 // instantiated from null becomes a vector of Dynamic, then use null as | 975 // instantiated from null becomes a vector of Dynamic, then use null as |
| 978 // the type arguments. | 976 // the type arguments. |
| 979 Label type_arguments_instantiated; | 977 Label type_arguments_instantiated; |
| 980 const intptr_t len = comp->type_arguments().Length(); | 978 const intptr_t len = comp->type_arguments().Length(); |
| 981 if (comp->type_arguments().IsRawInstantiatedRaw(len)) { | 979 if (comp->type_arguments().IsRawInstantiatedRaw(len)) { |
| 982 const Immediate raw_null = | 980 const Immediate raw_null = |
| (...skipping 11 matching lines...) Expand all Loading... |
| 994 __ LoadObject(RCX, Class::ZoneHandle(Object::type_arguments_class())); | 992 __ LoadObject(RCX, Class::ZoneHandle(Object::type_arguments_class())); |
| 995 __ cmpq(RCX, FieldAddress(RAX, Object::class_offset())); | 993 __ cmpq(RCX, FieldAddress(RAX, Object::class_offset())); |
| 996 __ j(NOT_EQUAL, &type_arguments_uninstantiated, Assembler::kNearJump); | 994 __ j(NOT_EQUAL, &type_arguments_uninstantiated, Assembler::kNearJump); |
| 997 Immediate arguments_length = | 995 Immediate arguments_length = |
| 998 Immediate(Smi::RawValue(comp->type_arguments().Length())); | 996 Immediate(Smi::RawValue(comp->type_arguments().Length())); |
| 999 __ cmpq(FieldAddress(RAX, TypeArguments::length_offset()), | 997 __ cmpq(FieldAddress(RAX, TypeArguments::length_offset()), |
| 1000 arguments_length); | 998 arguments_length); |
| 1001 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); | 999 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); |
| 1002 __ Bind(&type_arguments_uninstantiated); | 1000 __ Bind(&type_arguments_uninstantiated); |
| 1003 } | 1001 } |
| 1004 // A runtime call to instantiate the type arguments is required before | 1002 // A runtime call to instantiate the type arguments is required. |
| 1005 // calling the factory. | |
| 1006 __ PushObject(Object::ZoneHandle()); // Make room for the result. | 1003 __ PushObject(Object::ZoneHandle()); // Make room for the result. |
| 1007 __ PushObject(comp->type_arguments()); | 1004 __ PushObject(comp->type_arguments()); |
| 1008 __ pushq(RAX); // Push instantiator type arguments. | 1005 __ pushq(RAX); // Push instantiator type arguments. |
| 1009 GenerateCallRuntime(comp->cid(), | 1006 GenerateCallRuntime(comp->cid(), |
| 1010 comp->token_index(), | 1007 comp->token_index(), |
| 1011 comp->try_index(), | 1008 comp->try_index(), |
| 1012 kInstantiateTypeArgumentsRuntimeEntry); | 1009 kInstantiateTypeArgumentsRuntimeEntry); |
| 1013 __ popq(RAX); // Pop instantiator type arguments. | 1010 __ popq(RAX); // Pop instantiator type arguments. |
| 1014 __ popq(RAX); // Pop uninstantiated type arguments. | 1011 __ popq(RAX); // Pop uninstantiated type arguments. |
| 1015 __ popq(RAX); // Pop instantiated type arguments. | 1012 __ popq(RAX); // Pop instantiated type arguments. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 __ jmp(&done); | 1080 __ jmp(&done); |
| 1084 __ Bind(&instantiator_not_null); | 1081 __ Bind(&instantiator_not_null); |
| 1085 } | 1082 } |
| 1086 // Instantiate non-null type arguments. | 1083 // Instantiate non-null type arguments. |
| 1087 if (comp->type_arguments().IsUninstantiatedIdentity()) { | 1084 if (comp->type_arguments().IsUninstantiatedIdentity()) { |
| 1088 // TODO(regis): The following emitted code is duplicated in | 1085 // TODO(regis): The following emitted code is duplicated in |
| 1089 // VisitExtractConstructorTypeArguments above. The reason is that the code | 1086 // VisitExtractConstructorTypeArguments above. The reason is that the code |
| 1090 // is split between two computations, so that each one produces a | 1087 // is split between two computations, so that each one produces a |
| 1091 // single value, rather than producing a pair of values. | 1088 // single value, rather than producing a pair of values. |
| 1092 // If this becomes an issue, we should expose these tests at the IL level. | 1089 // If this becomes an issue, we should expose these tests at the IL level. |
| 1093 // TODO(regis): This code will still change, because bounds checking is not | |
| 1094 // implemented yet. | |
| 1095 | 1090 |
| 1096 // Check if the instantiator type argument vector is a TypeArguments of a | 1091 // Check if the instantiator type argument vector is a TypeArguments of a |
| 1097 // matching length and, if so, use it as the instantiated type_arguments. | 1092 // matching length and, if so, use it as the instantiated type_arguments. |
| 1098 // No need to check the instantiator (RAX) for null here, because a null | 1093 // No need to check the instantiator (RAX) for null here, because a null |
| 1099 // instantiator will have the wrong class (Null instead of TypeArguments). | 1094 // instantiator will have the wrong class (Null instead of TypeArguments). |
| 1100 __ LoadObject(RCX, Class::ZoneHandle(Object::type_arguments_class())); | 1095 __ LoadObject(RCX, Class::ZoneHandle(Object::type_arguments_class())); |
| 1101 __ cmpq(RCX, FieldAddress(RAX, Object::class_offset())); | 1096 __ cmpq(RCX, FieldAddress(RAX, Object::class_offset())); |
| 1102 __ j(NOT_EQUAL, &done, Assembler::kNearJump); | 1097 __ j(NOT_EQUAL, &done, Assembler::kNearJump); |
| 1103 Immediate arguments_length = | 1098 Immediate arguments_length = |
| 1104 Immediate(Smi::RawValue(comp->type_arguments().Length())); | 1099 Immediate(Smi::RawValue(comp->type_arguments().Length())); |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1728 ASSERT(exception_handlers_list_ != NULL); | 1723 ASSERT(exception_handlers_list_ != NULL); |
| 1729 const ExceptionHandlers& handlers = ExceptionHandlers::Handle( | 1724 const ExceptionHandlers& handlers = ExceptionHandlers::Handle( |
| 1730 exception_handlers_list_->FinalizeExceptionHandlers(code.EntryPoint())); | 1725 exception_handlers_list_->FinalizeExceptionHandlers(code.EntryPoint())); |
| 1731 code.set_exception_handlers(handlers); | 1726 code.set_exception_handlers(handlers); |
| 1732 } | 1727 } |
| 1733 | 1728 |
| 1734 | 1729 |
| 1735 } // namespace dart | 1730 } // namespace dart |
| 1736 | 1731 |
| 1737 #endif // defined TARGET_ARCH_X64 | 1732 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |