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.h" | 5 #include "src/builtins/builtins.h" |
6 #include "src/builtins/builtins-utils.h" | 6 #include "src/builtins/builtins-utils.h" |
7 | 7 |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 void Generate_GeneratorPrototypeResume( | 15 void Generate_GeneratorPrototypeResume( |
16 CodeStubAssembler* assembler, JSGeneratorObject::ResumeMode resume_mode, | 16 CodeStubAssembler* assembler, JSGeneratorObject::ResumeMode resume_mode, |
17 char const* const method_name) { | 17 char const* const method_name) { |
18 typedef CodeStubAssembler::Label Label; | 18 typedef CodeStubAssembler::Label Label; |
19 typedef compiler::Node Node; | 19 typedef compiler::Node Node; |
20 | 20 |
21 Node* receiver = assembler->Parameter(0); | 21 Node* receiver = assembler->Parameter(0); |
22 Node* value = assembler->Parameter(1); | 22 Node* value = assembler->Parameter(1); |
23 Node* context = assembler->Parameter(4); | 23 Node* context = assembler->Parameter(4); |
24 Node* closed = | 24 Node* closed = |
25 assembler->SmiConstant(Smi::FromInt(JSGeneratorObject::kGeneratorClosed)); | 25 assembler->SmiConstant(Smi::FromInt(JSGeneratorObject::kGeneratorClosed)); |
26 | 26 |
27 // Check if the {receiver} is actually a JSGeneratorObject. | 27 // Check if the {receiver} is actually a JSGeneratorObject. |
28 Label if_receiverisincompatible(assembler, Label::kDeferred); | 28 Label if_receiverisincompatible(assembler, Label::kDeferred); |
29 assembler->GotoIf(assembler->WordIsSmi(receiver), &if_receiverisincompatible); | 29 assembler->GotoIf(assembler->TaggedIsSmi(receiver), |
| 30 &if_receiverisincompatible); |
30 Node* receiver_instance_type = assembler->LoadInstanceType(receiver); | 31 Node* receiver_instance_type = assembler->LoadInstanceType(receiver); |
31 assembler->GotoUnless(assembler->Word32Equal( | 32 assembler->GotoUnless(assembler->Word32Equal( |
32 receiver_instance_type, | 33 receiver_instance_type, |
33 assembler->Int32Constant(JS_GENERATOR_OBJECT_TYPE)), | 34 assembler->Int32Constant(JS_GENERATOR_OBJECT_TYPE)), |
34 &if_receiverisincompatible); | 35 &if_receiverisincompatible); |
35 | 36 |
36 // Check if the {receiver} is running or already closed. | 37 // Check if the {receiver} is running or already closed. |
37 Node* receiver_continuation = assembler->LoadObjectField( | 38 Node* receiver_continuation = assembler->LoadObjectField( |
38 receiver, JSGeneratorObject::kContinuationOffset); | 39 receiver, JSGeneratorObject::kContinuationOffset); |
39 Label if_receiverisclosed(assembler, Label::kDeferred), | 40 Label if_receiverisclosed(assembler, Label::kDeferred), |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 } | 108 } |
108 | 109 |
109 // ES6 section 25.3.1.4 Generator.prototype.throw ( exception ) | 110 // ES6 section 25.3.1.4 Generator.prototype.throw ( exception ) |
110 void Builtins::Generate_GeneratorPrototypeThrow(CodeStubAssembler* assembler) { | 111 void Builtins::Generate_GeneratorPrototypeThrow(CodeStubAssembler* assembler) { |
111 Generate_GeneratorPrototypeResume(assembler, JSGeneratorObject::kThrow, | 112 Generate_GeneratorPrototypeResume(assembler, JSGeneratorObject::kThrow, |
112 "[Generator].prototype.throw"); | 113 "[Generator].prototype.throw"); |
113 } | 114 } |
114 | 115 |
115 } // namespace internal | 116 } // namespace internal |
116 } // namespace v8 | 117 } // namespace v8 |
OLD | NEW |