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

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

Issue 2006673002: Reduce boilerplace for common pattern to return MaybeHandle. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase and fix Created 4 years, 7 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-debug.cc ('k') | src/runtime/runtime-function.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/elements.h" 8 #include "src/elements.h"
9 #include "src/factory.h" 9 #include "src/factory.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 return HasEnumerableProperty(isolate, receiver, key); 100 return HasEnumerableProperty(isolate, receiver, key);
101 } 101 }
102 102
103 } // namespace 103 } // namespace
104 104
105 105
106 RUNTIME_FUNCTION(Runtime_ForInEnumerate) { 106 RUNTIME_FUNCTION(Runtime_ForInEnumerate) {
107 HandleScope scope(isolate); 107 HandleScope scope(isolate);
108 DCHECK_EQ(1, args.length()); 108 DCHECK_EQ(1, args.length());
109 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); 109 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0);
110 Handle<HeapObject> result; 110 RETURN_RESULT_OR_FAILURE(isolate, Enumerate(receiver));
111 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Enumerate(receiver));
112 return *result;
113 } 111 }
114 112
115 113
116 RUNTIME_FUNCTION_RETURN_TRIPLE(Runtime_ForInPrepare) { 114 RUNTIME_FUNCTION_RETURN_TRIPLE(Runtime_ForInPrepare) {
117 HandleScope scope(isolate); 115 HandleScope scope(isolate);
118 DCHECK_EQ(1, args.length()); 116 DCHECK_EQ(1, args.length());
119 Handle<JSReceiver> receiver = args.at<JSReceiver>(0); 117 Handle<JSReceiver> receiver = args.at<JSReceiver>(0);
120 Handle<Object> cache_type; 118 Handle<Object> cache_type;
121 if (!Enumerate(receiver).ToHandle(&cache_type)) { 119 if (!Enumerate(receiver).ToHandle(&cache_type)) {
122 return MakeTriple(isolate->heap()->exception(), nullptr, nullptr); 120 return MakeTriple(isolate->heap()->exception(), nullptr, nullptr);
(...skipping 29 matching lines...) Expand all
152 DCHECK_LE(index, length); 150 DCHECK_LE(index, length);
153 return isolate->heap()->ToBoolean(index == length); 151 return isolate->heap()->ToBoolean(index == length);
154 } 152 }
155 153
156 154
157 RUNTIME_FUNCTION(Runtime_ForInFilter) { 155 RUNTIME_FUNCTION(Runtime_ForInFilter) {
158 HandleScope scope(isolate); 156 HandleScope scope(isolate);
159 DCHECK_EQ(2, args.length()); 157 DCHECK_EQ(2, args.length());
160 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); 158 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0);
161 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 159 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
162 Handle<Object> result; 160 RETURN_RESULT_OR_FAILURE(isolate, Filter(receiver, key));
163 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Filter(receiver, key));
164 return *result;
165 } 161 }
166 162
167 163
168 RUNTIME_FUNCTION(Runtime_ForInNext) { 164 RUNTIME_FUNCTION(Runtime_ForInNext) {
169 HandleScope scope(isolate); 165 HandleScope scope(isolate);
170 DCHECK_EQ(4, args.length()); 166 DCHECK_EQ(4, args.length());
171 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); 167 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0);
172 CONVERT_ARG_HANDLE_CHECKED(FixedArray, cache_array, 1); 168 CONVERT_ARG_HANDLE_CHECKED(FixedArray, cache_array, 1);
173 CONVERT_ARG_HANDLE_CHECKED(Object, cache_type, 2); 169 CONVERT_ARG_HANDLE_CHECKED(Object, cache_type, 2);
174 CONVERT_SMI_ARG_CHECKED(index, 3); 170 CONVERT_SMI_ARG_CHECKED(index, 3);
175 Handle<Object> key = handle(cache_array->get(index), isolate); 171 Handle<Object> key = handle(cache_array->get(index), isolate);
176 // Don't need filtering if expected map still matches that of the receiver. 172 // Don't need filtering if expected map still matches that of the receiver.
177 if (receiver->map() == *cache_type) { 173 if (receiver->map() == *cache_type) {
178 return *key; 174 return *key;
179 } 175 }
180 Handle<Object> result; 176 RETURN_RESULT_OR_FAILURE(isolate, Filter(receiver, key));
181 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Filter(receiver, key));
182 return *result;
183 } 177 }
184 178
185 179
186 RUNTIME_FUNCTION(Runtime_ForInStep) { 180 RUNTIME_FUNCTION(Runtime_ForInStep) {
187 SealHandleScope scope(isolate); 181 SealHandleScope scope(isolate);
188 DCHECK_EQ(1, args.length()); 182 DCHECK_EQ(1, args.length());
189 CONVERT_SMI_ARG_CHECKED(index, 0); 183 CONVERT_SMI_ARG_CHECKED(index, 0);
190 DCHECK_LE(0, index); 184 DCHECK_LE(0, index);
191 DCHECK_LT(index, Smi::kMaxValue); 185 DCHECK_LT(index, Smi::kMaxValue);
192 return Smi::FromInt(index + 1); 186 return Smi::FromInt(index + 1);
193 } 187 }
194 188
195 } // namespace internal 189 } // namespace internal
196 } // namespace v8 190 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | src/runtime/runtime-function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698