diff options
Diffstat (limited to 'deps/v8/src/allocation-site-scopes.h')
-rw-r--r-- | deps/v8/src/allocation-site-scopes.h | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/deps/v8/src/allocation-site-scopes.h b/deps/v8/src/allocation-site-scopes.h index 1c3afdf369..a195b27d85 100644 --- a/deps/v8/src/allocation-site-scopes.h +++ b/deps/v8/src/allocation-site-scopes.h @@ -41,31 +41,22 @@ namespace internal { // boilerplate with AllocationSite and AllocationMemento support. class AllocationSiteContext { public: - AllocationSiteContext(Isolate* isolate, bool activated) { + explicit AllocationSiteContext(Isolate* isolate) { isolate_ = isolate; - activated_ = activated; }; - virtual ~AllocationSiteContext() {} Handle<AllocationSite> top() { return top_; } Handle<AllocationSite> current() { return current_; } - // If activated, then recursively create mementos - bool activated() const { return activated_; } + bool ShouldCreateMemento(Handle<JSObject> object) { return false; } - // 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()); @@ -75,7 +66,6 @@ class AllocationSiteContext { Isolate* isolate_; Handle<AllocationSite> top_; Handle<AllocationSite> current_; - bool activated_; }; @@ -84,11 +74,10 @@ class AllocationSiteContext { class AllocationSiteCreationContext : public AllocationSiteContext { public: explicit AllocationSiteCreationContext(Isolate* isolate) - : AllocationSiteContext(isolate, true) { } + : AllocationSiteContext(isolate) { } - 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); }; @@ -98,15 +87,35 @@ class AllocationSiteUsageContext : public AllocationSiteContext { public: AllocationSiteUsageContext(Isolate* isolate, Handle<AllocationSite> site, bool activated) - : AllocationSiteContext(isolate, activated), - top_site_(site) { } + : AllocationSiteContext(isolate), + top_site_(site), + activated_(activated) { } + + 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()); + } - virtual Handle<AllocationSite> EnterNewScope() V8_OVERRIDE; - virtual void ExitScope(Handle<AllocationSite> site, - Handle<JSObject> object) V8_OVERRIDE; + bool ShouldCreateMemento(Handle<JSObject> object); private: Handle<AllocationSite> top_site_; + bool activated_; }; |