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

Side by Side Diff: vm/stub_code_ia32.cc

Issue 10271032: - Add extra checking when validating objects. (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
« no previous file with comments | « vm/raw_object.cc ('k') | vm/stub_code_x64.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) 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/code_generator.h" 8 #include "vm/code_generator.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/object_store.h" 10 #include "vm/object_store.h"
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 __ cmpl(ECX, EBX); 1141 __ cmpl(ECX, EBX);
1142 __ j(EQUAL, &type_arguments_ready, Assembler::kNearJump); 1142 __ j(EQUAL, &type_arguments_ready, Assembler::kNearJump);
1143 // Initialize InstantiatedTypeArguments object at ECX. 1143 // Initialize InstantiatedTypeArguments object at ECX.
1144 __ movl(Address(ECX, 1144 __ movl(Address(ECX,
1145 InstantiatedTypeArguments::uninstantiated_type_arguments_offset()), 1145 InstantiatedTypeArguments::uninstantiated_type_arguments_offset()),
1146 EDI); 1146 EDI);
1147 __ movl(EDX, Address(ESP, kInstantiatorTypeArgumentsOffset)); 1147 __ movl(EDX, Address(ESP, kInstantiatorTypeArgumentsOffset));
1148 __ movl(Address(ECX, 1148 __ movl(Address(ECX,
1149 InstantiatedTypeArguments::instantiator_type_arguments_offset()), 1149 InstantiatedTypeArguments::instantiator_type_arguments_offset()),
1150 EDX); 1150 EDX);
1151 __ LoadObject(EDX, 1151 const Class& ita_cls =
1152 Class::ZoneHandle(Object::instantiated_type_arguments_class())); 1152 Class::ZoneHandle(Object::instantiated_type_arguments_class());
1153 __ LoadObject(EDX, ita_cls);
1153 __ movl(Address(ECX, Instance::class_offset()), EDX); // Set its class. 1154 __ movl(Address(ECX, Instance::class_offset()), EDX); // Set its class.
1154 // Set the tags. 1155 // Set the tags.
1155 __ movl(Address(ECX, Instance::tags_offset()), 1156 uword tags = 0;
1156 Immediate(RawObject::SizeTag::encode(type_args_size))); 1157 tags = RawObject::SizeTag::update(type_args_size, tags);
1158 tags = RawObject::ClassTag::update(ita_cls.index(), tags);
1159 __ movl(Address(ECX, Instance::tags_offset()), Immediate(tags));
1157 // Set the new InstantiatedTypeArguments object (ECX) as the type 1160 // Set the new InstantiatedTypeArguments object (ECX) as the type
1158 // arguments (EDI) of the new object (EAX). 1161 // arguments (EDI) of the new object (EAX).
1159 __ movl(EDI, ECX); 1162 __ movl(EDI, ECX);
1160 __ addl(EDI, Immediate(kHeapObjectTag)); 1163 __ addl(EDI, Immediate(kHeapObjectTag));
1161 // Set EBX to new object end. 1164 // Set EBX to new object end.
1162 __ movl(EBX, ECX); 1165 __ movl(EBX, ECX);
1163 __ Bind(&type_arguments_ready); 1166 __ Bind(&type_arguments_ready);
1164 // EAX: new object. 1167 // EAX: new object.
1165 // EDI: new object type arguments. 1168 // EDI: new object type arguments.
1166 } 1169 }
1167 1170
1168 // Initialize the class field in the object. 1171 // Initialize the class field in the object.
1169 // EAX: new object start. 1172 // EAX: new object start.
1170 // EBX: next object start. 1173 // EBX: next object start.
1171 // EDI: new object type arguments (if is_cls_parameterized). 1174 // EDI: new object type arguments (if is_cls_parameterized).
1172 __ LoadObject(EDX, cls); // Load class of object to be allocated. 1175 __ LoadObject(EDX, cls); // Load class of object to be allocated.
1173 __ movl(Address(EAX, Instance::class_offset()), EDX); 1176 __ movl(Address(EAX, Instance::class_offset()), EDX);
1174 // Set the tags. 1177 // Set the tags.
1175 intptr_t tags = 0; 1178 uword tags = 0;
1176 tags = RawObject::SizeTag::update(instance_size, tags); 1179 tags = RawObject::SizeTag::update(instance_size, tags);
1177 ASSERT(cls.index() != kIllegalObjectKind); 1180 ASSERT(cls.index() != kIllegalObjectKind);
1178 tags = RawObject::ClassTag::update(cls.index(), tags); 1181 tags = RawObject::ClassTag::update(cls.index(), tags);
1179 __ movl(Address(EAX, Instance::tags_offset()), Immediate(tags)); 1182 __ movl(Address(EAX, Instance::tags_offset()), Immediate(tags));
1180 1183
1181 // Initialize the remaining words of the object. 1184 // Initialize the remaining words of the object.
1182 const Immediate raw_null = 1185 const Immediate raw_null =
1183 Immediate(reinterpret_cast<intptr_t>(Object::null())); 1186 Immediate(reinterpret_cast<intptr_t>(Object::null()));
1184 1187
1185 // EAX: new object start. 1188 // EAX: new object start.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 // Successfully allocated the object, now update top to point to 1321 // Successfully allocated the object, now update top to point to
1319 // next object start and initialize the object. 1322 // next object start and initialize the object.
1320 __ movl(Address::Absolute(heap->TopAddress()), EBX); 1323 __ movl(Address::Absolute(heap->TopAddress()), EBX);
1321 1324
1322 // Initialize the class field in the object. 1325 // Initialize the class field in the object.
1323 // EAX: new closure object. 1326 // EAX: new closure object.
1324 // ECX: new context object (only if is_implicit_closure). 1327 // ECX: new context object (only if is_implicit_closure).
1325 __ LoadObject(EDX, cls); // Load signature class of closure. 1328 __ LoadObject(EDX, cls); // Load signature class of closure.
1326 __ movl(Address(EAX, Closure::class_offset()), EDX); 1329 __ movl(Address(EAX, Closure::class_offset()), EDX);
1327 // Set the tags. 1330 // Set the tags.
1328 intptr_t tags = 0; 1331 uword tags = 0;
1329 tags = RawObject::SizeTag::update(closure_size, tags); 1332 tags = RawObject::SizeTag::update(closure_size, tags);
1330 tags = RawObject::ClassTag::update(cls.index(), tags); 1333 tags = RawObject::ClassTag::update(cls.index(), tags);
1331 __ movl(Address(EAX, Closure::tags_offset()), Immediate(tags)); 1334 __ movl(Address(EAX, Closure::tags_offset()), Immediate(tags));
1332 1335
1333 // Initialize the function field in the object. 1336 // Initialize the function field in the object.
1334 // EAX: new closure object. 1337 // EAX: new closure object.
1335 // ECX: new context object (only if is_implicit_closure). 1338 // ECX: new context object (only if is_implicit_closure).
1336 // EBX: next object start. 1339 // EBX: next object start.
1337 __ LoadObject(EDX, func); // Load function of closure to be allocated. 1340 __ LoadObject(EDX, func); // Load function of closure to be allocated.
1338 __ movl(Address(EAX, Closure::function_offset()), EDX); 1341 __ movl(Address(EAX, Closure::function_offset()), EDX);
1339 1342
1340 // Setup the context for this closure. 1343 // Setup the context for this closure.
1341 if (is_implicit_static_closure) { 1344 if (is_implicit_static_closure) {
1342 ObjectStore* object_store = Isolate::Current()->object_store(); 1345 ObjectStore* object_store = Isolate::Current()->object_store();
1343 ASSERT(object_store != NULL); 1346 ASSERT(object_store != NULL);
1344 const Context& empty_context = 1347 const Context& empty_context =
1345 Context::ZoneHandle(object_store->empty_context()); 1348 Context::ZoneHandle(object_store->empty_context());
1346 __ LoadObject(EDX, empty_context); 1349 __ LoadObject(EDX, empty_context);
1347 __ movl(Address(EAX, Closure::context_offset()), EDX); 1350 __ movl(Address(EAX, Closure::context_offset()), EDX);
1348 } else if (is_implicit_instance_closure) { 1351 } else if (is_implicit_instance_closure) {
1349 // Initialize the new context capturing the receiver. 1352 // Initialize the new context capturing the receiver.
1350 1353
1351 // Set the class field to the Context class. 1354 // Set the class field to the Context class.
1352 const Class& context_class = Class::ZoneHandle(Object::context_class()); 1355 const Class& context_class = Class::ZoneHandle(Object::context_class());
1353 __ LoadObject(EBX, context_class); 1356 __ LoadObject(EBX, context_class);
1354 __ movl(Address(ECX, Context::class_offset()), EBX); 1357 __ movl(Address(ECX, Context::class_offset()), EBX);
1355 // Set the tags. 1358 // Set the tags.
1356 intptr_t tags = 0; 1359 uword tags = 0;
1357 tags = RawObject::SizeTag::update(context_size, tags); 1360 tags = RawObject::SizeTag::update(context_size, tags);
1358 tags = RawObject::ClassTag::update(context_class.index(), tags); 1361 tags = RawObject::ClassTag::update(context_class.index(), tags);
1359 __ movl(Address(ECX, Context::tags_offset()), Immediate(tags)); 1362 __ movl(Address(ECX, Context::tags_offset()), Immediate(tags));
1360 1363
1361 // Set number of variables field to 1 (for captured receiver). 1364 // Set number of variables field to 1 (for captured receiver).
1362 __ movl(Address(ECX, Context::num_variables_offset()), Immediate(1)); 1365 __ movl(Address(ECX, Context::num_variables_offset()), Immediate(1));
1363 1366
1364 // Set isolate field to isolate of current context. 1367 // Set isolate field to isolate of current context.
1365 __ movl(EDX, FieldAddress(CTX, Context::isolate_offset())); 1368 __ movl(EDX, FieldAddress(CTX, Context::isolate_offset()));
1366 __ movl(Address(ECX, Context::isolate_offset()), EDX); 1369 __ movl(Address(ECX, Context::isolate_offset()), EDX);
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1875 __ ret(); 1878 __ ret();
1876 1879
1877 __ Bind(&found); 1880 __ Bind(&found);
1878 __ movl(ECX, Address(EDX, kWordSize * SubTypeTestCache::kTestResult)); 1881 __ movl(ECX, Address(EDX, kWordSize * SubTypeTestCache::kTestResult));
1879 __ ret(); 1882 __ ret();
1880 } 1883 }
1881 1884
1882 } // namespace dart 1885 } // namespace dart
1883 1886
1884 #endif // defined TARGET_ARCH_IA32 1887 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « vm/raw_object.cc ('k') | vm/stub_code_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698