In crankshafted code, we were creating allocation mementos for shallow

SMI array literals when we shouldn't. The idea is that we should have learned
by this point what type of array we'll end up with.

R=hpayer@chromium.org

Review URL: https://codereview.chromium.org/25146007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17028 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 208890d1
...@@ -4321,9 +4321,7 @@ void HOptimizedGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) { ...@@ -4321,9 +4321,7 @@ void HOptimizedGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
&max_properties)) { &max_properties)) {
Handle<JSObject> boilerplate_object = Handle<JSObject>::cast(boilerplate); Handle<JSObject> boilerplate_object = Handle<JSObject>::cast(boilerplate);
literal = BuildFastLiteral(boilerplate_object, literal = BuildFastLiteral(boilerplate_object);
Handle<Object>::null(),
DONT_TRACK_ALLOCATION_SITE);
} else { } else {
NoObservableSideEffectsScope no_effects(this); NoObservableSideEffectsScope no_effects(this);
Handle<FixedArray> closure_literals(closure->literals(), isolate()); Handle<FixedArray> closure_literals(closure->literals(), isolate());
...@@ -4467,22 +4465,7 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { ...@@ -4467,22 +4465,7 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
if (IsFastLiteral(boilerplate_object, if (IsFastLiteral(boilerplate_object,
kMaxFastLiteralDepth, kMaxFastLiteralDepth,
&max_properties)) { &max_properties)) {
// TODO(mvstanton): This heuristic is only a temporary solution. In the literal = BuildFastLiteral(boilerplate_object);
// end, we want to quit creating allocation site info after a certain number
// of GCs for a call site.
AllocationSiteMode mode = AllocationSite::GetMode(
boilerplate_elements_kind);
// it doesn't make sense to create allocation mementos if we are going to
// create in old space.
if (mode == TRACK_ALLOCATION_SITE &&
isolate()->heap()->GetPretenureMode() == TENURED) {
mode = DONT_TRACK_ALLOCATION_SITE;
}
literal = BuildFastLiteral(boilerplate_object,
site,
mode);
} else { } else {
NoObservableSideEffectsScope no_effects(this); NoObservableSideEffectsScope no_effects(this);
// Boilerplate already exists and constant elements are never accessed, // Boilerplate already exists and constant elements are never accessed,
...@@ -8379,44 +8362,21 @@ HInstruction* HOptimizedGraphBuilder::BuildThisFunction() { ...@@ -8379,44 +8362,21 @@ HInstruction* HOptimizedGraphBuilder::BuildThisFunction() {
HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( HInstruction* HOptimizedGraphBuilder::BuildFastLiteral(
Handle<JSObject> boilerplate_object, Handle<JSObject> boilerplate_object) {
Handle<Object> allocation_site_object,
AllocationSiteMode mode) {
NoObservableSideEffectsScope no_effects(this); NoObservableSideEffectsScope no_effects(this);
Handle<FixedArrayBase> elements(boilerplate_object->elements());
int object_size = boilerplate_object->map()->instance_size();
int object_offset = object_size;
InstanceType instance_type = boilerplate_object->map()->instance_type(); InstanceType instance_type = boilerplate_object->map()->instance_type();
bool create_allocation_site_info = mode == TRACK_ALLOCATION_SITE;
// If using allocation sites, then
// 1) the payload on the site should already be filled in as a valid
// (boilerplate) array, and
// 2) we shouldn't be pretenuring the allocations.
ASSERT(!create_allocation_site_info ||
(AllocationSite::cast(*allocation_site_object)->IsLiteralSite() &&
isolate()->heap()->GetPretenureMode() == NOT_TENURED));
if (create_allocation_site_info) {
object_size += AllocationMemento::kSize;
}
ASSERT(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE); ASSERT(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE);
HType type = instance_type == JS_ARRAY_TYPE HType type = instance_type == JS_ARRAY_TYPE
? HType::JSArray() : HType::JSObject(); ? HType::JSArray() : HType::JSObject();
HValue* object_size_constant = Add<HConstant>(object_size); HValue* object_size_constant = Add<HConstant>(
boilerplate_object->map()->instance_size());
HInstruction* object = Add<HAllocate>(object_size_constant, type, HInstruction* object = Add<HAllocate>(object_size_constant, type,
isolate()->heap()->GetPretenureMode(), instance_type); isolate()->heap()->GetPretenureMode(), instance_type);
BuildEmitObjectHeader(boilerplate_object, object); BuildEmitObjectHeader(boilerplate_object, object);
if (create_allocation_site_info) { Handle<FixedArrayBase> elements(boilerplate_object->elements());
HInstruction* allocation_site = Add<HConstant>(allocation_site_object);
BuildCreateAllocationMemento(object, object_offset, allocation_site);
}
int elements_size = (elements->length() > 0 && int elements_size = (elements->length() > 0 &&
elements->map() != isolate()->heap()->fixed_cow_array_map()) ? elements->map() != isolate()->heap()->fixed_cow_array_map()) ?
elements->Size() : 0; elements->Size() : 0;
...@@ -8518,9 +8478,7 @@ void HOptimizedGraphBuilder::BuildEmitInObjectProperties( ...@@ -8518,9 +8478,7 @@ void HOptimizedGraphBuilder::BuildEmitInObjectProperties(
if (value->IsJSObject()) { if (value->IsJSObject()) {
Handle<JSObject> value_object = Handle<JSObject>::cast(value); Handle<JSObject> value_object = Handle<JSObject>::cast(value);
HInstruction* result = HInstruction* result = BuildFastLiteral(value_object);
BuildFastLiteral(value_object,
Handle<Object>::null(), DONT_TRACK_ALLOCATION_SITE);
Add<HStoreNamedField>(object, access, result); Add<HStoreNamedField>(object, access, result);
} else { } else {
Representation representation = details.representation(); Representation representation = details.representation();
...@@ -8606,9 +8564,7 @@ void HOptimizedGraphBuilder::BuildEmitFixedArray( ...@@ -8606,9 +8564,7 @@ void HOptimizedGraphBuilder::BuildEmitFixedArray(
HValue* key_constant = Add<HConstant>(i); HValue* key_constant = Add<HConstant>(i);
if (value->IsJSObject()) { if (value->IsJSObject()) {
Handle<JSObject> value_object = Handle<JSObject>::cast(value); Handle<JSObject> value_object = Handle<JSObject>::cast(value);
HInstruction* result = HInstruction* result = BuildFastLiteral(value_object);
BuildFastLiteral(value_object,
Handle<Object>::null(), DONT_TRACK_ALLOCATION_SITE);
Add<HStoreKeyed>(object_elements, key_constant, result, kind); Add<HStoreKeyed>(object_elements, key_constant, result, kind);
} else { } else {
HInstruction* value_instruction = HInstruction* value_instruction =
......
...@@ -2244,9 +2244,7 @@ class HOptimizedGraphBuilder V8_FINAL ...@@ -2244,9 +2244,7 @@ class HOptimizedGraphBuilder V8_FINAL
HInstruction* BuildThisFunction(); HInstruction* BuildThisFunction();
HInstruction* BuildFastLiteral(Handle<JSObject> boilerplate_object, HInstruction* BuildFastLiteral(Handle<JSObject> boilerplate_object);
Handle<Object> allocation_site,
AllocationSiteMode mode);
void BuildEmitObjectHeader(Handle<JSObject> boilerplate_object, void BuildEmitObjectHeader(Handle<JSObject> boilerplate_object,
HInstruction* object); HInstruction* object);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment