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

Unified Diff: src/runtime.cc

Issue 24250005: AllocationSites for all literals (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE 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
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 77014b1771c054e1ec8da1c400b2c2533dc421b0..2c3d9f7525d83294d24835033a245be203ca828c 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -31,6 +31,7 @@
#include "v8.h"
#include "accessors.h"
+#include "allocation-site-scopes.h"
#include "api.h"
#include "arguments.h"
#include "bootstrapper.h"
@@ -496,17 +497,25 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteral) {
should_have_fast_elements,
has_function_literal);
RETURN_IF_EMPTY_HANDLE(isolate, boilerplate);
- site = isolate->factory()->NewAllocationSite();
- site->set_transition_info(*boilerplate);
+
+ AllocationSiteContext site_context(isolate, true);
+ AllocationSiteCreationScope site_scope(&site_context);
+ Handle<Object> same = JSObject::DeepWalk(
+ Handle<JSObject>::cast(boilerplate), &site_context);
+ site_scope.RecordTransitionInfo(same);
+ site = site_context.top();
// Update the functions literal and return the boilerplate.
literals->set(literals_index, *site);
} else {
site = Handle<AllocationSite>::cast(literal_site);
- boilerplate = Handle<JSObject>(JSObject::cast(site->transition_info()));
+ boilerplate = Handle<Object>(site->transition_info(), isolate);
}
- Handle<Object> copy = JSObject::DeepCopy(Handle<JSObject>::cast(boilerplate));
+ AllocationSiteContext site_context(isolate, true);
+ AllocationSiteUsageScope site_scope(&site_context, site, boilerplate);
+ Handle<Object> copy = JSObject::DeepCopy(Handle<JSObject>::cast(boilerplate),
+ &site_context);
RETURN_IF_EMPTY_HANDLE(isolate, copy);
return *copy;
}
@@ -524,12 +533,15 @@ static Handle<AllocationSite> GetLiteralAllocationSite(
ASSERT(*elements != isolate->heap()->empty_fixed_array());
Handle<Object> boilerplate =
Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements);
- if (boilerplate.is_null()) {
- ASSERT(site.is_null());
- return site;
- }
- site = isolate->factory()->NewAllocationSite();
- site->set_transition_info(*boilerplate);
+ if (boilerplate.is_null()) return Handle<AllocationSite>::null();
+
+ AllocationSiteContext site_context(isolate, true);
+ AllocationSiteCreationScope site_scope(&site_context);
+ Handle<Object> same = JSObject::DeepWalk(
+ Handle<JSObject>::cast(boilerplate), &site_context);
+ site_scope.RecordTransitionInfo(same);
+ site = site_context.top();
+
literals->set(literals_index, *site);
} else {
site = Handle<AllocationSite>::cast(literal_site);
@@ -551,7 +563,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) {
RETURN_IF_EMPTY_HANDLE(isolate, site);
Handle<JSObject> boilerplate(JSObject::cast(site->transition_info()));
- Handle<JSObject> copy = JSObject::DeepCopy(boilerplate);
+ AllocationSiteContext site_context(isolate, true);
+ AllocationSiteUsageScope site_scope(&site_context, site, boilerplate);
+ Handle<JSObject> copy = JSObject::DeepCopy(boilerplate, &site_context);
RETURN_IF_EMPTY_HANDLE(isolate, copy);
return *copy;
}
@@ -574,9 +588,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) {
isolate->counters()->cow_arrays_created_runtime()->Increment();
}
- AllocationSiteMode mode = AllocationSite::GetMode(
- boilerplate->GetElementsKind());
- if (mode == TRACK_ALLOCATION_SITE) {
+ if (AllocationSite::GetMode(boilerplate->GetElementsKind()) ==
+ TRACK_ALLOCATION_SITE) {
return isolate->heap()->CopyJSObject(boilerplate, *site);
}

Powered by Google App Engine
This is Rietveld 408576698