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

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 af3c39e45ed07f5650a0af2859d6dfa67e4f8997..d945550b641f5fff504706232779d1d532a68c09 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"
@@ -486,19 +487,35 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteral) {
bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0;
// Check if boilerplate exists. If not, create it first.
- Handle<Object> boilerplate(literals->get(literals_index), isolate);
- if (*boilerplate == isolate->heap()->undefined_value()) {
+ Handle<Object> literal_site(literals->get(literals_index), isolate);
+ Handle<AllocationSite> site;
+ Handle<Object> boilerplate;
+ if (*literal_site == isolate->heap()->undefined_value()) {
boilerplate = CreateObjectLiteralBoilerplate(isolate,
literals,
constant_properties,
should_have_fast_elements,
has_function_literal);
RETURN_IF_EMPTY_HANDLE(isolate, 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, *boilerplate);
+ literals->set(literals_index, *site);
+ } else {
+ site = Handle<AllocationSite>::cast(literal_site);
+ 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);
Hannes Payer (out of office) 2013/10/11 12:55:44 As discussed offline, right now we would emit meme
mvstanton 2013/10/11 13:41:47 Good catch. I added this TODO in HOptimizedGraphBu
+ Handle<Object> copy = JSObject::DeepCopy(Handle<JSObject>::cast(boilerplate),
+ &site_context);
RETURN_IF_EMPTY_HANDLE(isolate, copy);
return *copy;
}
@@ -516,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);
@@ -543,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;
}
@@ -566,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);
}
« src/objects.cc ('K') | « src/objects.cc ('k') | test/mjsunit/allocation-site-info.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698