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 #ifndef RUNTIME_VM_OBJECT_H_ | 5 #ifndef RUNTIME_VM_OBJECT_H_ |
6 #define RUNTIME_VM_OBJECT_H_ | 6 #define RUNTIME_VM_OBJECT_H_ |
7 | 7 |
8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
(...skipping 7943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7954 void* DataAddr(intptr_t byte_offset) const { | 7954 void* DataAddr(intptr_t byte_offset) const { |
7955 ASSERT((byte_offset == 0) || | 7955 ASSERT((byte_offset == 0) || |
7956 ((byte_offset > 0) && (byte_offset < LengthInBytes()))); | 7956 ((byte_offset > 0) && (byte_offset < LengthInBytes()))); |
7957 return reinterpret_cast<void*>(UnsafeMutableNonPointer(raw_ptr()->data()) + | 7957 return reinterpret_cast<void*>(UnsafeMutableNonPointer(raw_ptr()->data()) + |
7958 byte_offset); | 7958 byte_offset); |
7959 } | 7959 } |
7960 | 7960 |
7961 virtual bool CanonicalizeEquals(const Instance& other) const; | 7961 virtual bool CanonicalizeEquals(const Instance& other) const; |
7962 virtual uword ComputeCanonicalTableHash() const; | 7962 virtual uword ComputeCanonicalTableHash() const; |
7963 | 7963 |
7964 #if defined(HOST_ARCH_IA32) || defined(HOST_ARCH_X64) | |
7965 #define TYPED_GETTER_SETTER(name, type) \ | 7964 #define TYPED_GETTER_SETTER(name, type) \ |
7966 type Get##name(intptr_t byte_offset) const { \ | 7965 type Get##name(intptr_t byte_offset) const { \ |
7967 NoSafepointScope no_safepoint; \ | 7966 NoSafepointScope no_safepoint; \ |
7968 return *reinterpret_cast<type*>(DataAddr(byte_offset)); \ | 7967 return ReadUnaligned(reinterpret_cast<type*>(DataAddr(byte_offset))); \ |
7969 } \ | 7968 } \ |
7970 void Set##name(intptr_t byte_offset, type value) const { \ | 7969 void Set##name(intptr_t byte_offset, type value) const { \ |
7971 NoSafepointScope no_safepoint; \ | 7970 NoSafepointScope no_safepoint; \ |
7972 *reinterpret_cast<type*>(DataAddr(byte_offset)) = value; \ | 7971 StoreUnaligned(reinterpret_cast<type*>(DataAddr(byte_offset)), value); \ |
7973 } | 7972 } |
7974 #else // defined(HOST_ARCH_IA32) || defined(HOST_ARCH_X64) | |
7975 #define TYPED_GETTER_SETTER(name, type) \ | |
7976 type Get##name(intptr_t byte_offset) const { \ | |
7977 NoSafepointScope no_safepoint; \ | |
7978 type result; \ | |
7979 memmove(&result, DataAddr(byte_offset), sizeof(type)); \ | |
7980 return result; \ | |
7981 } \ | |
7982 void Set##name(intptr_t byte_offset, type value) const { \ | |
7983 NoSafepointScope no_safepoint; \ | |
7984 memmove(DataAddr(byte_offset), &value, sizeof(type)); \ | |
7985 } | |
7986 #endif // defined(HOST_ARCH_IA32) || defined(HOST_ARCH_X64) | |
7987 | 7973 |
7988 TYPED_GETTER_SETTER(Int8, int8_t) | 7974 TYPED_GETTER_SETTER(Int8, int8_t) |
7989 TYPED_GETTER_SETTER(Uint8, uint8_t) | 7975 TYPED_GETTER_SETTER(Uint8, uint8_t) |
7990 TYPED_GETTER_SETTER(Int16, int16_t) | 7976 TYPED_GETTER_SETTER(Int16, int16_t) |
7991 TYPED_GETTER_SETTER(Uint16, uint16_t) | 7977 TYPED_GETTER_SETTER(Uint16, uint16_t) |
7992 TYPED_GETTER_SETTER(Int32, int32_t) | 7978 TYPED_GETTER_SETTER(Int32, int32_t) |
7993 TYPED_GETTER_SETTER(Uint32, uint32_t) | 7979 TYPED_GETTER_SETTER(Uint32, uint32_t) |
7994 TYPED_GETTER_SETTER(Int64, int64_t) | 7980 TYPED_GETTER_SETTER(Int64, int64_t) |
7995 TYPED_GETTER_SETTER(Uint64, uint64_t) | 7981 TYPED_GETTER_SETTER(Uint64, uint64_t) |
7996 TYPED_GETTER_SETTER(Float32, float) | 7982 TYPED_GETTER_SETTER(Float32, float) |
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9067 | 9053 |
9068 inline void TypeArguments::SetHash(intptr_t value) const { | 9054 inline void TypeArguments::SetHash(intptr_t value) const { |
9069 // This is only safe because we create a new Smi, which does not cause | 9055 // This is only safe because we create a new Smi, which does not cause |
9070 // heap allocation. | 9056 // heap allocation. |
9071 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); | 9057 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); |
9072 } | 9058 } |
9073 | 9059 |
9074 } // namespace dart | 9060 } // namespace dart |
9075 | 9061 |
9076 #endif // RUNTIME_VM_OBJECT_H_ | 9062 #endif // RUNTIME_VM_OBJECT_H_ |
OLD | NEW |