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

Unified Diff: src/hydrogen.cc

Issue 26539010: Revert "AllocationSites for all literals" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 2 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
« no previous file with comments | « src/hydrogen.h ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index b5e3a05de80163ad7ef1ea673f0a8ba44e1dd48b..a41be5e6b47624238e6383126ac8473f9f447527 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -30,7 +30,6 @@
#include <algorithm>
#include "v8.h"
-#include "allocation-site-scopes.h"
#include "codegen.h"
#include "full-codegen.h"
#include "hashmap.h"
@@ -4299,10 +4298,7 @@ void HOptimizedGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
if (!boilerplate.is_null() &&
IsFastLiteral(boilerplate, kMaxFastLiteralDepth, &max_properties)) {
- AllocationSiteUsageContext usage_context(isolate(), site, false);
- usage_context.EnterNewScope();
- literal = BuildFastLiteral(boilerplate, &usage_context);
- usage_context.ExitScope(site, boilerplate);
+ literal = BuildFastLiteral(boilerplate);
} else {
NoObservableSideEffectsScope no_effects(this);
Handle<FixedArray> closure_literals(closure->literals(), isolate());
@@ -4318,9 +4314,6 @@ void HOptimizedGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
Add<HPushArgument>(Add<HConstant>(constant_properties));
Add<HPushArgument>(Add<HConstant>(flags));
- // TODO(mvstanton): Add a flag to turn off creation of any
- // AllocationMementos for this call: we are in crankshaft and should have
- // learned enough about transition behavior to stop emitting mementos.
Runtime::FunctionId function_id = Runtime::kCreateObjectLiteral;
literal = Add<HCallRuntime>(isolate()->factory()->empty_string(),
Runtime::FunctionForId(function_id),
@@ -4411,48 +4404,45 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
bool uninitialized = false;
Handle<Object> literals_cell(literals->get(expr->literal_index()),
isolate());
- Handle<JSObject> boilerplate_object;
+ Handle<Object> raw_boilerplate;
if (literals_cell->IsUndefined()) {
uninitialized = true;
- Handle<Object> raw_boilerplate = Runtime::CreateArrayLiteralBoilerplate(
+ raw_boilerplate = Runtime::CreateArrayLiteralBoilerplate(
isolate(), literals, expr->constant_elements());
if (raw_boilerplate.is_null()) {
return Bailout(kArrayBoilerplateCreationFailed);
}
- boilerplate_object = Handle<JSObject>::cast(raw_boilerplate);
- AllocationSiteCreationContext creation_context(isolate());
- site = creation_context.EnterNewScope();
- JSObject::DeepWalk(boilerplate_object, &creation_context);
- creation_context.ExitScope(site, boilerplate_object);
+ site = isolate()->factory()->NewAllocationSite();
+ site->set_transition_info(*raw_boilerplate);
literals->set(expr->literal_index(), *site);
- if (boilerplate_object->elements()->map() ==
+ if (JSObject::cast(*raw_boilerplate)->elements()->map() ==
isolate()->heap()->fixed_cow_array_map()) {
isolate()->counters()->cow_arrays_created_runtime()->Increment();
}
} else {
ASSERT(literals_cell->IsAllocationSite());
site = Handle<AllocationSite>::cast(literals_cell);
- boilerplate_object = Handle<JSObject>(
- JSObject::cast(site->transition_info()), isolate());
+ raw_boilerplate = Handle<Object>(site->transition_info(), isolate());
}
- ASSERT(!boilerplate_object.is_null());
- ASSERT(site->SitePointsToLiteral());
+ ASSERT(!raw_boilerplate.is_null());
+ ASSERT(site->IsLiteralSite());
+ Handle<JSObject> boilerplate_object =
+ Handle<JSObject>::cast(raw_boilerplate);
ElementsKind boilerplate_elements_kind =
- boilerplate_object->GetElementsKind();
+ Handle<JSObject>::cast(boilerplate_object)->GetElementsKind();
+
+ ASSERT(AllocationSite::CanTrack(boilerplate_object->map()->instance_type()));
// Check whether to use fast or slow deep-copying for boilerplate.
int max_properties = kMaxFastLiteralProperties;
if (IsFastLiteral(boilerplate_object,
kMaxFastLiteralDepth,
&max_properties)) {
- AllocationSiteUsageContext usage_context(isolate(), site, false);
- usage_context.EnterNewScope();
- literal = BuildFastLiteral(boilerplate_object, &usage_context);
- usage_context.ExitScope(site, boilerplate_object);
+ literal = BuildFastLiteral(boilerplate_object);
} else {
NoObservableSideEffectsScope no_effects(this);
// Boilerplate already exists and constant elements are never accessed,
@@ -4464,9 +4454,6 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
Add<HPushArgument>(Add<HConstant>(literal_index));
Add<HPushArgument>(Add<HConstant>(constants));
- // TODO(mvstanton): Consider a flag to turn off creation of any
- // AllocationMementos for this call: we are in crankshaft and should have
- // learned enough about transition behavior to stop emitting mementos.
Runtime::FunctionId function_id = (expr->depth() > 1)
? Runtime::kCreateArrayLiteral : Runtime::kCreateArrayLiteralShallow;
literal = Add<HCallRuntime>(isolate()->factory()->empty_string(),
@@ -8355,8 +8342,7 @@ HInstruction* HOptimizedGraphBuilder::BuildThisFunction() {
HInstruction* HOptimizedGraphBuilder::BuildFastLiteral(
- Handle<JSObject> boilerplate_object,
- AllocationSiteContext* site_context) {
+ Handle<JSObject> boilerplate_object) {
NoObservableSideEffectsScope no_effects(this);
InstanceType instance_type = boilerplate_object->map()->instance_type();
ASSERT(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE);
@@ -8388,15 +8374,15 @@ HInstruction* HOptimizedGraphBuilder::BuildFastLiteral(
}
BuildInitElementsInObjectHeader(boilerplate_object, object, object_elements);
+
// Copy object elements if non-COW.
if (object_elements != NULL) {
- BuildEmitElements(boilerplate_object, elements, object_elements,
- site_context);
+ BuildEmitElements(boilerplate_object, elements, object_elements);
}
// Copy in-object properties.
if (boilerplate_object->map()->NumberOfFields() != 0) {
- BuildEmitInObjectProperties(boilerplate_object, object, site_context);
+ BuildEmitInObjectProperties(boilerplate_object, object);
}
return object;
}
@@ -8448,8 +8434,7 @@ void HOptimizedGraphBuilder::BuildInitElementsInObjectHeader(
void HOptimizedGraphBuilder::BuildEmitInObjectProperties(
Handle<JSObject> boilerplate_object,
- HInstruction* object,
- AllocationSiteContext* site_context) {
+ HInstruction* object) {
Handle<DescriptorArray> descriptors(
boilerplate_object->map()->instance_descriptors());
int limit = boilerplate_object->map()->NumberOfOwnDescriptors();
@@ -8473,10 +8458,7 @@ void HOptimizedGraphBuilder::BuildEmitInObjectProperties(
if (value->IsJSObject()) {
Handle<JSObject> value_object = Handle<JSObject>::cast(value);
- Handle<AllocationSite> current_site = site_context->EnterNewScope();
- HInstruction* result =
- BuildFastLiteral(value_object, site_context);
- site_context->ExitScope(current_site, value_object);
+ HInstruction* result = BuildFastLiteral(value_object);
Add<HStoreNamedField>(object, access, result);
} else {
Representation representation = details.representation();
@@ -8485,12 +8467,6 @@ void HOptimizedGraphBuilder::BuildEmitInObjectProperties(
if (representation.IsDouble()) {
// Allocate a HeapNumber box and store the value into it.
HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize);
- // TODO(mvstanton): This heap number alloc does not have a corresponding
- // AllocationSite. That is okay because
- // 1) it's a child object of another object with a valid allocation site
- // 2) we can just use the mode of the parent object for pretenuring
- // The todo is replace GetPretenureMode() with
- // site_context->top()->GetPretenureMode().
HInstruction* double_box =
Add<HAllocate>(heap_number_constant, HType::HeapNumber(),
isolate()->heap()->GetPretenureMode(), HEAP_NUMBER_TYPE);
@@ -8520,8 +8496,7 @@ void HOptimizedGraphBuilder::BuildEmitInObjectProperties(
void HOptimizedGraphBuilder::BuildEmitElements(
Handle<JSObject> boilerplate_object,
Handle<FixedArrayBase> elements,
- HValue* object_elements,
- AllocationSiteContext* site_context) {
+ HValue* object_elements) {
ElementsKind kind = boilerplate_object->map()->elements_kind();
int elements_length = elements->length();
HValue* object_elements_length = Add<HConstant>(elements_length);
@@ -8531,8 +8506,7 @@ void HOptimizedGraphBuilder::BuildEmitElements(
if (elements->IsFixedDoubleArray()) {
BuildEmitFixedDoubleArray(elements, kind, object_elements);
} else if (elements->IsFixedArray()) {
- BuildEmitFixedArray(elements, kind, object_elements,
- site_context);
+ BuildEmitFixedArray(elements, kind, object_elements);
} else {
UNREACHABLE();
}
@@ -8561,8 +8535,7 @@ void HOptimizedGraphBuilder::BuildEmitFixedDoubleArray(
void HOptimizedGraphBuilder::BuildEmitFixedArray(
Handle<FixedArrayBase> elements,
ElementsKind kind,
- HValue* object_elements,
- AllocationSiteContext* site_context) {
+ HValue* object_elements) {
HInstruction* boilerplate_elements = Add<HConstant>(elements);
int elements_length = elements->length();
Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements);
@@ -8571,10 +8544,7 @@ void HOptimizedGraphBuilder::BuildEmitFixedArray(
HValue* key_constant = Add<HConstant>(i);
if (value->IsJSObject()) {
Handle<JSObject> value_object = Handle<JSObject>::cast(value);
- Handle<AllocationSite> current_site = site_context->EnterNewScope();
- HInstruction* result =
- BuildFastLiteral(value_object, site_context);
- site_context->ExitScope(current_site, value_object);
+ HInstruction* result = BuildFastLiteral(value_object);
Add<HStoreKeyed>(object_elements, key_constant, result, kind);
} else {
HInstruction* value_instruction =
« no previous file with comments | « src/hydrogen.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698