Let V8 throw the exception when QML property lookup fails
authorKent Hansen <kent.hansen@nokia.com>
Wed, 14 Mar 2012 12:06:26 +0000 (13:06 +0100)
committerQt by Nokia <qt-info@nokia.com>
Wed, 14 Mar 2012 18:13:42 +0000 (19:13 +0100)
commitc511fa8a6a631e45ee4075453bcb2eeb7f01ba63
treeff77bbbbde1c48a5594af60a1d9a3679081be278
parent0fffefdf9747629521cc2f474c44c80dc21cf1ba
Let V8 throw the exception when QML property lookup fails

This should be squashed into the "Introduce a QML compilation mode"
commit (8a4d849a0152c76bd9107a1b38a641cf8c0ff226) the next time V8
is rebased.

In normal (non-QML) mode, when a global property lookup fails
(implicit receiver ("this") object), V8 decides to throw an exception
iff the expression evaluation is not part of a "typeof" evaluation.
If it is evaluated as part of "typeof", the result silently becomes
"undefined". This is the expected behavior as per the ECMA-262
standard; "typeof" shouldn't throw a ReferenceError even if the
expression involves a global variable that doesn't exist.

This commit brings the QML mode behavior in line with normal mode.
When the receiver object is a QML global object, V8 up until now
hasn't detected whether it should throw an error in that case. The
QML implementation has been working around that by explicitly
throwing the ReferenceError in the QML context wrapper, but that
breaks the "typeof" operator in QML mode. The QML context wrapper
should rather return an empty handle, and leave it up to V8 to
throw the exception as appropriate.

This also reverts the parts of the original QML mode patch that
changed the RelocInfo mode for QML variables, since V8 relies
precisely on this mode to know whether it's evaluating a "typeof".
(It's no longer clear why the RelocInfo mode was modified in the
first place.)

Task-number: QTBUG-24448
Change-Id: Ic33610d5e91bdf373b22d97a3181e6e5f2fc1843
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
12 files changed:
src/3rdparty/v8/src/arm/full-codegen-arm.cc
src/3rdparty/v8/src/arm/lithium-codegen-arm.cc
src/3rdparty/v8/src/ia32/full-codegen-ia32.cc
src/3rdparty/v8/src/ia32/lithium-codegen-ia32.cc
src/3rdparty/v8/src/ic.h
src/3rdparty/v8/src/mips/full-codegen-mips.cc
src/3rdparty/v8/src/x64/full-codegen-x64.cc
src/3rdparty/v8/src/x64/lithium-codegen-x64.cc
tests/auto/v8/tst_v8.cpp
tests/auto/v8/v8main.cpp
tests/auto/v8/v8test.cpp
tests/auto/v8/v8test.h