OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 #include "src/builtins/builtins-utils.h" | 5 #include "src/builtins/builtins-utils.h" |
6 #include "src/builtins/builtins.h" | 6 #include "src/builtins/builtins.h" |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/code-stub-assembler.h" | 8 #include "src/code-stub-assembler.h" |
9 #include "src/isolate.h" | 9 #include "src/isolate.h" |
10 | 10 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 GotoIf(SmiLessThan(receiver_continuation, closed), &if_receiverisrunning); | 49 GotoIf(SmiLessThan(receiver_continuation, closed), &if_receiverisrunning); |
50 | 50 |
51 // Resume the {receiver} using our trampoline. | 51 // Resume the {receiver} using our trampoline. |
52 Node* result = CallStub(CodeFactory::ResumeGenerator(isolate()), context, | 52 Node* result = CallStub(CodeFactory::ResumeGenerator(isolate()), context, |
53 value, receiver, SmiConstant(resume_mode)); | 53 value, receiver, SmiConstant(resume_mode)); |
54 Return(result); | 54 Return(result); |
55 | 55 |
56 Bind(&if_receiverisincompatible); | 56 Bind(&if_receiverisincompatible); |
57 { | 57 { |
58 // The {receiver} is not a valid JSGeneratorObject. | 58 // The {receiver} is not a valid JSGeneratorObject. |
59 Node* result = | 59 CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context, |
60 CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context, | 60 HeapConstant( |
61 HeapConstant(factory()->NewStringFromAsciiChecked( | 61 factory()->NewStringFromAsciiChecked(method_name, TENURED)), |
62 method_name, TENURED)), | 62 receiver); |
63 receiver); | 63 Unreachable(); |
64 Return(result); // Never reached. | |
65 } | 64 } |
66 | 65 |
67 Bind(&if_receiverisclosed); | 66 Bind(&if_receiverisclosed); |
68 { | 67 { |
69 Callable create_iter_result_object = | 68 Callable create_iter_result_object = |
70 CodeFactory::CreateIterResultObject(isolate()); | 69 CodeFactory::CreateIterResultObject(isolate()); |
71 | 70 |
72 // The {receiver} is closed already. | 71 // The {receiver} is closed already. |
73 Node* result = nullptr; | 72 Node* result = nullptr; |
74 switch (resume_mode) { | 73 switch (resume_mode) { |
75 case JSGeneratorObject::kNext: | 74 case JSGeneratorObject::kNext: |
76 result = CallStub(create_iter_result_object, context, | 75 result = CallStub(create_iter_result_object, context, |
77 UndefinedConstant(), TrueConstant()); | 76 UndefinedConstant(), TrueConstant()); |
78 break; | 77 break; |
79 case JSGeneratorObject::kReturn: | 78 case JSGeneratorObject::kReturn: |
80 result = | 79 result = |
81 CallStub(create_iter_result_object, context, value, TrueConstant()); | 80 CallStub(create_iter_result_object, context, value, TrueConstant()); |
82 break; | 81 break; |
83 case JSGeneratorObject::kThrow: | 82 case JSGeneratorObject::kThrow: |
84 result = CallRuntime(Runtime::kThrow, context, value); | 83 result = CallRuntime(Runtime::kThrow, context, value); |
85 break; | 84 break; |
86 } | 85 } |
87 Return(result); | 86 Return(result); |
88 } | 87 } |
89 | 88 |
90 Bind(&if_receiverisrunning); | 89 Bind(&if_receiverisrunning); |
91 { | 90 { |
92 Node* result = CallRuntime(Runtime::kThrowGeneratorRunning, context); | 91 CallRuntime(Runtime::kThrowGeneratorRunning, context); |
93 Return(result); // Never reached. | 92 Unreachable(); |
94 } | 93 } |
95 } | 94 } |
96 | 95 |
97 // ES6 section 25.3.1.2 Generator.prototype.next ( value ) | 96 // ES6 section 25.3.1.2 Generator.prototype.next ( value ) |
98 TF_BUILTIN(GeneratorPrototypeNext, GeneratorBuiltinsAssembler) { | 97 TF_BUILTIN(GeneratorPrototypeNext, GeneratorBuiltinsAssembler) { |
99 GeneratorPrototypeResume(JSGeneratorObject::kNext, | 98 GeneratorPrototypeResume(JSGeneratorObject::kNext, |
100 "[Generator].prototype.next"); | 99 "[Generator].prototype.next"); |
101 } | 100 } |
102 | 101 |
103 // ES6 section 25.3.1.3 Generator.prototype.return ( value ) | 102 // ES6 section 25.3.1.3 Generator.prototype.return ( value ) |
104 TF_BUILTIN(GeneratorPrototypeReturn, GeneratorBuiltinsAssembler) { | 103 TF_BUILTIN(GeneratorPrototypeReturn, GeneratorBuiltinsAssembler) { |
105 GeneratorPrototypeResume(JSGeneratorObject::kReturn, | 104 GeneratorPrototypeResume(JSGeneratorObject::kReturn, |
106 "[Generator].prototype.return"); | 105 "[Generator].prototype.return"); |
107 } | 106 } |
108 | 107 |
109 // ES6 section 25.3.1.4 Generator.prototype.throw ( exception ) | 108 // ES6 section 25.3.1.4 Generator.prototype.throw ( exception ) |
110 TF_BUILTIN(GeneratorPrototypeThrow, GeneratorBuiltinsAssembler) { | 109 TF_BUILTIN(GeneratorPrototypeThrow, GeneratorBuiltinsAssembler) { |
111 GeneratorPrototypeResume(JSGeneratorObject::kThrow, | 110 GeneratorPrototypeResume(JSGeneratorObject::kThrow, |
112 "[Generator].prototype.throw"); | 111 "[Generator].prototype.throw"); |
113 } | 112 } |
114 | 113 |
115 } // namespace internal | 114 } // namespace internal |
116 } // namespace v8 | 115 } // namespace v8 |
OLD | NEW |