| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 <setjmp.h> // NOLINT | 5 #include <setjmp.h> // NOLINT |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 | 7 |
| 8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
| 9 #if defined(TARGET_ARCH_DBC) | 9 #if defined(TARGET_ARCH_DBC) |
| 10 | 10 |
| (...skipping 2939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2950 NativeArguments args(thread, 2, SP + 1, SP - 1); | 2950 NativeArguments args(thread, 2, SP + 1, SP - 1); |
| 2951 INVOKE_RUNTIME(DRT_AllocateObject, args); | 2951 INVOKE_RUNTIME(DRT_AllocateObject, args); |
| 2952 SP -= 1; // Result is in SP - 1. | 2952 SP -= 1; // Result is in SP - 1. |
| 2953 DISPATCH(); | 2953 DISPATCH(); |
| 2954 } | 2954 } |
| 2955 | 2955 |
| 2956 { | 2956 { |
| 2957 BYTECODE(CreateArrayOpt, A_B_C); | 2957 BYTECODE(CreateArrayOpt, A_B_C); |
| 2958 const intptr_t length = Smi::Value(RAW_CAST(Smi, FP[rB])); | 2958 const intptr_t length = Smi::Value(RAW_CAST(Smi, FP[rB])); |
| 2959 if (LIKELY(static_cast<uintptr_t>(length) <= Array::kMaxElements)) { | 2959 if (LIKELY(static_cast<uintptr_t>(length) <= Array::kMaxElements)) { |
| 2960 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; | 2960 const intptr_t fixed_size_plus_alignment_padding = |
| 2961 sizeof(RawArray) + kObjectAlignment - 1; |
| 2961 const intptr_t instance_size = | 2962 const intptr_t instance_size = |
| 2962 (fixed_size + length * kWordSize) & ~(kObjectAlignment - 1); | 2963 (fixed_size_plus_alignment_padding + length * kWordSize) & |
| 2964 ~(kObjectAlignment - 1); |
| 2963 const uword start = | 2965 const uword start = |
| 2964 thread->heap()->new_space()->TryAllocate(instance_size); | 2966 thread->heap()->new_space()->TryAllocate(instance_size); |
| 2965 if (LIKELY(start != 0)) { | 2967 if (LIKELY(start != 0)) { |
| 2966 const intptr_t cid = kArrayCid; | 2968 const intptr_t cid = kArrayCid; |
| 2967 uword tags = 0; | 2969 uword tags = 0; |
| 2968 if (LIKELY(instance_size < RawObject::SizeTag::kMaxSizeTag)) { | 2970 if (LIKELY(instance_size < RawObject::SizeTag::kMaxSizeTag)) { |
| 2969 tags = RawObject::SizeTag::update(instance_size, tags); | 2971 tags = RawObject::SizeTag::update(instance_size, tags); |
| 2970 } | 2972 } |
| 2971 tags = RawObject::ClassIdTag::update(cid, tags); | 2973 tags = RawObject::ClassIdTag::update(cid, tags); |
| 2972 *reinterpret_cast<uword*>(start + Instance::tags_offset()) = tags; | 2974 *reinterpret_cast<uword*>(start + Instance::tags_offset()) = tags; |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3883 pc_ = pc; | 3885 pc_ = pc; |
| 3884 } | 3886 } |
| 3885 | 3887 |
| 3886 buf->Longjmp(); | 3888 buf->Longjmp(); |
| 3887 UNREACHABLE(); | 3889 UNREACHABLE(); |
| 3888 } | 3890 } |
| 3889 | 3891 |
| 3890 } // namespace dart | 3892 } // namespace dart |
| 3891 | 3893 |
| 3892 #endif // defined TARGET_ARCH_DBC | 3894 #endif // defined TARGET_ARCH_DBC |
| OLD | NEW |