OLD | NEW |
---|---|
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 Loading... | |
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 SFI and ensure that |
Toon Verwaest
2015/10/30 10:58:01
write out SFI
Igor Sheludko
2015/10/30 11:08:57
Done.
| |
89 return f; | 89 // |func| uses correct initial map from |new.target| if it's available. |
90 return %CompleteFunctionConstruction(func, GeneratorFunction, new.target); | |
90 } | 91 } |
91 | 92 |
92 // ---------------------------------------------------------------------------- | 93 // ---------------------------------------------------------------------------- |
93 | 94 |
94 // Both Runtime_GeneratorNext and Runtime_GeneratorThrow are supported by | 95 // Both Runtime_GeneratorNext and Runtime_GeneratorThrow are supported by |
95 // neither Crankshaft nor TurboFan, disable optimization of wrappers here. | 96 // neither Crankshaft nor TurboFan, disable optimization of wrappers here. |
96 %NeverOptimizeFunction(GeneratorObjectNext); | 97 %NeverOptimizeFunction(GeneratorObjectNext); |
97 %NeverOptimizeFunction(GeneratorObjectThrow); | 98 %NeverOptimizeFunction(GeneratorObjectThrow); |
98 | 99 |
99 // Set up non-enumerable functions on the generator prototype object. | 100 // Set up non-enumerable functions on the generator prototype object. |
100 var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype; | 101 var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype; |
101 utils.InstallFunctions(GeneratorObjectPrototype, | 102 utils.InstallFunctions(GeneratorObjectPrototype, |
102 DONT_ENUM, | 103 DONT_ENUM, |
103 ["next", GeneratorObjectNext, | 104 ["next", GeneratorObjectNext, |
104 "throw", GeneratorObjectThrow]); | 105 "throw", GeneratorObjectThrow]); |
105 | 106 |
106 %AddNamedProperty(GeneratorObjectPrototype, "constructor", | 107 %AddNamedProperty(GeneratorObjectPrototype, "constructor", |
107 GeneratorFunctionPrototype, DONT_ENUM | READ_ONLY); | 108 GeneratorFunctionPrototype, DONT_ENUM | READ_ONLY); |
108 %AddNamedProperty(GeneratorObjectPrototype, | 109 %AddNamedProperty(GeneratorObjectPrototype, |
109 toStringTagSymbol, "Generator", DONT_ENUM | READ_ONLY); | 110 toStringTagSymbol, "Generator", DONT_ENUM | READ_ONLY); |
110 %InternalSetPrototype(GeneratorFunctionPrototype, GlobalFunction.prototype); | 111 %InternalSetPrototype(GeneratorFunctionPrototype, GlobalFunction.prototype); |
111 %AddNamedProperty(GeneratorFunctionPrototype, | 112 %AddNamedProperty(GeneratorFunctionPrototype, |
112 toStringTagSymbol, "GeneratorFunction", DONT_ENUM | READ_ONLY); | 113 toStringTagSymbol, "GeneratorFunction", DONT_ENUM | READ_ONLY); |
113 %AddNamedProperty(GeneratorFunctionPrototype, "constructor", | 114 %AddNamedProperty(GeneratorFunctionPrototype, "constructor", |
114 GeneratorFunction, DONT_ENUM | READ_ONLY); | 115 GeneratorFunction, DONT_ENUM | READ_ONLY); |
115 %InternalSetPrototype(GeneratorFunction, GlobalFunction); | 116 %InternalSetPrototype(GeneratorFunction, GlobalFunction); |
116 %SetCode(GeneratorFunction, GeneratorFunctionConstructor); | 117 %SetCode(GeneratorFunction, GeneratorFunctionConstructor); |
117 | 118 |
118 }) | 119 }) |
OLD | NEW |