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

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

Issue 2613723002: [runtime] Use DCHECK_EQ instead of DCHECK for number of args. (Closed)
Patch Set: Rebase. Created 3 years, 11 months 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-futex.cc ('k') | src/runtime/runtime-i18n.cc » ('j') | 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/factory.h" 8 #include "src/factory.h"
9 #include "src/frames-inl.h" 9 #include "src/frames-inl.h"
10 #include "src/objects-inl.h" 10 #include "src/objects-inl.h"
11 11
12 namespace v8 { 12 namespace v8 {
13 namespace internal { 13 namespace internal {
14 14
15 RUNTIME_FUNCTION(Runtime_CreateJSGeneratorObject) { 15 RUNTIME_FUNCTION(Runtime_CreateJSGeneratorObject) {
16 HandleScope scope(isolate); 16 HandleScope scope(isolate);
17 DCHECK(args.length() == 2); 17 DCHECK_EQ(2, args.length());
18 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 18 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
19 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 1); 19 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 1);
20 CHECK(IsResumableFunction(function->shared()->kind())); 20 CHECK(IsResumableFunction(function->shared()->kind()));
21 21
22 // Underlying function needs to have bytecode available. 22 // Underlying function needs to have bytecode available.
23 DCHECK(function->shared()->HasBytecodeArray()); 23 DCHECK(function->shared()->HasBytecodeArray());
24 DCHECK(!function->shared()->HasBaselineCode()); 24 DCHECK(!function->shared()->HasBaselineCode());
25 int size = function->shared()->bytecode_array()->register_count(); 25 int size = function->shared()->bytecode_array()->register_count();
26 Handle<FixedArray> register_file = isolate->factory()->NewFixedArray(size); 26 Handle<FixedArray> register_file = isolate->factory()->NewFixedArray(size);
27 27
28 Handle<JSGeneratorObject> generator = 28 Handle<JSGeneratorObject> generator =
29 isolate->factory()->NewJSGeneratorObject(function); 29 isolate->factory()->NewJSGeneratorObject(function);
30 generator->set_function(*function); 30 generator->set_function(*function);
31 generator->set_context(isolate->context()); 31 generator->set_context(isolate->context());
32 generator->set_receiver(*receiver); 32 generator->set_receiver(*receiver);
33 generator->set_register_file(*register_file); 33 generator->set_register_file(*register_file);
34 generator->set_continuation(JSGeneratorObject::kGeneratorExecuting); 34 generator->set_continuation(JSGeneratorObject::kGeneratorExecuting);
35 return *generator; 35 return *generator;
36 } 36 }
37 37
38 RUNTIME_FUNCTION(Runtime_GeneratorClose) { 38 RUNTIME_FUNCTION(Runtime_GeneratorClose) {
39 HandleScope scope(isolate); 39 HandleScope scope(isolate);
40 DCHECK(args.length() == 1); 40 DCHECK_EQ(1, args.length());
41 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); 41 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
42 42
43 generator->set_continuation(JSGeneratorObject::kGeneratorClosed); 43 generator->set_continuation(JSGeneratorObject::kGeneratorClosed);
44 44
45 return isolate->heap()->undefined_value(); 45 return isolate->heap()->undefined_value();
46 } 46 }
47 47
48 RUNTIME_FUNCTION(Runtime_GeneratorGetFunction) { 48 RUNTIME_FUNCTION(Runtime_GeneratorGetFunction) {
49 HandleScope scope(isolate); 49 HandleScope scope(isolate);
50 DCHECK(args.length() == 1); 50 DCHECK_EQ(1, args.length());
51 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); 51 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
52 52
53 return generator->function(); 53 return generator->function();
54 } 54 }
55 55
56 RUNTIME_FUNCTION(Runtime_GeneratorGetReceiver) { 56 RUNTIME_FUNCTION(Runtime_GeneratorGetReceiver) {
57 HandleScope scope(isolate); 57 HandleScope scope(isolate);
58 DCHECK(args.length() == 1); 58 DCHECK_EQ(1, args.length());
59 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); 59 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
60 60
61 return generator->receiver(); 61 return generator->receiver();
62 } 62 }
63 63
64 RUNTIME_FUNCTION(Runtime_GeneratorGetInputOrDebugPos) { 64 RUNTIME_FUNCTION(Runtime_GeneratorGetInputOrDebugPos) {
65 HandleScope scope(isolate); 65 HandleScope scope(isolate);
66 DCHECK(args.length() == 1); 66 DCHECK_EQ(1, args.length());
67 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); 67 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
68 68
69 return generator->input_or_debug_pos(); 69 return generator->input_or_debug_pos();
70 } 70 }
71 71
72 RUNTIME_FUNCTION(Runtime_GeneratorGetResumeMode) { 72 RUNTIME_FUNCTION(Runtime_GeneratorGetResumeMode) {
73 HandleScope scope(isolate); 73 HandleScope scope(isolate);
74 DCHECK(args.length() == 1); 74 DCHECK_EQ(1, args.length());
75 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); 75 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
76 76
77 return Smi::FromInt(generator->resume_mode()); 77 return Smi::FromInt(generator->resume_mode());
78 } 78 }
79 79
80 RUNTIME_FUNCTION(Runtime_GeneratorGetContinuation) { 80 RUNTIME_FUNCTION(Runtime_GeneratorGetContinuation) {
81 HandleScope scope(isolate); 81 HandleScope scope(isolate);
82 DCHECK(args.length() == 1); 82 DCHECK_EQ(1, args.length());
83 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); 83 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
84 84
85 return Smi::FromInt(generator->continuation()); 85 return Smi::FromInt(generator->continuation());
86 } 86 }
87 87
88 RUNTIME_FUNCTION(Runtime_GeneratorGetSourcePosition) { 88 RUNTIME_FUNCTION(Runtime_GeneratorGetSourcePosition) {
89 HandleScope scope(isolate); 89 HandleScope scope(isolate);
90 DCHECK(args.length() == 1); 90 DCHECK_EQ(1, args.length());
91 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); 91 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
92 92
93 if (!generator->is_suspended()) return isolate->heap()->undefined_value(); 93 if (!generator->is_suspended()) return isolate->heap()->undefined_value();
94 return Smi::FromInt(generator->source_position()); 94 return Smi::FromInt(generator->source_position());
95 } 95 }
96 96
97 } // namespace internal 97 } // namespace internal
98 } // namespace v8 98 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-futex.cc ('k') | src/runtime/runtime-i18n.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698