| 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/globals.h" // Needed here to get TARGET_ARCH_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/code_generator.h" | 8 #include "vm/code_generator.h" |
| 9 | 9 |
| 10 #include "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 2274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2285 __ popq(CTX); | 2285 __ popq(CTX); |
| 2286 // Result is in RAX. | 2286 // Result is in RAX. |
| 2287 if (IsResultNeeded(node)) { | 2287 if (IsResultNeeded(node)) { |
| 2288 __ pushq(RAX); | 2288 __ pushq(RAX); |
| 2289 } | 2289 } |
| 2290 } | 2290 } |
| 2291 | 2291 |
| 2292 | 2292 |
| 2293 // Pushes the type arguments of the instantiator on the stack. | 2293 // Pushes the type arguments of the instantiator on the stack. |
| 2294 void CodeGenerator::GenerateInstantiatorTypeArguments(intptr_t token_index) { | 2294 void CodeGenerator::GenerateInstantiatorTypeArguments(intptr_t token_index) { |
| 2295 Class& instantiator_class = Class::Handle(); | 2295 const Class& instantiator_class = Class::Handle( |
| 2296 Function& outer_function = | 2296 parsed_function().function().owner()); |
| 2297 Function::Handle(parsed_function().function().raw()); | |
| 2298 while (outer_function.IsLocalFunction()) { | |
| 2299 outer_function = outer_function.parent_function(); | |
| 2300 } | |
| 2301 // TODO(regis): Remove support for type parameters on factories. | |
| 2302 if (outer_function.IsFactory() && | |
| 2303 (outer_function.signature_class() != Class::null())) { | |
| 2304 instantiator_class = outer_function.signature_class(); | |
| 2305 } else { | |
| 2306 instantiator_class = outer_function.owner(); | |
| 2307 } | |
| 2308 if (instantiator_class.NumTypeParameters() == 0) { | 2297 if (instantiator_class.NumTypeParameters() == 0) { |
| 2309 // The type arguments are compile time constants. | 2298 // The type arguments are compile time constants. |
| 2310 AbstractTypeArguments& type_arguments = AbstractTypeArguments::ZoneHandle(); | 2299 AbstractTypeArguments& type_arguments = AbstractTypeArguments::ZoneHandle(); |
| 2311 // TODO(regis): Temporary type should be allocated in new gen heap. | 2300 // TODO(regis): Temporary type should be allocated in new gen heap. |
| 2312 Type& type = Type::Handle( | 2301 Type& type = Type::Handle( |
| 2313 Type::NewParameterizedType(instantiator_class, type_arguments)); | 2302 Type::NewParameterizedType(instantiator_class, type_arguments)); |
| 2314 Error& error = Error::Handle(); | 2303 Error& error = Error::Handle(); |
| 2315 type ^= ClassFinalizer::FinalizeAndCanonicalizeType(instantiator_class, | 2304 type ^= ClassFinalizer::FinalizeAndCanonicalizeType(instantiator_class, |
| 2316 type, | 2305 type, |
| 2317 &error); | 2306 &error); |
| 2318 if (!error.IsNull()) { | 2307 if (!error.IsNull()) { |
| 2319 ErrorMsg(token_index, error.ToErrorCString()); | 2308 ErrorMsg(token_index, error.ToErrorCString()); |
| 2320 } | 2309 } |
| 2321 type_arguments = type.arguments(); | 2310 type_arguments = type.arguments(); |
| 2322 __ PushObject(type_arguments); | 2311 __ PushObject(type_arguments); |
| 2323 } else { | 2312 } else { |
| 2324 ASSERT(parsed_function().instantiator() != NULL); | 2313 ASSERT(parsed_function().instantiator() != NULL); |
| 2325 parsed_function().instantiator()->Visit(this); | 2314 parsed_function().instantiator()->Visit(this); |
| 2315 Function& outer_function = |
| 2316 Function::Handle(parsed_function().function().raw()); |
| 2317 while (outer_function.IsLocalFunction()) { |
| 2318 outer_function = outer_function.parent_function(); |
| 2319 } |
| 2326 if (!outer_function.IsFactory()) { | 2320 if (!outer_function.IsFactory()) { |
| 2327 __ popq(RAX); // Pop instantiator. | 2321 __ popq(RAX); // Pop instantiator. |
| 2328 // The instantiator is the receiver of the caller, which is not a factory. | 2322 // The instantiator is the receiver of the caller, which is not a factory. |
| 2329 // The receiver cannot be null; extract its AbstractTypeArguments object. | 2323 // The receiver cannot be null; extract its AbstractTypeArguments object. |
| 2330 // Note that in the factory case, the instantiator is the first parameter | 2324 // Note that in the factory case, the instantiator is the first parameter |
| 2331 // of the factory, i.e. already an AbstractTypeArguments object. | 2325 // of the factory, i.e. already an AbstractTypeArguments object. |
| 2332 intptr_t type_arguments_instance_field_offset = | 2326 intptr_t type_arguments_instance_field_offset = |
| 2333 instantiator_class.type_arguments_instance_field_offset(); | 2327 instantiator_class.type_arguments_instance_field_offset(); |
| 2334 ASSERT(type_arguments_instance_field_offset != Class::kNoTypeArguments); | 2328 ASSERT(type_arguments_instance_field_offset != Class::kNoTypeArguments); |
| 2335 __ movq(RAX, FieldAddress(RAX, type_arguments_instance_field_offset)); | 2329 __ movq(RAX, FieldAddress(RAX, type_arguments_instance_field_offset)); |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2800 const Error& error = Error::Handle( | 2794 const Error& error = Error::Handle( |
| 2801 Parser::FormatError(script, token_index, "Error", format, args)); | 2795 Parser::FormatError(script, token_index, "Error", format, args)); |
| 2802 va_end(args); | 2796 va_end(args); |
| 2803 Isolate::Current()->long_jump_base()->Jump(1, error); | 2797 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2804 UNREACHABLE(); | 2798 UNREACHABLE(); |
| 2805 } | 2799 } |
| 2806 | 2800 |
| 2807 } // namespace dart | 2801 } // namespace dart |
| 2808 | 2802 |
| 2809 #endif // defined TARGET_ARCH_X64 | 2803 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |