| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| 11 #include "vm/flow_graph_compiler.h" | 11 #include "vm/flow_graph_compiler.h" |
| 12 #include "vm/heap.h" |
| 12 #include "vm/instructions.h" | 13 #include "vm/instructions.h" |
| 13 #include "vm/object_store.h" | 14 #include "vm/object_store.h" |
| 14 #include "vm/pages.h" | |
| 15 #include "vm/resolver.h" | 15 #include "vm/resolver.h" |
| 16 #include "vm/scavenger.h" | 16 #include "vm/scavenger.h" |
| 17 #include "vm/stub_code.h" | 17 #include "vm/stub_code.h" |
| 18 | 18 |
| 19 | 19 |
| 20 #define __ assembler-> | 20 #define __ assembler-> |
| 21 | 21 |
| 22 namespace dart { | 22 namespace dart { |
| 23 | 23 |
| 24 DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects."); | 24 DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects."); |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 const bool is_cls_parameterized = | 1003 const bool is_cls_parameterized = |
| 1004 cls.type_arguments_field_offset() != Class::kNoTypeArguments; | 1004 cls.type_arguments_field_offset() != Class::kNoTypeArguments; |
| 1005 // kInlineInstanceSize is a constant used as a threshold for determining | 1005 // kInlineInstanceSize is a constant used as a threshold for determining |
| 1006 // when the object initialization should be done as a loop or as | 1006 // when the object initialization should be done as a loop or as |
| 1007 // straight line code. | 1007 // straight line code. |
| 1008 const int kInlineInstanceSize = 12; // In words. | 1008 const int kInlineInstanceSize = 12; // In words. |
| 1009 const intptr_t instance_size = cls.instance_size(); | 1009 const intptr_t instance_size = cls.instance_size(); |
| 1010 ASSERT(instance_size > 0); | 1010 ASSERT(instance_size > 0); |
| 1011 const intptr_t type_args_size = InstantiatedTypeArguments::InstanceSize(); | 1011 const intptr_t type_args_size = InstantiatedTypeArguments::InstanceSize(); |
| 1012 if (FLAG_inline_alloc && | 1012 if (FLAG_inline_alloc && |
| 1013 PageSpace::IsPageAllocatableSize(instance_size + type_args_size)) { | 1013 Heap::IsNewAllocatableSize(instance_size + type_args_size)) { |
| 1014 Label slow_case; | 1014 Label slow_case; |
| 1015 Heap* heap = Isolate::Current()->heap(); | 1015 Heap* heap = Isolate::Current()->heap(); |
| 1016 __ movq(RAX, Immediate(heap->TopAddress())); | 1016 __ movq(RAX, Immediate(heap->TopAddress())); |
| 1017 __ movq(RAX, Address(RAX, 0)); | 1017 __ movq(RAX, Address(RAX, 0)); |
| 1018 __ leaq(RBX, Address(RAX, instance_size)); | 1018 __ leaq(RBX, Address(RAX, instance_size)); |
| 1019 if (is_cls_parameterized) { | 1019 if (is_cls_parameterized) { |
| 1020 __ movq(RCX, RBX); | 1020 __ movq(RCX, RBX); |
| 1021 // A new InstantiatedTypeArguments object only needs to be allocated if | 1021 // A new InstantiatedTypeArguments object only needs to be allocated if |
| 1022 // the instantiator is provided (not kNoInstantiator, but may be null). | 1022 // the instantiator is provided (not kNoInstantiator, but may be null). |
| 1023 Label no_instantiator; | 1023 Label no_instantiator; |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 func.IsImplicitStaticClosureFunction(); | 1177 func.IsImplicitStaticClosureFunction(); |
| 1178 const bool is_implicit_instance_closure = | 1178 const bool is_implicit_instance_closure = |
| 1179 func.IsImplicitInstanceClosureFunction(); | 1179 func.IsImplicitInstanceClosureFunction(); |
| 1180 const Class& cls = Class::ZoneHandle(func.signature_class()); | 1180 const Class& cls = Class::ZoneHandle(func.signature_class()); |
| 1181 const bool has_type_arguments = cls.HasTypeArguments(); | 1181 const bool has_type_arguments = cls.HasTypeArguments(); |
| 1182 const intptr_t kTypeArgumentsOffset = 1 * kWordSize; | 1182 const intptr_t kTypeArgumentsOffset = 1 * kWordSize; |
| 1183 const intptr_t kReceiverOffset = 2 * kWordSize; | 1183 const intptr_t kReceiverOffset = 2 * kWordSize; |
| 1184 const intptr_t closure_size = Closure::InstanceSize(); | 1184 const intptr_t closure_size = Closure::InstanceSize(); |
| 1185 const intptr_t context_size = Context::InstanceSize(1); // Captured receiver. | 1185 const intptr_t context_size = Context::InstanceSize(1); // Captured receiver. |
| 1186 if (FLAG_inline_alloc && | 1186 if (FLAG_inline_alloc && |
| 1187 PageSpace::IsPageAllocatableSize(closure_size + context_size)) { | 1187 Heap::IsNewAllocatableSize(closure_size + context_size)) { |
| 1188 Label slow_case; | 1188 Label slow_case; |
| 1189 Heap* heap = Isolate::Current()->heap(); | 1189 Heap* heap = Isolate::Current()->heap(); |
| 1190 __ movq(RAX, Immediate(heap->TopAddress())); | 1190 __ movq(RAX, Immediate(heap->TopAddress())); |
| 1191 __ movq(RAX, Address(RAX, 0)); | 1191 __ movq(RAX, Address(RAX, 0)); |
| 1192 __ leaq(R13, Address(RAX, closure_size)); | 1192 __ leaq(R13, Address(RAX, closure_size)); |
| 1193 if (is_implicit_instance_closure) { | 1193 if (is_implicit_instance_closure) { |
| 1194 __ movq(RBX, R13); // RBX: new context address. | 1194 __ movq(RBX, R13); // RBX: new context address. |
| 1195 __ addq(R13, Immediate(context_size)); | 1195 __ addq(R13, Immediate(context_size)); |
| 1196 } | 1196 } |
| 1197 // Check if the allocation fits into the remaining space. | 1197 // Check if the allocation fits into the remaining space. |
| (...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2054 __ cmpq(left, right); | 2054 __ cmpq(left, right); |
| 2055 __ Bind(&done); | 2055 __ Bind(&done); |
| 2056 __ popq(right); | 2056 __ popq(right); |
| 2057 __ popq(left); | 2057 __ popq(left); |
| 2058 __ ret(); | 2058 __ ret(); |
| 2059 } | 2059 } |
| 2060 | 2060 |
| 2061 } // namespace dart | 2061 } // namespace dart |
| 2062 | 2062 |
| 2063 #endif // defined TARGET_ARCH_X64 | 2063 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |