Reviewers: Michael Starzinger,
Description:
Put new global var semantics behind a flag until WebKit tests are cleaned
up.
[email protected]
BUG=
TEST=
Please review this at https://chromiumcodereview.appspot.com/10163003/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/flag-definitions.h
M src/runtime.cc
M test/cctest/test-api.cc
M test/cctest/test-decls.cc
M test/mjsunit/declare-locally.js
M test/mjsunit/regress/regress-1119.js
M test/mjsunit/regress/regress-115452.js
M test/mjsunit/regress/regress-1170.js
Index: src/flag-definitions.h
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index
101900ea27fb378cb00888060cff5359a9c426ea..64a83e4d05993e1b45ba8333a74882d81c87a297
100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -132,6 +132,7 @@ public:
// Flags for language modes and experimental language features.
DEFINE_bool(use_strict, false, "enforce strict mode")
+DEFINE_bool(es52_globals, false, "activate new semantics for global var
declarations")
DEFINE_bool(harmony_typeof, false, "enable harmony semantics for typeof")
DEFINE_bool(harmony_scoping, false, "enable harmony block scoping")
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
d8da56ced5a4bc7c9f6e9b2f23226f3f5e1bc155..f3b6e2c6a7f9f585b77b44d63f6314fdd0f0c542
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -1300,7 +1300,10 @@ RUNTIME_FUNCTION(MaybeObject*,
Runtime_DeclareGlobals) {
// value of the variable if the property is already there.
// Do the lookup locally only, see ES5 errata.
LookupResult lookup(isolate);
- global->LocalLookup(*name, &lookup);
+ if (FLAG_es52_globals)
+ global->LocalLookup(*name, &lookup);
+ 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.
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index
9155993612dd71f420f444634df77e666cc6d3a7..1d22c5e463ac66f9d55bc55a59628215302c8e78
100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -12483,6 +12483,7 @@ THREADED_TEST(GetCallingContext) {
// Check that a variable declaration with no explicit initialization
// value does shadow an existing property in the prototype chain.
THREADED_TEST(InitGlobalVarInProtoChain) {
+ v8::internal::FLAG_es52_globals = true;
v8::HandleScope scope;
LocalContext context;
// Introduce a variable in the prototype chain.
Index: test/cctest/test-decls.cc
diff --git a/test/cctest/test-decls.cc b/test/cctest/test-decls.cc
index
e3d61582c53d5eae1b6ec2c96552899b90d0427e..c029394e1cf7f54bf154ee34960eb48239e6f099
100644
--- a/test/cctest/test-decls.cc
+++ b/test/cctest/test-decls.cc
@@ -521,6 +521,7 @@ class ExistsInPrototypeContext: public
DeclarationContext {
TEST(ExistsInPrototype) {
+ v8::internal::FLAG_es52_globals = true;
HandleScope scope;
// Sanity check to make sure that the holder of the interceptor
@@ -583,6 +584,7 @@ class AbsentInPrototypeContext: public
DeclarationContext {
TEST(AbsentInPrototype) {
+ v8::internal::FLAG_es52_globals = true;
HandleScope scope;
{ AbsentInPrototypeContext context;
Index: test/mjsunit/declare-locally.js
diff --git a/test/mjsunit/declare-locally.js
b/test/mjsunit/declare-locally.js
index
458ac7e9dcbbcb1bd3c9ead3b3eb94d56d75168c..20bfe6da1fe65bb2b7f4299cfd85e08d039e2a5c
100644
--- a/test/mjsunit/declare-locally.js
+++ b/test/mjsunit/declare-locally.js
@@ -33,6 +33,8 @@
// This exercises the code in runtime.cc in
// DeclareGlobal...Locally().
+// Flags: --es52_globals
+
this.__proto__.foo = 42;
this.__proto__.bar = 87;
Index: test/mjsunit/regress/regress-1119.js
diff --git a/test/mjsunit/regress/regress-1119.js
b/test/mjsunit/regress/regress-1119.js
index
1163ca042e4cd7a61046c0fb45c341b1a2c8e3d5..5fd8f369b14e1a398331eae74ab53d5716ab9e6c
100644
--- a/test/mjsunit/regress/regress-1119.js
+++ b/test/mjsunit/regress/regress-1119.js
@@ -28,6 +28,8 @@
// Test runtime declaration of properties with var which are intercepted
// by JS accessors.
+// Flags: --es52_globals
+
this.__defineSetter__("x", function() { hasBeenInvoked = true; });
this.__defineSetter__("y", function() { throw 'exception'; });
Index: test/mjsunit/regress/regress-115452.js
diff --git a/test/mjsunit/regress/regress-115452.js
b/test/mjsunit/regress/regress-115452.js
index
f745e1bad39da446858a16f8b257584f1eb4dbe7..dc711581e928520e4b4af80b4c95d36a8c4df363
100644
--- a/test/mjsunit/regress/regress-115452.js
+++ b/test/mjsunit/regress/regress-115452.js
@@ -27,6 +27,8 @@
// Test that a function declaration cannot overwrite a read-only property.
+// Flags: --es52_globals
+
function foobl() {}
assertTrue(typeof this.foobl == "function");
assertTrue(Object.getOwnPropertyDescriptor(this, "foobl").writable);
Index: test/mjsunit/regress/regress-1170.js
diff --git a/test/mjsunit/regress/regress-1170.js
b/test/mjsunit/regress/regress-1170.js
index
eb3f3c71b72eb090ff2742026940d6c79df74de4..8c5f6f8ab4b309d82776a8e4763b987991cf78ea
100644
--- a/test/mjsunit/regress/regress-1170.js
+++ b/test/mjsunit/regress/regress-1170.js
@@ -25,6 +25,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+// Flags: --es52_globals
+
var setter_value = 0;
this.__defineSetter__("a", function(v) { setter_value = v; });
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev