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_ASSEMBLER_H_ | 5 #ifndef VM_ASSEMBLER_H_ |
| 6 #define VM_ASSEMBLER_H_ | 6 #define VM_ASSEMBLER_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
| 10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 // description of kMinimumGap for the reasoning behind the value. | 198 // description of kMinimumGap for the reasoning behind the value. |
| 199 static uword ComputeLimit(uword data, intptr_t capacity) { | 199 static uword ComputeLimit(uword data, intptr_t capacity) { |
| 200 return data + capacity - kMinimumGap; | 200 return data + capacity - kMinimumGap; |
| 201 } | 201 } |
| 202 | 202 |
| 203 void ExtendCapacity(); | 203 void ExtendCapacity(); |
| 204 | 204 |
| 205 friend class AssemblerFixup; | 205 friend class AssemblerFixup; |
| 206 }; | 206 }; |
| 207 | 207 |
| 208 | |
| 209 // Pair type parameter for DirectChainedHashMap used for the constant pool. | |
| 210 class ObjIndexPair { | |
| 211 public: | |
| 212 // Typedefs needed for the DirectChainedHashMap template. | |
| 213 typedef const Object* Key; | |
| 214 typedef intptr_t Value; | |
| 215 typedef ObjIndexPair Pair; | |
| 216 | |
| 217 explicit ObjIndexPair(Value value) : key_(NULL), value_(NoValue()) { } | |
|
Vyacheslav Egorov (Google)
2015/01/13 13:47:30
I think parameter is redundant. Just provide defau
Florian Schneider
2015/01/13 14:09:08
Done.
| |
| 218 | |
| 219 ObjIndexPair(Key key, Value value) | |
| 220 : key_(key->IsNotTemporaryScopedHandle() | |
| 221 ? key : &Object::ZoneHandle(key->raw())), | |
| 222 value_(value) { } | |
| 223 | |
| 224 static Key KeyOf(Pair kv) { return kv.key_; } | |
| 225 | |
| 226 static Value ValueOf(Pair kv) { return kv.value_; } | |
| 227 | |
| 228 static Value NoValue() { return -1; } | |
| 229 | |
| 230 static intptr_t Hashcode(Key key) { | |
| 231 if (key->IsSmi()) { | |
| 232 return Smi::Cast(*key).Value(); | |
| 233 } | |
| 234 if (key->IsDouble()) { | |
| 235 return static_cast<intptr_t>( | |
| 236 bit_cast<int32_t, float>( | |
| 237 static_cast<float>(Double::Cast(*key).value()))); | |
| 238 } | |
| 239 if (key->IsMint()) { | |
| 240 return static_cast<intptr_t>(Mint::Cast(*key).value()); | |
| 241 } | |
| 242 if (key->IsString()) { | |
| 243 return String::Cast(*key).Hash(); | |
| 244 } | |
| 245 // TODO(fschneider): Add hash function for other classes commonly used as | |
| 246 // compile-time constants. | |
| 247 return key->GetClassId(); | |
| 248 } | |
| 249 | |
| 250 static inline bool IsKeyEqual(Pair kv, Key key) { | |
| 251 return kv.key_->raw() == key->raw(); | |
| 252 } | |
| 253 | |
| 254 private: | |
| 255 Key key_; | |
| 256 Value value_; | |
| 257 }; | |
| 258 | |
| 208 } // namespace dart | 259 } // namespace dart |
| 209 | 260 |
| 210 | 261 |
| 211 #if defined(TARGET_ARCH_IA32) | 262 #if defined(TARGET_ARCH_IA32) |
| 212 #include "vm/assembler_ia32.h" | 263 #include "vm/assembler_ia32.h" |
| 213 #elif defined(TARGET_ARCH_X64) | 264 #elif defined(TARGET_ARCH_X64) |
| 214 #include "vm/assembler_x64.h" | 265 #include "vm/assembler_x64.h" |
| 215 #elif defined(TARGET_ARCH_ARM) | 266 #elif defined(TARGET_ARCH_ARM) |
| 216 #include "vm/assembler_arm.h" | 267 #include "vm/assembler_arm.h" |
| 217 #elif defined(TARGET_ARCH_ARM64) | 268 #elif defined(TARGET_ARCH_ARM64) |
| 218 #include "vm/assembler_arm64.h" | 269 #include "vm/assembler_arm64.h" |
| 219 #elif defined(TARGET_ARCH_MIPS) | 270 #elif defined(TARGET_ARCH_MIPS) |
| 220 #include "vm/assembler_mips.h" | 271 #include "vm/assembler_mips.h" |
| 221 #else | 272 #else |
| 222 #error Unknown architecture. | 273 #error Unknown architecture. |
| 223 #endif | 274 #endif |
| 224 | 275 |
| 225 #endif // VM_ASSEMBLER_H_ | 276 #endif // VM_ASSEMBLER_H_ |
| OLD | NEW |