Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: src/js/generator.js

Issue 1415683007: Reland "[es6] Fix Function and GeneratorFunction built-ins subclassing." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@fix-subclass
Patch Set: Improved test Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/factory.cc ('k') | src/js/v8natives.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function(global, utils) { 5 (function(global, utils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 throw MakeTypeError(kGeneratorRunning); 77 throw MakeTypeError(kGeneratorRunning);
78 } 78 }
79 } 79 }
80 80
81 81
82 function GeneratorFunctionConstructor(arg1) { // length == 1 82 function GeneratorFunctionConstructor(arg1) { // length == 1
83 var source = NewFunctionString(arguments, 'function*'); 83 var source = NewFunctionString(arguments, 'function*');
84 var global_proxy = %GlobalProxy(GeneratorFunctionConstructor); 84 var global_proxy = %GlobalProxy(GeneratorFunctionConstructor);
85 // Compile the string in the constructor and not a helper so that errors 85 // Compile the string in the constructor and not a helper so that errors
86 // appear to come from here. 86 // appear to come from here.
87 var f = %_CallFunction(global_proxy, %CompileString(source, true)); 87 var func = %_CallFunction(global_proxy, %CompileString(source, true));
88 %FunctionMarkNameShouldPrintAsAnonymous(f); 88 // Set name-should-print-as-anonymous flag on the ShareFunctionInfo and
89 return f; 89 // ensure that |func| uses correct initial map from |new.target| if
90 // it's available.
91 return %CompleteFunctionConstruction(func, GeneratorFunction, new.target);
90 } 92 }
91 93
92 // ---------------------------------------------------------------------------- 94 // ----------------------------------------------------------------------------
93 95
94 // Both Runtime_GeneratorNext and Runtime_GeneratorThrow are supported by 96 // Both Runtime_GeneratorNext and Runtime_GeneratorThrow are supported by
95 // neither Crankshaft nor TurboFan, disable optimization of wrappers here. 97 // neither Crankshaft nor TurboFan, disable optimization of wrappers here.
96 %NeverOptimizeFunction(GeneratorObjectNext); 98 %NeverOptimizeFunction(GeneratorObjectNext);
97 %NeverOptimizeFunction(GeneratorObjectThrow); 99 %NeverOptimizeFunction(GeneratorObjectThrow);
98 100
99 // Set up non-enumerable functions on the generator prototype object. 101 // Set up non-enumerable functions on the generator prototype object.
100 var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype; 102 var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype;
101 utils.InstallFunctions(GeneratorObjectPrototype, 103 utils.InstallFunctions(GeneratorObjectPrototype,
102 DONT_ENUM, 104 DONT_ENUM,
103 ["next", GeneratorObjectNext, 105 ["next", GeneratorObjectNext,
104 "throw", GeneratorObjectThrow]); 106 "throw", GeneratorObjectThrow]);
105 107
106 %AddNamedProperty(GeneratorObjectPrototype, "constructor", 108 %AddNamedProperty(GeneratorObjectPrototype, "constructor",
107 GeneratorFunctionPrototype, DONT_ENUM | READ_ONLY); 109 GeneratorFunctionPrototype, DONT_ENUM | READ_ONLY);
108 %AddNamedProperty(GeneratorObjectPrototype, 110 %AddNamedProperty(GeneratorObjectPrototype,
109 toStringTagSymbol, "Generator", DONT_ENUM | READ_ONLY); 111 toStringTagSymbol, "Generator", DONT_ENUM | READ_ONLY);
110 %InternalSetPrototype(GeneratorFunctionPrototype, GlobalFunction.prototype); 112 %InternalSetPrototype(GeneratorFunctionPrototype, GlobalFunction.prototype);
111 %AddNamedProperty(GeneratorFunctionPrototype, 113 %AddNamedProperty(GeneratorFunctionPrototype,
112 toStringTagSymbol, "GeneratorFunction", DONT_ENUM | READ_ONLY); 114 toStringTagSymbol, "GeneratorFunction", DONT_ENUM | READ_ONLY);
113 %AddNamedProperty(GeneratorFunctionPrototype, "constructor", 115 %AddNamedProperty(GeneratorFunctionPrototype, "constructor",
114 GeneratorFunction, DONT_ENUM | READ_ONLY); 116 GeneratorFunction, DONT_ENUM | READ_ONLY);
115 %InternalSetPrototype(GeneratorFunction, GlobalFunction); 117 %InternalSetPrototype(GeneratorFunction, GlobalFunction);
116 %SetCode(GeneratorFunction, GeneratorFunctionConstructor); 118 %SetCode(GeneratorFunction, GeneratorFunctionConstructor);
117 119
118 }) 120 })
OLDNEW
« no previous file with comments | « src/factory.cc ('k') | src/js/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698