Index: src/allocation-site-scopes.h |
diff --git a/src/allocation-site-scopes.h b/src/allocation-site-scopes.h |
index 1c3afdf369546e3178472b173225c5ac9e2c884b..f106c5e88934e7d54f4d80b359c3ae65c33b8e5e 100644 |
--- a/src/allocation-site-scopes.h |
+++ b/src/allocation-site-scopes.h |
@@ -45,7 +45,6 @@ class AllocationSiteContext { |
isolate_ = isolate; |
activated_ = activated; |
}; |
- virtual ~AllocationSiteContext() {} |
Handle<AllocationSite> top() { return top_; } |
Handle<AllocationSite> current() { return current_; } |
@@ -53,19 +52,13 @@ class AllocationSiteContext { |
// If activated, then recursively create mementos |
bool activated() const { return activated_; } |
- // Returns the AllocationSite that matches this scope. |
- virtual Handle<AllocationSite> EnterNewScope() = 0; |
- |
- // scope_site should be the handle returned by the matching EnterNewScope() |
- virtual void ExitScope(Handle<AllocationSite> scope_site, |
- Handle<JSObject> object) = 0; |
+ Isolate* isolate() { return isolate_; } |
protected: |
void update_current_site(AllocationSite* site) { |
*(current_.location()) = site; |
} |
- Isolate* isolate() { return isolate_; } |
void InitializeTraversal(Handle<AllocationSite> site) { |
top_ = site; |
current_ = Handle<AllocationSite>(*top_, isolate()); |
@@ -86,9 +79,8 @@ class AllocationSiteCreationContext : public AllocationSiteContext { |
explicit AllocationSiteCreationContext(Isolate* isolate) |
: AllocationSiteContext(isolate, true) { } |
- virtual Handle<AllocationSite> EnterNewScope() V8_OVERRIDE; |
- virtual void ExitScope(Handle<AllocationSite> site, |
- Handle<JSObject> object) V8_OVERRIDE; |
+ Handle<AllocationSite> EnterNewScope(); |
+ void ExitScope(Handle<AllocationSite> site, Handle<JSObject> object); |
}; |
@@ -101,9 +93,25 @@ class AllocationSiteUsageContext : public AllocationSiteContext { |
: AllocationSiteContext(isolate, activated), |
top_site_(site) { } |
- virtual Handle<AllocationSite> EnterNewScope() V8_OVERRIDE; |
- virtual void ExitScope(Handle<AllocationSite> site, |
- Handle<JSObject> object) V8_OVERRIDE; |
+ inline Handle<AllocationSite> EnterNewScope() { |
+ if (top().is_null()) { |
+ InitializeTraversal(top_site_); |
+ } else { |
+ // Advance current site |
+ Object* nested_site = current()->nested_site(); |
+ // Something is wrong if we advance to the end of the list here. |
+ ASSERT(nested_site->IsAllocationSite()); |
+ update_current_site(AllocationSite::cast(nested_site)); |
+ } |
+ return Handle<AllocationSite>(*current(), isolate()); |
+ } |
+ |
+ inline void ExitScope(Handle<AllocationSite> scope_site, |
+ Handle<JSObject> object) { |
+ // This assert ensures that we are pointing at the right sub-object in a |
+ // recursive walk of a nested literal. |
+ ASSERT(object.is_null() || *object == scope_site->transition_info()); |
+ } |
private: |
Handle<AllocationSite> top_site_; |