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

Unified Diff: vm/stub_code_ia32.cc

Issue 9072011: - Add a size field to the header. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 8 years, 12 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 side-by-side diff with in-line comments
Download patch
Index: vm/stub_code_ia32.cc
===================================================================
--- vm/stub_code_ia32.cc (revision 2918)
+++ vm/stub_code_ia32.cc (working copy)
@@ -647,6 +647,7 @@
// next object start and initialize the object.
// EAX: potential new object start.
// EBX: potential next object start.
+ // EDX: Array length as Smi.
// EDI: Points to new space object.
__ movl(Address(EDI, Scavenger::top_offset()), EBX);
__ addl(EAX, Immediate(kHeapObjectTag));
@@ -666,6 +667,9 @@
FieldAddress(EAX, Array::length_offset()),
EDX);
+ // EAX: new object start as a tagged pointer.
+ // EBX: new object end address.
+ // EDX: Array length as Smi.
// Store class value for array.
__ movl(ECX, FieldAddress(CTX, Context::isolate_offset()));
__ movl(ECX, Address(ECX, Isolate::object_store_offset()));
@@ -673,14 +677,34 @@
__ StoreIntoObject(EAX,
FieldAddress(EAX, Array::class_offset()),
ECX);
- __ movl(FieldAddress(EAX, Array::tags_offset()), Immediate(0)); // Tags.
+ // Calculate the size tag.
+ // EAX: new object start as a tagged pointer.
+ // EBX: new object end address.
+ // EDX: Array length as Smi.
+ {
+ Label size_tag_overflow, done;
+ __ leal(ECX, Address(EDX, TIMES_2, fixed_size)); // EDX is Smi.
+ ASSERT(kSmiTagShift == 1);
+ __ andl(ECX, Immediate(-kObjectAlignment));
+ __ cmpl(ECX,
+ Immediate(RawObject::SizeTag::kMaxSizeTag));
siva 2012/01/04 01:56:03 Can't this be in one line?
Ivan Posva 2012/01/04 07:59:42 Done.
+ __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump);
+ __ shll(ECX, Immediate(RawObject::kSizeTagBit - kObjectAlignmentLog2));
+ __ movl(FieldAddress(EAX, Array::tags_offset()), ECX);
+ __ jmp(&done);
+ __ Bind(&size_tag_overflow);
+ __ movl(FieldAddress(EAX, Array::tags_offset()), Immediate(0));
+ __ Bind(&done);
+ }
+
// Initialize all array elements to raw_null.
// EAX: new object start as a tagged pointer.
// EBX: new object end address.
+ // EDX: Array length as Smi.
+ __ leal(ECX, FieldAddress(EAX, Array::data_offset()));
// ECX: iterator which initially points to the start of the variable
// data area to be initialized.
- __ leal(ECX, FieldAddress(EAX, Array::data_offset()));
Label done;
Label init_loop;
__ Bind(&init_loop);
@@ -693,6 +717,7 @@
// Done allocating and initializing the array.
// EAX: new object.
+ // EDX: Array length as Smi (preserved for the caller.)
__ ret();
}
@@ -977,8 +1002,26 @@
__ StoreIntoObject(EAX,
FieldAddress(EAX, Context::class_offset()),
EBX);
- __ movl(FieldAddress(EAX, Context::tags_offset()), Immediate(0)); // Tags.
+ // Calculate the size tag.
+ // EAX: new object.
+ // EDX: number of context variables.
+ {
+ Label size_tag_overflow, done;
+ __ leal(EBX, Address(EDX, TIMES_4, fixed_size));
+ __ andl(EBX, Immediate(-kObjectAlignment));
+ __ cmpl(EBX,
+ Immediate(RawObject::SizeTag::kMaxSizeTag));
siva 2012/01/04 01:56:03 Can't this be in one line?
Ivan Posva 2012/01/04 07:59:42 Done.
+ __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump);
+ __ shll(EBX, Immediate(RawObject::kSizeTagBit - kObjectAlignmentLog2));
+ __ movl(FieldAddress(EAX, Context::tags_offset()), EBX); // Tags.
+ __ jmp(&done);
+ __ Bind(&size_tag_overflow);
+ // Set overflow size tag value.
+ __ movl(FieldAddress(EAX, Context::tags_offset()), Immediate(0));
+ __ Bind(&done);
siva 2012/01/04 01:56:03 Can this piece of code which is repeated here and
Ivan Posva 2012/01/04 07:59:42 We should evaluate that once we are done with sett
+ }
+
// Setup up number of context variables field.
// EAX: new object.
// EDX: number of context variables as integer value (not object).
@@ -1111,7 +1154,9 @@
__ LoadObject(EDX,
Class::ZoneHandle(Object::instantiated_type_arguments_class()));
__ movl(Address(ECX, Instance::class_offset()), EDX); // Set its class.
- __ movl(Address(ECX, Instance::tags_offset()), Immediate(0)); // Tags.
+ // Set the tags.
siva 2012/01/04 01:56:03 ASSERT(type_args_size <= RawObject::SizeTag::kMaxS
Ivan Posva 2012/01/04 07:59:42 ditto
+ __ movl(Address(ECX, Instance::tags_offset()),
+ Immediate(RawObject::SizeTag::encode(type_args_size)));
// Set the new InstantiatedTypeArguments object (ECX) as the type
// arguments (EDI) of the new object (EAX).
__ movl(EDI, ECX);
@@ -1129,7 +1174,9 @@
// EDI: new object type arguments (if is_cls_parameterized).
__ LoadObject(EDX, cls); // Load class of object to be allocated.
__ movl(Address(EAX, Instance::class_offset()), EDX);
- __ movl(Address(EAX, Instance::tags_offset()), Immediate(0)); // Tags.
+ // Set the tags.
siva 2012/01/04 01:56:03 ASSERT(instance_size <= RawObject::SizeTag::kMaxSi
Ivan Posva 2012/01/04 07:59:42 ditto
+ __ movl(Address(EAX, Instance::tags_offset()),
+ Immediate(RawObject::SizeTag::encode(instance_size)));
// Initialize the remaining words of the object.
const Immediate raw_null =
@@ -1277,7 +1324,9 @@
// ECX: new context object (only if is_implicit_closure).
__ LoadObject(EDX, cls); // Load signature class of closure.
__ movl(Address(EAX, Closure::class_offset()), EDX);
- __ movl(Address(EAX, Closure::tags_offset()), Immediate(0)); // Tags.
+ // Set the tags.
siva 2012/01/04 01:56:03 ASSERT(closure_size <= RawObject::SizeTag::kMaxSiz
Ivan Posva 2012/01/04 07:59:42 ditto.
+ __ movl(Address(EAX, Closure::tags_offset()),
+ Immediate(RawObject::SizeTag::encode(closure_size)));
// Initialize the function field in the object.
// EAX: new closure object.
@@ -1300,7 +1349,9 @@
// Set the class field to the Context class.
__ LoadObject(EBX, Class::ZoneHandle(Object::context_class()));
__ movl(Address(ECX, Context::class_offset()), EBX);
- __ movl(Address(ECX, Context::tags_offset()), Immediate(0)); // Tags.
+ // Set the tags.
siva 2012/01/04 01:56:03 ASSERT(context_size <= RawObject::SizeTag::kMaxSiz
Ivan Posva 2012/01/04 07:59:42 ditto.
+ __ movl(Address(ECX, Context::tags_offset()),
+ Immediate(RawObject::SizeTag::encode(context_size)));
// Set number of variables field to 1 (for captured receiver).
__ movl(Address(ECX, Context::num_variables_offset()), Immediate(1));

Powered by Google App Engine
This is Rietveld 408576698