Move derived get trap from builtins to global context.
authorrossberg@chromium.org <rossberg@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 18 May 2011 14:00:34 +0000 (14:00 +0000)
committerrossberg@chromium.org <rossberg@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 18 May 2011 14:00:34 +0000 (14:00 +0000)
Review URL: http://codereview.chromium.org/7017008

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7936 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/bootstrapper.cc
src/builtins.h
src/contexts.h
src/objects.cc
src/proxy.js
src/runtime.js

index 69608e92da2ce021df16b6b5ccea7b30afc5af82..215ea8aae5cf022a11d77030e38baedf378b8225 100644 (file)
@@ -199,6 +199,7 @@ class Genesis BASE_EMBEDDED {
   // Installs the contents of the native .js files on the global objects.
   // Used for creating a context from scratch.
   void InstallNativeFunctions();
+  void InstallExperimentalNativeFunctions();
   bool InstallNatives();
   bool InstallExperimentalNatives();
   void InstallBuiltinFunctionIds();
@@ -1285,6 +1286,12 @@ void Genesis::InstallNativeFunctions() {
   INSTALL_NATIVE(JSObject, "functionCache", function_cache);
 }
 
+void Genesis::InstallExperimentalNativeFunctions() {
+  if (FLAG_harmony_proxies) {
+    INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap);
+  }
+}
+
 #undef INSTALL_NATIVE
 
 
@@ -1647,6 +1654,9 @@ bool Genesis::InstallExperimentalNatives() {
       if (!CompileExperimentalBuiltin(isolate(), i)) return false;
     }
   }
+
+  InstallExperimentalNativeFunctions();
+
   return true;
 }
 
index b01f10b2744dc42b54517f88e67a97a060bd32e0..0d733d82c1334e27ced754cd7ce51903c5b6a15b 100644 (file)
@@ -244,8 +244,7 @@ enum BuiltinExtraArguments {
   V(STRING_ADD_LEFT, 1)                  \
   V(STRING_ADD_RIGHT, 1)                 \
   V(APPLY_PREPARE, 1)                    \
-  V(APPLY_OVERFLOW, 1)                   \
-  V(DERIVED_GET_TRAP, 2)
+  V(APPLY_OVERFLOW, 1)
 
 
 class BuiltinFunctionTable;
index 4b077263a4043f80f8dadd795ef18058dd5796c4..b0d3ae4cdc0d218bb450cc5df0f467ff5ed7d243 100644 (file)
@@ -107,7 +107,8 @@ enum ContextLookupFlags {
   V(OUT_OF_MEMORY_INDEX, Object, out_of_memory) \
   V(MAP_CACHE_INDEX, Object, map_cache) \
   V(CONTEXT_DATA_INDEX, Object, data) \
-  V(ALLOW_CODE_GEN_FROM_STRINGS_INDEX, Object, allow_code_gen_from_strings)
+  V(ALLOW_CODE_GEN_FROM_STRINGS_INDEX, Object, allow_code_gen_from_strings) \
+  V(DERIVED_GET_TRAP_INDEX, JSFunction, derived_get_trap)
 
 // JSFunctions are pairs (context, function code), sometimes also called
 // closures. A Context object is used to represent function contexts and
@@ -238,6 +239,7 @@ class Context: public FixedArray {
     MAP_CACHE_INDEX,
     CONTEXT_DATA_INDEX,
     ALLOW_CODE_GEN_FROM_STRINGS_INDEX,
+    DERIVED_GET_TRAP_INDEX,
 
     // Properties from here are treated as weak references by the full GC.
     // Scavenge treats them as strong references.
index 126e9d0960ad8754fb58dcce028978452d4cee15..ec67039e7048b5239c9c97f5306682771319207b 100644 (file)
@@ -239,9 +239,7 @@ MaybeObject* Object::GetPropertyWithHandler(Object* receiver_raw,
   Handle<Object> trap(v8::internal::GetProperty(handler, "get", &lookup));
   if (!lookup.IsFound()) {
     // Get the derived `get' property.
-    Object* derived = isolate->global_context()->builtins()->javascript_builtin(
-        Builtins::DERIVED_GET_TRAP);
-    trap = Handle<JSFunction>(JSFunction::cast(derived));
+    trap = isolate->derived_get_trap();
   }
 
   // Call trap function.
index 01d48b485ac193a19c6cc681b4e88a1533f56945..c11852b0f89f5ca84b698c43ef04ff8d3b00b88a 100644 (file)
@@ -63,3 +63,21 @@ $Proxy.create = function(handler, proto) {
   if (!IS_SPEC_OBJECT(proto)) proto = $Object.prototype
   return %CreateJSProxy(handler, proto)
 }
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Builtins
+////////////////////////////////////////////////////////////////////////////////
+
+function DerivedGetTrap(receiver, name) {
+  var desc = this.getPropertyDescriptor(name)
+  if (IS_UNDEFINED(desc)) { return desc; }
+  if ('value' in desc) {
+    return desc.value
+  } else {
+    if (IS_UNDEFINED(desc.get)) { return desc.get; }
+    return desc.get.call(receiver)  // The proposal says so...
+  }
+}
index 66e1661b759cc6ed66888d0f69d5cee4f9e3b6f6..77b97aed837d654f8f8a3fda74cce5393674c25b 100644 (file)
@@ -647,20 +647,3 @@ function DefaultString(x) {
 // that is cloned when running the code.  It is essential that the
 // boilerplate gets the right prototype.
 %FunctionSetPrototype($Array, new $Array(0));
-
-
-/* ------------------------------------------
-- - -   H a r m o n y   P r o x i e s   - - -
----------------------------------------------
-*/
-
-function DERIVED_GET_TRAP(receiver, name) {
-  var desc = this.getPropertyDescriptor(name);
-  if (IS_UNDEFINED(desc)) { return desc; }
-  if ('value' in desc) {
-    return desc.value;
-  } else {
-    if (IS_UNDEFINED(desc.get)) { return desc.get; }
-    return desc.get().call(receiver);  // The proposal says so...
-  }
-}