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/isolate-inl.h" | 8 #include "src/isolate-inl.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 | 150 |
| 151 namespace { | |
| 152 | |
| 153 MaybeHandle<JSReceiver> ToObjectHelper(Object** args_object, Isolate* isolate) { | |
| 154 Object* o = Runtime_ToObject(1, args_object, isolate); | |
| 155 return MaybeHandle<JSReceiver>(handle(JSReceiver::cast(o), isolate)); | |
| 156 } | |
| 157 | |
| 158 | |
| 159 MaybeHandle<Object> GetPropertyNamesFastHelper(Object** args_object, | |
| 160 Isolate* isolate) { | |
| 161 Object* o = Runtime_GetPropertyNamesFast(1, args_object, isolate); | |
| 162 return MaybeHandle<Object>(handle(Object::cast(o), isolate)); | |
| 163 } | |
| 164 | |
| 165 } // namespace | |
| 166 | |
| 167 | |
| 151 RUNTIME_FUNCTION(Runtime_InterpreterForInPrepare) { | 168 RUNTIME_FUNCTION(Runtime_InterpreterForInPrepare) { |
| 152 HandleScope scope(isolate); | 169 HandleScope scope(isolate); |
| 153 DCHECK_EQ(2, args.length()); | 170 DCHECK_EQ(1, args.length()); |
| 154 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); | |
| 155 CONVERT_ARG_HANDLE_CHECKED(HeapObject, property_names, 1); | |
| 156 | 171 |
| 157 Handle<Object> cache_type = property_names; | 172 // Initialize return return triple such that cache_length is zero |
|
rmcilroy
2015/12/17 15:43:27
extra "return"
oth
2015/12/17 19:28:24
Done.
| |
| 158 Handle<Map> cache_type_map = handle(property_names->map(), isolate); | 173 // which'll coax ForInDone to quit on first attempt. |
|
rmcilroy
2015/12/17 15:43:27
s/first attempt/first attempt if this function ret
oth
2015/12/17 19:28:24
Done.
| |
| 174 Handle<FixedArray> result = isolate->factory()->NewFixedArray(4); | |
| 175 result->set(3, Smi::FromInt(0)); | |
| 176 | |
| 177 // Cast to accumulator | |
|
rmcilroy
2015/12/17 15:43:27
/a/accumulator/object
oth
2015/12/17 19:28:24
Done.
| |
| 178 Handle<JSReceiver> receiver; | |
| 179 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | |
| 180 isolate, receiver, ToObjectHelper(args.arguments(), isolate), *result); | |
| 181 | |
| 182 Handle<Object> cache_type; | |
| 183 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | |
| 184 isolate, cache_type, | |
| 185 GetPropertyNamesFastHelper(Handle<Object>::cast(receiver).location(), | |
| 186 isolate), | |
| 187 *result); | |
| 188 | |
| 159 Handle<Map> receiver_map = handle(receiver->map(), isolate); | 189 Handle<Map> receiver_map = handle(receiver->map(), isolate); |
| 160 | |
| 161 Handle<FixedArray> cache_array; | 190 Handle<FixedArray> cache_array; |
| 162 int cache_length; | 191 int cache_length; |
| 163 | 192 if (cache_type->IsMap()) { |
| 164 if (cache_type_map.is_identical_to(isolate->factory()->meta_map())) { | 193 Handle<Map> cache_type_map = |
| 194 handle(Handle<Map>::cast(cache_type)->map(), isolate); | |
| 195 DCHECK(cache_type_map.is_identical_to(isolate->factory()->meta_map())); | |
| 165 int enum_length = cache_type_map->EnumLength(); | 196 int enum_length = cache_type_map->EnumLength(); |
| 166 DescriptorArray* descriptors = receiver_map->instance_descriptors(); | 197 DescriptorArray* descriptors = receiver_map->instance_descriptors(); |
| 167 if (enum_length > 0 && descriptors->HasEnumCache()) { | 198 if (enum_length > 0 && descriptors->HasEnumCache()) { |
| 168 cache_array = handle(descriptors->GetEnumCache(), isolate); | 199 cache_array = handle(descriptors->GetEnumCache(), isolate); |
| 169 cache_length = cache_array->length(); | 200 cache_length = cache_array->length(); |
| 170 } else { | 201 } else { |
| 171 cache_array = isolate->factory()->empty_fixed_array(); | 202 cache_array = isolate->factory()->empty_fixed_array(); |
| 172 cache_length = 0; | 203 cache_length = 0; |
| 173 } | 204 } |
| 174 } else { | 205 } else { |
| 175 cache_array = Handle<FixedArray>::cast(cache_type); | 206 cache_array = Handle<FixedArray>::cast(cache_type); |
| 176 cache_length = cache_array->length(); | 207 cache_length = cache_array->length(); |
| 177 | 208 |
| 178 STATIC_ASSERT(JS_PROXY_TYPE == FIRST_JS_RECEIVER_TYPE); | 209 STATIC_ASSERT(JS_PROXY_TYPE == FIRST_JS_RECEIVER_TYPE); |
| 179 if (receiver_map->instance_type() == JS_PROXY_TYPE) { | 210 if (receiver_map->instance_type() == JS_PROXY_TYPE) { |
| 180 // Zero indicates proxy | 211 // Zero indicates proxy |
| 181 cache_type = Handle<Object>(Smi::FromInt(0), isolate); | 212 cache_type = Handle<Object>(Smi::FromInt(0), isolate); |
| 182 } else { | 213 } else { |
| 183 // One entails slow check | 214 // One entails slow check |
| 184 cache_type = Handle<Object>(Smi::FromInt(1), isolate); | 215 cache_type = Handle<Object>(Smi::FromInt(1), isolate); |
| 185 } | 216 } |
| 186 } | 217 } |
| 187 | 218 |
| 188 Handle<FixedArray> result = isolate->factory()->NewFixedArray(4); | |
| 189 result->set(0, *receiver); | 219 result->set(0, *receiver); |
| 190 result->set(1, *cache_array); | 220 result->set(1, *cache_type); |
| 191 result->set(2, *cache_type); | 221 result->set(2, *cache_array); |
| 192 result->set(3, Smi::FromInt(cache_length)); | 222 result->set(3, Smi::FromInt(cache_length)); |
| 193 return *result; | 223 return *result; |
| 194 } | 224 } |
| 195 | 225 |
| 196 | |
| 197 } // namespace internal | 226 } // namespace internal |
| 198 } // namespace v8 | 227 } // namespace v8 |
| OLD | NEW |