Chromium Code Reviews| 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-gen.h" | 5 #include "src/builtins/builtins-utils-gen.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 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 Node* receiver_continuation = | 40 Node* receiver_continuation = |
| 41 LoadObjectField(receiver, JSGeneratorObject::kContinuationOffset); | 41 LoadObjectField(receiver, JSGeneratorObject::kContinuationOffset); |
| 42 Label if_receiverisclosed(this, Label::kDeferred), | 42 Label if_receiverisclosed(this, Label::kDeferred), |
| 43 if_receiverisrunning(this, Label::kDeferred); | 43 if_receiverisrunning(this, Label::kDeferred); |
| 44 GotoIf(SmiEqual(receiver_continuation, closed), &if_receiverisclosed); | 44 GotoIf(SmiEqual(receiver_continuation, closed), &if_receiverisclosed); |
| 45 DCHECK_LT(JSGeneratorObject::kGeneratorExecuting, | 45 DCHECK_LT(JSGeneratorObject::kGeneratorExecuting, |
| 46 JSGeneratorObject::kGeneratorClosed); | 46 JSGeneratorObject::kGeneratorClosed); |
| 47 GotoIf(SmiLessThan(receiver_continuation, closed), &if_receiverisrunning); | 47 GotoIf(SmiLessThan(receiver_continuation, closed), &if_receiverisrunning); |
| 48 | 48 |
| 49 // Resume the {receiver} using our trampoline. | 49 // Resume the {receiver} using our trampoline. |
| 50 VARIABLE(var_exception, MachineRepresentation::kTagged, UndefinedConstant()); | |
| 51 Label if_exception(this, Label::kDeferred); | |
| 50 Node* result = | 52 Node* result = |
| 51 CallStub(CodeFactory::ResumeGenerator(isolate()), context, value, | 53 CallStub(CodeFactory::ResumeGenerator(isolate()), context, value, |
| 52 receiver, SmiConstant(resume_mode), | 54 receiver, SmiConstant(resume_mode), |
| 53 SmiConstant(static_cast<int>(SuspendFlags::kGeneratorYield))); | 55 SmiConstant(static_cast<int>(SuspendFlags::kGeneratorYield))); |
| 56 // Make sure we close the generator if there was an exception. | |
| 57 GotoIfException(result, &if_exception, &var_exception); | |
|
caitp
2017/06/03 23:14:00
also, given what I said in the top-level comment,
Jarin
2017/06/04 08:49:39
At the moment normal returns are handled in Byteco
Jarin
2017/06/04 08:56:47
Note that we can only do this for normal returns b
| |
| 54 Return(result); | 58 Return(result); |
| 55 | 59 |
| 56 BIND(&if_receiverisincompatible); | 60 BIND(&if_receiverisincompatible); |
| 57 { | 61 { |
| 58 // The {receiver} is not a valid JSGeneratorObject. | 62 // The {receiver} is not a valid JSGeneratorObject. |
| 59 CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context, | 63 CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context, |
| 60 HeapConstant( | 64 HeapConstant( |
| 61 factory()->NewStringFromAsciiChecked(method_name, TENURED)), | 65 factory()->NewStringFromAsciiChecked(method_name, TENURED)), |
| 62 receiver); | 66 receiver); |
| 63 Unreachable(); | 67 Unreachable(); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 84 break; | 88 break; |
| 85 } | 89 } |
| 86 Return(result); | 90 Return(result); |
| 87 } | 91 } |
| 88 | 92 |
| 89 BIND(&if_receiverisrunning); | 93 BIND(&if_receiverisrunning); |
| 90 { | 94 { |
| 91 CallRuntime(Runtime::kThrowGeneratorRunning, context); | 95 CallRuntime(Runtime::kThrowGeneratorRunning, context); |
| 92 Unreachable(); | 96 Unreachable(); |
| 93 } | 97 } |
| 98 | |
| 99 BIND(&if_exception); | |
| 100 { | |
| 101 StoreObjectFieldNoWriteBarrier( | |
| 102 receiver, JSGeneratorObject::kContinuationOffset, closed); | |
| 103 CallRuntime(Runtime::kReThrow, context, var_exception.value()); | |
| 104 Unreachable(); | |
| 105 } | |
| 94 } | 106 } |
| 95 | 107 |
| 96 // ES6 #sec-generator.prototype.next | 108 // ES6 #sec-generator.prototype.next |
| 97 TF_BUILTIN(GeneratorPrototypeNext, GeneratorBuiltinsAssembler) { | 109 TF_BUILTIN(GeneratorPrototypeNext, GeneratorBuiltinsAssembler) { |
| 98 Node* receiver = Parameter(Descriptor::kReceiver); | 110 Node* receiver = Parameter(Descriptor::kReceiver); |
| 99 Node* value = Parameter(Descriptor::kValue); | 111 Node* value = Parameter(Descriptor::kValue); |
| 100 Node* context = Parameter(Descriptor::kContext); | 112 Node* context = Parameter(Descriptor::kContext); |
| 101 GeneratorPrototypeResume(receiver, value, context, JSGeneratorObject::kNext, | 113 GeneratorPrototypeResume(receiver, value, context, JSGeneratorObject::kNext, |
| 102 "[Generator].prototype.next"); | 114 "[Generator].prototype.next"); |
| 103 } | 115 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 116 Node* receiver = Parameter(Descriptor::kReceiver); | 128 Node* receiver = Parameter(Descriptor::kReceiver); |
| 117 Node* exception = Parameter(Descriptor::kException); | 129 Node* exception = Parameter(Descriptor::kException); |
| 118 Node* context = Parameter(Descriptor::kContext); | 130 Node* context = Parameter(Descriptor::kContext); |
| 119 GeneratorPrototypeResume(receiver, exception, context, | 131 GeneratorPrototypeResume(receiver, exception, context, |
| 120 JSGeneratorObject::kThrow, | 132 JSGeneratorObject::kThrow, |
| 121 "[Generator].prototype.throw"); | 133 "[Generator].prototype.throw"); |
| 122 } | 134 } |
| 123 | 135 |
| 124 } // namespace internal | 136 } // namespace internal |
| 125 } // namespace v8 | 137 } // namespace v8 |
| OLD | NEW |