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

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

Issue 10521004: Eliminate RawObject::class_ field entirely. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/assembler_macros.h" 9 #include "vm/assembler_macros.h"
10 #include "vm/code_generator.h" 10 #include "vm/code_generator.h"
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 // Store the type argument field. 666 // Store the type argument field.
667 __ StoreIntoObject(EAX, 667 __ StoreIntoObject(EAX,
668 FieldAddress(EAX, Array::type_arguments_offset()), 668 FieldAddress(EAX, Array::type_arguments_offset()),
669 ECX); 669 ECX);
670 670
671 // Set the length field. 671 // Set the length field.
672 __ StoreIntoObject(EAX, 672 __ StoreIntoObject(EAX,
673 FieldAddress(EAX, Array::length_offset()), 673 FieldAddress(EAX, Array::length_offset()),
674 EDX); 674 EDX);
675 675
676 // EAX: new object start as a tagged pointer.
677 // EBX: new object end address.
678 // EDX: Array length as Smi.
679 // Store class value for array.
680 __ movl(ECX, FieldAddress(CTX, Context::isolate_offset()));
681 __ movl(ECX, Address(ECX, Isolate::object_store_offset()));
682 __ movl(ECX, Address(ECX, ObjectStore::array_class_offset()));
683 __ StoreIntoObject(EAX,
684 FieldAddress(EAX, Array::class_offset()),
685 ECX);
686 // Calculate the size tag. 676 // Calculate the size tag.
687 // EAX: new object start as a tagged pointer. 677 // EAX: new object start as a tagged pointer.
688 // EBX: new object end address. 678 // EBX: new object end address.
689 // EDX: Array length as Smi. 679 // EDX: Array length as Smi.
690 { 680 {
691 Label size_tag_overflow, done; 681 Label size_tag_overflow, done;
692 __ leal(ECX, Address(EDX, TIMES_2, fixed_size)); // EDX is Smi. 682 __ leal(ECX, Address(EDX, TIMES_2, fixed_size)); // EDX is Smi.
693 ASSERT(kSmiTagShift == 1); 683 ASSERT(kSmiTagShift == 1);
694 __ andl(ECX, Immediate(-kObjectAlignment)); 684 __ andl(ECX, Immediate(-kObjectAlignment));
695 __ cmpl(ECX, Immediate(RawObject::SizeTag::kMaxSizeTag)); 685 __ cmpl(ECX, Immediate(RawObject::SizeTag::kMaxSizeTag));
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 } 987 }
998 988
999 // Successfully allocated the object, now update top to point to 989 // Successfully allocated the object, now update top to point to
1000 // next object start and initialize the object. 990 // next object start and initialize the object.
1001 // EAX: new object. 991 // EAX: new object.
1002 // EBX: next object start. 992 // EBX: next object start.
1003 // EDX: number of context variables. 993 // EDX: number of context variables.
1004 __ movl(Address::Absolute(heap->TopAddress()), EBX); 994 __ movl(Address::Absolute(heap->TopAddress()), EBX);
1005 __ addl(EAX, Immediate(kHeapObjectTag)); 995 __ addl(EAX, Immediate(kHeapObjectTag));
1006 996
1007 // Initialize the class field in the context object.
1008 // EAX: new object.
1009 // EDX: number of context variables.
1010 __ LoadObject(EBX, context_class); // Load up class field of context.
1011 __ StoreIntoObject(EAX,
1012 FieldAddress(EAX, Context::class_offset()),
1013 EBX);
1014 // Calculate the size tag. 997 // Calculate the size tag.
1015 // EAX: new object. 998 // EAX: new object.
1016 // EDX: number of context variables. 999 // EDX: number of context variables.
1017 { 1000 {
1018 Label size_tag_overflow, done; 1001 Label size_tag_overflow, done;
1019 __ leal(EBX, Address(EDX, TIMES_4, fixed_size)); 1002 __ leal(EBX, Address(EDX, TIMES_4, fixed_size));
1020 __ andl(EBX, Immediate(-kObjectAlignment)); 1003 __ andl(EBX, Immediate(-kObjectAlignment));
1021 __ cmpl(EBX, Immediate(RawObject::SizeTag::kMaxSizeTag)); 1004 __ cmpl(EBX, Immediate(RawObject::SizeTag::kMaxSizeTag));
1022 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); 1005 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump);
1023 __ shll(EBX, Immediate(RawObject::kSizeTagBit - kObjectAlignmentLog2)); 1006 __ shll(EBX, Immediate(RawObject::kSizeTagBit - kObjectAlignmentLog2));
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 // Initialize InstantiatedTypeArguments object at ECX. 1145 // Initialize InstantiatedTypeArguments object at ECX.
1163 __ movl(Address(ECX, 1146 __ movl(Address(ECX,
1164 InstantiatedTypeArguments::uninstantiated_type_arguments_offset()), 1147 InstantiatedTypeArguments::uninstantiated_type_arguments_offset()),
1165 EDI); 1148 EDI);
1166 __ movl(EDX, Address(ESP, kInstantiatorTypeArgumentsOffset)); 1149 __ movl(EDX, Address(ESP, kInstantiatorTypeArgumentsOffset));
1167 __ movl(Address(ECX, 1150 __ movl(Address(ECX,
1168 InstantiatedTypeArguments::instantiator_type_arguments_offset()), 1151 InstantiatedTypeArguments::instantiator_type_arguments_offset()),
1169 EDX); 1152 EDX);
1170 const Class& ita_cls = 1153 const Class& ita_cls =
1171 Class::ZoneHandle(Object::instantiated_type_arguments_class()); 1154 Class::ZoneHandle(Object::instantiated_type_arguments_class());
1172 __ LoadObject(EDX, ita_cls);
1173 __ movl(Address(ECX, Instance::class_offset()), EDX); // Set its class.
1174 // Set the tags. 1155 // Set the tags.
1175 uword tags = 0; 1156 uword tags = 0;
1176 tags = RawObject::SizeTag::update(type_args_size, tags); 1157 tags = RawObject::SizeTag::update(type_args_size, tags);
1177 tags = RawObject::ClassIdTag::update(ita_cls.id(), tags); 1158 tags = RawObject::ClassIdTag::update(ita_cls.id(), tags);
1178 __ movl(Address(ECX, Instance::tags_offset()), Immediate(tags)); 1159 __ movl(Address(ECX, Instance::tags_offset()), Immediate(tags));
1179 // Set the new InstantiatedTypeArguments object (ECX) as the type 1160 // Set the new InstantiatedTypeArguments object (ECX) as the type
1180 // arguments (EDI) of the new object (EAX). 1161 // arguments (EDI) of the new object (EAX).
1181 __ movl(EDI, ECX); 1162 __ movl(EDI, ECX);
1182 __ addl(EDI, Immediate(kHeapObjectTag)); 1163 __ addl(EDI, Immediate(kHeapObjectTag));
1183 // Set EBX to new object end. 1164 // Set EBX to new object end.
1184 __ movl(EBX, ECX); 1165 __ movl(EBX, ECX);
1185 __ Bind(&type_arguments_ready); 1166 __ Bind(&type_arguments_ready);
1186 // EAX: new object. 1167 // EAX: new object.
1187 // EDI: new object type arguments. 1168 // EDI: new object type arguments.
1188 } 1169 }
1189 1170
1190 // Initialize the class field in the object.
1191 // EAX: new object start. 1171 // EAX: new object start.
1192 // EBX: next object start. 1172 // EBX: next object start.
1193 // EDI: new object type arguments (if is_cls_parameterized). 1173 // EDI: new object type arguments (if is_cls_parameterized).
1194 __ LoadObject(EDX, cls); // Load class of object to be allocated. 1174 __ LoadObject(EDX, cls); // Load class of object to be allocated.
1195 __ movl(Address(EAX, Instance::class_offset()), EDX);
1196 // Set the tags. 1175 // Set the tags.
1197 uword tags = 0; 1176 uword tags = 0;
1198 tags = RawObject::SizeTag::update(instance_size, tags); 1177 tags = RawObject::SizeTag::update(instance_size, tags);
1199 ASSERT(cls.id() != kIllegalObjectKind); 1178 ASSERT(cls.id() != kIllegalObjectKind);
1200 tags = RawObject::ClassIdTag::update(cls.id(), tags); 1179 tags = RawObject::ClassIdTag::update(cls.id(), tags);
1201 __ movl(Address(EAX, Instance::tags_offset()), Immediate(tags)); 1180 __ movl(Address(EAX, Instance::tags_offset()), Immediate(tags));
1202 1181
1203 // Initialize the remaining words of the object. 1182 // Initialize the remaining words of the object.
1204 const Immediate raw_null = 1183 const Immediate raw_null =
1205 Immediate(reinterpret_cast<intptr_t>(Object::null())); 1184 Immediate(reinterpret_cast<intptr_t>(Object::null()));
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 if (FLAG_use_slow_path) { 1312 if (FLAG_use_slow_path) {
1334 __ jmp(&slow_case); 1313 __ jmp(&slow_case);
1335 } else { 1314 } else {
1336 __ j(ABOVE_EQUAL, &slow_case, Assembler::kNearJump); 1315 __ j(ABOVE_EQUAL, &slow_case, Assembler::kNearJump);
1337 } 1316 }
1338 1317
1339 // Successfully allocated the object, now update top to point to 1318 // Successfully allocated the object, now update top to point to
1340 // next object start and initialize the object. 1319 // next object start and initialize the object.
1341 __ movl(Address::Absolute(heap->TopAddress()), EBX); 1320 __ movl(Address::Absolute(heap->TopAddress()), EBX);
1342 1321
1343 // Initialize the class field in the object.
1344 // EAX: new closure object. 1322 // EAX: new closure object.
1345 // ECX: new context object (only if is_implicit_closure). 1323 // ECX: new context object (only if is_implicit_closure).
1346 __ LoadObject(EDX, cls); // Load signature class of closure.
1347 __ movl(Address(EAX, Closure::class_offset()), EDX);
1348 // Set the tags. 1324 // Set the tags.
1349 uword tags = 0; 1325 uword tags = 0;
1350 tags = RawObject::SizeTag::update(closure_size, tags); 1326 tags = RawObject::SizeTag::update(closure_size, tags);
1351 tags = RawObject::ClassIdTag::update(cls.id(), tags); 1327 tags = RawObject::ClassIdTag::update(cls.id(), tags);
1352 __ movl(Address(EAX, Closure::tags_offset()), Immediate(tags)); 1328 __ movl(Address(EAX, Closure::tags_offset()), Immediate(tags));
1353 1329
1354 // Initialize the function field in the object. 1330 // Initialize the function field in the object.
1355 // EAX: new closure object. 1331 // EAX: new closure object.
1356 // ECX: new context object (only if is_implicit_closure). 1332 // ECX: new context object (only if is_implicit_closure).
1357 // EBX: next object start. 1333 // EBX: next object start.
1358 __ LoadObject(EDX, func); // Load function of closure to be allocated. 1334 __ LoadObject(EDX, func); // Load function of closure to be allocated.
1359 __ movl(Address(EAX, Closure::function_offset()), EDX); 1335 __ movl(Address(EAX, Closure::function_offset()), EDX);
1360 1336
1361 // Setup the context for this closure. 1337 // Setup the context for this closure.
1362 if (is_implicit_static_closure) { 1338 if (is_implicit_static_closure) {
1363 ObjectStore* object_store = Isolate::Current()->object_store(); 1339 ObjectStore* object_store = Isolate::Current()->object_store();
1364 ASSERT(object_store != NULL); 1340 ASSERT(object_store != NULL);
1365 const Context& empty_context = 1341 const Context& empty_context =
1366 Context::ZoneHandle(object_store->empty_context()); 1342 Context::ZoneHandle(object_store->empty_context());
1367 __ LoadObject(EDX, empty_context); 1343 __ LoadObject(EDX, empty_context);
1368 __ movl(Address(EAX, Closure::context_offset()), EDX); 1344 __ movl(Address(EAX, Closure::context_offset()), EDX);
1369 } else if (is_implicit_instance_closure) { 1345 } else if (is_implicit_instance_closure) {
1370 // Initialize the new context capturing the receiver. 1346 // Initialize the new context capturing the receiver.
1371
1372 // Set the class field to the Context class.
1373 const Class& context_class = Class::ZoneHandle(Object::context_class()); 1347 const Class& context_class = Class::ZoneHandle(Object::context_class());
1374 __ LoadObject(EBX, context_class);
1375 __ movl(Address(ECX, Context::class_offset()), EBX);
1376 // Set the tags. 1348 // Set the tags.
1377 uword tags = 0; 1349 uword tags = 0;
1378 tags = RawObject::SizeTag::update(context_size, tags); 1350 tags = RawObject::SizeTag::update(context_size, tags);
1379 tags = RawObject::ClassIdTag::update(context_class.id(), tags); 1351 tags = RawObject::ClassIdTag::update(context_class.id(), tags);
1380 __ movl(Address(ECX, Context::tags_offset()), Immediate(tags)); 1352 __ movl(Address(ECX, Context::tags_offset()), Immediate(tags));
1381 1353
1382 // Set number of variables field to 1 (for captured receiver). 1354 // Set number of variables field to 1 (for captured receiver).
1383 __ movl(Address(ECX, Context::num_variables_offset()), Immediate(1)); 1355 __ movl(Address(ECX, Context::num_variables_offset()), Immediate(1));
1384 1356
1385 // Set isolate field to isolate of current context. 1357 // Set isolate field to isolate of current context.
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1882 // TOS + 2: instance. 1854 // TOS + 2: instance.
1883 // TOS + 3: cache array. 1855 // TOS + 3: cache array.
1884 // Result in ECX: null -> not found, otherwise result (true or false). 1856 // Result in ECX: null -> not found, otherwise result (true or false).
1885 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) { 1857 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) {
1886 GenerateSubtypeNTestCacheStub(assembler, 3); 1858 GenerateSubtypeNTestCacheStub(assembler, 3);
1887 } 1859 }
1888 1860
1889 } // namespace dart 1861 } // namespace dart
1890 1862
1891 #endif // defined TARGET_ARCH_IA32 1863 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698