Reviewers: Mads Ager, Kasper Lund, bak, iposva,

Description:
Split window support from V8.

Here is a description of the background and design of split window in
Chrome and V8:
https://docs.google.com/a/google.com/Doc?id=chhjkpg_47fwddxbfr

This change list splits the window object into two parts: 1) an inner
window object used as the global object of contexts; 2) an outer window
object exposed to JavaScript and accessible by the name 'window'.
Firefox did it awhile ago, here are some discussions:
https://wiki.mozilla.org/Gecko:SplitWindow. One additional benefit of
splitting window in Chrome is that accessing global variables don't need
security checks anymore, it can improve applications that use many
global variables.

V8 support of split window:
   There are a small number of changes on V8 api to support split window:
Security context is removed from V8, so does related API functions;
A global object can be detached from its context and reused by a new
context;
Access checks on an object template can be turned on/off by default;
An object can turn on its access checks later;

   V8 has a new object type, ApiGlobalObject, which is the outer window
object type. The existing JSGlobalObject becomes the inner window object
type. Security checks are moved from JSGlobalObject to ApiGlobalObject.
ApiGlobalObject is the one exposed to JavaScript, it is accessible
through Context::Global(). ApiGlobalObject's prototype is set to
JSGlobalObject so that property lookups are forwarded to JSGlobalObject.
ApiGlobalObject forwards all other property access requests to
JSGlobalObject, such as SetProperty, DeleteProperty, etc.

   Security token is moved to a global context, and ApiGlobalObject has a
reference to its global context. JSGlobalObject has a reference to its
global context as well. When accessing properties on a global object in
JavaScript, the domain security check is performed by comparing the
security token of the lexical context (Top::global_context()) to the
token of global object's context. The check is only needed when the
receiver is a window object, such as 'window.document'. Accessing global
variables, such as 'var foo = 3; foo' does not need checks because the
receiver is the inner window object.

   When an outer window is detached from its global context (when a frame
navigates away from a page), it is completely detached from the inner
window. A new context is created for the new page, and the outer global
object is reused. At this point, the access check on the DOMWindow
wrapper of the old context is turned on. The code in old context is
still able to access DOMWindow properties, but it has to go through
domain security checks.


It is debatable on how to implement the outer window object. Currently
each property access function has to check if the receiver is
ApiGlobalObject type. This approach might be error-prone that one may
forget to check the receiver when adding new functions. It is unlikely a
performance issue because accessing global variables are more common
than 'window.foo' style coding.

I am still working on the ARM port, and I'd like to hear comments and
suggestions on the best way to support it in V8.



Please review this at http://codereview.chromium.org/7366

Affected files:
   M     include/v8.h
   M     samples/shell.cc
   M     src/api.h
   M     src/api.cc
   M     src/bootstrapper.h
   M     src/bootstrapper.cc
   M     src/builtins-ia32.cc
   M     src/builtins.cc
   M     src/codegen-ia32.h
   M     src/codegen-ia32.cc
   M     src/contexts.h
   M     src/contexts.cc
   M     src/debug.h
   M     src/debug.cc
   M     src/factory.h
   M     src/factory.cc
   M     src/handles.h
   M     src/handles.cc
   M     src/heap.h
   M     src/heap.cc
   M     src/ic-ia32.cc
   M     src/ic.cc
   M     src/macro-assembler-ia32.h
   M     src/macro-assembler-ia32.cc
   M     src/messages.cc
   M     src/mirror-delay.js
   M     src/objects-debug.cc
   M     src/objects-inl.h
   M     src/objects.h
   M     src/objects.cc
   M     src/runtime.h
   M     src/runtime.cc
   M     src/runtime.js
   M     src/serialize.cc
   M     src/string-stream.cc
   M     src/stub-cache-ia32.cc
   M     src/top.h
   M     src/top.cc
   M     src/v8natives.js
   M     test/cctest/test-api.cc
   M     test/cctest/test-debug.cc
   M     test/cctest/test-decls.cc



--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to