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

Side by Side Diff: src/runtime/runtime-generator.cc

Issue 2504223002: [fullcodegen] Remove deprecated generator implementation. (Closed)
Patch Set: Rebased. Created 4 years 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/runtime/runtime.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/debug/debug.h"
9 #include "src/factory.h" 8 #include "src/factory.h"
10 #include "src/frames-inl.h" 9 #include "src/frames-inl.h"
11 #include "src/objects-inl.h" 10 #include "src/objects-inl.h"
12 11
13 namespace v8 { 12 namespace v8 {
14 namespace internal { 13 namespace internal {
15 14
16 RUNTIME_FUNCTION(Runtime_CreateJSGeneratorObject) { 15 RUNTIME_FUNCTION(Runtime_CreateJSGeneratorObject) {
17 HandleScope scope(isolate); 16 HandleScope scope(isolate);
18 DCHECK(args.length() == 2); 17 DCHECK(args.length() == 2);
(...skipping 16 matching lines...) Expand all
35 Handle<JSGeneratorObject> generator = 34 Handle<JSGeneratorObject> generator =
36 isolate->factory()->NewJSGeneratorObject(function); 35 isolate->factory()->NewJSGeneratorObject(function);
37 generator->set_function(*function); 36 generator->set_function(*function);
38 generator->set_context(isolate->context()); 37 generator->set_context(isolate->context());
39 generator->set_receiver(*receiver); 38 generator->set_receiver(*receiver);
40 generator->set_operand_stack(*operand_stack); 39 generator->set_operand_stack(*operand_stack);
41 generator->set_continuation(JSGeneratorObject::kGeneratorExecuting); 40 generator->set_continuation(JSGeneratorObject::kGeneratorExecuting);
42 return *generator; 41 return *generator;
43 } 42 }
44 43
45 RUNTIME_FUNCTION(Runtime_SuspendJSGeneratorObject) {
46 HandleScope handle_scope(isolate);
47 DCHECK(args.length() == 1);
48 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator_object, 0);
49
50 JavaScriptFrameIterator stack_iterator(isolate);
51 JavaScriptFrame* frame = stack_iterator.frame();
52 CHECK(IsResumableFunction(frame->function()->shared()->kind()));
53 DCHECK_EQ(frame->function(), generator_object->function());
54 DCHECK(frame->function()->shared()->is_compiled());
55 DCHECK(!frame->function()->IsOptimized());
56
57 isolate->debug()->RecordGenerator(generator_object);
58
59 // The caller should have saved the context and continuation already.
60 DCHECK_EQ(generator_object->context(), Context::cast(frame->context()));
61 DCHECK_LT(0, generator_object->continuation());
62
63 // We expect there to be at least two values on the operand stack: the return
64 // value of the yield expression, and the arguments to this runtime call.
65 // Neither of those should be saved.
66 int operands_count = frame->ComputeOperandsCount();
67 DCHECK_GE(operands_count, 1 + args.length());
68 operands_count -= 1 + args.length();
69
70 if (operands_count == 0) {
71 // Although it's semantically harmless to call this function with an
72 // operands_count of zero, it is also unnecessary.
73 DCHECK_EQ(generator_object->operand_stack(),
74 isolate->heap()->empty_fixed_array());
75 } else {
76 Handle<FixedArray> operand_stack =
77 isolate->factory()->NewFixedArray(operands_count);
78 frame->SaveOperandStack(*operand_stack);
79 generator_object->set_operand_stack(*operand_stack);
80 }
81
82 return isolate->heap()->undefined_value();
83 }
84
85 RUNTIME_FUNCTION(Runtime_GeneratorClose) { 44 RUNTIME_FUNCTION(Runtime_GeneratorClose) {
86 HandleScope scope(isolate); 45 HandleScope scope(isolate);
87 DCHECK(args.length() == 1); 46 DCHECK(args.length() == 1);
88 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); 47 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
89 48
90 generator->set_continuation(JSGeneratorObject::kGeneratorClosed); 49 generator->set_continuation(JSGeneratorObject::kGeneratorClosed);
91 50
92 return isolate->heap()->undefined_value(); 51 return isolate->heap()->undefined_value();
93 } 52 }
94 53
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 HandleScope scope(isolate); 95 HandleScope scope(isolate);
137 DCHECK(args.length() == 1); 96 DCHECK(args.length() == 1);
138 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); 97 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
139 98
140 if (!generator->is_suspended()) return isolate->heap()->undefined_value(); 99 if (!generator->is_suspended()) return isolate->heap()->undefined_value();
141 return Smi::FromInt(generator->source_position()); 100 return Smi::FromInt(generator->source_position());
142 } 101 }
143 102
144 } // namespace internal 103 } // namespace internal
145 } // namespace v8 104 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698