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/isolate-inl.h" | 8 #include "src/isolate-inl.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 RUNTIME_FUNCTION(Runtime_InterpreterNewClosure) { | 140 RUNTIME_FUNCTION(Runtime_InterpreterNewClosure) { |
141 HandleScope scope(isolate); | 141 HandleScope scope(isolate); |
142 DCHECK_EQ(2, args.length()); | 142 DCHECK_EQ(2, args.length()); |
143 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); | 143 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); |
144 CONVERT_SMI_ARG_CHECKED(pretenured_flag, 1); | 144 CONVERT_SMI_ARG_CHECKED(pretenured_flag, 1); |
145 Handle<Context> context(isolate->context(), isolate); | 145 Handle<Context> context(isolate->context(), isolate); |
146 return *isolate->factory()->NewFunctionFromSharedFunctionInfo( | 146 return *isolate->factory()->NewFunctionFromSharedFunctionInfo( |
147 shared, context, static_cast<PretenureFlag>(pretenured_flag)); | 147 shared, context, static_cast<PretenureFlag>(pretenured_flag)); |
148 } | 148 } |
149 | 149 |
| 150 |
| 151 RUNTIME_FUNCTION(Runtime_InterpreterForInPrepare) { |
| 152 HandleScope scope(isolate); |
| 153 DCHECK_EQ(2, args.length()); |
| 154 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); |
| 155 CONVERT_ARG_HANDLE_CHECKED(HeapObject, property_names, 1); |
| 156 |
| 157 Handle<Object> cache_type = property_names; |
| 158 Handle<Map> cache_type_map = handle(property_names->map(), isolate); |
| 159 Handle<Map> receiver_map = handle(receiver->map(), isolate); |
| 160 |
| 161 Handle<FixedArray> cache_array; |
| 162 int cache_length; |
| 163 |
| 164 if (cache_type_map.is_identical_to(isolate->factory()->meta_map())) { |
| 165 int enum_length = cache_type_map->EnumLength(); |
| 166 DescriptorArray* descriptors = receiver_map->instance_descriptors(); |
| 167 if (enum_length > 0 && descriptors->HasEnumCache()) { |
| 168 cache_array = handle(descriptors->GetEnumCache(), isolate); |
| 169 cache_length = cache_array->length(); |
| 170 } else { |
| 171 cache_array = isolate->factory()->empty_fixed_array(); |
| 172 cache_length = 0; |
| 173 } |
| 174 } else { |
| 175 cache_array = Handle<FixedArray>::cast(cache_type); |
| 176 cache_length = cache_array->length(); |
| 177 |
| 178 STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE); |
| 179 if (receiver_map->instance_type() <= LAST_JS_PROXY_TYPE) { |
| 180 DCHECK_GE(receiver_map->instance_type(), LAST_JS_PROXY_TYPE); |
| 181 // Zero indicates proxy |
| 182 cache_type = Handle<Object>(Smi::FromInt(0), isolate); |
| 183 } else { |
| 184 // One entails slow check |
| 185 cache_type = Handle<Object>(Smi::FromInt(1), isolate); |
| 186 } |
| 187 } |
| 188 |
| 189 Handle<FixedArray> result = isolate->factory()->NewFixedArray(4); |
| 190 result->set(0, *receiver); |
| 191 result->set(1, *cache_array); |
| 192 result->set(2, *cache_type); |
| 193 result->set(3, Smi::FromInt(cache_length)); |
| 194 return *result; |
| 195 } |
| 196 |
| 197 |
150 } // namespace internal | 198 } // namespace internal |
151 } // namespace v8 | 199 } // namespace v8 |
OLD | NEW |