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

Side by Side Diff: vm/intrinsifier_ia32.cc

Issue 9965042: - Add a class index to the classes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 7 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
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 // The intrinsic code below is executed before a method has built its frame. 5 // The intrinsic code below is executed before a method has built its frame.
6 // The return address is on the stack and the arguments below it. 6 // The return address is on the stack and the arguments below it.
7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved. 7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved.
8 // Each intrinsification method returns true if the corresponding 8 // Each intrinsification method returns true if the corresponding
9 // Dart method was intrinsified. 9 // Dart method was intrinsified.
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // Assert that length is a Smi. 42 // Assert that length is a Smi.
43 __ testl(EDI, Immediate(kSmiTagSize)); 43 __ testl(EDI, Immediate(kSmiTagSize));
44 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); 44 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump);
45 __ cmpl(EDI, Immediate(0)); 45 __ cmpl(EDI, Immediate(0));
46 __ j(LESS, &fall_through, Assembler::kNearJump); 46 __ j(LESS, &fall_through, Assembler::kNearJump);
47 intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; 47 intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1;
48 __ leal(EDI, Address(EDI, TIMES_2, fixed_size)); // EDI is a Smi. 48 __ leal(EDI, Address(EDI, TIMES_2, fixed_size)); // EDI is a Smi.
49 ASSERT(kSmiTagShift == 1); 49 ASSERT(kSmiTagShift == 1);
50 __ andl(EDI, Immediate(-kObjectAlignment)); 50 __ andl(EDI, Immediate(-kObjectAlignment));
51 51
52 Heap* heap = Isolate::Current()->heap(); 52 Isolate* isolate = Isolate::Current();
53 Heap* heap = isolate->heap();
53 54
54 // EDI: allocation size. 55 // EDI: allocation size.
55 __ movl(EAX, Address::Absolute(heap->TopAddress())); 56 __ movl(EAX, Address::Absolute(heap->TopAddress()));
56 __ leal(EBX, Address(EAX, EDI, TIMES_1, 0)); 57 __ leal(EBX, Address(EAX, EDI, TIMES_1, 0));
57 58
58 // Check if the allocation fits into the remaining space. 59 // Check if the allocation fits into the remaining space.
59 // EAX: potential new object start. 60 // EAX: potential new object start.
60 // EBX: potential next object start. 61 // EBX: potential next object start.
61 // EDI: allocation size. 62 // EDI: allocation size.
62 __ cmpl(EBX, Address::Absolute(heap->EndAddress())); 63 __ cmpl(EBX, Address::Absolute(heap->EndAddress()));
63 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); 64 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump);
64 65
65 // Successfully allocated the object(s), now update top to point to 66 // Successfully allocated the object(s), now update top to point to
66 // next object start and initialize the object. 67 // next object start and initialize the object.
67 __ movl(Address::Absolute(heap->TopAddress()), EBX); 68 __ movl(Address::Absolute(heap->TopAddress()), EBX);
68 __ addl(EAX, Immediate(kHeapObjectTag)); 69 __ addl(EAX, Immediate(kHeapObjectTag));
69 70
70 // Initialize the tags. 71 // Initialize the tags.
71 // EAX: new object start as a tagged pointer. 72 // EAX: new object start as a tagged pointer.
72 // EBX: new object end address. 73 // EBX: new object end address.
73 // EDI: allocation size. 74 // EDI: allocation size.
74 { 75 {
75 Label size_tag_overflow, done; 76 Label size_tag_overflow, done;
76 __ cmpl(EDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); 77 __ cmpl(EDI, Immediate(RawObject::SizeTag::kMaxSizeTag));
77 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); 78 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump);
78 __ shll(EDI, Immediate(RawObject::kSizeTagBit - kObjectAlignmentLog2)); 79 __ shll(EDI, Immediate(RawObject::kSizeTagBit - kObjectAlignmentLog2));
79 __ movl(FieldAddress(EAX, Array::tags_offset()), EDI); // Tags.
80 __ jmp(&done, Assembler::kNearJump); 80 __ jmp(&done, Assembler::kNearJump);
81 81
82 __ Bind(&size_tag_overflow); 82 __ Bind(&size_tag_overflow);
83 __ movl(FieldAddress(EAX, Array::tags_offset()), Immediate(0)); 83 __ movl(EDI, Immediate(0));
84 __ Bind(&done); 84 __ Bind(&done);
85
86 // Get the class index and insert it into the tags.
87 const Class& cls = Class::Handle(isolate->object_store()->array_class());
88 __ orl(EDI, Immediate(RawObject::ClassTag::encode(cls.index())));
89 __ movl(FieldAddress(EAX, Array::tags_offset()), EDI); // Tags.
85 } 90 }
86 91
87 // Store class value for array. 92 // Store class value for array.
88 // EAX: new object start as a tagged pointer. 93 // EAX: new object start as a tagged pointer.
89 // EBX: new object end address. 94 // EBX: new object end address.
90 __ movl(EDI, FieldAddress(CTX, Context::isolate_offset())); 95 __ movl(EDI, FieldAddress(CTX, Context::isolate_offset()));
91 __ movl(EDI, Address(EDI, Isolate::object_store_offset())); 96 __ movl(EDI, Address(EDI, Isolate::object_store_offset()));
92 __ movl(EDI, Address(EDI, ObjectStore::array_class_offset())); 97 __ movl(EDI, Address(EDI, ObjectStore::array_class_offset()));
93 __ StoreIntoObject(EAX, FieldAddress(EAX, Array::class_offset()), EDI); 98 __ StoreIntoObject(EAX, FieldAddress(EAX, Array::class_offset()), EDI);
94 99
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // and the newly allocated object is returned in EAX. 264 // and the newly allocated object is returned in EAX.
260 const intptr_t kTypeArgumentsOffset = 2 * kWordSize; 265 const intptr_t kTypeArgumentsOffset = 2 * kWordSize;
261 const intptr_t kArrayOffset = 1 * kWordSize; 266 const intptr_t kArrayOffset = 1 * kWordSize;
262 Label fall_through; 267 Label fall_through;
263 268
264 // Compute the size to be allocated, it is based on the array length 269 // Compute the size to be allocated, it is based on the array length
265 // and it computed as: 270 // and it computed as:
266 // RoundedAllocationSize(sizeof(RawGrowableObjectArray)) + 271 // RoundedAllocationSize(sizeof(RawGrowableObjectArray)) +
267 intptr_t fixed_size = GrowableObjectArray::InstanceSize(); 272 intptr_t fixed_size = GrowableObjectArray::InstanceSize();
268 273
269 Heap* heap = Isolate::Current()->heap(); 274 Isolate* isolate = Isolate::Current();
275 Heap* heap = isolate->heap();
270 276
271 __ movl(EAX, Address::Absolute(heap->TopAddress())); 277 __ movl(EAX, Address::Absolute(heap->TopAddress()));
272 __ leal(EBX, Address(EAX, fixed_size)); 278 __ leal(EBX, Address(EAX, fixed_size));
273 279
274 // Check if the allocation fits into the remaining space. 280 // Check if the allocation fits into the remaining space.
275 // EAX: potential new backing array object start. 281 // EAX: potential new backing array object start.
276 // EBX: potential next object start. 282 // EBX: potential next object start.
277 __ cmpl(EBX, Address::Absolute(heap->EndAddress())); 283 __ cmpl(EBX, Address::Absolute(heap->EndAddress()));
278 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); 284 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump);
279 285
280 // Successfully allocated the object(s), now update top to point to 286 // Successfully allocated the object(s), now update top to point to
281 // next object start and initialize the object. 287 // next object start and initialize the object.
282 __ movl(Address::Absolute(heap->TopAddress()), EBX); 288 __ movl(Address::Absolute(heap->TopAddress()), EBX);
283 __ addl(EAX, Immediate(kHeapObjectTag)); 289 __ addl(EAX, Immediate(kHeapObjectTag));
284 290
285 // Initialize the tags. 291 // Initialize the tags.
286 // EAX: new growable array object start as a tagged pointer. 292 // EAX: new growable array object start as a tagged pointer.
293 const Class& cls = Class::Handle(
294 isolate->object_store()->growable_object_array_class());
295 intptr_t tags = 0;
296 tags = RawObject::SizeTag::update(fixed_size, tags);
297 tags = RawObject::ClassTag::update(cls.index(), tags);
287 __ movl(FieldAddress(EAX, GrowableObjectArray::tags_offset()), 298 __ movl(FieldAddress(EAX, GrowableObjectArray::tags_offset()),
288 Immediate(RawObject::SizeTag::update(fixed_size, 0))); 299 Immediate(tags));
289 300
290 // Store backing array object in growable array object. 301 // Store backing array object in growable array object.
291 __ movl(EBX, Address(ESP, kArrayOffset)); // data argument. 302 __ movl(EBX, Address(ESP, kArrayOffset)); // data argument.
292 __ StoreIntoObject(EAX, 303 __ StoreIntoObject(EAX,
293 FieldAddress(EAX, GrowableObjectArray::data_offset()), 304 FieldAddress(EAX, GrowableObjectArray::data_offset()),
294 EBX); 305 EBX);
295 306
296 // Store class value for the growable array object. 307 // Store class value for the growable array object.
297 // EAX: new growable array object start as a tagged pointer. 308 // EAX: new growable array object start as a tagged pointer.
298 __ movl(EBX, FieldAddress(CTX, Context::isolate_offset())); 309 __ movl(EBX, FieldAddress(CTX, Context::isolate_offset()));
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 __ Bind(&is_true); 1337 __ Bind(&is_true);
1327 __ LoadObject(EAX, bool_true); 1338 __ LoadObject(EAX, bool_true);
1328 __ ret(); 1339 __ ret();
1329 return true; 1340 return true;
1330 } 1341 }
1331 1342
1332 #undef __ 1343 #undef __
1333 } // namespace dart 1344 } // namespace dart
1334 1345
1335 #endif // defined TARGET_ARCH_IA32 1346 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « vm/dart_api_impl.cc ('k') | vm/isolate.h » ('j') | vm/raw_object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698