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

Side by Side Diff: bindings/v8/V8IsolatedWorld.h

Issue 355047: Faster access to isolated worlds. (Closed) Base URL: http://svn.webkit.org/repository/webkit/trunk/WebCore/
Patch Set: '' Created 11 years 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
« no previous file with comments | « bindings/v8/V8HiddenPropertyName.h ('k') | bindings/v8/V8IsolatedWorld.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // 78 //
79 static V8IsolatedWorld* getEntered() 79 static V8IsolatedWorld* getEntered()
80 { 80 {
81 // This is a temporary performance optimization. Essentially, 81 // This is a temporary performance optimization. Essentially,
82 // GetHiddenValue is too slow for this code path. We need to get th e 82 // GetHiddenValue is too slow for this code path. We need to get th e
83 // V8 team to add a real property to v8::Context for isolated worlds . 83 // V8 team to add a real property to v8::Context for isolated worlds .
84 // Until then, we optimize the common case of not having any isolate d 84 // Until then, we optimize the common case of not having any isolate d
85 // worlds at all. 85 // worlds at all.
86 if (!isolatedWorldCount) 86 if (!isolatedWorldCount)
87 return 0; 87 return 0;
88 return getEnteredImpl(); 88 if (!v8::Context::InContext())
89 return 0;
90 return reinterpret_cast<V8IsolatedWorld*>(getGlobalObject(v8::Contex t::GetEntered())->GetPointerFromInternalField(V8Custom::kDOMWindowEnteredIsolate dWorldIndex));
89 } 91 }
90 92
91 v8::Handle<v8::Context> context() { return m_context->get(); } 93 v8::Handle<v8::Context> context() { return m_context->get(); }
92 PassRefPtr<SharedPersistent<v8::Context> > sharedContext() { return m_co ntext; } 94 PassRefPtr<SharedPersistent<v8::Context> > sharedContext() { return m_co ntext; }
93 95
94 DOMDataStore* getDOMDataStore() const { return m_domDataStore.getStore() ; } 96 DOMDataStore* getDOMDataStore() const { return m_domDataStore.getStore() ; }
95 97
96 private: 98 private:
97 static V8IsolatedWorld* getEnteredImpl(); 99 static v8::Handle<v8::Object> getGlobalObject(v8::Handle<v8::Context> co ntext)
100 {
101 return v8::Handle<v8::Object>::Cast(context->Global()->GetPrototype( ));
102 }
98 103
99 // Called by the garbage collector when our JavaScript context is about 104 // Called by the garbage collector when our JavaScript context is about
100 // to be destroyed. 105 // to be destroyed.
101 static void contextWeakReferenceCallback(v8::Persistent<v8::Value> objec t, void* isolated_world); 106 static void contextWeakReferenceCallback(v8::Persistent<v8::Value> objec t, void* isolated_world);
102 107
103 // The v8::Context for the isolated world. This object is keep on the 108 // The v8::Context for the isolated world. This object is keep on the
104 // heap as long as |m_context| has not been garbage collected. 109 // heap as long as |m_context| has not been garbage collected.
105 RefPtr<SharedPersistent<v8::Context> > m_context; 110 RefPtr<SharedPersistent<v8::Context> > m_context;
106 111
107 // The backing store for the isolated world's DOM wrappers. This class 112 // The backing store for the isolated world's DOM wrappers. This class
108 // doesn't have visibility into the wrappers. This handle simply helps 113 // doesn't have visibility into the wrappers. This handle simply helps
109 // manage their lifetime. 114 // manage their lifetime.
110 DOMDataStoreHandle m_domDataStore; 115 DOMDataStoreHandle m_domDataStore;
111 116
112 static int isolatedWorldCount; 117 static int isolatedWorldCount;
113 }; 118 };
114 119
115 } // namespace WebCore 120 } // namespace WebCore
116 121
117 #endif // V8IsolatedWorld_h 122 #endif // V8IsolatedWorld_h
OLDNEW
« no previous file with comments | « bindings/v8/V8HiddenPropertyName.h ('k') | bindings/v8/V8IsolatedWorld.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698