V8 Project
allocation-site-scopes.cc
Go to the documentation of this file.
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.
4 
6 
7 namespace v8 {
8 namespace internal {
9 
10 
12  Handle<AllocationSite> scope_site;
13  if (top().is_null()) {
14  // We are creating the top level AllocationSite as opposed to a nested
15  // AllocationSite.
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));
21  }
22  } else {
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));
30  }
31  current()->set_nested_site(*scope_site);
32  update_current_site(*scope_site);
33  }
34  DCHECK(!scope_site.is_null());
35  return scope_site;
36 }
37 
38 
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);
45 
46  scope_site->set_transition_info(*object);
47  if (FLAG_trace_creation_allocation_sites) {
48  if (top_level) {
49  PrintF("*** Setting AllocationSite %p transition_info %p\n",
50  static_cast<void*>(*scope_site),
51  static_cast<void*>(*object));
52  } else {
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));
57  }
58  }
59  }
60 }
61 
62 
64  if (activated_ && AllocationSite::CanTrack(object->map()->instance_type())) {
65  if (FLAG_allocation_site_pretenuring ||
66  AllocationSite::GetMode(object->GetElementsKind()) ==
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));
72  }
73  return true;
74  }
75  }
76  return false;
77 }
78 
79 } } // namespace v8::internal
void InitializeTraversal(Handle< AllocationSite > site)
void update_current_site(AllocationSite *site)
void ExitScope(Handle< AllocationSite > site, Handle< JSObject > object)
bool ShouldCreateMemento(Handle< JSObject > object)
static bool CanTrack(InstanceType type)
Definition: objects-inl.h:1614
static AllocationSiteMode GetMode(ElementsKind boilerplate_elements_kind)
Definition: objects-inl.h:1591
bool is_null() const
Definition: handles.h:124
Factory * factory()
Definition: isolate.h:982
#define DCHECK(condition)
Definition: logging.h:205
@ TRACK_ALLOCATION_SITE
Definition: objects.h:8085
void PrintF(const char *format,...)
Definition: utils.cc:80
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20