Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(895)

Side by Side Diff: runtime/vm/assembler.h

Issue 848703002: Improve constant pool implementation in the assembler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/assembler_arm.h » ('j') | runtime/vm/assembler_arm64.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 static const intptr_t kNoIndex = -1;
218
219 ObjIndexPair() : key_(NULL), value_(kNoIndex) { }
220
221 ObjIndexPair(Key key, Value value)
222 : key_(key->IsNotTemporaryScopedHandle()
223 ? key : &Object::ZoneHandle(key->raw())),
224 value_(value) { }
225
226 static Key KeyOf(Pair kv) { return kv.key_; }
227
228 static Value ValueOf(Pair kv) { return kv.value_; }
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_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/assembler_arm.h » ('j') | runtime/vm/assembler_arm64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698