OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
9 | 9 |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 namespace dart { | 23 namespace dart { |
24 | 24 |
25 DECLARE_FLAG(bool, emit_edge_counters); | 25 DECLARE_FLAG(bool, emit_edge_counters); |
26 DECLARE_FLAG(int, optimization_counter_threshold); | 26 DECLARE_FLAG(int, optimization_counter_threshold); |
27 DECLARE_FLAG(bool, propagate_ic_data); | 27 DECLARE_FLAG(bool, propagate_ic_data); |
28 DECLARE_FLAG(bool, use_osr); | 28 DECLARE_FLAG(bool, use_osr); |
29 DECLARE_FLAG(bool, throw_on_javascript_int_overflow); | 29 DECLARE_FLAG(bool, throw_on_javascript_int_overflow); |
30 | 30 |
31 // Generic summary for call instructions that have all arguments pushed | 31 // Generic summary for call instructions that have all arguments pushed |
32 // on the stack and return the result in a fixed register EAX. | 32 // on the stack and return the result in a fixed register EAX. |
33 LocationSummary* Instruction::MakeCallSummary() { | 33 LocationSummary* Instruction::MakeCallSummary(Isolate* isolate) { |
34 Isolate* isolate = Isolate::Current(); | 34 const intptr_t kNumInputs = 0; |
| 35 const intptr_t kNumTemps= 0; |
35 LocationSummary* result = new(isolate) LocationSummary( | 36 LocationSummary* result = new(isolate) LocationSummary( |
36 isolate, 0, 0, LocationSummary::kCall); | 37 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); |
37 result->set_out(0, Location::RegisterLocation(EAX)); | 38 result->set_out(0, Location::RegisterLocation(EAX)); |
38 return result; | 39 return result; |
39 } | 40 } |
40 | 41 |
41 | 42 |
42 LocationSummary* PushArgumentInstr::MakeLocationSummary(Isolate* isolate, | 43 LocationSummary* PushArgumentInstr::MakeLocationSummary(Isolate* isolate, |
43 bool opt) const { | 44 bool opt) const { |
44 const intptr_t kNumInputs = 1; | 45 const intptr_t kNumInputs = 1; |
45 const intptr_t kNumTemps= 0; | 46 const intptr_t kNumTemps= 0; |
46 LocationSummary* locs = new(isolate) LocationSummary( | 47 LocationSummary* locs = new(isolate) LocationSummary( |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 void RelationalOpInstr::EmitBranchCode(FlowGraphCompiler* compiler, | 797 void RelationalOpInstr::EmitBranchCode(FlowGraphCompiler* compiler, |
797 BranchInstr* branch) { | 798 BranchInstr* branch) { |
798 BranchLabels labels = compiler->CreateBranchLabels(branch); | 799 BranchLabels labels = compiler->CreateBranchLabels(branch); |
799 Condition true_condition = EmitComparisonCode(compiler, labels); | 800 Condition true_condition = EmitComparisonCode(compiler, labels); |
800 EmitBranchOnCondition(compiler, true_condition, labels); | 801 EmitBranchOnCondition(compiler, true_condition, labels); |
801 } | 802 } |
802 | 803 |
803 | 804 |
804 LocationSummary* NativeCallInstr::MakeLocationSummary(Isolate* isolate, | 805 LocationSummary* NativeCallInstr::MakeLocationSummary(Isolate* isolate, |
805 bool opt) const { | 806 bool opt) const { |
806 const intptr_t kNumInputs = 0; | 807 return MakeCallSummary(isolate); |
807 const intptr_t kNumTemps = 3; | |
808 LocationSummary* locs = new(isolate) LocationSummary( | |
809 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); | |
810 locs->set_temp(0, Location::RegisterLocation(EAX)); | |
811 locs->set_temp(1, Location::RegisterLocation(ECX)); | |
812 locs->set_temp(2, Location::RegisterLocation(EDX)); | |
813 locs->set_out(0, Location::RegisterLocation(EAX)); | |
814 return locs; | |
815 } | 808 } |
816 | 809 |
817 | 810 |
818 void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 811 void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
819 ASSERT(locs()->temp(0).reg() == EAX); | |
820 ASSERT(locs()->temp(1).reg() == ECX); | |
821 ASSERT(locs()->temp(2).reg() == EDX); | |
822 Register result = locs()->out(0).reg(); | 812 Register result = locs()->out(0).reg(); |
823 const intptr_t argc_tag = NativeArguments::ComputeArgcTag(function()); | 813 const intptr_t argc_tag = NativeArguments::ComputeArgcTag(function()); |
824 const bool is_leaf_call = | 814 const bool is_leaf_call = |
825 (argc_tag & NativeArguments::AutoSetupScopeMask()) == 0; | 815 (argc_tag & NativeArguments::AutoSetupScopeMask()) == 0; |
826 StubCode* stub_code = compiler->isolate()->stub_code(); | 816 StubCode* stub_code = compiler->isolate()->stub_code(); |
827 | 817 |
828 // Push the result place holder initialized to NULL. | 818 // Push the result place holder initialized to NULL. |
829 __ PushObject(Object::null_object()); | 819 __ PushObject(Object::null_object()); |
830 // Pass a pointer to the first argument in EAX. | 820 // Pass a pointer to the first argument in EAX. |
831 if (!function().HasOptionalParameters()) { | 821 if (!function().HasOptionalParameters()) { |
(...skipping 4556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5388 __ addl(ESP, Immediate(2 * kWordSize)); | 5378 __ addl(ESP, Immediate(2 * kWordSize)); |
5389 return; | 5379 return; |
5390 } | 5380 } |
5391 | 5381 |
5392 UNIMPLEMENTED(); | 5382 UNIMPLEMENTED(); |
5393 } | 5383 } |
5394 | 5384 |
5395 | 5385 |
5396 LocationSummary* PolymorphicInstanceCallInstr::MakeLocationSummary( | 5386 LocationSummary* PolymorphicInstanceCallInstr::MakeLocationSummary( |
5397 Isolate* isolate, bool opt) const { | 5387 Isolate* isolate, bool opt) const { |
5398 return MakeCallSummary(); | 5388 return MakeCallSummary(isolate); |
5399 } | 5389 } |
5400 | 5390 |
5401 | 5391 |
5402 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 5392 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
5403 ASSERT(ic_data().NumArgsTested() == 1); | 5393 ASSERT(ic_data().NumArgsTested() == 1); |
5404 if (!with_checks()) { | 5394 if (!with_checks()) { |
5405 ASSERT(ic_data().HasOneTarget()); | 5395 ASSERT(ic_data().HasOneTarget()); |
5406 const Function& target = Function::ZoneHandle(ic_data().GetTargetAt(0)); | 5396 const Function& target = Function::ZoneHandle(ic_data().GetTargetAt(0)); |
5407 compiler->GenerateStaticCall(deopt_id(), | 5397 compiler->GenerateStaticCall(deopt_id(), |
5408 instance_call()->token_pos(), | 5398 instance_call()->token_pos(), |
(...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6661 Smi::RawValue(true_value) - Smi::RawValue(false_value))); | 6651 Smi::RawValue(true_value) - Smi::RawValue(false_value))); |
6662 if (false_value != 0) { | 6652 if (false_value != 0) { |
6663 __ addl(EDX, Immediate(Smi::RawValue(false_value))); | 6653 __ addl(EDX, Immediate(Smi::RawValue(false_value))); |
6664 } | 6654 } |
6665 } | 6655 } |
6666 } | 6656 } |
6667 | 6657 |
6668 | 6658 |
6669 LocationSummary* ClosureCallInstr::MakeLocationSummary(Isolate* isolate, | 6659 LocationSummary* ClosureCallInstr::MakeLocationSummary(Isolate* isolate, |
6670 bool opt) const { | 6660 bool opt) const { |
6671 const intptr_t kNumInputs = 1; | 6661 const intptr_t kNumInputs = 2; |
6672 const intptr_t kNumTemps = 0; | 6662 const intptr_t kNumTemps = 0; |
6673 LocationSummary* summary = new(isolate) LocationSummary( | 6663 LocationSummary* summary = new(isolate) LocationSummary( |
6674 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); | 6664 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); |
6675 summary->set_in(0, Location::RegisterLocation(EAX)); // Function. | 6665 summary->set_in(kFunctionPos, Location::RegisterLocation(EAX)); // Function. |
| 6666 summary->set_in(kContextPos, Location::RegisterLocation(CTX)); // Context. |
6676 summary->set_out(0, Location::RegisterLocation(EAX)); | 6667 summary->set_out(0, Location::RegisterLocation(EAX)); |
6677 return summary; | 6668 return summary; |
6678 } | 6669 } |
6679 | 6670 |
6680 | 6671 |
6681 void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 6672 void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
6682 // Load arguments descriptors. | 6673 // Load arguments descriptors. |
6683 intptr_t argument_count = ArgumentCount(); | 6674 intptr_t argument_count = ArgumentCount(); |
6684 const Array& arguments_descriptor = | 6675 const Array& arguments_descriptor = |
6685 Array::ZoneHandle(ArgumentsDescriptor::New(argument_count, | 6676 Array::ZoneHandle(ArgumentsDescriptor::New(argument_count, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6733 __ LoadObject(result, Bool::True()); | 6724 __ LoadObject(result, Bool::True()); |
6734 __ CompareRegisters(result, value); | 6725 __ CompareRegisters(result, value); |
6735 __ j(NOT_EQUAL, &done, Assembler::kNearJump); | 6726 __ j(NOT_EQUAL, &done, Assembler::kNearJump); |
6736 __ LoadObject(result, Bool::False()); | 6727 __ LoadObject(result, Bool::False()); |
6737 __ Bind(&done); | 6728 __ Bind(&done); |
6738 } | 6729 } |
6739 | 6730 |
6740 | 6731 |
6741 LocationSummary* AllocateObjectInstr::MakeLocationSummary(Isolate* isolate, | 6732 LocationSummary* AllocateObjectInstr::MakeLocationSummary(Isolate* isolate, |
6742 bool opt) const { | 6733 bool opt) const { |
6743 return MakeCallSummary(); | 6734 return MakeCallSummary(isolate); |
6744 } | 6735 } |
6745 | 6736 |
6746 | 6737 |
6747 void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 6738 void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
6748 Isolate* isolate = compiler->isolate(); | 6739 Isolate* isolate = compiler->isolate(); |
6749 StubCode* stub_code = isolate->stub_code(); | 6740 StubCode* stub_code = isolate->stub_code(); |
6750 const Code& stub = Code::Handle(isolate, | 6741 const Code& stub = Code::Handle(isolate, |
6751 stub_code->GetAllocationStubForClass(cls())); | 6742 stub_code->GetAllocationStubForClass(cls())); |
6752 const ExternalLabel label(stub.EntryPoint()); | 6743 const ExternalLabel label(stub.EntryPoint()); |
6753 compiler->GenerateCall(token_pos(), | 6744 compiler->GenerateCall(token_pos(), |
6754 &label, | 6745 &label, |
6755 RawPcDescriptors::kOther, | 6746 RawPcDescriptors::kOther, |
6756 locs()); | 6747 locs()); |
6757 compiler->AddStubCallTarget(stub); | 6748 compiler->AddStubCallTarget(stub); |
6758 __ Drop(ArgumentCount()); // Discard arguments. | 6749 __ Drop(ArgumentCount()); // Discard arguments. |
6759 } | 6750 } |
6760 | 6751 |
6761 | 6752 |
6762 void DebugStepCheckInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 6753 void DebugStepCheckInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
6763 ASSERT(!compiler->is_optimizing()); | 6754 ASSERT(!compiler->is_optimizing()); |
6764 StubCode* stub_code = compiler->isolate()->stub_code(); | 6755 StubCode* stub_code = compiler->isolate()->stub_code(); |
6765 const ExternalLabel label(stub_code->DebugStepCheckEntryPoint()); | 6756 const ExternalLabel label(stub_code->DebugStepCheckEntryPoint()); |
6766 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); | 6757 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); |
6767 #if defined(DEBUG) | 6758 #if defined(DEBUG) |
6768 __ movl(EDX, Immediate(kInvalidObjectPointer)); | 6759 __ movl(EDX, Immediate(kInvalidObjectPointer)); |
6769 __ movl(EDX, Immediate(kInvalidObjectPointer)); | |
6770 #endif | 6760 #endif |
6771 } | 6761 } |
6772 | 6762 |
6773 } // namespace dart | 6763 } // namespace dart |
6774 | 6764 |
6775 #undef __ | 6765 #undef __ |
6776 | 6766 |
6777 #endif // defined TARGET_ARCH_IA32 | 6767 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |