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

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

Issue 1713853003: VM: Share object pool entries for optimized static calls. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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/assembler.h ('k') | runtime/vm/assembler_arm.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) 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 #include "vm/assembler.h" 5 #include "vm/assembler.h"
6 6
7 #include "platform/utils.h" 7 #include "platform/utils.h"
8 #include "vm/cpu.h" 8 #include "vm/cpu.h"
9 #include "vm/heap.h" 9 #include "vm/heap.h"
10 #include "vm/memory_region.h" 10 #include "vm/memory_region.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 comments.SetPCOffsetAt(i, comments_[i]->pc_offset()); 237 comments.SetPCOffsetAt(i, comments_[i]->pc_offset());
238 comments.SetCommentAt(i, comments_[i]->comment()); 238 comments.SetCommentAt(i, comments_[i]->comment());
239 } 239 }
240 240
241 return comments; 241 return comments;
242 } 242 }
243 243
244 244
245 intptr_t ObjectPoolWrapper::AddObject(const Object& obj, 245 intptr_t ObjectPoolWrapper::AddObject(const Object& obj,
246 Patchability patchable) { 246 Patchability patchable) {
247 return AddObject(ObjectPool::Entry(&obj), patchable); 247 return AddObject(ObjectPoolWrapperEntry(&obj), patchable);
248 } 248 }
249 249
250 250
251 intptr_t ObjectPoolWrapper::AddImmediate(uword imm) { 251 intptr_t ObjectPoolWrapper::AddImmediate(uword imm) {
252 return AddObject(ObjectPool::Entry(imm, ObjectPool::kImmediate), 252 return AddObject(ObjectPoolWrapperEntry(imm, ObjectPool::kImmediate),
253 kNotPatchable); 253 kNotPatchable);
254 } 254 }
255 255
256 intptr_t ObjectPoolWrapper::AddObject(ObjectPool::Entry entry, 256 intptr_t ObjectPoolWrapper::AddObject(ObjectPoolWrapperEntry entry,
257 Patchability patchable) { 257 Patchability patchable) {
258 object_pool_.Add(entry); 258 object_pool_.Add(entry);
259 if (patchable == kNotPatchable) { 259 if (patchable == kNotPatchable) {
260 // The object isn't patchable. Record the index for fast lookup. 260 // The object isn't patchable. Record the index for fast lookup.
261 object_pool_index_table_.Insert( 261 object_pool_index_table_.Insert(
262 ObjIndexPair(entry, object_pool_.length() - 1)); 262 ObjIndexPair(entry, object_pool_.length() - 1));
263 } 263 }
264 return object_pool_.length() - 1; 264 return object_pool_.length() - 1;
265 } 265 }
266 266
267 267
268 intptr_t ObjectPoolWrapper::FindObject(ObjectPool::Entry entry, 268 intptr_t ObjectPoolWrapper::FindObject(ObjectPoolWrapperEntry entry,
269 Patchability patchable) { 269 Patchability patchable) {
270 // If the object is not patchable, check if we've already got it in the 270 // If the object is not patchable, check if we've already got it in the
271 // object pool. 271 // object pool.
272 if (patchable == kNotPatchable) { 272 if (patchable == kNotPatchable) {
273 intptr_t idx = object_pool_index_table_.Lookup(entry); 273 intptr_t idx = object_pool_index_table_.Lookup(entry);
274 if (idx != ObjIndexPair::kNoIndex) { 274 if (idx != ObjIndexPair::kNoIndex) {
275 return idx; 275 return idx;
276 } 276 }
277 } 277 }
278 278
279 return AddObject(entry, patchable); 279 return AddObject(entry, patchable);
280 } 280 }
281 281
282 282
283 intptr_t ObjectPoolWrapper::FindObject(const Object& obj, 283 intptr_t ObjectPoolWrapper::FindObject(const Object& obj,
284 Patchability patchable) { 284 Patchability patchable) {
285 return FindObject(ObjectPool::Entry(&obj), patchable); 285 return FindObject(ObjectPoolWrapperEntry(&obj), patchable);
286 }
287
288
289 intptr_t ObjectPoolWrapper::FindObject(const Object& obj,
290 const Object& equivalence) {
291 return FindObject(ObjectPoolWrapperEntry(&obj, &equivalence),
292 kNotPatchable);
286 } 293 }
287 294
288 295
289 intptr_t ObjectPoolWrapper::FindImmediate(uword imm) { 296 intptr_t ObjectPoolWrapper::FindImmediate(uword imm) {
290 return FindObject(ObjectPool::Entry(imm, ObjectPool::kImmediate), 297 return FindObject(ObjectPoolWrapperEntry(imm, ObjectPool::kImmediate),
291 kNotPatchable); 298 kNotPatchable);
292 } 299 }
293 300
294 301
295 intptr_t ObjectPoolWrapper::FindNativeEntry(const ExternalLabel* label, 302 intptr_t ObjectPoolWrapper::FindNativeEntry(const ExternalLabel* label,
296 Patchability patchable) { 303 Patchability patchable) {
297 return FindObject(ObjectPool::Entry(label->address(), 304 return FindObject(ObjectPoolWrapperEntry(label->address(),
298 ObjectPool::kNativeEntry), 305 ObjectPool::kNativeEntry),
299 patchable); 306 patchable);
300 } 307 }
301 308
302 309
303 RawObjectPool* ObjectPoolWrapper::MakeObjectPool() { 310 RawObjectPool* ObjectPoolWrapper::MakeObjectPool() {
304 intptr_t len = object_pool_.length(); 311 intptr_t len = object_pool_.length();
305 if (len == 0) { 312 if (len == 0) {
306 return Object::empty_object_pool().raw(); 313 return Object::empty_object_pool().raw();
307 } 314 }
308 const ObjectPool& result = ObjectPool::Handle(ObjectPool::New(len)); 315 const ObjectPool& result = ObjectPool::Handle(ObjectPool::New(len));
309 const TypedData& info_array = TypedData::Handle(result.info_array()); 316 const TypedData& info_array = TypedData::Handle(result.info_array());
310 for (intptr_t i = 0; i < len; ++i) { 317 for (intptr_t i = 0; i < len; ++i) {
311 ObjectPool::EntryType info = object_pool_[i].type_; 318 ObjectPool::EntryType info = object_pool_[i].type_;
312 info_array.SetInt8(i, static_cast<int8_t>(info)); 319 info_array.SetInt8(i, static_cast<int8_t>(info));
313 if (info == ObjectPool::kTaggedObject) { 320 if (info == ObjectPool::kTaggedObject) {
314 result.SetObjectAt(i, *object_pool_[i].obj_); 321 result.SetObjectAt(i, *object_pool_[i].obj_);
315 } else { 322 } else {
316 result.SetRawValueAt(i, object_pool_[i].raw_value_); 323 result.SetRawValueAt(i, object_pool_[i].raw_value_);
317 } 324 }
318 } 325 }
319 return result.raw(); 326 return result.raw();
320 } 327 }
321 328
322 329
323 } // namespace dart 330 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/assembler.h ('k') | runtime/vm/assembler_arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698