Revision: 11818
Author:   [email protected]
Date:     Thu Jun 14 07:37:10 2012
Log:      ES5.2 var semantics: take hidden prototypes into account.

[email protected]
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/10546166
http://code.google.com/p/v8/source/detail?r=11818

Modified:
 /branches/bleeding_edge/src/runtime.cc

=======================================
--- /branches/bleeding_edge/src/runtime.cc      Thu Jun 14 07:06:22 2012
+++ /branches/bleeding_edge/src/runtime.cc      Thu Jun 14 07:37:10 2012
@@ -1309,12 +1309,18 @@
     if (is_var || is_const) {
       // Lookup the property in the global object, and don't set the
       // value of the variable if the property is already there.
-      // Do the lookup locally only, see ES5 errata.
+      // Do the lookup locally only, see ES5 erratum.
       LookupResult lookup(isolate);
-      if (FLAG_es52_globals)
-        global->LocalLookup(*name, &lookup);
-      else
+      if (FLAG_es52_globals) {
+        Object* obj = *global;
+        do {
+          JSObject::cast(obj)->LocalLookup(*name, &lookup);
+          obj = obj->GetPrototype();
+        } while (!lookup.IsFound() && obj->IsJSObject() &&
+                 JSObject::cast(obj)->map()->is_hidden_prototype());
+      } else {
         global->Lookup(*name, &lookup);
+      }
       if (lookup.IsProperty()) {
         // We found an existing property. Unless it was an interceptor
         // that claims the property is absent, skip this declaration.

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

Reply via email to