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

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

Issue 1229283002: VM: Share some stub code between isolates. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: addressed comments Created 5 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 | « no previous file | runtime/vm/assembler_arm64.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) 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 247 }
248 248
249 249
250 intptr_t ObjectPoolWrapper::AddImmediate(uword imm) { 250 intptr_t ObjectPoolWrapper::AddImmediate(uword imm) {
251 return AddObject(ObjectPool::Entry(imm, ObjectPool::kImmediate), 251 return AddObject(ObjectPool::Entry(imm, ObjectPool::kImmediate),
252 kNotPatchable); 252 kNotPatchable);
253 } 253 }
254 254
255 intptr_t ObjectPoolWrapper::AddObject(ObjectPool::Entry entry, 255 intptr_t ObjectPoolWrapper::AddObject(ObjectPool::Entry entry,
256 Patchability patchable) { 256 Patchability patchable) {
257 // The object pool cannot be used in the vm isolate.
258 ASSERT(Isolate::Current() != Dart::vm_isolate());
259 object_pool_.Add(entry); 257 object_pool_.Add(entry);
260 if (patchable == kNotPatchable) { 258 if (patchable == kNotPatchable) {
261 // The object isn't patchable. Record the index for fast lookup. 259 // The object isn't patchable. Record the index for fast lookup.
262 object_pool_index_table_.Insert( 260 object_pool_index_table_.Insert(
263 ObjIndexPair(entry, object_pool_.length() - 1)); 261 ObjIndexPair(entry, object_pool_.length() - 1));
264 } 262 }
265 return object_pool_.length() - 1; 263 return object_pool_.length() - 1;
266 } 264 }
267 265
268 266
269 intptr_t ObjectPoolWrapper::AddExternalLabel(const ExternalLabel* label, 267 intptr_t ObjectPoolWrapper::AddExternalLabel(const ExternalLabel* label,
270 Patchability patchable) { 268 Patchability patchable) {
271 ASSERT(Isolate::Current() != Dart::vm_isolate());
272 return AddObject(ObjectPool::Entry(label->address(), 269 return AddObject(ObjectPool::Entry(label->address(),
273 ObjectPool::kImmediate), 270 ObjectPool::kImmediate),
274 patchable); 271 patchable);
275 } 272 }
276 273
277 274
278 intptr_t ObjectPoolWrapper::FindObject(ObjectPool::Entry entry, 275 intptr_t ObjectPoolWrapper::FindObject(ObjectPool::Entry entry,
279 Patchability patchable) { 276 Patchability patchable) {
280 // The object pool cannot be used in the vm isolate.
281 ASSERT(Isolate::Current() != Dart::vm_isolate());
282
283 // If the object is not patchable, check if we've already got it in the 277 // If the object is not patchable, check if we've already got it in the
284 // object pool. 278 // object pool.
285 if (patchable == kNotPatchable) { 279 if (patchable == kNotPatchable) {
286 intptr_t idx = object_pool_index_table_.Lookup(entry); 280 intptr_t idx = object_pool_index_table_.Lookup(entry);
287 if (idx != ObjIndexPair::kNoIndex) { 281 if (idx != ObjIndexPair::kNoIndex) {
288 return idx; 282 return idx;
289 } 283 }
290 } 284 }
291 285
292 return AddObject(entry, patchable); 286 return AddObject(entry, patchable);
293 } 287 }
294 288
295 289
296 intptr_t ObjectPoolWrapper::FindObject(const Object& obj) { 290 intptr_t ObjectPoolWrapper::FindObject(const Object& obj) {
297 return FindObject(ObjectPool::Entry(&obj), kNotPatchable); 291 return FindObject(ObjectPool::Entry(&obj), kNotPatchable);
298 } 292 }
299 293
300 294
301 intptr_t ObjectPoolWrapper::FindImmediate(uword imm) { 295 intptr_t ObjectPoolWrapper::FindImmediate(uword imm) {
302 return FindObject(ObjectPool::Entry(imm, ObjectPool::kImmediate), 296 return FindObject(ObjectPool::Entry(imm, ObjectPool::kImmediate),
303 kNotPatchable); 297 kNotPatchable);
304 } 298 }
305 299
306 300
307 intptr_t ObjectPoolWrapper::FindExternalLabel(const ExternalLabel* label, 301 intptr_t ObjectPoolWrapper::FindExternalLabel(const ExternalLabel* label,
308 Patchability patchable) { 302 Patchability patchable) {
309 // The object pool cannot be used in the vm isolate.
310 ASSERT(Isolate::Current() != Dart::vm_isolate());
311 return FindObject(ObjectPool::Entry(label->address(), 303 return FindObject(ObjectPool::Entry(label->address(),
312 ObjectPool::kImmediate), 304 ObjectPool::kImmediate),
313 patchable); 305 patchable);
314 } 306 }
315 307
316 308
317 RawObjectPool* ObjectPoolWrapper::MakeObjectPool() { 309 RawObjectPool* ObjectPoolWrapper::MakeObjectPool() {
318 intptr_t len = object_pool_.length(); 310 intptr_t len = object_pool_.length();
319 if (len == 0) { 311 if (len == 0) {
320 return Object::empty_object_pool().raw(); 312 return Object::empty_object_pool().raw();
321 } 313 }
322 const ObjectPool& result = ObjectPool::Handle(ObjectPool::New(len)); 314 const ObjectPool& result = ObjectPool::Handle(ObjectPool::New(len));
323 for (intptr_t i = 0; i < len; ++i) { 315 for (intptr_t i = 0; i < len; ++i) {
324 ObjectPool::EntryType info = object_pool_[i].type_; 316 ObjectPool::EntryType info = object_pool_[i].type_;
325 result.SetInfoAt(i, info); 317 result.SetInfoAt(i, info);
326 if (info == ObjectPool::kTaggedObject) { 318 if (info == ObjectPool::kTaggedObject) {
327 result.SetObjectAt(i, *object_pool_[i].obj_); 319 result.SetObjectAt(i, *object_pool_[i].obj_);
328 } else { 320 } else {
329 result.SetRawValueAt(i, object_pool_[i].raw_value_); 321 result.SetRawValueAt(i, object_pool_[i].raw_value_);
330 } 322 }
331 } 323 }
332 return result.raw(); 324 return result.raw();
333 } 325 }
334 326
335 327
336 } // namespace dart 328 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/assembler_arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698