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); |
} |