1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "src/allocation-site-scopes.h"
11 Handle<AllocationSite> AllocationSiteCreationContext::EnterNewScope() {
12 Handle<AllocationSite> scope_site;
13 if (top().is_null()) {
14 // We are creating the top level AllocationSite as opposed to a nested
16 InitializeTraversal(isolate()->factory()->NewAllocationSite());
17 scope_site = Handle<AllocationSite>(*top(), isolate());
18 if (FLAG_trace_creation_allocation_sites) {
19 PrintF("*** Creating top level AllocationSite %p\n",
20 static_cast<void*>(*scope_site));
23 DCHECK(!current().is_null());
24 scope_site = isolate()->factory()->NewAllocationSite();
25 if (FLAG_trace_creation_allocation_sites) {
26 PrintF("Creating nested site (top, current, new) (%p, %p, %p)\n",
27 static_cast<void*>(*top()),
28 static_cast<void*>(*current()),
29 static_cast<void*>(*scope_site));
31 current()->set_nested_site(*scope_site);
32 update_current_site(*scope_site);
34 DCHECK(!scope_site.is_null());
39 void AllocationSiteCreationContext::ExitScope(
40 Handle<AllocationSite> scope_site,
41 Handle<JSObject> object) {
42 if (!object.is_null()) {
43 bool top_level = !scope_site.is_null() &&
44 top().is_identical_to(scope_site);
46 scope_site->set_transition_info(*object);
47 if (FLAG_trace_creation_allocation_sites) {
49 PrintF("*** Setting AllocationSite %p transition_info %p\n",
50 static_cast<void*>(*scope_site),
51 static_cast<void*>(*object));
53 PrintF("Setting AllocationSite (%p, %p) transition_info %p\n",
54 static_cast<void*>(*top()),
55 static_cast<void*>(*scope_site),
56 static_cast<void*>(*object));
63 bool AllocationSiteUsageContext::ShouldCreateMemento(Handle<JSObject> object) {
64 if (activated_ && AllocationSite::CanTrack(object->map()->instance_type())) {
65 if (FLAG_allocation_site_pretenuring ||
66 AllocationSite::GetMode(object->GetElementsKind()) ==
67 TRACK_ALLOCATION_SITE) {
68 if (FLAG_trace_creation_allocation_sites) {
69 PrintF("*** Creating Memento for %s %p\n",
70 object->IsJSArray() ? "JSArray" : "JSObject",
71 static_cast<void*>(*object));
79 } } // namespace v8::internal