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

Side by Side Diff: src/assembler.h

Issue 12391055: Cleaned up CpuFeature scope handling. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed nits Created 7 years, 9 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 | « src/arm/stub-cache-arm.cc ('k') | src/assembler.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) 1994-2006 Sun Microsystems Inc. 1 // Copyright (c) 1994-2006 Sun Microsystems Inc.
2 // All Rights Reserved. 2 // All Rights Reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // - Redistributions of source code must retain the above copyright notice, 8 // - Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer. 9 // this list of conditions and the following disclaimer.
10 // 10 //
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 Isolate* isolate() const { return isolate_; } 62 Isolate* isolate() const { return isolate_; }
63 int jit_cookie() const { return jit_cookie_; } 63 int jit_cookie() const { return jit_cookie_; }
64 64
65 bool emit_debug_code() const { return emit_debug_code_; } 65 bool emit_debug_code() const { return emit_debug_code_; }
66 void set_emit_debug_code(bool value) { emit_debug_code_ = value; } 66 void set_emit_debug_code(bool value) { emit_debug_code_ = value; }
67 67
68 bool predictable_code_size() const { return predictable_code_size_; } 68 bool predictable_code_size() const { return predictable_code_size_; }
69 void set_predictable_code_size(bool value) { predictable_code_size_ = value; } 69 void set_predictable_code_size(bool value) { predictable_code_size_ = value; }
70 70
71 uint64_t enabled_cpu_features() const { return enabled_cpu_features_; }
72 void set_enabled_cpu_features(uint64_t features) {
73 enabled_cpu_features_ = features;
74 }
75 bool IsEnabled(CpuFeature f) {
76 return (enabled_cpu_features_ & (static_cast<uint64_t>(1) << f)) != 0;
77 }
78
71 // Overwrite a host NaN with a quiet target NaN. Used by mksnapshot for 79 // Overwrite a host NaN with a quiet target NaN. Used by mksnapshot for
72 // cross-snapshotting. 80 // cross-snapshotting.
73 static void QuietNaN(HeapObject* nan) { } 81 static void QuietNaN(HeapObject* nan) { }
74 82
75 int pc_offset() const { return static_cast<int>(pc_ - buffer_); } 83 int pc_offset() const { return static_cast<int>(pc_ - buffer_); }
76 84
77 static const int kMinimalBufferSize = 4*KB; 85 static const int kMinimalBufferSize = 4*KB;
78 86
79 protected: 87 protected:
80 // The buffer into which code and relocation info are generated. It could 88 // The buffer into which code and relocation info are generated. It could
81 // either be owned by the assembler or be provided externally. 89 // either be owned by the assembler or be provided externally.
82 byte* buffer_; 90 byte* buffer_;
83 int buffer_size_; 91 int buffer_size_;
84 bool own_buffer_; 92 bool own_buffer_;
85 93
86 // The program counter, which points into the buffer above and moves forward. 94 // The program counter, which points into the buffer above and moves forward.
87 byte* pc_; 95 byte* pc_;
88 96
89 private: 97 private:
90 Isolate* isolate_; 98 Isolate* isolate_;
91 int jit_cookie_; 99 int jit_cookie_;
100 uint64_t enabled_cpu_features_;
92 bool emit_debug_code_; 101 bool emit_debug_code_;
93 bool predictable_code_size_; 102 bool predictable_code_size_;
94 }; 103 };
95 104
96 105
97 // Avoids using instructions that vary in size in unpredictable ways between the 106 // Avoids using instructions that vary in size in unpredictable ways between the
98 // snapshot and the running VM. 107 // snapshot and the running VM.
99 class PredictableCodeSizeScope { 108 class PredictableCodeSizeScope {
100 public: 109 public:
101 PredictableCodeSizeScope(AssemblerBase* assembler, int expected_size); 110 PredictableCodeSizeScope(AssemblerBase* assembler, int expected_size);
102 ~PredictableCodeSizeScope(); 111 ~PredictableCodeSizeScope();
103 112
104 private: 113 private:
105 AssemblerBase* assembler_; 114 AssemblerBase* assembler_;
106 int expected_size_; 115 int expected_size_;
107 int start_offset_; 116 int start_offset_;
108 bool old_value_; 117 bool old_value_;
109 }; 118 };
110 119
111 120
121 // Enable a specified feature within a scope.
122 class CpuFeatureScope BASE_EMBEDDED {
123 public:
124 #ifdef DEBUG
125 CpuFeatureScope(AssemblerBase* assembler, CpuFeature f);
126 ~CpuFeatureScope();
127
128 private:
129 AssemblerBase* assembler_;
130 uint64_t old_enabled_;
131 #else
132 CpuFeatureScope(AssemblerBase* assembler, CpuFeature f) {}
133 #endif
134 };
135
136
112 // ----------------------------------------------------------------------------- 137 // -----------------------------------------------------------------------------
113 // Labels represent pc locations; they are typically jump or call targets. 138 // Labels represent pc locations; they are typically jump or call targets.
114 // After declaration, a label can be freely used to denote known or (yet) 139 // After declaration, a label can be freely used to denote known or (yet)
115 // unknown pc location. Assembler::bind() is used to bind a label to the 140 // unknown pc location. Assembler::bind() is used to bind a label to the
116 // current pc. A label can be bound only once. 141 // current pc. A label can be bound only once.
117 142
118 class Label BASE_EMBEDDED { 143 class Label BASE_EMBEDDED {
119 public: 144 public:
120 enum Distance { 145 enum Distance {
121 kNear, kFar 146 kNear, kFar
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 public: 1016 public:
992 NullCallWrapper() { } 1017 NullCallWrapper() { }
993 virtual ~NullCallWrapper() { } 1018 virtual ~NullCallWrapper() { }
994 virtual void BeforeCall(int call_size) const { } 1019 virtual void BeforeCall(int call_size) const { }
995 virtual void AfterCall() const { } 1020 virtual void AfterCall() const { }
996 }; 1021 };
997 1022
998 } } // namespace v8::internal 1023 } } // namespace v8::internal
999 1024
1000 #endif // V8_ASSEMBLER_H_ 1025 #endif // V8_ASSEMBLER_H_
OLDNEW
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698