OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "src/arguments.h" |
| 6 #include "src/runtime/runtime-utils.h" |
| 7 #include "src/v8.h" |
| 8 |
| 9 namespace v8 { |
| 10 namespace internal { |
| 11 |
| 12 RUNTIME_FUNCTION(Runtime_ForInDone) { |
| 13 SealHandleScope scope(isolate); |
| 14 DCHECK_EQ(2, args.length()); |
| 15 CONVERT_SMI_ARG_CHECKED(index, 0); |
| 16 CONVERT_SMI_ARG_CHECKED(length, 1); |
| 17 DCHECK_LE(0, index); |
| 18 DCHECK_LE(index, length); |
| 19 return isolate->heap()->ToBoolean(index == length); |
| 20 } |
| 21 |
| 22 |
| 23 RUNTIME_FUNCTION(Runtime_ForInFilter) { |
| 24 HandleScope scope(isolate); |
| 25 DCHECK_EQ(2, args.length()); |
| 26 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); |
| 27 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 28 // TODO(turbofan): Fast case for array indices. |
| 29 Handle<Name> name = Runtime::ToName(isolate, key).ToHandleChecked(); |
| 30 Maybe<bool> result = JSReceiver::HasProperty(receiver, name); |
| 31 if (result.IsJust() && result.FromJust()) return *name; |
| 32 return isolate->heap()->undefined_value(); |
| 33 } |
| 34 |
| 35 |
| 36 RUNTIME_FUNCTION(Runtime_ForInNext) { |
| 37 HandleScope scope(isolate); |
| 38 DCHECK_EQ(4, args.length()); |
| 39 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); |
| 40 CONVERT_ARG_HANDLE_CHECKED(FixedArray, cache_array, 1); |
| 41 CONVERT_ARG_HANDLE_CHECKED(Object, cache_type, 2); |
| 42 CONVERT_SMI_ARG_CHECKED(index, 3); |
| 43 Handle<Object> key = handle(cache_array->get(index), isolate); |
| 44 // Don't need filtering if expected map still matches that of the receiver, |
| 45 // and neither for proxies. |
| 46 if (receiver->map() == *cache_type || *cache_type == Smi::FromInt(0)) { |
| 47 return *key; |
| 48 } |
| 49 // TODO(turbofan): Fast case for array indices. |
| 50 Handle<Name> name = Runtime::ToName(isolate, key).ToHandleChecked(); |
| 51 Maybe<bool> result = JSReceiver::HasProperty(receiver, name); |
| 52 if (result.IsJust() && result.FromJust()) return *name; |
| 53 return isolate->heap()->undefined_value(); |
| 54 } |
| 55 |
| 56 |
| 57 RUNTIME_FUNCTION(Runtime_ForInStep) { |
| 58 SealHandleScope scope(isolate); |
| 59 DCHECK_EQ(1, args.length()); |
| 60 CONVERT_SMI_ARG_CHECKED(index, 0); |
| 61 DCHECK_LE(0, index); |
| 62 DCHECK_LT(index, Smi::kMaxValue); |
| 63 return Smi::FromInt(index + 1); |
| 64 } |
| 65 |
| 66 } // namespace internal |
| 67 } // namespace v8 |
OLD | NEW |