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

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

Issue 23723008: Fixes slow object pool search on x64. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 | « runtime/tests/vm/vm.status ('k') | 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
11 11
12 #include "platform/assert.h" 12 #include "platform/assert.h"
13 #include "platform/utils.h" 13 #include "platform/utils.h"
14 #include "vm/constants_x64.h" 14 #include "vm/constants_x64.h"
15 #include "vm/hash_map.h"
15 16
16 namespace dart { 17 namespace dart {
17 18
18 // Forward declarations. 19 // Forward declarations.
19 class RuntimeEntry; 20 class RuntimeEntry;
20 21
21 class Immediate : public ValueObject { 22 class Immediate : public ValueObject {
22 public: 23 public:
23 explicit Immediate(int64_t value) : value_(value) { } 24 explicit Immediate(int64_t value) : value_(value) { }
24 25
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 831
831 private: 832 private:
832 AssemblerBuffer buffer_; 833 AssemblerBuffer buffer_;
833 834
834 // Objects and jump targets. 835 // Objects and jump targets.
835 GrowableObjectArray& object_pool_; 836 GrowableObjectArray& object_pool_;
836 837
837 // Patchability of pool entries. 838 // Patchability of pool entries.
838 GrowableArray<Patchability> patchable_pool_entries_; 839 GrowableArray<Patchability> patchable_pool_entries_;
839 840
841 // Pair type parameter for DirectChainedHashMap.
842 class ObjIndexPair {
843 public:
844 // TODO(zra): A WeakTable should be used here instead, but then it would
845 // also have to be possible to register and de-register WeakTables with the
846 // heap. Also, the Assembler would need to become a StackResource.
847 // Issue 13305. In the meantime...
848 // CAUTION: the RawObject* below is only safe because:
849 // The HashMap that will use this pair type will not contain any RawObject*
850 // keys that are not in the object_pool_ array. Since the keys will be
851 // visited by the GC when it visits the object_pool_, and since all objects
852 // in the object_pool_ are Old (and so will not be moved) the GC does not
853 // also need to visit the keys here in the HashMap.
854
855 // Typedefs needed for the DirectChainedHashMap template.
856 typedef RawObject* Key;
Florian Schneider 2013/09/16 09:09:48 Is there a performance reason for using raw pointe
Ivan Posva 2013/09/16 15:02:21 You cannot hash on handles when you are trying to
857 typedef intptr_t Value;
858 typedef ObjIndexPair Pair;
859
860 ObjIndexPair(Key key, Value value) : key_(key), value_(value) { }
861
862 static Key KeyOf(Pair kv) { return kv.key_; }
863
864 static Value ValueOf(Pair kv) { return kv.value_; }
865
866 static intptr_t Hashcode(Key key) {
867 return reinterpret_cast<intptr_t>(key) >> kObjectAlignmentLog2;
Florian Schneider 2013/09/16 09:09:48 Again, using the raw pointer as hash it not good i
868 }
869
870 static inline bool IsKeyEqual(Pair kv, Key key) {
871 return kv.key_ == key;
Florian Schneider 2013/09/16 09:09:48 If you use handles as keys, this becomes kv.key_-
872 }
873
874 private:
875 Key key_;
876 Value value_;
877 };
878
879 // Hashmap for fast lookup in object pool.
880 DirectChainedHashMap<ObjIndexPair> object_pool_index_table_;
881
840 int prologue_offset_; 882 int prologue_offset_;
841 883
842 class CodeComment : public ZoneAllocated { 884 class CodeComment : public ZoneAllocated {
843 public: 885 public:
844 CodeComment(intptr_t pc_offset, const String& comment) 886 CodeComment(intptr_t pc_offset, const String& comment)
845 : pc_offset_(pc_offset), comment_(comment) { } 887 : pc_offset_(pc_offset), comment_(comment) { }
846 888
847 intptr_t pc_offset() const { return pc_offset_; } 889 intptr_t pc_offset() const { return pc_offset_; }
848 const String& comment() const { return comment_; } 890 const String& comment() const { return comment_; }
849 891
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 } 1023 }
982 1024
983 1025
984 inline void Assembler::EmitOperandSizeOverride() { 1026 inline void Assembler::EmitOperandSizeOverride() {
985 EmitUint8(0x66); 1027 EmitUint8(0x66);
986 } 1028 }
987 1029
988 } // namespace dart 1030 } // namespace dart
989 1031
990 #endif // VM_ASSEMBLER_X64_H_ 1032 #endif // VM_ASSEMBLER_X64_H_
OLDNEW
« no previous file with comments | « runtime/tests/vm/vm.status ('k') | runtime/vm/assembler_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698