Chromium Code Reviews| Index: src/allocation-site-scopes.h |
| diff --git a/src/allocation-site-scopes.h b/src/allocation-site-scopes.h |
| index 1c3afdf369546e3178472b173225c5ac9e2c884b..95dcb1f3615585292354cde19d249fa1fe80ef2a 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()); |
|
Michael Starzinger
2013/11/22 20:07:16
nit: If this is the only use-site of AllocationSit
mvstanton
2013/11/25 11:51:50
Hmm, the isolate does get used to access the facto
|
| @@ -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,26 @@ 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()); |
| + } |
| + |
|
Michael Starzinger
2013/11/22 20:07:16
nit: Only one empty new-line.
mvstanton
2013/11/25 11:51:50
Done.
|
| private: |
| Handle<AllocationSite> top_site_; |