Chromium Code Reviews| 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/factory.h" | |
| 9 #include "src/isolate-inl.h" | |
| 8 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
| 9 | 11 |
| 10 namespace v8 { | 12 namespace v8 { |
| 11 namespace internal { | 13 namespace internal { |
| 12 | 14 |
| 15 RUNTIME_FUNCTION_RETURN_TRIPLE(Runtime_ForInPrepare) { | |
| 16 HandleScope scope(isolate); | |
| 17 DCHECK_EQ(1, args.length()); | |
| 18 | |
| 19 if (!args[0]->IsJSReceiver()) { | |
| 20 return MakeTriple(isolate->ThrowIllegalOperation(), nullptr, nullptr); | |
| 21 } | |
| 22 Handle<JSReceiver> receiver = args.at<JSReceiver>(0); | |
| 23 | |
| 24 Object* property_names = Runtime_GetPropertyNamesFast( | |
| 25 1, Handle<Object>::cast(receiver).location(), isolate); | |
| 26 if (isolate->has_pending_exception()) { | |
| 27 return MakeTriple(property_names, nullptr, nullptr); | |
| 28 } | |
| 29 | |
| 30 Handle<Object> cache_type(property_names, isolate); | |
| 31 Handle<FixedArray> cache_array; | |
| 32 int cache_length; | |
| 33 | |
| 34 Handle<Map> receiver_map = handle(receiver->map(), isolate); | |
| 35 if (cache_type->IsMap()) { | |
| 36 Handle<Map> cache_type_map = | |
| 37 handle(Handle<Map>::cast(cache_type)->map(), isolate); | |
| 38 DCHECK(cache_type_map.is_identical_to(isolate->factory()->meta_map())); | |
| 39 int enum_length = cache_type_map->EnumLength(); | |
| 40 DescriptorArray* descriptors = receiver_map->instance_descriptors(); | |
| 41 if (enum_length > 0 && descriptors->HasEnumCache()) { | |
| 42 cache_array = handle(descriptors->GetEnumCache(), isolate); | |
| 43 cache_length = cache_array->length(); | |
| 44 } else { | |
| 45 cache_array = isolate->factory()->empty_fixed_array(); | |
| 46 cache_length = 0; | |
| 47 } | |
| 48 } else { | |
| 49 cache_array = Handle<FixedArray>::cast(cache_type); | |
| 50 cache_length = cache_array->length(); | |
| 51 | |
| 52 STATIC_ASSERT(JS_PROXY_TYPE == FIRST_JS_RECEIVER_TYPE); | |
| 53 if (receiver_map->instance_type() == JS_PROXY_TYPE) { | |
| 54 // Zero indicates proxy | |
| 55 cache_type = Handle<Object>(Smi::FromInt(0), isolate); | |
|
Benedikt Meurer
2016/01/13 14:48:53
This no longer matches the current implementatin f
rmcilroy
2016/01/14 12:13:52
Done.
| |
| 56 } else { | |
| 57 // One entails slow check | |
| 58 cache_type = Handle<Object>(Smi::FromInt(1), isolate); | |
| 59 } | |
| 60 } | |
| 61 | |
| 62 return MakeTriple(*cache_type, *cache_array, Smi::FromInt(cache_length)); | |
| 63 } | |
| 64 | |
| 65 | |
| 13 RUNTIME_FUNCTION(Runtime_ForInDone) { | 66 RUNTIME_FUNCTION(Runtime_ForInDone) { |
| 14 SealHandleScope scope(isolate); | 67 SealHandleScope scope(isolate); |
| 15 DCHECK_EQ(2, args.length()); | 68 DCHECK_EQ(2, args.length()); |
| 16 CONVERT_SMI_ARG_CHECKED(index, 0); | 69 CONVERT_SMI_ARG_CHECKED(index, 0); |
| 17 CONVERT_SMI_ARG_CHECKED(length, 1); | 70 CONVERT_SMI_ARG_CHECKED(length, 1); |
| 18 DCHECK_LE(0, index); | 71 DCHECK_LE(0, index); |
| 19 DCHECK_LE(index, length); | 72 DCHECK_LE(index, length); |
| 20 return isolate->heap()->ToBoolean(index == length); | 73 return isolate->heap()->ToBoolean(index == length); |
| 21 } | 74 } |
| 22 | 75 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 SealHandleScope scope(isolate); | 120 SealHandleScope scope(isolate); |
| 68 DCHECK_EQ(1, args.length()); | 121 DCHECK_EQ(1, args.length()); |
| 69 CONVERT_SMI_ARG_CHECKED(index, 0); | 122 CONVERT_SMI_ARG_CHECKED(index, 0); |
| 70 DCHECK_LE(0, index); | 123 DCHECK_LE(0, index); |
| 71 DCHECK_LT(index, Smi::kMaxValue); | 124 DCHECK_LT(index, Smi::kMaxValue); |
| 72 return Smi::FromInt(index + 1); | 125 return Smi::FromInt(index + 1); |
| 73 } | 126 } |
| 74 | 127 |
| 75 } // namespace internal | 128 } // namespace internal |
| 76 } // namespace v8 | 129 } // namespace v8 |
| OLD | NEW |