| 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_MIPS) | 6 #if defined(TARGET_ARCH_MIPS) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/code_generator.h" | 9 #include "vm/code_generator.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 __ sll(T3, T3, 1); // T3 is a Smi. | 721 __ sll(T3, T3, 1); // T3 is a Smi. |
| 722 __ addu(T2, T2, T3); | 722 __ addu(T2, T2, T3); |
| 723 ASSERT(kSmiTagShift == 1); | 723 ASSERT(kSmiTagShift == 1); |
| 724 __ LoadImmediate(T3, ~(kObjectAlignment - 1)); | 724 __ LoadImmediate(T3, ~(kObjectAlignment - 1)); |
| 725 __ and_(T2, T2, T3); | 725 __ and_(T2, T2, T3); |
| 726 | 726 |
| 727 // T2: Allocation size. | 727 // T2: Allocation size. |
| 728 | 728 |
| 729 Heap* heap = isolate->heap(); | 729 Heap* heap = isolate->heap(); |
| 730 const intptr_t cid = kArrayCid; | 730 const intptr_t cid = kArrayCid; |
| 731 Heap::Space space = heap->SpaceForAllocation(cid); | 731 Heap::Space space = Heap::SpaceForAllocation(cid); |
| 732 __ LoadImmediate(T3, heap->TopAddress(space)); | 732 __ LoadImmediate(T3, heap->TopAddress(space)); |
| 733 __ lw(T0, Address(T3, 0)); // Potential new object start. | 733 __ lw(T0, Address(T3, 0)); // Potential new object start. |
| 734 | 734 |
| 735 __ addu(T1, T0, T2); // Potential next object start. | 735 __ addu(T1, T0, T2); // Potential next object start. |
| 736 __ BranchUnsignedLess(T1, T0, &slow_case); // Branch on unsigned overflow. | 736 __ BranchUnsignedLess(T1, T0, &slow_case); // Branch on unsigned overflow. |
| 737 | 737 |
| 738 // Check if the allocation fits into the remaining space. | 738 // Check if the allocation fits into the remaining space. |
| 739 // T0: potential new object start. | 739 // T0: potential new object start. |
| 740 // T1: potential next object start. | 740 // T1: potential next object start. |
| 741 // T2: allocation size. | 741 // T2: allocation size. |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 | 975 |
| 976 // Called for inline allocation of contexts. | 976 // Called for inline allocation of contexts. |
| 977 // Input: | 977 // Input: |
| 978 // T1: number of context variables. | 978 // T1: number of context variables. |
| 979 // Output: | 979 // Output: |
| 980 // V0: new allocated RawContext object. | 980 // V0: new allocated RawContext object. |
| 981 void StubCode::GenerateAllocateContextStub(Assembler* assembler) { | 981 void StubCode::GenerateAllocateContextStub(Assembler* assembler) { |
| 982 __ Comment("AllocateContext"); | 982 __ Comment("AllocateContext"); |
| 983 if (FLAG_inline_alloc) { | 983 if (FLAG_inline_alloc) { |
| 984 Label slow_case; | 984 Label slow_case; |
| 985 Heap* heap = Isolate::Current()->heap(); | |
| 986 // First compute the rounded instance size. | 985 // First compute the rounded instance size. |
| 987 // T1: number of context variables. | 986 // T1: number of context variables. |
| 988 intptr_t fixed_size = sizeof(RawContext) + kObjectAlignment - 1; | 987 intptr_t fixed_size = sizeof(RawContext) + kObjectAlignment - 1; |
| 989 __ LoadImmediate(T2, fixed_size); | 988 __ LoadImmediate(T2, fixed_size); |
| 990 __ sll(T0, T1, 2); | 989 __ sll(T0, T1, 2); |
| 991 __ addu(T2, T2, T0); | 990 __ addu(T2, T2, T0); |
| 992 ASSERT(kSmiTagShift == 1); | 991 ASSERT(kSmiTagShift == 1); |
| 993 __ LoadImmediate(T0, ~((kObjectAlignment) - 1)); | 992 __ LoadImmediate(T0, ~((kObjectAlignment) - 1)); |
| 994 __ and_(T2, T2, T0); | 993 __ and_(T2, T2, T0); |
| 995 | 994 |
| 996 // Now allocate the object. | 995 // Now allocate the object. |
| 997 // T1: number of context variables. | 996 // T1: number of context variables. |
| 998 // T2: object size. | 997 // T2: object size. |
| 999 const intptr_t cid = kContextCid; | 998 const intptr_t cid = kContextCid; |
| 1000 Heap::Space space = heap->SpaceForAllocation(cid); | 999 Heap::Space space = Heap::SpaceForAllocation(cid); |
| 1001 __ LoadImmediate(T5, heap->TopAddress(space)); | 1000 __ LoadIsolate(T5); |
| 1002 __ lw(V0, Address(T5, 0)); | 1001 __ lw(T5, Address(T5, Isolate::heap_offset())); |
| 1002 __ lw(V0, Address(T5, Heap::TopOffset(space))); |
| 1003 __ addu(T3, T2, V0); | 1003 __ addu(T3, T2, V0); |
| 1004 | 1004 |
| 1005 // Check if the allocation fits into the remaining space. | 1005 // Check if the allocation fits into the remaining space. |
| 1006 // V0: potential new object. | 1006 // V0: potential new object. |
| 1007 // T1: number of context variables. | 1007 // T1: number of context variables. |
| 1008 // T2: object size. | 1008 // T2: object size. |
| 1009 // T3: potential next object start. | 1009 // T3: potential next object start. |
| 1010 __ LoadImmediate(TMP, heap->EndAddress(space)); | 1010 // T5: heap. |
| 1011 __ lw(CMPRES1, Address(TMP, 0)); | 1011 __ lw(CMPRES1, Address(T5, Heap::EndOffset(space))); |
| 1012 if (FLAG_use_slow_path) { | 1012 if (FLAG_use_slow_path) { |
| 1013 __ b(&slow_case); | 1013 __ b(&slow_case); |
| 1014 } else { | 1014 } else { |
| 1015 __ BranchUnsignedGreaterEqual(T3, CMPRES1, &slow_case); | 1015 __ BranchUnsignedGreaterEqual(T3, CMPRES1, &slow_case); |
| 1016 } | 1016 } |
| 1017 | 1017 |
| 1018 // Successfully allocated the object, now update top to point to | 1018 // Successfully allocated the object, now update top to point to |
| 1019 // next object start and initialize the object. | 1019 // next object start and initialize the object. |
| 1020 // V0: new object. | 1020 // V0: new object. |
| 1021 // T1: number of context variables. | 1021 // T1: number of context variables. |
| 1022 // T2: object size. | 1022 // T2: object size. |
| 1023 // T3: next object start. | 1023 // T3: next object start. |
| 1024 __ sw(T3, Address(T5, 0)); | 1024 // T5: heap. |
| 1025 __ sw(T3, Address(T5, Heap::TopOffset(space))); |
| 1025 __ addiu(V0, V0, Immediate(kHeapObjectTag)); | 1026 __ addiu(V0, V0, Immediate(kHeapObjectTag)); |
| 1026 __ UpdateAllocationStatsWithSize(cid, T2, T5, space); | 1027 __ UpdateAllocationStatsWithSize(cid, T2, T5, space, |
| 1028 /* inline_isolate = */ false); |
| 1027 | 1029 |
| 1028 // Calculate the size tag. | 1030 // Calculate the size tag. |
| 1029 // V0: new object. | 1031 // V0: new object. |
| 1030 // T1: number of context variables. | 1032 // T1: number of context variables. |
| 1031 // T2: object size. | 1033 // T2: object size. |
| 1032 const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2; | 1034 const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2; |
| 1033 __ LoadImmediate(TMP, RawObject::SizeTag::kMaxSizeTag); | 1035 __ LoadImmediate(TMP, RawObject::SizeTag::kMaxSizeTag); |
| 1034 __ sltu(CMPRES1, TMP, T2); // CMPRES1 = T2 > TMP ? 1 : 0. | 1036 __ sltu(CMPRES1, TMP, T2); // CMPRES1 = T2 > TMP ? 1 : 0. |
| 1035 __ movn(T2, ZR, CMPRES1); // T2 = CMPRES1 != 0 ? 0 : T2. | 1037 __ movn(T2, ZR, CMPRES1); // T2 = CMPRES1 != 0 ? 0 : T2. |
| 1036 __ sll(TMP, T2, shift); // TMP = T2 << shift. | 1038 __ sll(TMP, T2, shift); // TMP = T2 << shift. |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1184 __ lw(T1, Address(SP, 0 * kWordSize)); | 1186 __ lw(T1, Address(SP, 0 * kWordSize)); |
| 1185 // T1: type arguments. | 1187 // T1: type arguments. |
| 1186 } | 1188 } |
| 1187 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size) && | 1189 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size) && |
| 1188 !cls.trace_allocation()) { | 1190 !cls.trace_allocation()) { |
| 1189 Label slow_case; | 1191 Label slow_case; |
| 1190 // Allocate the object and update top to point to | 1192 // Allocate the object and update top to point to |
| 1191 // next object start and initialize the allocated object. | 1193 // next object start and initialize the allocated object. |
| 1192 // T1: instantiated type arguments (if is_cls_parameterized). | 1194 // T1: instantiated type arguments (if is_cls_parameterized). |
| 1193 Heap* heap = Isolate::Current()->heap(); | 1195 Heap* heap = Isolate::Current()->heap(); |
| 1194 Heap::Space space = heap->SpaceForAllocation(cls.id()); | 1196 Heap::Space space = Heap::SpaceForAllocation(cls.id()); |
| 1195 __ LoadImmediate(T5, heap->TopAddress(space)); | 1197 __ LoadImmediate(T5, heap->TopAddress(space)); |
| 1196 __ lw(T2, Address(T5)); | 1198 __ lw(T2, Address(T5)); |
| 1197 __ LoadImmediate(T4, instance_size); | 1199 __ LoadImmediate(T4, instance_size); |
| 1198 __ addu(T3, T2, T4); | 1200 __ addu(T3, T2, T4); |
| 1199 // Check if the allocation fits into the remaining space. | 1201 // Check if the allocation fits into the remaining space. |
| 1200 // T2: potential new object start. | 1202 // T2: potential new object start. |
| 1201 // T3: potential next object start. | 1203 // T3: potential next object start. |
| 1202 __ LoadImmediate(TMP, heap->EndAddress(space)); | 1204 __ LoadImmediate(TMP, heap->EndAddress(space)); |
| 1203 __ lw(CMPRES1, Address(TMP)); | 1205 __ lw(CMPRES1, Address(TMP)); |
| 1204 if (FLAG_use_slow_path) { | 1206 if (FLAG_use_slow_path) { |
| (...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2319 // Result: | 2321 // Result: |
| 2320 // T1: entry point. | 2322 // T1: entry point. |
| 2321 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { | 2323 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { |
| 2322 EmitMegamorphicLookup(assembler, T0, T1, T1); | 2324 EmitMegamorphicLookup(assembler, T0, T1, T1); |
| 2323 __ Ret(); | 2325 __ Ret(); |
| 2324 } | 2326 } |
| 2325 | 2327 |
| 2326 } // namespace dart | 2328 } // namespace dart |
| 2327 | 2329 |
| 2328 #endif // defined TARGET_ARCH_MIPS | 2330 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |