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 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 namespace { | |
| 152 | |
| 153 HeapObject* GetPropertyNamesFast(Handle<JSReceiver> raw_object, | |
| 154 Isolate* isolate) { | |
| 155 // REVIEW(oth): should we be calling the existing runtime method | |
| 156 // rather than re-implementing here. | |
| 157 SealHandleScope shs(isolate); | |
| 158 | |
| 159 if (raw_object->IsSimpleEnum()) return raw_object->map(); | |
| 160 | |
| 161 HandleScope scope(isolate); | |
| 162 Handle<FixedArray> content; | |
| 163 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | |
| 164 isolate, content, | |
| 165 JSReceiver::GetKeys(raw_object, JSReceiver::INCLUDE_PROTOS)); | |
| 166 | |
| 167 // Test again, since cache may have been built by preceding call. | |
| 168 if (raw_object->IsSimpleEnum()) return raw_object->map(); | |
| 169 | |
| 170 return *content; | |
| 171 } | |
| 172 | |
| 173 } // namespace | |
| 174 | |
| 175 | |
| 176 RUNTIME_FUNCTION(Runtime_InterpreterForInPrepare) { | |
|
Benedikt Meurer
2015/10/26 12:17:37
Is this is a temporary thing? Because this runtime
oth
2015/10/28 11:53:12
Yes, good points - I was not thinking about this.
Benedikt Meurer
2015/10/28 12:03:31
Ack. Thanks.
| |
| 177 HandleScope scope(isolate); | |
| 178 DCHECK_EQ(1, args.length()); | |
| 179 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | |
| 180 | |
| 181 // First check if object is null or undefined. | |
| 182 if (object->IsNull() || object->IsUndefined()) { | |
| 183 return isolate->heap()->undefined_value(); | |
| 184 } | |
| 185 | |
| 186 Handle<JSReceiver> receiver; | |
| 187 if (!JSReceiver::ToObject(isolate, object).ToHandle(&receiver)) { | |
| 188 return isolate->heap()->undefined_value(); | |
| 189 } | |
| 190 | |
| 191 Handle<Object> cache_type = | |
| 192 handle(GetPropertyNamesFast(receiver, isolate), isolate); | |
| 193 Handle<Map> cache_type_map = | |
| 194 handle(Handle<HeapObject>::cast(cache_type)->map(), isolate); | |
| 195 Handle<Map> receiver_map = handle(receiver->map(), isolate); | |
| 196 | |
| 197 Handle<FixedArray> cache_array; | |
| 198 int cache_length; | |
| 199 | |
| 200 if (cache_type_map.is_identical_to(isolate->factory()->meta_map())) { | |
| 201 cache_length = cache_type_map->EnumLength(); | |
| 202 if (cache_length > 0) { | |
| 203 DescriptorArray* descriptors = receiver_map->instance_descriptors(); | |
| 204 cache_array = handle(descriptors->GetEnumCache(), isolate); | |
| 205 } else { | |
| 206 cache_array = isolate->factory()->empty_fixed_array(); | |
| 207 } | |
| 208 } else { | |
| 209 cache_array = Handle<FixedArray>::cast(cache_type); | |
| 210 cache_length = cache_array->length(); | |
| 211 | |
| 212 STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE); | |
| 213 if (receiver_map->instance_type() <= LAST_JS_PROXY_TYPE) { | |
| 214 DCHECK_GE(receiver_map->instance_type(), LAST_JS_PROXY_TYPE); | |
| 215 // Zero indicates proxy | |
| 216 cache_type = Handle<Object>(Smi::FromInt(0), isolate); | |
| 217 } else { | |
| 218 // One entails slow check | |
| 219 cache_type = Handle<Object>(Smi::FromInt(1), isolate); | |
| 220 } | |
| 221 } | |
| 222 | |
| 223 Handle<FixedArray> result = isolate->factory()->NewFixedArray(4); | |
| 224 result->set(0, *receiver); | |
| 225 result->set(1, *cache_array); | |
| 226 result->set(2, *cache_type); | |
| 227 result->set(3, Smi::FromInt(cache_length)); | |
| 228 return *result; | |
| 229 } | |
| 230 | |
| 231 | |
| 150 } // namespace internal | 232 } // namespace internal |
| 151 } // namespace v8 | 233 } // namespace v8 |
| OLD | NEW |