| 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_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 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/instructions.h" | 12 #include "vm/instructions.h" |
| 13 #include "vm/heap.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 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1022 const bool is_cls_parameterized = | 1022 const bool is_cls_parameterized = |
| 1023 cls.type_arguments_field_offset() != Class::kNoTypeArguments; | 1023 cls.type_arguments_field_offset() != Class::kNoTypeArguments; |
| 1024 // kInlineInstanceSize is a constant used as a threshold for determining | 1024 // kInlineInstanceSize is a constant used as a threshold for determining |
| 1025 // when the object initialization should be done as a loop or as | 1025 // when the object initialization should be done as a loop or as |
| 1026 // straight line code. | 1026 // straight line code. |
| 1027 const int kInlineInstanceSize = 12; | 1027 const int kInlineInstanceSize = 12; |
| 1028 const intptr_t instance_size = cls.instance_size(); | 1028 const intptr_t instance_size = cls.instance_size(); |
| 1029 ASSERT(instance_size > 0); | 1029 ASSERT(instance_size > 0); |
| 1030 const intptr_t type_args_size = InstantiatedTypeArguments::InstanceSize(); | 1030 const intptr_t type_args_size = InstantiatedTypeArguments::InstanceSize(); |
| 1031 if (FLAG_inline_alloc && | 1031 if (FLAG_inline_alloc && |
| 1032 PageSpace::IsPageAllocatableSize(instance_size + type_args_size)) { | 1032 Heap::IsNewAllocatableSize(instance_size + type_args_size)) { |
| 1033 Label slow_case; | 1033 Label slow_case; |
| 1034 Heap* heap = Isolate::Current()->heap(); | 1034 Heap* heap = Isolate::Current()->heap(); |
| 1035 __ movl(EAX, Address::Absolute(heap->TopAddress())); | 1035 __ movl(EAX, Address::Absolute(heap->TopAddress())); |
| 1036 __ leal(EBX, Address(EAX, instance_size)); | 1036 __ leal(EBX, Address(EAX, instance_size)); |
| 1037 if (is_cls_parameterized) { | 1037 if (is_cls_parameterized) { |
| 1038 __ movl(ECX, EBX); | 1038 __ movl(ECX, EBX); |
| 1039 // A new InstantiatedTypeArguments object only needs to be allocated if | 1039 // A new InstantiatedTypeArguments object only needs to be allocated if |
| 1040 // the instantiator is provided (not kNoInstantiator, but may be null). | 1040 // the instantiator is provided (not kNoInstantiator, but may be null). |
| 1041 Label no_instantiator; | 1041 Label no_instantiator; |
| 1042 __ cmpl(Address(ESP, kInstantiatorTypeArgumentsOffset), | 1042 __ cmpl(Address(ESP, kInstantiatorTypeArgumentsOffset), |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1195 func.IsImplicitStaticClosureFunction(); | 1195 func.IsImplicitStaticClosureFunction(); |
| 1196 const bool is_implicit_instance_closure = | 1196 const bool is_implicit_instance_closure = |
| 1197 func.IsImplicitInstanceClosureFunction(); | 1197 func.IsImplicitInstanceClosureFunction(); |
| 1198 const Class& cls = Class::ZoneHandle(func.signature_class()); | 1198 const Class& cls = Class::ZoneHandle(func.signature_class()); |
| 1199 const bool has_type_arguments = cls.HasTypeArguments(); | 1199 const bool has_type_arguments = cls.HasTypeArguments(); |
| 1200 const intptr_t kTypeArgumentsOffset = 1 * kWordSize; | 1200 const intptr_t kTypeArgumentsOffset = 1 * kWordSize; |
| 1201 const intptr_t kReceiverOffset = 2 * kWordSize; | 1201 const intptr_t kReceiverOffset = 2 * kWordSize; |
| 1202 const intptr_t closure_size = Closure::InstanceSize(); | 1202 const intptr_t closure_size = Closure::InstanceSize(); |
| 1203 const intptr_t context_size = Context::InstanceSize(1); // Captured receiver. | 1203 const intptr_t context_size = Context::InstanceSize(1); // Captured receiver. |
| 1204 if (FLAG_inline_alloc && | 1204 if (FLAG_inline_alloc && |
| 1205 PageSpace::IsPageAllocatableSize(closure_size + context_size)) { | 1205 Heap::IsNewAllocatableSize(closure_size + context_size)) { |
| 1206 Label slow_case; | 1206 Label slow_case; |
| 1207 Heap* heap = Isolate::Current()->heap(); | 1207 Heap* heap = Isolate::Current()->heap(); |
| 1208 __ movl(EAX, Address::Absolute(heap->TopAddress())); | 1208 __ movl(EAX, Address::Absolute(heap->TopAddress())); |
| 1209 __ leal(EBX, Address(EAX, closure_size)); | 1209 __ leal(EBX, Address(EAX, closure_size)); |
| 1210 if (is_implicit_instance_closure) { | 1210 if (is_implicit_instance_closure) { |
| 1211 __ movl(ECX, EBX); // ECX: new context address. | 1211 __ movl(ECX, EBX); // ECX: new context address. |
| 1212 __ addl(EBX, Immediate(context_size)); | 1212 __ addl(EBX, Immediate(context_size)); |
| 1213 } | 1213 } |
| 1214 // Check if the allocation fits into the remaining space. | 1214 // Check if the allocation fits into the remaining space. |
| 1215 // EAX: potential new closure object. | 1215 // EAX: potential new closure object. |
| (...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2100 __ Bind(&done); | 2100 __ Bind(&done); |
| 2101 __ popl(temp); | 2101 __ popl(temp); |
| 2102 __ popl(right); | 2102 __ popl(right); |
| 2103 __ popl(left); | 2103 __ popl(left); |
| 2104 __ ret(); | 2104 __ ret(); |
| 2105 } | 2105 } |
| 2106 | 2106 |
| 2107 } // namespace dart | 2107 } // namespace dart |
| 2108 | 2108 |
| 2109 #endif // defined TARGET_ARCH_IA32 | 2109 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |