OLD | NEW |
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // TypedArray out-of-bounds access. | 94 // TypedArray out-of-bounds access. |
95 return isolate->factory()->undefined_value(); | 95 return isolate->factory()->undefined_value(); |
96 case LookupIterator::ACCESSOR: | 96 case LookupIterator::ACCESSOR: |
97 case LookupIterator::DATA: | 97 case LookupIterator::DATA: |
98 return it.GetName(); | 98 return it.GetName(); |
99 } | 99 } |
100 } | 100 } |
101 return isolate->factory()->undefined_value(); | 101 return isolate->factory()->undefined_value(); |
102 } | 102 } |
103 | 103 |
104 MaybeHandle<Object> Filter(Handle<JSReceiver> receiver, Handle<Object> key) { | |
105 Isolate* const isolate = receiver->GetIsolate(); | |
106 return HasEnumerableProperty(isolate, receiver, key); | |
107 } | |
108 | |
109 } // namespace | 104 } // namespace |
110 | 105 |
111 | 106 |
112 RUNTIME_FUNCTION(Runtime_ForInEnumerate) { | 107 RUNTIME_FUNCTION(Runtime_ForInEnumerate) { |
113 HandleScope scope(isolate); | 108 HandleScope scope(isolate); |
114 DCHECK_EQ(1, args.length()); | 109 DCHECK_EQ(1, args.length()); |
115 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); | 110 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); |
116 RETURN_RESULT_OR_FAILURE(isolate, Enumerate(receiver)); | 111 RETURN_RESULT_OR_FAILURE(isolate, Enumerate(receiver)); |
117 } | 112 } |
118 | 113 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 RUNTIME_FUNCTION(Runtime_ForInDone) { | 145 RUNTIME_FUNCTION(Runtime_ForInDone) { |
151 SealHandleScope scope(isolate); | 146 SealHandleScope scope(isolate); |
152 DCHECK_EQ(2, args.length()); | 147 DCHECK_EQ(2, args.length()); |
153 CONVERT_SMI_ARG_CHECKED(index, 0); | 148 CONVERT_SMI_ARG_CHECKED(index, 0); |
154 CONVERT_SMI_ARG_CHECKED(length, 1); | 149 CONVERT_SMI_ARG_CHECKED(length, 1); |
155 DCHECK_LE(0, index); | 150 DCHECK_LE(0, index); |
156 DCHECK_LE(index, length); | 151 DCHECK_LE(index, length); |
157 return isolate->heap()->ToBoolean(index == length); | 152 return isolate->heap()->ToBoolean(index == length); |
158 } | 153 } |
159 | 154 |
| 155 RUNTIME_FUNCTION(Runtime_ForInHasProperty) { |
| 156 HandleScope scope(isolate); |
| 157 DCHECK_EQ(2, args.length()); |
| 158 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); |
| 159 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 160 Handle<Object> result; |
| 161 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 162 isolate, result, HasEnumerableProperty(isolate, receiver, key)); |
| 163 return isolate->heap()->ToBoolean(!result->IsUndefined(isolate)); |
| 164 } |
160 | 165 |
161 RUNTIME_FUNCTION(Runtime_ForInFilter) { | 166 RUNTIME_FUNCTION(Runtime_ForInFilter) { |
162 HandleScope scope(isolate); | 167 HandleScope scope(isolate); |
163 DCHECK_EQ(2, args.length()); | 168 DCHECK_EQ(2, args.length()); |
164 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); | 169 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); |
165 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 170 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
166 RETURN_RESULT_OR_FAILURE(isolate, Filter(receiver, key)); | 171 RETURN_RESULT_OR_FAILURE(isolate, |
| 172 HasEnumerableProperty(isolate, receiver, key)); |
167 } | 173 } |
168 | 174 |
169 | 175 |
170 RUNTIME_FUNCTION(Runtime_ForInNext) { | 176 RUNTIME_FUNCTION(Runtime_ForInNext) { |
171 HandleScope scope(isolate); | 177 HandleScope scope(isolate); |
172 DCHECK_EQ(4, args.length()); | 178 DCHECK_EQ(4, args.length()); |
173 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); | 179 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); |
174 CONVERT_ARG_HANDLE_CHECKED(FixedArray, cache_array, 1); | 180 CONVERT_ARG_HANDLE_CHECKED(FixedArray, cache_array, 1); |
175 CONVERT_ARG_HANDLE_CHECKED(Object, cache_type, 2); | 181 CONVERT_ARG_HANDLE_CHECKED(Object, cache_type, 2); |
176 CONVERT_SMI_ARG_CHECKED(index, 3); | 182 CONVERT_SMI_ARG_CHECKED(index, 3); |
177 Handle<Object> key = handle(cache_array->get(index), isolate); | 183 Handle<Object> key = handle(cache_array->get(index), isolate); |
178 // Don't need filtering if expected map still matches that of the receiver. | 184 // Don't need filtering if expected map still matches that of the receiver. |
179 if (receiver->map() == *cache_type) { | 185 if (receiver->map() == *cache_type) { |
180 return *key; | 186 return *key; |
181 } | 187 } |
182 RETURN_RESULT_OR_FAILURE(isolate, Filter(receiver, key)); | 188 RETURN_RESULT_OR_FAILURE(isolate, |
| 189 HasEnumerableProperty(isolate, receiver, key)); |
183 } | 190 } |
184 | 191 |
185 | 192 |
186 RUNTIME_FUNCTION(Runtime_ForInStep) { | 193 RUNTIME_FUNCTION(Runtime_ForInStep) { |
187 SealHandleScope scope(isolate); | 194 SealHandleScope scope(isolate); |
188 DCHECK_EQ(1, args.length()); | 195 DCHECK_EQ(1, args.length()); |
189 CONVERT_SMI_ARG_CHECKED(index, 0); | 196 CONVERT_SMI_ARG_CHECKED(index, 0); |
190 DCHECK_LE(0, index); | 197 DCHECK_LE(0, index); |
191 DCHECK_LT(index, Smi::kMaxValue); | 198 DCHECK_LT(index, Smi::kMaxValue); |
192 return Smi::FromInt(index + 1); | 199 return Smi::FromInt(index + 1); |
193 } | 200 } |
194 | 201 |
195 } // namespace internal | 202 } // namespace internal |
196 } // namespace v8 | 203 } // namespace v8 |
OLD | NEW |