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

Side by Side Diff: runtime/vm/assembler_x64.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_x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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_X64_H_ 5 #ifndef VM_ASSEMBLER_X64_H_
6 #define VM_ASSEMBLER_X64_H_ 6 #define VM_ASSEMBLER_X64_H_
7 7
8 #ifndef VM_ASSEMBLER_H_ 8 #ifndef VM_ASSEMBLER_H_
9 #error Do not include assembler_x64.h directly; use assembler.h instead. 9 #error Do not include assembler_x64.h directly; use assembler.h instead.
10 #endif 10 #endif
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 1019
1020 // Objects and jump targets. 1020 // Objects and jump targets.
1021 GrowableObjectArray& object_pool_; 1021 GrowableObjectArray& object_pool_;
1022 1022
1023 // Patchability of pool entries. 1023 // Patchability of pool entries.
1024 GrowableArray<Patchability> patchable_pool_entries_; 1024 GrowableArray<Patchability> patchable_pool_entries_;
1025 1025
1026 // Pair type parameter for DirectChainedHashMap. 1026 // Pair type parameter for DirectChainedHashMap.
1027 class ObjIndexPair { 1027 class ObjIndexPair {
1028 public: 1028 public:
1029 // TODO(zra): A WeakTable should be used here instead, but then it would
1030 // also have to be possible to register and de-register WeakTables with the
1031 // heap. Also, the Assembler would need to become a StackResource.
1032 // Issue 13305. In the meantime...
1033 // CAUTION: the RawObject* below is only safe because:
1034 // The HashMap that will use this pair type will not contain any RawObject*
1035 // keys that are not in the object_pool_ array. Since the keys will be
1036 // visited by the GC when it visits the object_pool_, and since all objects
1037 // in the object_pool_ are Old (and so will not be moved) the GC does not
1038 // also need to visit the keys here in the HashMap.
1039
1040 // Typedefs needed for the DirectChainedHashMap template. 1029 // Typedefs needed for the DirectChainedHashMap template.
1041 typedef RawObject* Key; 1030 typedef const Object* Key;
1042 typedef intptr_t Value; 1031 typedef intptr_t Value;
1043 typedef ObjIndexPair Pair; 1032 typedef ObjIndexPair Pair;
1044 1033
1045 ObjIndexPair(Key key, Value value) : key_(key), value_(value) { } 1034 explicit ObjIndexPair(Value value) : key_(NULL), value_(NoValue()) { }
1035
1036 ObjIndexPair(Key key, Value value)
1037 : key_(key->IsNotTemporaryScopedHandle()
1038 ? key : &Object::ZoneHandle(key->raw())),
zra 2015/01/12 17:33:59 I'm not sure I understand what the implications ar
Florian Schneider 2015/01/13 09:54:19 The zone goes away as soon as compilation is finis
1039 value_(value) { }
1046 1040
1047 static Key KeyOf(Pair kv) { return kv.key_; } 1041 static Key KeyOf(Pair kv) { return kv.key_; }
1048 1042
1049 static Value ValueOf(Pair kv) { return kv.value_; } 1043 static Value ValueOf(Pair kv) { return kv.value_; }
1050 1044
1045 static Value NoValue() { return -1; }
1046
1051 static intptr_t Hashcode(Key key) { 1047 static intptr_t Hashcode(Key key) {
1052 return reinterpret_cast<intptr_t>(key) >> kObjectAlignmentLog2; 1048 if (key->IsSmi()) {
1049 return Smi::Cast(*key).Value();
1050 }
1051 if (key->IsDouble()) {
1052 return static_cast<intptr_t>(
1053 bit_cast<int32_t, float>(
1054 static_cast<float>(Double::Cast(*key).value())));
1055 }
1056 if (key->IsMint()) {
1057 return static_cast<intptr_t>(Mint::Cast(*key).value());
1058 }
1059 if (key->IsString()) {
1060 return String::Cast(*key).Hash();
1061 }
1062 return key->GetClassId();
zra 2015/01/12 17:33:59 So, Bool::True and Bool::False will end up in the
Florian Schneider 2015/01/13 09:54:19 So, for Object::null, Bool::True/False we don't ev
1053 } 1063 }
1054 1064
1055 static inline bool IsKeyEqual(Pair kv, Key key) { 1065 static inline bool IsKeyEqual(Pair kv, Key key) {
1056 return kv.key_ == key; 1066 return kv.key_->raw() == key->raw();
1057 } 1067 }
1058 1068
1059 private: 1069 private:
1060 Key key_; 1070 Key key_;
1061 Value value_; 1071 Value value_;
1062 }; 1072 };
1063 1073
1064 // Hashmap for fast lookup in object pool. 1074 // Hashmap for fast lookup in object pool.
1065 DirectChainedHashMap<ObjIndexPair> object_pool_index_table_; 1075 DirectChainedHashMap<ObjIndexPair> object_pool_index_table_;
1066 1076
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 } 1236 }
1227 1237
1228 1238
1229 inline void Assembler::EmitOperandSizeOverride() { 1239 inline void Assembler::EmitOperandSizeOverride() {
1230 EmitUint8(0x66); 1240 EmitUint8(0x66);
1231 } 1241 }
1232 1242
1233 } // namespace dart 1243 } // namespace dart
1234 1244
1235 #endif // VM_ASSEMBLER_X64_H_ 1245 #endif // VM_ASSEMBLER_X64_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/assembler_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698