Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index f4c9dc72e3c573dc10bef4349c623402cb0739e8..85e0b84050430ca7d36d286cb9a82638642f5d4c 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -1309,12 +1309,18 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareGlobals) { |
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() && |
Michael Starzinger
2012/06/14 13:16:28
Can we move the "lookup.IsFound()" condition into
arv (Not doing code reviews)
2012/06/20 19:34:14
Also, there is no reason to get the prototype if l
|
+ 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. |