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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 150 |
151 RUNTIME_FUNCTION(Runtime_InterpreterForInPrepare) { | 151 RUNTIME_FUNCTION(Runtime_InterpreterForInPrepare) { |
152 HandleScope scope(isolate); | 152 HandleScope scope(isolate); |
153 DCHECK_EQ(2, args.length()); | 153 DCHECK_EQ(1, args.length()); |
154 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); | 154 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); |
155 CONVERT_ARG_HANDLE_CHECKED(HeapObject, property_names, 1); | |
156 | 155 |
157 Handle<Object> cache_type = property_names; | 156 Object* property_names = Runtime_GetPropertyNamesFast( |
158 Handle<Map> cache_type_map = handle(property_names->map(), isolate); | 157 1, Handle<Object>::cast(receiver).location(), isolate); |
159 Handle<Map> receiver_map = handle(receiver->map(), isolate); | 158 if (isolate->has_pending_exception()) { |
| 159 return property_names; |
| 160 } |
160 | 161 |
| 162 Handle<Object> cache_type(property_names, isolate); |
161 Handle<FixedArray> cache_array; | 163 Handle<FixedArray> cache_array; |
162 int cache_length; | 164 int cache_length; |
163 | 165 |
164 if (cache_type_map.is_identical_to(isolate->factory()->meta_map())) { | 166 Handle<Map> receiver_map = handle(receiver->map(), isolate); |
| 167 if (cache_type->IsMap()) { |
| 168 Handle<Map> cache_type_map = |
| 169 handle(Handle<Map>::cast(cache_type)->map(), isolate); |
| 170 DCHECK(cache_type_map.is_identical_to(isolate->factory()->meta_map())); |
165 int enum_length = cache_type_map->EnumLength(); | 171 int enum_length = cache_type_map->EnumLength(); |
166 DescriptorArray* descriptors = receiver_map->instance_descriptors(); | 172 DescriptorArray* descriptors = receiver_map->instance_descriptors(); |
167 if (enum_length > 0 && descriptors->HasEnumCache()) { | 173 if (enum_length > 0 && descriptors->HasEnumCache()) { |
168 cache_array = handle(descriptors->GetEnumCache(), isolate); | 174 cache_array = handle(descriptors->GetEnumCache(), isolate); |
169 cache_length = cache_array->length(); | 175 cache_length = cache_array->length(); |
170 } else { | 176 } else { |
171 cache_array = isolate->factory()->empty_fixed_array(); | 177 cache_array = isolate->factory()->empty_fixed_array(); |
172 cache_length = 0; | 178 cache_length = 0; |
173 } | 179 } |
174 } else { | 180 } else { |
175 cache_array = Handle<FixedArray>::cast(cache_type); | 181 cache_array = Handle<FixedArray>::cast(cache_type); |
176 cache_length = cache_array->length(); | 182 cache_length = cache_array->length(); |
177 | 183 |
178 STATIC_ASSERT(JS_PROXY_TYPE == FIRST_JS_RECEIVER_TYPE); | 184 STATIC_ASSERT(JS_PROXY_TYPE == FIRST_JS_RECEIVER_TYPE); |
179 if (receiver_map->instance_type() == JS_PROXY_TYPE) { | 185 if (receiver_map->instance_type() == JS_PROXY_TYPE) { |
180 // Zero indicates proxy | 186 // Zero indicates proxy |
181 cache_type = Handle<Object>(Smi::FromInt(0), isolate); | 187 cache_type = Handle<Object>(Smi::FromInt(0), isolate); |
182 } else { | 188 } else { |
183 // One entails slow check | 189 // One entails slow check |
184 cache_type = Handle<Object>(Smi::FromInt(1), isolate); | 190 cache_type = Handle<Object>(Smi::FromInt(1), isolate); |
185 } | 191 } |
186 } | 192 } |
187 | 193 |
188 Handle<FixedArray> result = isolate->factory()->NewFixedArray(4); | 194 Handle<FixedArray> result = isolate->factory()->NewFixedArray(3); |
189 result->set(0, *receiver); | 195 result->set(0, *cache_type); |
190 result->set(1, *cache_array); | 196 result->set(1, *cache_array); |
191 result->set(2, *cache_type); | 197 result->set(2, Smi::FromInt(cache_length)); |
192 result->set(3, Smi::FromInt(cache_length)); | |
193 return *result; | 198 return *result; |
194 } | 199 } |
195 | 200 |
196 | |
197 } // namespace internal | 201 } // namespace internal |
198 } // namespace v8 | 202 } // namespace v8 |
OLD | NEW |