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

Side by Side Diff: src/allocation-site-scopes.h

Issue 26539010: Revert "AllocationSites for all literals" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/allocation-site-scopes.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 #ifndef V8_ALLOCATION_SITE_SCOPES_H_
29 #define V8_ALLOCATION_SITE_SCOPES_H_
30
31 #include "ast.h"
32 #include "handles.h"
33 #include "objects.h"
34 #include "zone.h"
35
36 namespace v8 {
37 namespace internal {
38
39
40 // AllocationSiteContext is the base class for walking and copying a nested
41 // boilerplate with AllocationSite and AllocationMemento support.
42 class AllocationSiteContext {
43 public:
44 AllocationSiteContext(Isolate* isolate, bool activated) {
45 isolate_ = isolate;
46 activated_ = activated;
47 };
48 virtual ~AllocationSiteContext() {}
49
50 Handle<AllocationSite> top() { return top_; }
51 Handle<AllocationSite> current() { return current_; }
52
53 // If activated, then recursively create mementos
54 bool activated() const { return activated_; }
55
56 // Returns the AllocationSite that matches this scope.
57 virtual Handle<AllocationSite> EnterNewScope() = 0;
58
59 // scope_site should be the handle returned by the matching EnterNewScope()
60 virtual void ExitScope(Handle<AllocationSite> scope_site,
61 Handle<JSObject> object) = 0;
62
63 protected:
64 void update_current_site(AllocationSite* site) {
65 *(current_.location()) = site;
66 }
67
68 Isolate* isolate() { return isolate_; }
69 void InitializeTraversal(Handle<AllocationSite> site) {
70 top_ = site;
71 current_ = Handle<AllocationSite>(*top_, isolate());
72 }
73
74 private:
75 Isolate* isolate_;
76 Handle<AllocationSite> top_;
77 Handle<AllocationSite> current_;
78 bool activated_;
79 };
80
81
82 // AllocationSiteCreationContext aids in the creation of AllocationSites to
83 // accompany object literals.
84 class AllocationSiteCreationContext : public AllocationSiteContext {
85 public:
86 explicit AllocationSiteCreationContext(Isolate* isolate)
87 : AllocationSiteContext(isolate, true) { }
88
89 virtual Handle<AllocationSite> EnterNewScope() V8_OVERRIDE;
90 virtual void ExitScope(Handle<AllocationSite> site,
91 Handle<JSObject> object) V8_OVERRIDE;
92 };
93
94
95 // AllocationSiteUsageContext aids in the creation of AllocationMementos placed
96 // behind some/all components of a copied object literal.
97 class AllocationSiteUsageContext : public AllocationSiteContext {
98 public:
99 AllocationSiteUsageContext(Isolate* isolate, Handle<AllocationSite> site,
100 bool activated)
101 : AllocationSiteContext(isolate, activated),
102 top_site_(site) { }
103
104 virtual Handle<AllocationSite> EnterNewScope() V8_OVERRIDE;
105 virtual void ExitScope(Handle<AllocationSite> site,
106 Handle<JSObject> object) V8_OVERRIDE;
107
108 private:
109 Handle<AllocationSite> top_site_;
110 };
111
112
113 } } // namespace v8::internal
114
115 #endif // V8_ALLOCATION_SITE_SCOPES_H_
OLDNEW
« no previous file with comments | « no previous file | src/allocation-site-scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698