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

Unified Diff: src/arm/lithium-codegen-arm.cc

Issue 12114054: Supporting AllocationSiteInfo for Nested arrays (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Now with ports to arm and x64 Created 7 years, 10 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: src/arm/lithium-codegen-arm.cc
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc
index a18f894b00c00bba1809f3e6407b66cf17d1a3f8..4ad819ab8b12ba5dc46f5d6c7a6b8331e7ff8181 100644
--- a/src/arm/lithium-codegen-arm.cc
+++ b/src/arm/lithium-codegen-arm.cc
@@ -5444,13 +5444,18 @@ void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) {
DeoptimizeIf(ne, instr->environment());
}
+ int flags = allocation_site_mode == TRACK_ALLOCATION_SITE
+ ? ArrayLiteral::kAllocationSiteInfoAllowed
+ : ArrayLiteral::kNoFlags;
+
// Set up the parameters to the stub/runtime call.
- __ LoadHeapObject(r3, literals);
- __ mov(r2, Operand(Smi::FromInt(instr->hydrogen()->literal_index())));
+ __ LoadHeapObject(r4, literals);
+ __ mov(r3, Operand(Smi::FromInt(instr->hydrogen()->literal_index())));
// Boilerplate already exists, constant elements are never accessed.
// Pass an empty fixed array.
- __ mov(r1, Operand(isolate()->factory()->empty_fixed_array()));
- __ Push(r3, r2, r1);
+ __ mov(r2, Operand(isolate()->factory()->empty_fixed_array()));
+ __ mov(r1, Operand(Smi::FromInt(flags)));
+ __ Push(r4, r3, r2, r1);
// Pick the right runtime function or stub to call.
int length = instr->hydrogen()->length();
@@ -5461,9 +5466,9 @@ void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) {
FastCloneShallowArrayStub stub(mode, DONT_TRACK_ALLOCATION_SITE, length);
CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
} else if (instr->hydrogen()->depth() > 1) {
- CallRuntime(Runtime::kCreateArrayLiteral, 3, instr);
+ CallRuntime(Runtime::kCreateArrayLiteral, 4, instr);
} else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) {
- CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr);
+ CallRuntime(Runtime::kCreateArrayLiteralShallow, 4, instr);
} else {
FastCloneShallowArrayStub::Mode mode =
boilerplate_elements_kind == FAST_DOUBLE_ELEMENTS
@@ -5476,6 +5481,7 @@ void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) {
void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
+ Handle<JSObject> original_object,
Register result,
Register source,
int* offset,
@@ -5483,11 +5489,18 @@ void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
ASSERT(!source.is(r2));
ASSERT(!result.is(r2));
+ // Should we track allocation info for *this* object in the tree?
bool create_allocation_site_info = mode == TRACK_ALLOCATION_SITE &&
object->map()->CanTrackAllocationSite();
+ if (create_allocation_site_info && object->IsJSArray()) {
+ create_allocation_site_info = AllocationSiteInfo::GetMode(
+ object->GetElementsKind()) == TRACK_ALLOCATION_SITE;
+ }
+
// Only elements backing stores for non-COW arrays need to be copied.
Handle<FixedArrayBase> elements(object->elements());
+ Handle<FixedArrayBase> original_elements(original_object->elements());
bool has_elements = elements->length() > 0 &&
elements->map() != isolate()->heap()->fixed_cow_array_map();
@@ -5523,11 +5536,14 @@ void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
Handle<Object> value = Handle<Object>(object->InObjectPropertyAt(i));
if (value->IsJSObject()) {
Handle<JSObject> value_object = Handle<JSObject>::cast(value);
+ Handle<JSObject> original_value_object = Handle<JSObject>::cast(
+ Handle<Object>(original_object->InObjectPropertyAt(i)));
+
__ add(r2, result, Operand(*offset));
__ str(r2, FieldMemOperand(result, total_offset));
__ LoadHeapObject(source, value_object);
- EmitDeepCopy(value_object, result, source, offset,
- DONT_TRACK_ALLOCATION_SITE);
+ EmitDeepCopy(value_object, original_value_object, result, source,
+ offset, mode);
} else if (value->IsHeapObject()) {
__ LoadHeapObject(r2, Handle<HeapObject>::cast(value));
__ str(r2, FieldMemOperand(result, total_offset));
@@ -5541,8 +5557,10 @@ void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
if (create_allocation_site_info) {
__ mov(r2, Operand(Handle<Map>(isolate()->heap()->
allocation_site_info_map())));
- __ str(r2, FieldMemOperand(result, object_size));
- __ str(source, FieldMemOperand(result, object_size + kPointerSize));
+ __ str(r2, FieldMemOperand(result, object_size + object_offset));
+ __ LoadHeapObject(r2, original_object);
+ __ str(r2, FieldMemOperand(result,
+ object_size + object_offset + kPointerSize));
}
if (has_elements) {
@@ -5572,16 +5590,26 @@ void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
}
} else if (elements->IsFixedArray()) {
Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements);
+ Handle<FixedArray> original_fast_elements =
+ Handle<FixedArray>::cast(original_elements);
for (int i = 0; i < elements_length; i++) {
int total_offset = elements_offset + FixedArray::OffsetOfElementAt(i);
Handle<Object> value(fast_elements->get(i));
if (value->IsJSObject()) {
Handle<JSObject> value_object = Handle<JSObject>::cast(value);
+ Handle<JSObject> original_value_object = Handle<JSObject>::cast(
+ Handle<Object>(original_fast_elements->get(i)));
__ add(r2, result, Operand(*offset));
__ str(r2, FieldMemOperand(result, total_offset));
__ LoadHeapObject(source, value_object);
- EmitDeepCopy(value_object, result, source, offset,
- DONT_TRACK_ALLOCATION_SITE);
+
+ // TODO(mvstanton): do we have to worry that the original object
+ // changed from a fixed array to a fixeddoublearray? If that happened
+ // then the original_value_object expression might point to garbage
+ // memory, right?
danno 2013/02/08 13:44:38 No, I don't think so, since if the array already c
mvstanton 2013/02/11 11:11:24 Good point, thx.
+ ASSERT(!value_object.is_identical_to(original_value_object));
+ EmitDeepCopy(value_object, original_value_object, result, source,
+ offset, mode);
} else if (value->IsHeapObject()) {
__ LoadHeapObject(r2, Handle<HeapObject>::cast(value));
__ str(r2, FieldMemOperand(result, total_offset));
@@ -5599,26 +5627,7 @@ void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
void LCodeGen::DoFastLiteral(LFastLiteral* instr) {
int size = instr->hydrogen()->total_size();
- ElementsKind boilerplate_elements_kind =
- instr->hydrogen()->boilerplate()->GetElementsKind();
-
- // Deopt if the array literal boilerplate ElementsKind is of a type different
- // than the expected one. The check isn't necessary if the boilerplate has
- // already been converted to TERMINAL_FAST_ELEMENTS_KIND.
- if (CanTransitionToMoreGeneralFastElementsKind(
- boilerplate_elements_kind, true)) {
- __ LoadHeapObject(r1, instr->hydrogen()->boilerplate());
- // Load map into r2.
- __ ldr(r2, FieldMemOperand(r1, HeapObject::kMapOffset));
- // Load the map's "bit field 2".
- __ ldrb(r2, FieldMemOperand(r2, Map::kBitField2Offset));
- // Retrieve elements_kind from bit field 2.
- __ ubfx(r2, r2, Map::kElementsKindShift, Map::kElementsKindBitCount);
- __ cmp(r2, Operand(boilerplate_elements_kind));
- DeoptimizeIf(ne, instr->environment());
- }
- // Allocate all objects that are part of the literal in one big
// allocation. This avoids multiple limit checks.
Label allocated, runtime_allocate;
__ AllocateInNewSpace(size, r0, r2, r3, &runtime_allocate, TAG_OBJECT);
@@ -5632,7 +5641,9 @@ void LCodeGen::DoFastLiteral(LFastLiteral* instr) {
__ bind(&allocated);
int offset = 0;
__ LoadHeapObject(r1, instr->hydrogen()->boilerplate());
- EmitDeepCopy(instr->hydrogen()->boilerplate(), r0, r1, &offset,
+ EmitDeepCopy(instr->hydrogen()->boilerplate(),
+ instr->hydrogen()->original_boilerplate(),
+ r0, r1, &offset,
instr->hydrogen()->allocation_site_mode());
ASSERT_EQ(size, offset);
}
@@ -5650,6 +5661,11 @@ void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) {
int flags = instr->hydrogen()->fast_elements()
? ObjectLiteral::kFastElements
: ObjectLiteral::kNoFlags;
+
+ if (instr->hydrogen()->allocation_site_mode() == TRACK_ALLOCATION_SITE) {
+ flags |= ObjectLiteral::kAllocationSiteInfoAllowed;
+ }
+
__ mov(r1, Operand(Smi::FromInt(flags)));
__ Push(r4, r3, r2, r1);

Powered by Google App Engine
This is Rietveld 408576698