OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 2192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2203 for (intptr_t i = 0; i < arr.Length(); i++) { | 2203 for (intptr_t i = 0; i < arr.Length(); i++) { |
2204 entry ^= arr.At(i); | 2204 entry ^= arr.At(i); |
2205 if (function.raw() != entry.raw()) { | 2205 if (function.raw() != entry.raw()) { |
2206 AddFunction(entry); | 2206 AddFunction(entry); |
2207 } | 2207 } |
2208 } | 2208 } |
2209 } | 2209 } |
2210 | 2210 |
2211 | 2211 |
2212 intptr_t Class::FindFunctionIndex(const Function& needle) const { | 2212 intptr_t Class::FindFunctionIndex(const Function& needle) const { |
2213 Isolate* isolate = Isolate::Current(); | 2213 Thread* thread = Thread::Current(); |
2214 if (EnsureIsFinalized(isolate) != Error::null()) { | 2214 Isolate* isolate = thread->isolate(); |
| 2215 if (EnsureIsFinalized(thread) != Error::null()) { |
2215 return -1; | 2216 return -1; |
2216 } | 2217 } |
2217 REUSABLE_ARRAY_HANDLESCOPE(isolate); | 2218 REUSABLE_ARRAY_HANDLESCOPE(isolate); |
2218 REUSABLE_FUNCTION_HANDLESCOPE(isolate); | 2219 REUSABLE_FUNCTION_HANDLESCOPE(isolate); |
2219 Array& funcs = isolate->ArrayHandle(); | 2220 Array& funcs = isolate->ArrayHandle(); |
2220 Function& function = isolate->FunctionHandle(); | 2221 Function& function = isolate->FunctionHandle(); |
2221 funcs ^= functions(); | 2222 funcs ^= functions(); |
2222 ASSERT(!funcs.IsNull()); | 2223 ASSERT(!funcs.IsNull()); |
2223 const intptr_t len = funcs.Length(); | 2224 const intptr_t len = funcs.Length(); |
2224 for (intptr_t i = 0; i < len; i++) { | 2225 for (intptr_t i = 0; i < len; i++) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2256 return Function::null(); | 2257 return Function::null(); |
2257 } | 2258 } |
2258 const Function& closure_func = | 2259 const Function& closure_func = |
2259 Function::Handle(func.ImplicitClosureFunction()); | 2260 Function::Handle(func.ImplicitClosureFunction()); |
2260 ASSERT(!closure_func.IsNull()); | 2261 ASSERT(!closure_func.IsNull()); |
2261 return closure_func.raw(); | 2262 return closure_func.raw(); |
2262 } | 2263 } |
2263 | 2264 |
2264 | 2265 |
2265 intptr_t Class::FindImplicitClosureFunctionIndex(const Function& needle) const { | 2266 intptr_t Class::FindImplicitClosureFunctionIndex(const Function& needle) const { |
2266 Isolate* isolate = Isolate::Current(); | 2267 Thread* thread = Thread::Current(); |
2267 if (EnsureIsFinalized(isolate) != Error::null()) { | 2268 Isolate* isolate = thread->isolate(); |
| 2269 if (EnsureIsFinalized(thread) != Error::null()) { |
2268 return -1; | 2270 return -1; |
2269 } | 2271 } |
2270 REUSABLE_ARRAY_HANDLESCOPE(isolate); | 2272 REUSABLE_ARRAY_HANDLESCOPE(isolate); |
2271 REUSABLE_FUNCTION_HANDLESCOPE(isolate); | 2273 REUSABLE_FUNCTION_HANDLESCOPE(isolate); |
2272 Array& funcs = isolate->ArrayHandle(); | 2274 Array& funcs = isolate->ArrayHandle(); |
2273 Function& function = isolate->FunctionHandle(); | 2275 Function& function = isolate->FunctionHandle(); |
2274 funcs ^= functions(); | 2276 funcs ^= functions(); |
2275 ASSERT(!funcs.IsNull()); | 2277 ASSERT(!funcs.IsNull()); |
2276 Function& implicit_closure = Function::Handle(isolate); | 2278 Function& implicit_closure = Function::Handle(isolate); |
2277 const intptr_t len = funcs.Length(); | 2279 const intptr_t len = funcs.Length(); |
2278 for (intptr_t i = 0; i < len; i++) { | 2280 for (intptr_t i = 0; i < len; i++) { |
2279 function ^= funcs.At(i); | 2281 function ^= funcs.At(i); |
2280 implicit_closure ^= function.implicit_closure_function(); | 2282 implicit_closure ^= function.implicit_closure_function(); |
2281 if (implicit_closure.IsNull()) { | 2283 if (implicit_closure.IsNull()) { |
2282 // Skip non-implicit closure functions. | 2284 // Skip non-implicit closure functions. |
2283 continue; | 2285 continue; |
2284 } | 2286 } |
2285 if (needle.raw() == implicit_closure.raw()) { | 2287 if (needle.raw() == implicit_closure.raw()) { |
2286 return i; | 2288 return i; |
2287 } | 2289 } |
2288 } | 2290 } |
2289 // No function found. | 2291 // No function found. |
2290 return -1; | 2292 return -1; |
2291 } | 2293 } |
2292 | 2294 |
2293 | 2295 |
2294 | 2296 |
2295 intptr_t Class::FindInvocationDispatcherFunctionIndex( | 2297 intptr_t Class::FindInvocationDispatcherFunctionIndex( |
2296 const Function& needle) const { | 2298 const Function& needle) const { |
2297 Isolate* isolate = Isolate::Current(); | 2299 Thread* thread = Thread::Current(); |
2298 if (EnsureIsFinalized(isolate) != Error::null()) { | 2300 Isolate* isolate = thread->isolate(); |
| 2301 if (EnsureIsFinalized(thread) != Error::null()) { |
2299 return -1; | 2302 return -1; |
2300 } | 2303 } |
2301 REUSABLE_ARRAY_HANDLESCOPE(isolate); | 2304 REUSABLE_ARRAY_HANDLESCOPE(isolate); |
2302 REUSABLE_OBJECT_HANDLESCOPE(isolate); | 2305 REUSABLE_OBJECT_HANDLESCOPE(isolate); |
2303 Array& funcs = isolate->ArrayHandle(); | 2306 Array& funcs = isolate->ArrayHandle(); |
2304 Object& object = isolate->ObjectHandle(); | 2307 Object& object = isolate->ObjectHandle(); |
2305 funcs ^= invocation_dispatcher_cache(); | 2308 funcs ^= invocation_dispatcher_cache(); |
2306 ASSERT(!funcs.IsNull()); | 2309 ASSERT(!funcs.IsNull()); |
2307 const intptr_t len = funcs.Length(); | 2310 const intptr_t len = funcs.Length(); |
2308 for (intptr_t i = 0; i < len; i++) { | 2311 for (intptr_t i = 0; i < len; i++) { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2425 void Class::set_library(const Library& value) const { | 2428 void Class::set_library(const Library& value) const { |
2426 StorePointer(&raw_ptr()->library_, value.raw()); | 2429 StorePointer(&raw_ptr()->library_, value.raw()); |
2427 } | 2430 } |
2428 | 2431 |
2429 | 2432 |
2430 void Class::set_type_parameters(const TypeArguments& value) const { | 2433 void Class::set_type_parameters(const TypeArguments& value) const { |
2431 StorePointer(&raw_ptr()->type_parameters_, value.raw()); | 2434 StorePointer(&raw_ptr()->type_parameters_, value.raw()); |
2432 } | 2435 } |
2433 | 2436 |
2434 | 2437 |
2435 intptr_t Class::NumTypeParameters(Isolate* isolate) const { | 2438 intptr_t Class::NumTypeParameters(Thread* thread) const { |
2436 if (IsMixinApplication() && !is_mixin_type_applied()) { | 2439 if (IsMixinApplication() && !is_mixin_type_applied()) { |
2437 ClassFinalizer::ApplyMixinType(*this); | 2440 ClassFinalizer::ApplyMixinType(*this); |
2438 } | 2441 } |
2439 if (type_parameters() == TypeArguments::null()) { | 2442 if (type_parameters() == TypeArguments::null()) { |
2440 return 0; | 2443 return 0; |
2441 } | 2444 } |
| 2445 Isolate* isolate = thread->isolate(); |
2442 REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(isolate); | 2446 REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(isolate); |
2443 TypeArguments& type_params = isolate->TypeArgumentsHandle(); | 2447 TypeArguments& type_params = isolate->TypeArgumentsHandle(); |
2444 type_params = type_parameters(); | 2448 type_params = type_parameters(); |
2445 return type_params.Length(); | 2449 return type_params.Length(); |
2446 } | 2450 } |
2447 | 2451 |
2448 | 2452 |
2449 intptr_t Class::NumOwnTypeArguments() const { | 2453 intptr_t Class::NumOwnTypeArguments() const { |
2450 // Return cached value if already calculated. | 2454 // Return cached value if already calculated. |
2451 if (num_own_type_arguments() != kUnknownNumTypeArguments) { | 2455 if (num_own_type_arguments() != kUnknownNumTypeArguments) { |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3023 const Function& eval_func = | 3027 const Function& eval_func = |
3024 Function::Handle(EvaluateHelper(*this, expr, param_names, true)); | 3028 Function::Handle(EvaluateHelper(*this, expr, param_names, true)); |
3025 const Object& result = | 3029 const Object& result = |
3026 Object::Handle(DartEntry::InvokeFunction(eval_func, param_values)); | 3030 Object::Handle(DartEntry::InvokeFunction(eval_func, param_values)); |
3027 return result.raw(); | 3031 return result.raw(); |
3028 } | 3032 } |
3029 | 3033 |
3030 | 3034 |
3031 // Ensure that top level parsing of the class has been done. | 3035 // Ensure that top level parsing of the class has been done. |
3032 // TODO(24109): Migrate interface to Thread*. | 3036 // TODO(24109): Migrate interface to Thread*. |
3033 RawError* Class::EnsureIsFinalized(Isolate* isolate) const { | 3037 RawError* Class::EnsureIsFinalized(Thread* thread) const { |
3034 // Finalized classes have already been parsed. | 3038 // Finalized classes have already been parsed. |
3035 if (is_finalized()) { | 3039 if (is_finalized()) { |
3036 return Error::null(); | 3040 return Error::null(); |
3037 } | 3041 } |
3038 ASSERT(isolate != NULL); | 3042 ASSERT(thread != NULL); |
3039 const Error& error = Error::Handle(isolate, Compiler::CompileClass(*this)); | 3043 const Error& error = Error::Handle( |
| 3044 thread->zone(), Compiler::CompileClass(*this)); |
3040 if (!error.IsNull()) { | 3045 if (!error.IsNull()) { |
3041 ASSERT(isolate == Thread::Current()->isolate()); | 3046 ASSERT(thread == Thread::Current()); |
3042 if (Thread::Current()->long_jump_base() != NULL) { | 3047 if (thread->long_jump_base() != NULL) { |
3043 Report::LongJump(error); | 3048 Report::LongJump(error); |
3044 UNREACHABLE(); | 3049 UNREACHABLE(); |
3045 } | 3050 } |
3046 } | 3051 } |
3047 return error.raw(); | 3052 return error.raw(); |
3048 } | 3053 } |
3049 | 3054 |
3050 | 3055 |
3051 void Class::SetFields(const Array& value) const { | 3056 void Class::SetFields(const Array& value) const { |
3052 ASSERT(!value.IsNull()); | 3057 ASSERT(!value.IsNull()); |
(...skipping 27 matching lines...) Expand all Loading... |
3080 const Array& new_arr = Array::Handle( | 3085 const Array& new_arr = Array::Handle( |
3081 Array::Grow(arr, num_old_fields + num_new_fields, Heap::kOld)); | 3086 Array::Grow(arr, num_old_fields + num_new_fields, Heap::kOld)); |
3082 for (intptr_t i = 0; i < num_new_fields; i++) { | 3087 for (intptr_t i = 0; i < num_new_fields; i++) { |
3083 new_arr.SetAt(i + num_old_fields, *new_fields.At(i)); | 3088 new_arr.SetAt(i + num_old_fields, *new_fields.At(i)); |
3084 } | 3089 } |
3085 SetFields(new_arr); | 3090 SetFields(new_arr); |
3086 } | 3091 } |
3087 | 3092 |
3088 | 3093 |
3089 intptr_t Class::FindFieldIndex(const Field& needle) const { | 3094 intptr_t Class::FindFieldIndex(const Field& needle) const { |
3090 Isolate* isolate = Isolate::Current(); | 3095 Thread* thread = Thread::Current(); |
3091 if (EnsureIsFinalized(isolate) != Error::null()) { | 3096 Isolate* isolate = thread->isolate(); |
| 3097 if (EnsureIsFinalized(thread) != Error::null()) { |
3092 return -1; | 3098 return -1; |
3093 } | 3099 } |
3094 REUSABLE_ARRAY_HANDLESCOPE(isolate); | 3100 REUSABLE_ARRAY_HANDLESCOPE(isolate); |
3095 REUSABLE_FIELD_HANDLESCOPE(isolate); | 3101 REUSABLE_FIELD_HANDLESCOPE(isolate); |
3096 REUSABLE_STRING_HANDLESCOPE(isolate); | 3102 REUSABLE_STRING_HANDLESCOPE(isolate); |
3097 Array& fields_array = isolate->ArrayHandle(); | 3103 Array& fields_array = isolate->ArrayHandle(); |
3098 Field& field = isolate->FieldHandle(); | 3104 Field& field = isolate->FieldHandle(); |
3099 String& field_name = isolate->StringHandle(); | 3105 String& field_name = isolate->StringHandle(); |
3100 fields_array ^= fields(); | 3106 fields_array ^= fields(); |
3101 ASSERT(!fields_array.IsNull()); | 3107 ASSERT(!fields_array.IsNull()); |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3694 Array& types = Array::Handle(); | 3700 Array& types = Array::Handle(); |
3695 types ^= canonical_types(); | 3701 types ^= canonical_types(); |
3696 ASSERT(!types.IsNull() && (types.Length() > 1)); | 3702 ASSERT(!types.IsNull() && (types.Length() > 1)); |
3697 ASSERT((types.At(0) == Object::null()) || (types.At(0) == type.raw())); | 3703 ASSERT((types.At(0) == Object::null()) || (types.At(0) == type.raw())); |
3698 types.SetAt(0, type); | 3704 types.SetAt(0, type); |
3699 } | 3705 } |
3700 } | 3706 } |
3701 | 3707 |
3702 | 3708 |
3703 intptr_t Class::FindCanonicalTypeIndex(const Type& needle) const { | 3709 intptr_t Class::FindCanonicalTypeIndex(const Type& needle) const { |
3704 Isolate* isolate = Isolate::Current(); | 3710 Thread* thread = Thread::Current(); |
3705 if (EnsureIsFinalized(isolate) != Error::null()) { | 3711 Isolate* isolate = thread->isolate(); |
| 3712 if (EnsureIsFinalized(thread) != Error::null()) { |
3706 return -1; | 3713 return -1; |
3707 } | 3714 } |
3708 if (needle.raw() == CanonicalType()) { | 3715 if (needle.raw() == CanonicalType()) { |
3709 // For a generic type or signature type, there exists another index with the | 3716 // For a generic type or signature type, there exists another index with the |
3710 // same type. It will never be returned by this function. | 3717 // same type. It will never be returned by this function. |
3711 return 0; | 3718 return 0; |
3712 } | 3719 } |
3713 REUSABLE_OBJECT_HANDLESCOPE(isolate); | 3720 REUSABLE_OBJECT_HANDLESCOPE(isolate); |
3714 Object& types = isolate->ObjectHandle(); | 3721 Object& types = isolate->ObjectHandle(); |
3715 types = canonical_types(); | 3722 types = canonical_types(); |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4091 return func.raw(); | 4098 return func.raw(); |
4092 } | 4099 } |
4093 } else if (kind == kAny) { | 4100 } else if (kind == kAny) { |
4094 return func.raw(); | 4101 return func.raw(); |
4095 } | 4102 } |
4096 return Function::null(); | 4103 return Function::null(); |
4097 } | 4104 } |
4098 | 4105 |
4099 | 4106 |
4100 RawFunction* Class::LookupFunction(const String& name, MemberKind kind) const { | 4107 RawFunction* Class::LookupFunction(const String& name, MemberKind kind) const { |
4101 Isolate* isolate = Isolate::Current(); | 4108 Thread* thread = Thread::Current(); |
4102 if (EnsureIsFinalized(isolate) != Error::null()) { | 4109 Isolate* isolate = thread->isolate(); |
| 4110 if (EnsureIsFinalized(thread) != Error::null()) { |
4103 return Function::null(); | 4111 return Function::null(); |
4104 } | 4112 } |
4105 REUSABLE_ARRAY_HANDLESCOPE(isolate); | 4113 REUSABLE_ARRAY_HANDLESCOPE(isolate); |
4106 REUSABLE_FUNCTION_HANDLESCOPE(isolate); | 4114 REUSABLE_FUNCTION_HANDLESCOPE(isolate); |
4107 Array& funcs = isolate->ArrayHandle(); | 4115 Array& funcs = isolate->ArrayHandle(); |
4108 funcs ^= functions(); | 4116 funcs ^= functions(); |
4109 ASSERT(!funcs.IsNull()); | 4117 ASSERT(!funcs.IsNull()); |
4110 const intptr_t len = funcs.Length(); | 4118 const intptr_t len = funcs.Length(); |
4111 Function& function = isolate->FunctionHandle(); | 4119 Function& function = isolate->FunctionHandle(); |
4112 if (len >= kFunctionLookupHashTreshold) { | 4120 if (len >= kFunctionLookupHashTreshold) { |
(...skipping 25 matching lines...) Expand all Loading... |
4138 } | 4146 } |
4139 } | 4147 } |
4140 } | 4148 } |
4141 // No function found. | 4149 // No function found. |
4142 return Function::null(); | 4150 return Function::null(); |
4143 } | 4151 } |
4144 | 4152 |
4145 | 4153 |
4146 RawFunction* Class::LookupFunctionAllowPrivate(const String& name, | 4154 RawFunction* Class::LookupFunctionAllowPrivate(const String& name, |
4147 MemberKind kind) const { | 4155 MemberKind kind) const { |
4148 Isolate* isolate = Isolate::Current(); | 4156 Thread* thread = Thread::Current(); |
4149 if (EnsureIsFinalized(isolate) != Error::null()) { | 4157 Isolate* isolate = thread->isolate(); |
| 4158 if (EnsureIsFinalized(thread) != Error::null()) { |
4150 return Function::null(); | 4159 return Function::null(); |
4151 } | 4160 } |
4152 REUSABLE_ARRAY_HANDLESCOPE(isolate); | 4161 REUSABLE_ARRAY_HANDLESCOPE(isolate); |
4153 REUSABLE_FUNCTION_HANDLESCOPE(isolate); | 4162 REUSABLE_FUNCTION_HANDLESCOPE(isolate); |
4154 REUSABLE_STRING_HANDLESCOPE(isolate); | 4163 REUSABLE_STRING_HANDLESCOPE(isolate); |
4155 Array& funcs = isolate->ArrayHandle(); | 4164 Array& funcs = isolate->ArrayHandle(); |
4156 funcs ^= functions(); | 4165 funcs ^= functions(); |
4157 ASSERT(!funcs.IsNull()); | 4166 ASSERT(!funcs.IsNull()); |
4158 const intptr_t len = funcs.Length(); | 4167 const intptr_t len = funcs.Length(); |
4159 Function& function = isolate->FunctionHandle(); | 4168 Function& function = isolate->FunctionHandle(); |
(...skipping 16 matching lines...) Expand all Loading... |
4176 | 4185 |
4177 | 4186 |
4178 RawFunction* Class::LookupSetterFunction(const String& name) const { | 4187 RawFunction* Class::LookupSetterFunction(const String& name) const { |
4179 return LookupAccessorFunction(kSetterPrefix, kSetterPrefixLength, name); | 4188 return LookupAccessorFunction(kSetterPrefix, kSetterPrefixLength, name); |
4180 } | 4189 } |
4181 | 4190 |
4182 | 4191 |
4183 RawFunction* Class::LookupAccessorFunction(const char* prefix, | 4192 RawFunction* Class::LookupAccessorFunction(const char* prefix, |
4184 intptr_t prefix_length, | 4193 intptr_t prefix_length, |
4185 const String& name) const { | 4194 const String& name) const { |
4186 Isolate* isolate = Isolate::Current(); | 4195 Thread* thread = Thread::Current(); |
4187 if (EnsureIsFinalized(isolate) != Error::null()) { | 4196 Isolate* isolate = thread->isolate(); |
| 4197 if (EnsureIsFinalized(thread) != Error::null()) { |
4188 return Function::null(); | 4198 return Function::null(); |
4189 } | 4199 } |
4190 REUSABLE_ARRAY_HANDLESCOPE(isolate); | 4200 REUSABLE_ARRAY_HANDLESCOPE(isolate); |
4191 REUSABLE_FUNCTION_HANDLESCOPE(isolate); | 4201 REUSABLE_FUNCTION_HANDLESCOPE(isolate); |
4192 REUSABLE_STRING_HANDLESCOPE(isolate); | 4202 REUSABLE_STRING_HANDLESCOPE(isolate); |
4193 Array& funcs = isolate->ArrayHandle(); | 4203 Array& funcs = isolate->ArrayHandle(); |
4194 funcs ^= functions(); | 4204 funcs ^= functions(); |
4195 intptr_t len = funcs.Length(); | 4205 intptr_t len = funcs.Length(); |
4196 Function& function = isolate->FunctionHandle(); | 4206 Function& function = isolate->FunctionHandle(); |
4197 String& function_name = isolate->StringHandle(); | 4207 String& function_name = isolate->StringHandle(); |
4198 for (intptr_t i = 0; i < len; i++) { | 4208 for (intptr_t i = 0; i < len; i++) { |
4199 function ^= funcs.At(i); | 4209 function ^= funcs.At(i); |
4200 function_name ^= function.name(); | 4210 function_name ^= function.name(); |
4201 if (MatchesAccessorName(function_name, prefix, prefix_length, name)) { | 4211 if (MatchesAccessorName(function_name, prefix, prefix_length, name)) { |
4202 return function.raw(); | 4212 return function.raw(); |
4203 } | 4213 } |
4204 } | 4214 } |
4205 | 4215 |
4206 // No function found. | 4216 // No function found. |
4207 return Function::null(); | 4217 return Function::null(); |
4208 } | 4218 } |
4209 | 4219 |
4210 | 4220 |
4211 RawFunction* Class::LookupFunctionAtToken(intptr_t token_pos) const { | 4221 RawFunction* Class::LookupFunctionAtToken(intptr_t token_pos) const { |
4212 // TODO(hausner): we can shortcut the negative case if we knew the | 4222 // TODO(hausner): we can shortcut the negative case if we knew the |
4213 // beginning and end token position of the class. | 4223 // beginning and end token position of the class. |
4214 Isolate* isolate = Isolate::Current(); | 4224 Thread* thread = Thread::Current(); |
4215 if (EnsureIsFinalized(isolate) != Error::null()) { | 4225 Isolate* isolate = thread->isolate(); |
| 4226 if (EnsureIsFinalized(thread) != Error::null()) { |
4216 return Function::null(); | 4227 return Function::null(); |
4217 } | 4228 } |
4218 Function& func = Function::Handle(isolate); | 4229 Function& func = Function::Handle(isolate); |
4219 func = LookupClosureFunction(token_pos); | 4230 func = LookupClosureFunction(token_pos); |
4220 if (!func.IsNull()) { | 4231 if (!func.IsNull()) { |
4221 return func.raw(); | 4232 return func.raw(); |
4222 } | 4233 } |
4223 Array& funcs = Array::Handle(isolate, functions()); | 4234 Array& funcs = Array::Handle(isolate, functions()); |
4224 intptr_t len = funcs.Length(); | 4235 intptr_t len = funcs.Length(); |
4225 for (intptr_t i = 0; i < len; i++) { | 4236 for (intptr_t i = 0; i < len; i++) { |
(...skipping 17 matching lines...) Expand all Loading... |
4243 return LookupField(name, kStatic); | 4254 return LookupField(name, kStatic); |
4244 } | 4255 } |
4245 | 4256 |
4246 | 4257 |
4247 RawField* Class::LookupField(const String& name) const { | 4258 RawField* Class::LookupField(const String& name) const { |
4248 return LookupField(name, kAny); | 4259 return LookupField(name, kAny); |
4249 } | 4260 } |
4250 | 4261 |
4251 | 4262 |
4252 RawField* Class::LookupField(const String& name, MemberKind kind) const { | 4263 RawField* Class::LookupField(const String& name, MemberKind kind) const { |
4253 Isolate* isolate = Isolate::Current(); | 4264 Thread* thread = Thread::Current(); |
4254 if (EnsureIsFinalized(isolate) != Error::null()) { | 4265 Isolate* isolate = thread->isolate(); |
| 4266 if (EnsureIsFinalized(thread) != Error::null()) { |
4255 return Field::null(); | 4267 return Field::null(); |
4256 } | 4268 } |
4257 REUSABLE_ARRAY_HANDLESCOPE(isolate); | 4269 REUSABLE_ARRAY_HANDLESCOPE(isolate); |
4258 REUSABLE_FIELD_HANDLESCOPE(isolate); | 4270 REUSABLE_FIELD_HANDLESCOPE(isolate); |
4259 REUSABLE_STRING_HANDLESCOPE(isolate); | 4271 REUSABLE_STRING_HANDLESCOPE(isolate); |
4260 Array& flds = isolate->ArrayHandle(); | 4272 Array& flds = isolate->ArrayHandle(); |
4261 flds ^= fields(); | 4273 flds ^= fields(); |
4262 ASSERT(!flds.IsNull()); | 4274 ASSERT(!flds.IsNull()); |
4263 intptr_t len = flds.Length(); | 4275 intptr_t len = flds.Length(); |
4264 Field& field = isolate->FieldHandle(); | 4276 Field& field = isolate->FieldHandle(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4317 } | 4329 } |
4318 AddCommonObjectProperties(&jsobj, "Class", ref); | 4330 AddCommonObjectProperties(&jsobj, "Class", ref); |
4319 jsobj.AddFixedServiceId("classes/%" Pd "", id()); | 4331 jsobj.AddFixedServiceId("classes/%" Pd "", id()); |
4320 const String& user_name = String::Handle(PrettyName()); | 4332 const String& user_name = String::Handle(PrettyName()); |
4321 const String& vm_name = String::Handle(Name()); | 4333 const String& vm_name = String::Handle(Name()); |
4322 AddNameProperties(&jsobj, user_name, vm_name); | 4334 AddNameProperties(&jsobj, user_name, vm_name); |
4323 if (ref) { | 4335 if (ref) { |
4324 return; | 4336 return; |
4325 } | 4337 } |
4326 | 4338 |
4327 const Error& err = Error::Handle(EnsureIsFinalized(Isolate::Current())); | 4339 const Error& err = Error::Handle(EnsureIsFinalized(Thread::Current())); |
4328 if (!err.IsNull()) { | 4340 if (!err.IsNull()) { |
4329 jsobj.AddProperty("error", err); | 4341 jsobj.AddProperty("error", err); |
4330 } | 4342 } |
4331 jsobj.AddProperty("abstract", is_abstract()); | 4343 jsobj.AddProperty("abstract", is_abstract()); |
4332 jsobj.AddProperty("const", is_const()); | 4344 jsobj.AddProperty("const", is_const()); |
4333 jsobj.AddProperty("_finalized", is_finalized()); | 4345 jsobj.AddProperty("_finalized", is_finalized()); |
4334 jsobj.AddProperty("_implemented", is_implemented()); | 4346 jsobj.AddProperty("_implemented", is_implemented()); |
4335 jsobj.AddProperty("_patch", is_patch()); | 4347 jsobj.AddProperty("_patch", is_patch()); |
4336 jsobj.AddProperty("_traceAllocations", TraceAllocation(isolate)); | 4348 jsobj.AddProperty("_traceAllocations", TraceAllocation(isolate)); |
4337 const Class& superClass = Class::Handle(SuperClass()); | 4349 const Class& superClass = Class::Handle(SuperClass()); |
(...skipping 2784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7122 // id ring. Current known examples are signature functions of closures | 7134 // id ring. Current known examples are signature functions of closures |
7123 // and stubs like 'megamorphic_miss'. | 7135 // and stubs like 'megamorphic_miss'. |
7124 jsobj.AddServiceId(f); | 7136 jsobj.AddServiceId(f); |
7125 } | 7137 } |
7126 | 7138 |
7127 | 7139 |
7128 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const { | 7140 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const { |
7129 Class& cls = Class::Handle(Owner()); | 7141 Class& cls = Class::Handle(Owner()); |
7130 ASSERT(!cls.IsNull()); | 7142 ASSERT(!cls.IsNull()); |
7131 Error& err = Error::Handle(); | 7143 Error& err = Error::Handle(); |
7132 err ^= cls.EnsureIsFinalized(Isolate::Current()); | 7144 err ^= cls.EnsureIsFinalized(Thread::Current()); |
7133 ASSERT(err.IsNull()); | 7145 ASSERT(err.IsNull()); |
7134 JSONObject jsobj(stream); | 7146 JSONObject jsobj(stream); |
7135 AddCommonObjectProperties(&jsobj, "Function", ref); | 7147 AddCommonObjectProperties(&jsobj, "Function", ref); |
7136 AddFunctionServiceId(jsobj, *this, cls); | 7148 AddFunctionServiceId(jsobj, *this, cls); |
7137 const String& user_name = String::Handle(PrettyName()); | 7149 const String& user_name = String::Handle(PrettyName()); |
7138 const String& vm_name = String::Handle(name()); | 7150 const String& vm_name = String::Handle(name()); |
7139 AddNameProperties(&jsobj, user_name, vm_name); | 7151 AddNameProperties(&jsobj, user_name, vm_name); |
7140 const Function& parent = Function::Handle(parent_function()); | 7152 const Function& parent = Function::Handle(parent_function()); |
7141 if (!parent.IsNull()) { | 7153 if (!parent.IsNull()) { |
7142 jsobj.AddProperty("owner", parent); | 7154 jsobj.AddProperty("owner", parent); |
(...skipping 3702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10845 Error& error = Error::Handle(); | 10857 Error& error = Error::Handle(); |
10846 const GrowableObjectArray& libs = GrowableObjectArray::Handle( | 10858 const GrowableObjectArray& libs = GrowableObjectArray::Handle( |
10847 Isolate::Current()->object_store()->libraries()); | 10859 Isolate::Current()->object_store()->libraries()); |
10848 Library& lib = Library::Handle(); | 10860 Library& lib = Library::Handle(); |
10849 Class& cls = Class::Handle(); | 10861 Class& cls = Class::Handle(); |
10850 for (int i = 0; i < libs.Length(); i++) { | 10862 for (int i = 0; i < libs.Length(); i++) { |
10851 lib ^= libs.At(i); | 10863 lib ^= libs.At(i); |
10852 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate); | 10864 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate); |
10853 while (it.HasNext()) { | 10865 while (it.HasNext()) { |
10854 cls = it.GetNextClass(); | 10866 cls = it.GetNextClass(); |
10855 error = cls.EnsureIsFinalized(Isolate::Current()); | 10867 error = cls.EnsureIsFinalized(Thread::Current()); |
10856 if (!error.IsNull()) { | 10868 if (!error.IsNull()) { |
10857 return error.raw(); | 10869 return error.raw(); |
10858 } | 10870 } |
10859 error = Compiler::CompileAllFunctions(cls); | 10871 error = Compiler::CompileAllFunctions(cls); |
10860 if (!error.IsNull()) { | 10872 if (!error.IsNull()) { |
10861 return error.raw(); | 10873 return error.raw(); |
10862 } | 10874 } |
10863 } | 10875 } |
10864 } | 10876 } |
10865 return error.raw(); | 10877 return error.raw(); |
(...skipping 3793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14659 } | 14671 } |
14660 return true; | 14672 return true; |
14661 } | 14673 } |
14662 cls = cls.SuperClass(); | 14674 cls = cls.SuperClass(); |
14663 } while (!cls.IsNull()); | 14675 } while (!cls.IsNull()); |
14664 return false; | 14676 return false; |
14665 } | 14677 } |
14666 | 14678 |
14667 | 14679 |
14668 RawInstance* Instance::New(const Class& cls, Heap::Space space) { | 14680 RawInstance* Instance::New(const Class& cls, Heap::Space space) { |
14669 Isolate* isolate = Isolate::Current(); | 14681 Thread* thread = Thread::Current(); |
14670 if (cls.EnsureIsFinalized(isolate) != Error::null()) { | 14682 if (cls.EnsureIsFinalized(thread) != Error::null()) { |
14671 return Instance::null(); | 14683 return Instance::null(); |
14672 } | 14684 } |
14673 intptr_t instance_size = cls.instance_size(); | 14685 intptr_t instance_size = cls.instance_size(); |
14674 ASSERT(instance_size > 0); | 14686 ASSERT(instance_size > 0); |
14675 RawObject* raw = Object::Allocate(cls.id(), instance_size, space); | 14687 RawObject* raw = Object::Allocate(cls.id(), instance_size, space); |
14676 return reinterpret_cast<RawInstance*>(raw); | 14688 return reinterpret_cast<RawInstance*>(raw); |
14677 } | 14689 } |
14678 | 14690 |
14679 | 14691 |
14680 bool Instance::IsValidFieldOffset(intptr_t offset) const { | 14692 bool Instance::IsValidFieldOffset(intptr_t offset) const { |
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15640 } | 15652 } |
15641 if (type_class() != other_type.type_class()) { | 15653 if (type_class() != other_type.type_class()) { |
15642 return false; | 15654 return false; |
15643 } | 15655 } |
15644 if (!IsFinalized() || !other_type.IsFinalized()) { | 15656 if (!IsFinalized() || !other_type.IsFinalized()) { |
15645 return false; | 15657 return false; |
15646 } | 15658 } |
15647 if (arguments() == other_type.arguments()) { | 15659 if (arguments() == other_type.arguments()) { |
15648 return true; | 15660 return true; |
15649 } | 15661 } |
15650 Isolate* isolate = Isolate::Current(); | 15662 Thread* thread = Thread::Current(); |
15651 const Class& cls = Class::Handle(isolate, type_class()); | 15663 Zone* zone = thread->zone(); |
15652 const intptr_t num_type_params = cls.NumTypeParameters(isolate); | 15664 const Class& cls = Class::Handle(zone, type_class()); |
| 15665 const intptr_t num_type_params = cls.NumTypeParameters(thread); |
15653 if (num_type_params == 0) { | 15666 if (num_type_params == 0) { |
15654 // Shortcut unnecessary handle allocation below. | 15667 // Shortcut unnecessary handle allocation below. |
15655 return true; | 15668 return true; |
15656 } | 15669 } |
15657 const intptr_t num_type_args = cls.NumTypeArguments(); | 15670 const intptr_t num_type_args = cls.NumTypeArguments(); |
15658 const intptr_t from_index = num_type_args - num_type_params; | 15671 const intptr_t from_index = num_type_args - num_type_params; |
15659 const TypeArguments& type_args = TypeArguments::Handle(isolate, arguments()); | 15672 const TypeArguments& type_args = TypeArguments::Handle(zone, arguments()); |
15660 const TypeArguments& other_type_args = TypeArguments::Handle( | 15673 const TypeArguments& other_type_args = TypeArguments::Handle( |
15661 isolate, other_type.arguments()); | 15674 zone, other_type.arguments()); |
15662 if (type_args.IsNull()) { | 15675 if (type_args.IsNull()) { |
15663 // Ignore from_index. | 15676 // Ignore from_index. |
15664 return other_type_args.IsRaw(0, num_type_args); | 15677 return other_type_args.IsRaw(0, num_type_args); |
15665 } | 15678 } |
15666 if (other_type_args.IsNull()) { | 15679 if (other_type_args.IsNull()) { |
15667 // Ignore from_index. | 15680 // Ignore from_index. |
15668 return type_args.IsRaw(0, num_type_args); | 15681 return type_args.IsRaw(0, num_type_args); |
15669 } | 15682 } |
15670 if (!type_args.IsSubvectorEquivalent(other_type_args, | 15683 if (!type_args.IsSubvectorEquivalent(other_type_args, |
15671 from_index, | 15684 from_index, |
15672 num_type_params)) { | 15685 num_type_params)) { |
15673 return false; | 15686 return false; |
15674 } | 15687 } |
15675 #ifdef DEBUG | 15688 #ifdef DEBUG |
15676 if (from_index > 0) { | 15689 if (from_index > 0) { |
15677 // Verify that the type arguments of the super class match, since they | 15690 // Verify that the type arguments of the super class match, since they |
15678 // depend solely on the type parameters that were just verified to match. | 15691 // depend solely on the type parameters that were just verified to match. |
15679 ASSERT(type_args.Length() >= (from_index + num_type_params)); | 15692 ASSERT(type_args.Length() >= (from_index + num_type_params)); |
15680 ASSERT(other_type_args.Length() >= (from_index + num_type_params)); | 15693 ASSERT(other_type_args.Length() >= (from_index + num_type_params)); |
15681 AbstractType& type_arg = AbstractType::Handle(isolate); | 15694 AbstractType& type_arg = AbstractType::Handle(zone); |
15682 AbstractType& other_type_arg = AbstractType::Handle(isolate); | 15695 AbstractType& other_type_arg = AbstractType::Handle(zone); |
15683 for (intptr_t i = 0; i < from_index; i++) { | 15696 for (intptr_t i = 0; i < from_index; i++) { |
15684 type_arg = type_args.TypeAt(i); | 15697 type_arg = type_args.TypeAt(i); |
15685 other_type_arg = other_type_args.TypeAt(i); | 15698 other_type_arg = other_type_args.TypeAt(i); |
15686 ASSERT(type_arg.IsEquivalent(other_type_arg, trail)); | 15699 ASSERT(type_arg.IsEquivalent(other_type_arg, trail)); |
15687 } | 15700 } |
15688 } | 15701 } |
15689 #endif | 15702 #endif |
15690 return true; | 15703 return true; |
15691 } | 15704 } |
15692 | 15705 |
(...skipping 5798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21491 return tag_label.ToCString(); | 21504 return tag_label.ToCString(); |
21492 } | 21505 } |
21493 | 21506 |
21494 | 21507 |
21495 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21508 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
21496 Instance::PrintJSONImpl(stream, ref); | 21509 Instance::PrintJSONImpl(stream, ref); |
21497 } | 21510 } |
21498 | 21511 |
21499 | 21512 |
21500 } // namespace dart | 21513 } // namespace dart |
OLD | NEW |