Reviewers: Michael Starzinger,
Description:
ES5.2 var semantics: take hidden prototypes into account.
[email protected]
BUG=
TEST=
Please review this at https://chromiumcodereview.appspot.com/10546166/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/runtime.cc
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() &&
+ 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