Title: [202664] trunk/Source/_javascript_Core
- Revision
- 202664
- Author
- sbar...@apple.com
- Date
- 2016-06-29 20:55:34 -0700 (Wed, 29 Jun 2016)
Log Message
JSGlobalLexicalEnvironment needs a toThis implementation
https://bugs.webkit.org/show_bug.cgi?id=159285
Reviewed by Mark Lam.
This was a huge oversight of my original implementation. It gave users
of the language direct access to the JSGlobalLexicalEnvironment object.
* runtime/JSGlobalLexicalEnvironment.cpp:
(JSC::JSGlobalLexicalEnvironment::isConstVariable):
(JSC::JSGlobalLexicalEnvironment::toThis):
* runtime/JSGlobalLexicalEnvironment.h:
(JSC::JSGlobalLexicalEnvironment::isEmpty):
* tests/stress/global-lexical-environment-to-this.js: Added.
(assert):
(let.f):
(let.fStrict):
Modified Paths
Added Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (202663 => 202664)
--- trunk/Source/_javascript_Core/ChangeLog 2016-06-30 02:34:22 UTC (rev 202663)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-06-30 03:55:34 UTC (rev 202664)
@@ -1,3 +1,23 @@
+2016-06-29 Saam barati <sbar...@apple.com>
+
+ JSGlobalLexicalEnvironment needs a toThis implementation
+ https://bugs.webkit.org/show_bug.cgi?id=159285
+
+ Reviewed by Mark Lam.
+
+ This was a huge oversight of my original implementation. It gave users
+ of the language direct access to the JSGlobalLexicalEnvironment object.
+
+ * runtime/JSGlobalLexicalEnvironment.cpp:
+ (JSC::JSGlobalLexicalEnvironment::isConstVariable):
+ (JSC::JSGlobalLexicalEnvironment::toThis):
+ * runtime/JSGlobalLexicalEnvironment.h:
+ (JSC::JSGlobalLexicalEnvironment::isEmpty):
+ * tests/stress/global-lexical-environment-to-this.js: Added.
+ (assert):
+ (let.f):
+ (let.fStrict):
+
2016-06-29 Joseph Pecoraro <pecor...@apple.com>
Web Inspector: Wrong function name next to scope
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalLexicalEnvironment.cpp (202663 => 202664)
--- trunk/Source/_javascript_Core/runtime/JSGlobalLexicalEnvironment.cpp 2016-06-30 02:34:22 UTC (rev 202663)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalLexicalEnvironment.cpp 2016-06-30 03:55:34 UTC (rev 202664)
@@ -61,4 +61,11 @@
return entry.isReadOnly();
}
+JSValue JSGlobalLexicalEnvironment::toThis(JSCell*, ExecState* exec, ECMAMode ecmaMode)
+{
+ if (ecmaMode == StrictMode)
+ return jsUndefined();
+ return exec->globalThisValue();
+}
+
} // namespace JSC
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalLexicalEnvironment.h (202663 => 202664)
--- trunk/Source/_javascript_Core/runtime/JSGlobalLexicalEnvironment.h 2016-06-30 02:34:22 UTC (rev 202663)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalLexicalEnvironment.h 2016-06-30 03:55:34 UTC (rev 202664)
@@ -35,7 +35,7 @@
public:
typedef JSSegmentedVariableObject Base;
- static const unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot;
+ static const unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesToThis;
static JSGlobalLexicalEnvironment* create(VM& vm, Structure* structure, JSScope* parentScope)
{
@@ -56,6 +56,8 @@
bool isEmpty() const { return !symbolTable()->size(); }
bool isConstVariable(UniquedStringImpl*);
+
+ static JSValue toThis(JSCell*, ExecState*, ECMAMode);
DECLARE_INFO;
Added: trunk/Source/_javascript_Core/tests/stress/global-lexical-environment-to-this.js (0 => 202664)
--- trunk/Source/_javascript_Core/tests/stress/global-lexical-environment-to-this.js (rev 0)
+++ trunk/Source/_javascript_Core/tests/stress/global-lexical-environment-to-this.js 2016-06-30 03:55:34 UTC (rev 202664)
@@ -0,0 +1,22 @@
+function assert(b, i) {
+ if (!b)
+ throw new Error("Bad! " + i)
+}
+
+let f = function() {
+ return this;
+}
+noInline(f);
+
+let fStrict = function() {
+ "use strict";
+ return this;
+}
+noInline(fStrict);
+
+const globalThis = this;
+for (let i = 0; i < 1000; i++)
+ assert(f() === globalThis, i);
+
+for (let i = 0; i < 1000; i++)
+ assert(fStrict() === undefined);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes