| 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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 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 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 node->expr(), | 785 node->expr(), |
| 786 node->type(), | 786 node->type(), |
| 787 node->dst_name()); | 787 node->dst_name()); |
| 788 if (IsResultNeeded(node)) { | 788 if (IsResultNeeded(node)) { |
| 789 __ pushl(EAX); | 789 __ pushl(EAX); |
| 790 } | 790 } |
| 791 } | 791 } |
| 792 | 792 |
| 793 | 793 |
| 794 void CodeGenerator::VisitClosureNode(ClosureNode* node) { | 794 void CodeGenerator::VisitClosureNode(ClosureNode* node) { |
| 795 const Immediate raw_null = |
| 796 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 795 const Function& function = node->function(); | 797 const Function& function = node->function(); |
| 796 if (function.IsNonImplicitClosureFunction()) { | 798 if (function.IsNonImplicitClosureFunction()) { |
| 797 // The context scope may have already been set by the new non-optimizing | 799 // The context scope may have already been set by the new non-optimizing |
| 798 // compiler. If it was not, set it here. | 800 // compiler. If it was not, set it here. |
| 799 if (function.context_scope() == ContextScope::null()) { | 801 if (function.context_scope() == ContextScope::null()) { |
| 800 const intptr_t current_context_level = context_level(); | 802 const intptr_t current_context_level = context_level(); |
| 801 const ContextScope& context_scope = ContextScope::ZoneHandle( | 803 const ContextScope& context_scope = ContextScope::ZoneHandle( |
| 802 node->scope()->PreserveOuterScope(current_context_level)); | 804 node->scope()->PreserveOuterScope(current_context_level)); |
| 803 ASSERT(!function.HasCode()); | 805 ASSERT(!function.HasCode()); |
| 804 function.set_context_scope(context_scope); | 806 function.set_context_scope(context_scope); |
| 805 } | 807 } |
| 808 __ pushl(raw_null); // No receiver. |
| 806 } else if (function.IsImplicitInstanceClosureFunction()) { | 809 } else if (function.IsImplicitInstanceClosureFunction()) { |
| 807 node->receiver()->Visit(this); | 810 node->receiver()->Visit(this); |
| 811 } else { |
| 812 __ pushl(raw_null); // No receiver. |
| 808 } | 813 } |
| 809 ASSERT(function.context_scope() != ContextScope::null()); | 814 ASSERT(function.context_scope() != ContextScope::null()); |
| 810 | 815 |
| 811 // The function type of a closure may have type arguments. In that case, pass | 816 // The function type of a closure may have type arguments. In that case, pass |
| 812 // the type arguments of the instantiator. | 817 // the type arguments of the instantiator. |
| 813 const Class& cls = Class::Handle(function.signature_class()); | 818 const Class& cls = Class::Handle(function.signature_class()); |
| 814 ASSERT(!cls.IsNull()); | 819 ASSERT(!cls.IsNull()); |
| 815 const bool requires_type_arguments = cls.HasTypeArguments(); | 820 const bool requires_type_arguments = cls.HasTypeArguments(); |
| 816 if (requires_type_arguments) { | 821 if (requires_type_arguments) { |
| 817 ASSERT(!function.IsImplicitStaticClosureFunction()); | 822 ASSERT(!function.IsImplicitStaticClosureFunction()); |
| 818 const bool kPushInstantiator = false; | 823 const bool kPushInstantiator = false; |
| 819 GenerateInstantiatorTypeArguments(node->token_index(), kPushInstantiator); | 824 GenerateInstantiatorTypeArguments(node->token_index(), kPushInstantiator); |
| 825 } else { |
| 826 __ pushl(raw_null); // No type arguments. |
| 820 } | 827 } |
| 821 const Code& stub = Code::Handle( | 828 const Code& stub = Code::Handle( |
| 822 StubCode::GetAllocationStubForClosure(function)); | 829 StubCode::GetAllocationStubForClosure(function)); |
| 823 const ExternalLabel label(function.ToCString(), stub.EntryPoint()); | 830 const ExternalLabel label(function.ToCString(), stub.EntryPoint()); |
| 824 GenerateCall(node->token_index(), &label, PcDescriptors::kOther); | 831 GenerateCall(node->token_index(), &label, PcDescriptors::kOther); |
| 825 if (requires_type_arguments) { | 832 __ popl(ECX); // Pop type arguments. |
| 826 __ popl(ECX); // Pop type arguments. | 833 __ popl(ECX); // Pop receiver. |
| 827 } | |
| 828 if (function.IsImplicitInstanceClosureFunction()) { | |
| 829 __ popl(ECX); // Pop receiver. | |
| 830 } | |
| 831 if (IsResultNeeded(node)) { | 834 if (IsResultNeeded(node)) { |
| 832 __ pushl(EAX); | 835 __ pushl(EAX); |
| 833 } | 836 } |
| 834 } | 837 } |
| 835 | 838 |
| 836 | 839 |
| 837 void CodeGenerator::VisitPrimaryNode(PrimaryNode* node) { | 840 void CodeGenerator::VisitPrimaryNode(PrimaryNode* node) { |
| 838 // PrimaryNodes are temporary during parsing. | 841 // PrimaryNodes are temporary during parsing. |
| 839 UNREACHABLE(); | 842 UNREACHABLE(); |
| 840 } | 843 } |
| (...skipping 2130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2971 const Error& error = Error::Handle( | 2974 const Error& error = Error::Handle( |
| 2972 Parser::FormatError(script, token_index, "Error", format, args)); | 2975 Parser::FormatError(script, token_index, "Error", format, args)); |
| 2973 va_end(args); | 2976 va_end(args); |
| 2974 Isolate::Current()->long_jump_base()->Jump(1, error); | 2977 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2975 UNREACHABLE(); | 2978 UNREACHABLE(); |
| 2976 } | 2979 } |
| 2977 | 2980 |
| 2978 } // namespace dart | 2981 } // namespace dart |
| 2979 | 2982 |
| 2980 #endif // defined TARGET_ARCH_IA32 | 2983 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |