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

Side by Side Diff: runtime/vm/instructions_dbc.cc

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 years, 5 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
« no previous file with comments | « runtime/vm/instructions_dbc.h ('k') | runtime/vm/instructions_ia32.h » ('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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 #include "vm/globals.h" // Needed here to get TARGET_ARCH_DBC. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_DBC.
6 #if defined(TARGET_ARCH_DBC) 6 #if defined(TARGET_ARCH_DBC)
7 7
8 #include "vm/instructions.h" 8 #include "vm/instructions.h"
9 #include "vm/instructions_dbc.h" 9 #include "vm/instructions_dbc.h"
10 10
(...skipping 19 matching lines...) Expand all
30 case Bytecode::kAllocate: 30 case Bytecode::kAllocate:
31 case Bytecode::kInstantiateType: 31 case Bytecode::kInstantiateType:
32 case Bytecode::kInstantiateTypeArgumentsTOS: 32 case Bytecode::kInstantiateTypeArgumentsTOS:
33 case Bytecode::kAssertAssignable: 33 case Bytecode::kAssertAssignable:
34 return true; 34 return true;
35 default: 35 default:
36 return false; 36 return false;
37 } 37 }
38 } 38 }
39 39
40
41 static bool GetLoadedObjectAt(uword pc, 40 static bool GetLoadedObjectAt(uword pc,
42 const ObjectPool& object_pool, 41 const ObjectPool& object_pool,
43 Object* obj) { 42 Object* obj) {
44 Instr instr = Bytecode::At(pc); 43 Instr instr = Bytecode::At(pc);
45 if (HasLoadFromPool(instr)) { 44 if (HasLoadFromPool(instr)) {
46 uint16_t index = Bytecode::DecodeD(instr); 45 uint16_t index = Bytecode::DecodeD(instr);
47 if (object_pool.InfoAt(index) == ObjectPool::kTaggedObject) { 46 if (object_pool.InfoAt(index) == ObjectPool::kTaggedObject) {
48 *obj = object_pool.ObjectAt(index); 47 *obj = object_pool.ObjectAt(index);
49 return true; 48 return true;
50 } 49 }
51 } 50 }
52 return false; 51 return false;
53 } 52 }
54 53
55
56 CallPattern::CallPattern(uword pc, const Code& code) 54 CallPattern::CallPattern(uword pc, const Code& code)
57 : object_pool_(ObjectPool::Handle(code.GetObjectPool())), 55 : object_pool_(ObjectPool::Handle(code.GetObjectPool())),
58 end_(pc), 56 end_(pc),
59 ic_data_load_end_(0), 57 ic_data_load_end_(0),
60 target_code_pool_index_(-1), 58 target_code_pool_index_(-1),
61 ic_data_(ICData::Handle()) { 59 ic_data_(ICData::Handle()) {
62 ASSERT(code.ContainsInstructionAt(end_)); 60 ASSERT(code.ContainsInstructionAt(end_));
63 const uword call_pc = end_ - sizeof(Instr); 61 const uword call_pc = end_ - sizeof(Instr);
64 Instr call_instr = Bytecode::At(call_pc); 62 Instr call_instr = Bytecode::At(call_pc);
65 ASSERT(Bytecode::IsCallOpcode(call_instr)); 63 ASSERT(Bytecode::IsCallOpcode(call_instr));
66 ic_data_load_end_ = call_pc; 64 ic_data_load_end_ = call_pc;
67 target_code_pool_index_ = Bytecode::DecodeD(call_instr); 65 target_code_pool_index_ = Bytecode::DecodeD(call_instr);
68 } 66 }
69 67
70
71 NativeCallPattern::NativeCallPattern(uword pc, const Code& code) 68 NativeCallPattern::NativeCallPattern(uword pc, const Code& code)
72 : object_pool_(ObjectPool::Handle(code.GetObjectPool())), 69 : object_pool_(ObjectPool::Handle(code.GetObjectPool())),
73 end_(pc), 70 end_(pc),
74 native_function_pool_index_(-1), 71 native_function_pool_index_(-1),
75 target_code_pool_index_(-1) { 72 target_code_pool_index_(-1) {
76 UNIMPLEMENTED(); 73 UNIMPLEMENTED();
77 } 74 }
78 75
79
80 RawCode* NativeCallPattern::target() const { 76 RawCode* NativeCallPattern::target() const {
81 return reinterpret_cast<RawCode*>( 77 return reinterpret_cast<RawCode*>(
82 object_pool_.ObjectAt(target_code_pool_index_)); 78 object_pool_.ObjectAt(target_code_pool_index_));
83 } 79 }
84 80
85
86 void NativeCallPattern::set_target(const Code& new_target) const { 81 void NativeCallPattern::set_target(const Code& new_target) const {
87 object_pool_.SetObjectAt(target_code_pool_index_, new_target); 82 object_pool_.SetObjectAt(target_code_pool_index_, new_target);
88 // No need to flush the instruction cache, since the code is not modified. 83 // No need to flush the instruction cache, since the code is not modified.
89 } 84 }
90 85
91
92 NativeFunction NativeCallPattern::native_function() const { 86 NativeFunction NativeCallPattern::native_function() const {
93 return reinterpret_cast<NativeFunction>( 87 return reinterpret_cast<NativeFunction>(
94 object_pool_.RawValueAt(native_function_pool_index_)); 88 object_pool_.RawValueAt(native_function_pool_index_));
95 } 89 }
96 90
97
98 void NativeCallPattern::set_native_function(NativeFunction func) const { 91 void NativeCallPattern::set_native_function(NativeFunction func) const {
99 object_pool_.SetRawValueAt(native_function_pool_index_, 92 object_pool_.SetRawValueAt(native_function_pool_index_,
100 reinterpret_cast<uword>(func)); 93 reinterpret_cast<uword>(func));
101 } 94 }
102 95
103
104 // Decodes a load sequence ending at 'end' (the last instruction of the load 96 // Decodes a load sequence ending at 'end' (the last instruction of the load
105 // sequence is the instruction before the one at end). Returns a pointer to 97 // sequence is the instruction before the one at end). Returns a pointer to
106 // the first instruction in the sequence. Returns the register being loaded 98 // the first instruction in the sequence. Returns the register being loaded
107 // and the loaded object in the output parameters 'reg' and 'obj' 99 // and the loaded object in the output parameters 'reg' and 'obj'
108 // respectively. 100 // respectively.
109 uword InstructionPattern::DecodeLoadObject(uword end, 101 uword InstructionPattern::DecodeLoadObject(uword end,
110 const ObjectPool& object_pool, 102 const ObjectPool& object_pool,
111 Register* reg, 103 Register* reg,
112 Object* obj) { 104 Object* obj) {
113 UNIMPLEMENTED(); 105 UNIMPLEMENTED();
114 return 0; 106 return 0;
115 } 107 }
116 108
117
118 // Decodes a load sequence ending at 'end' (the last instruction of the load 109 // Decodes a load sequence ending at 'end' (the last instruction of the load
119 // sequence is the instruction before the one at end). Returns a pointer to 110 // sequence is the instruction before the one at end). Returns a pointer to
120 // the first instruction in the sequence. Returns the register being loaded 111 // the first instruction in the sequence. Returns the register being loaded
121 // and the loaded immediate value in the output parameters 'reg' and 'value' 112 // and the loaded immediate value in the output parameters 'reg' and 'value'
122 // respectively. 113 // respectively.
123 uword InstructionPattern::DecodeLoadWordImmediate(uword end, 114 uword InstructionPattern::DecodeLoadWordImmediate(uword end,
124 Register* reg, 115 Register* reg,
125 intptr_t* value) { 116 intptr_t* value) {
126 UNIMPLEMENTED(); 117 UNIMPLEMENTED();
127 return 0; 118 return 0;
128 } 119 }
129 120
130
131 // Decodes a load sequence ending at 'end' (the last instruction of the load 121 // Decodes a load sequence ending at 'end' (the last instruction of the load
132 // sequence is the instruction before the one at end). Returns a pointer to 122 // sequence is the instruction before the one at end). Returns a pointer to
133 // the first instruction in the sequence. Returns the register being loaded 123 // the first instruction in the sequence. Returns the register being loaded
134 // and the index in the pool being read from in the output parameters 'reg' 124 // and the index in the pool being read from in the output parameters 'reg'
135 // and 'index' respectively. 125 // and 'index' respectively.
136 uword InstructionPattern::DecodeLoadWordFromPool(uword end, 126 uword InstructionPattern::DecodeLoadWordFromPool(uword end,
137 Register* reg, 127 Register* reg,
138 intptr_t* index) { 128 intptr_t* index) {
139 UNIMPLEMENTED(); 129 UNIMPLEMENTED();
140 return 0; 130 return 0;
141 } 131 }
142 132
143
144 bool DecodeLoadObjectFromPoolOrThread(uword pc, const Code& code, Object* obj) { 133 bool DecodeLoadObjectFromPoolOrThread(uword pc, const Code& code, Object* obj) {
145 ASSERT(code.ContainsInstructionAt(pc)); 134 ASSERT(code.ContainsInstructionAt(pc));
146 const ObjectPool& pool = ObjectPool::Handle(code.object_pool()); 135 const ObjectPool& pool = ObjectPool::Handle(code.object_pool());
147 return GetLoadedObjectAt(pc, pool, obj); 136 return GetLoadedObjectAt(pc, pool, obj);
148 } 137 }
149 138
150
151 RawICData* CallPattern::IcData() { 139 RawICData* CallPattern::IcData() {
152 if (ic_data_.IsNull()) { 140 if (ic_data_.IsNull()) {
153 bool found = GetLoadedObjectAt(ic_data_load_end_, object_pool_, &ic_data_); 141 bool found = GetLoadedObjectAt(ic_data_load_end_, object_pool_, &ic_data_);
154 ASSERT(found); 142 ASSERT(found);
155 } 143 }
156 return ic_data_.raw(); 144 return ic_data_.raw();
157 } 145 }
158 146
159
160 RawCode* CallPattern::TargetCode() const { 147 RawCode* CallPattern::TargetCode() const {
161 return reinterpret_cast<RawCode*>( 148 return reinterpret_cast<RawCode*>(
162 object_pool_.ObjectAt(target_code_pool_index_)); 149 object_pool_.ObjectAt(target_code_pool_index_));
163 } 150 }
164 151
165
166 void CallPattern::SetTargetCode(const Code& target_code) const { 152 void CallPattern::SetTargetCode(const Code& target_code) const {
167 object_pool_.SetObjectAt(target_code_pool_index_, target_code); 153 object_pool_.SetObjectAt(target_code_pool_index_, target_code);
168 } 154 }
169 155
170
171 void CallPattern::InsertDeoptCallAt(uword pc) { 156 void CallPattern::InsertDeoptCallAt(uword pc) {
172 const uint8_t argc = Bytecode::IsCallOpcode(Bytecode::At(pc)) 157 const uint8_t argc = Bytecode::IsCallOpcode(Bytecode::At(pc))
173 ? Bytecode::DecodeArgc(Bytecode::At(pc)) 158 ? Bytecode::DecodeArgc(Bytecode::At(pc))
174 : 0; 159 : 0;
175 *reinterpret_cast<Instr*>(pc) = Bytecode::Encode(Bytecode::kDeopt, argc, 0); 160 *reinterpret_cast<Instr*>(pc) = Bytecode::Encode(Bytecode::kDeopt, argc, 0);
176 } 161 }
177 162
178
179 SwitchableCallPattern::SwitchableCallPattern(uword pc, const Code& code) 163 SwitchableCallPattern::SwitchableCallPattern(uword pc, const Code& code)
180 : object_pool_(ObjectPool::Handle(code.GetObjectPool())), 164 : object_pool_(ObjectPool::Handle(code.GetObjectPool())),
181 data_pool_index_(-1), 165 data_pool_index_(-1),
182 target_pool_index_(-1) { 166 target_pool_index_(-1) {
183 UNIMPLEMENTED(); 167 UNIMPLEMENTED();
184 } 168 }
185 169
186
187 RawObject* SwitchableCallPattern::data() const { 170 RawObject* SwitchableCallPattern::data() const {
188 return object_pool_.ObjectAt(data_pool_index_); 171 return object_pool_.ObjectAt(data_pool_index_);
189 } 172 }
190 173
191
192 RawCode* SwitchableCallPattern::target() const { 174 RawCode* SwitchableCallPattern::target() const {
193 return reinterpret_cast<RawCode*>(object_pool_.ObjectAt(target_pool_index_)); 175 return reinterpret_cast<RawCode*>(object_pool_.ObjectAt(target_pool_index_));
194 } 176 }
195 177
196
197 void SwitchableCallPattern::SetData(const Object& data) const { 178 void SwitchableCallPattern::SetData(const Object& data) const {
198 ASSERT(!Object::Handle(object_pool_.ObjectAt(data_pool_index_)).IsCode()); 179 ASSERT(!Object::Handle(object_pool_.ObjectAt(data_pool_index_)).IsCode());
199 object_pool_.SetObjectAt(data_pool_index_, data); 180 object_pool_.SetObjectAt(data_pool_index_, data);
200 } 181 }
201 182
202
203 void SwitchableCallPattern::SetTarget(const Code& target) const { 183 void SwitchableCallPattern::SetTarget(const Code& target) const {
204 ASSERT(Object::Handle(object_pool_.ObjectAt(target_pool_index_)).IsCode()); 184 ASSERT(Object::Handle(object_pool_.ObjectAt(target_pool_index_)).IsCode());
205 object_pool_.SetObjectAt(target_pool_index_, target); 185 object_pool_.SetObjectAt(target_pool_index_, target);
206 } 186 }
207 187
208
209 ReturnPattern::ReturnPattern(uword pc) : pc_(pc) { 188 ReturnPattern::ReturnPattern(uword pc) : pc_(pc) {
210 USE(pc_); 189 USE(pc_);
211 } 190 }
212 191
213
214 bool ReturnPattern::IsValid() const { 192 bool ReturnPattern::IsValid() const {
215 UNIMPLEMENTED(); 193 UNIMPLEMENTED();
216 return false; 194 return false;
217 } 195 }
218 196
219 } // namespace dart 197 } // namespace dart
220 198
221 #endif // defined TARGET_ARCH_DBC 199 #endif // defined TARGET_ARCH_DBC
OLDNEW
« no previous file with comments | « runtime/vm/instructions_dbc.h ('k') | runtime/vm/instructions_ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698