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