| 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/objects-inl.h" | 8 #include "src/objects-inl.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 } | 21 } |
| 22 | 22 |
| 23 | 23 |
| 24 RUNTIME_FUNCTION(Runtime_ForInFilter) { | 24 RUNTIME_FUNCTION(Runtime_ForInFilter) { |
| 25 HandleScope scope(isolate); | 25 HandleScope scope(isolate); |
| 26 DCHECK_EQ(2, args.length()); | 26 DCHECK_EQ(2, args.length()); |
| 27 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); | 27 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); |
| 28 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 28 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 29 // TODO(turbofan): Fast case for array indices. | 29 // TODO(turbofan): Fast case for array indices. |
| 30 Handle<Name> name; | 30 Handle<Name> name; |
| 31 if (!Runtime::ToName(isolate, key).ToHandle(&name)) { | 31 if (!Object::ToName(isolate, key).ToHandle(&name)) { |
| 32 return isolate->heap()->exception(); | 32 return isolate->heap()->exception(); |
| 33 } | 33 } |
| 34 Maybe<bool> result = JSReceiver::HasProperty(receiver, name); | 34 Maybe<bool> result = JSReceiver::HasProperty(receiver, name); |
| 35 if (!result.IsJust()) return isolate->heap()->exception(); | 35 if (!result.IsJust()) return isolate->heap()->exception(); |
| 36 if (result.FromJust()) return *name; | 36 if (result.FromJust()) return *name; |
| 37 return isolate->heap()->undefined_value(); | 37 return isolate->heap()->undefined_value(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 | 40 |
| 41 RUNTIME_FUNCTION(Runtime_ForInNext) { | 41 RUNTIME_FUNCTION(Runtime_ForInNext) { |
| 42 HandleScope scope(isolate); | 42 HandleScope scope(isolate); |
| 43 DCHECK_EQ(4, args.length()); | 43 DCHECK_EQ(4, args.length()); |
| 44 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); | 44 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); |
| 45 CONVERT_ARG_HANDLE_CHECKED(FixedArray, cache_array, 1); | 45 CONVERT_ARG_HANDLE_CHECKED(FixedArray, cache_array, 1); |
| 46 CONVERT_ARG_HANDLE_CHECKED(Object, cache_type, 2); | 46 CONVERT_ARG_HANDLE_CHECKED(Object, cache_type, 2); |
| 47 CONVERT_SMI_ARG_CHECKED(index, 3); | 47 CONVERT_SMI_ARG_CHECKED(index, 3); |
| 48 Handle<Object> key = handle(cache_array->get(index), isolate); | 48 Handle<Object> key = handle(cache_array->get(index), isolate); |
| 49 // Don't need filtering if expected map still matches that of the receiver, | 49 // Don't need filtering if expected map still matches that of the receiver, |
| 50 // and neither for proxies. | 50 // and neither for proxies. |
| 51 if (receiver->map() == *cache_type || *cache_type == Smi::FromInt(0)) { | 51 if (receiver->map() == *cache_type || *cache_type == Smi::FromInt(0)) { |
| 52 return *key; | 52 return *key; |
| 53 } | 53 } |
| 54 // TODO(turbofan): Fast case for array indices. | 54 // TODO(turbofan): Fast case for array indices. |
| 55 Handle<Name> name; | 55 Handle<Name> name; |
| 56 if (!Runtime::ToName(isolate, key).ToHandle(&name)) { | 56 if (!Object::ToName(isolate, key).ToHandle(&name)) { |
| 57 return isolate->heap()->exception(); | 57 return isolate->heap()->exception(); |
| 58 } | 58 } |
| 59 Maybe<bool> result = JSReceiver::HasProperty(receiver, name); | 59 Maybe<bool> result = JSReceiver::HasProperty(receiver, name); |
| 60 if (!result.IsJust()) return isolate->heap()->exception(); | 60 if (!result.IsJust()) return isolate->heap()->exception(); |
| 61 if (result.FromJust()) return *name; | 61 if (result.FromJust()) return *name; |
| 62 return isolate->heap()->undefined_value(); | 62 return isolate->heap()->undefined_value(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 | 65 |
| 66 RUNTIME_FUNCTION(Runtime_ForInStep) { | 66 RUNTIME_FUNCTION(Runtime_ForInStep) { |
| 67 SealHandleScope scope(isolate); | 67 SealHandleScope scope(isolate); |
| 68 DCHECK_EQ(1, args.length()); | 68 DCHECK_EQ(1, args.length()); |
| 69 CONVERT_SMI_ARG_CHECKED(index, 0); | 69 CONVERT_SMI_ARG_CHECKED(index, 0); |
| 70 DCHECK_LE(0, index); | 70 DCHECK_LE(0, index); |
| 71 DCHECK_LT(index, Smi::kMaxValue); | 71 DCHECK_LT(index, Smi::kMaxValue); |
| 72 return Smi::FromInt(index + 1); | 72 return Smi::FromInt(index + 1); |
| 73 } | 73 } |
| 74 | 74 |
| 75 } // namespace internal | 75 } // namespace internal |
| 76 } // namespace v8 | 76 } // namespace v8 |
| OLD | NEW |