Chromium Code Reviews| 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 VM_RAW_OBJECT_H_ | 5 #ifndef VM_RAW_OBJECT_H_ |
| 6 #define VM_RAW_OBJECT_H_ | 6 #define VM_RAW_OBJECT_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/atomic.h" | 9 #include "vm/atomic.h" |
| 10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
| (...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1204 RawAbstractType* type; | 1204 RawAbstractType* type; |
| 1205 RawInstance* value; // iff is_const is true | 1205 RawInstance* value; // iff is_const is true |
| 1206 }; | 1206 }; |
| 1207 RawSmi* context_index; | 1207 RawSmi* context_index; |
| 1208 RawSmi* context_level; | 1208 RawSmi* context_level; |
| 1209 }; | 1209 }; |
| 1210 | 1210 |
| 1211 int32_t num_variables_; | 1211 int32_t num_variables_; |
| 1212 | 1212 |
| 1213 RawObject** from() { | 1213 RawObject** from() { |
| 1214 return reinterpret_cast<RawObject**>(&ptr()->data()[0]); | 1214 VariableDesc* begin = const_cast<VariableDesc*>(ptr()->VariableDescAddr(0)); |
| 1215 return reinterpret_cast<RawObject**>(begin); | |
| 1215 } | 1216 } |
| 1216 // Variable length data follows here. | 1217 // Variable length data follows here. |
| 1217 RawObject** data() { OPEN_ARRAY_START(RawObject*, RawObject*); } | 1218 RawObject* const* data() const { OPEN_ARRAY_START(RawObject*, RawObject*); } |
| 1219 const VariableDesc* VariableDescAddr(intptr_t index) const { | |
| 1220 ASSERT((index >= 0) && (index < num_variables_ + 1)); | |
| 1221 // data() points to the first component of the first descriptor. | |
| 1222 return &(reinterpret_cast<const VariableDesc*>(data())[index]); | |
| 1223 } | |
| 1218 RawObject** to(intptr_t num_vars) { | 1224 RawObject** to(intptr_t num_vars) { |
| 1219 const intptr_t data_length = num_vars * (sizeof(VariableDesc)/kWordSize); | 1225 VariableDesc* end = |
| 1220 return reinterpret_cast<RawObject**>(&ptr()->data()[data_length - 1]); | 1226 const_cast<VariableDesc*>(ptr()->VariableDescAddr(num_vars)); |
| 1227 // 'end' points at the first word beyond the last descriptor, so step back. | |
| 1228 return reinterpret_cast<RawObject**>(end) - 1; | |
|
Ivan Posva
2014/11/07 00:18:12
Pointer arithmetic?
| |
| 1221 } | 1229 } |
| 1222 }; | 1230 }; |
| 1223 | 1231 |
| 1224 | 1232 |
| 1225 class RawICData : public RawObject { | 1233 class RawICData : public RawObject { |
| 1226 RAW_HEAP_OBJECT_IMPLEMENTATION(ICData); | 1234 RAW_HEAP_OBJECT_IMPLEMENTATION(ICData); |
| 1227 | 1235 |
| 1228 RawObject** from() { | 1236 RawObject** from() { |
| 1229 return reinterpret_cast<RawObject**>(&ptr()->owner_); | 1237 return reinterpret_cast<RawObject**>(&ptr()->owner_); |
| 1230 } | 1238 } |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2068 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == | 2076 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == |
| 2069 kTypedDataInt8ArrayViewCid + 15); | 2077 kTypedDataInt8ArrayViewCid + 15); |
| 2070 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); | 2078 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); |
| 2071 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); | 2079 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); |
| 2072 return (kNullCid - kTypedDataInt8ArrayCid); | 2080 return (kNullCid - kTypedDataInt8ArrayCid); |
| 2073 } | 2081 } |
| 2074 | 2082 |
| 2075 } // namespace dart | 2083 } // namespace dart |
| 2076 | 2084 |
| 2077 #endif // VM_RAW_OBJECT_H_ | 2085 #endif // VM_RAW_OBJECT_H_ |
| OLD | NEW |