[ES6][ES7] Drop Constructability of generator function
https://bugs.webkit.org/show_bug.cgi?id=152383

Reviewed by Saam Barati.

We drop the constructability of generator functions.
This functionality is already landed in ES 2016 draft[1].
And this simplifies the existing JSC's generator implementation;
dropping GeneratorThisMode flag.

[1]: https://github.com/tc39/ecma262/releases/tag/es2016-draft-20151201

* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
* JavaScriptCore.xcodeproj/project.pbxproj:
* builtins/BuiltinExecutables.cpp:
(JSC::createExecutableInternal):
* bytecode/ExecutableInfo.h:
(JSC::ExecutableInfo::ExecutableInfo):
(JSC::ExecutableInfo::generatorThisMode): Deleted.
* bytecode/UnlinkedCodeBlock.cpp:
(JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): Deleted.
* bytecode/UnlinkedCodeBlock.h:
(JSC::UnlinkedCodeBlock::generatorThisMode): Deleted.
* bytecode/UnlinkedFunctionExecutable.cpp:
(JSC::generateUnlinkedFunctionCodeBlock):
(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
* bytecode/UnlinkedFunctionExecutable.h:
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::BytecodeGenerator): Deleted.
* bytecompiler/BytecodeGenerator.h:
(JSC::BytecodeGenerator::makeFunction):
(JSC::BytecodeGenerator::generatorThisMode): Deleted.
* bytecompiler/NodesCodegen.cpp:
(JSC::ThisNode::emitBytecode):
* interpreter/Interpreter.cpp:
(JSC::eval): Deleted.
* runtime/CodeCache.cpp:
(JSC::CodeCache::getFunctionExecutableFromGlobalCode):
* runtime/Executable.h:
* runtime/GeneratorThisMode.h: Removed.
* tests/stress/generator-eval-this.js:
(shouldThrow):
* tests/stress/generator-is-not-constructible.js: Added.
(shouldThrow):
(A.staticGen):
(A.prototype.gen):
(A):
(TypeError):
* tests/stress/generator-this.js:
(shouldBe.g.next):
* tests/stress/generator-with-new-target.js:
(shouldThrow):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@194435 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/tests/stress/generator-with-new-target.js b/Source/JavaScriptCore/tests/stress/generator-with-new-target.js
index 0d3b2df..ba5013e 100644
--- a/Source/JavaScriptCore/tests/stress/generator-with-new-target.js
+++ b/Source/JavaScriptCore/tests/stress/generator-with-new-target.js
@@ -3,6 +3,21 @@
         throw new Error('bad value: ' + actual);
 }
 
+function shouldThrow(func, errorMessage) {
+    var errorThrown = false;
+    var error = null;
+    try {
+        func();
+    } catch (e) {
+        errorThrown = true;
+        error = e;
+    }
+    if (!errorThrown)
+        throw new Error('not thrown');
+    if (String(error) !== errorMessage)
+        throw new Error(`bad error: ${String(error)}`);
+}
+
 function *gen()
 {
     yield new.target;
@@ -11,5 +26,6 @@
 var g = gen();
 shouldBe(g.next().value, undefined);
 
-var g2 = new gen();
-shouldBe(g.next().value, undefined);
+shouldThrow(() => {
+    var g2 = new gen();
+}, `TypeError: function is not a constructor (evaluating 'new gen()')`);