| 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 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6733 __ LoadObject(result, Bool::True()); | 6723 __ LoadObject(result, Bool::True()); |
| 6734 __ CompareRegisters(result, value); | 6724 __ CompareRegisters(result, value); |
| 6735 __ j(NOT_EQUAL, &done, Assembler::kNearJump); | 6725 __ j(NOT_EQUAL, &done, Assembler::kNearJump); |
| 6736 __ LoadObject(result, Bool::False()); | 6726 __ LoadObject(result, Bool::False()); |
| 6737 __ Bind(&done); | 6727 __ Bind(&done); |
| 6738 } | 6728 } |
| 6739 | 6729 |
| 6740 | 6730 |
| 6741 LocationSummary* AllocateObjectInstr::MakeLocationSummary(Isolate* isolate, | 6731 LocationSummary* AllocateObjectInstr::MakeLocationSummary(Isolate* isolate, |
| 6742 bool opt) const { | 6732 bool opt) const { |
| 6743 return MakeCallSummary(); | 6733 return MakeCallSummary(isolate); |
| 6744 } | 6734 } |
| 6745 | 6735 |
| 6746 | 6736 |
| 6747 void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 6737 void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 6748 Isolate* isolate = compiler->isolate(); | 6738 Isolate* isolate = compiler->isolate(); |
| 6749 StubCode* stub_code = isolate->stub_code(); | 6739 StubCode* stub_code = isolate->stub_code(); |
| 6750 const Code& stub = Code::Handle(isolate, | 6740 const Code& stub = Code::Handle(isolate, |
| 6751 stub_code->GetAllocationStubForClass(cls())); | 6741 stub_code->GetAllocationStubForClass(cls())); |
| 6752 const ExternalLabel label(stub.EntryPoint()); | 6742 const ExternalLabel label(stub.EntryPoint()); |
| 6753 compiler->GenerateCall(token_pos(), | 6743 compiler->GenerateCall(token_pos(), |
| 6754 &label, | 6744 &label, |
| 6755 RawPcDescriptors::kOther, | 6745 RawPcDescriptors::kOther, |
| 6756 locs()); | 6746 locs()); |
| 6757 compiler->AddStubCallTarget(stub); | 6747 compiler->AddStubCallTarget(stub); |
| 6758 __ Drop(ArgumentCount()); // Discard arguments. | 6748 __ Drop(ArgumentCount()); // Discard arguments. |
| 6759 } | 6749 } |
| 6760 | 6750 |
| 6761 | 6751 |
| 6762 void DebugStepCheckInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 6752 void DebugStepCheckInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 6763 ASSERT(!compiler->is_optimizing()); | 6753 ASSERT(!compiler->is_optimizing()); |
| 6764 StubCode* stub_code = compiler->isolate()->stub_code(); | 6754 StubCode* stub_code = compiler->isolate()->stub_code(); |
| 6765 const ExternalLabel label(stub_code->DebugStepCheckEntryPoint()); | 6755 const ExternalLabel label(stub_code->DebugStepCheckEntryPoint()); |
| 6766 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); | 6756 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); |
| 6767 #if defined(DEBUG) | 6757 #if defined(DEBUG) |
| 6768 __ movl(EDX, Immediate(kInvalidObjectPointer)); | 6758 __ movl(EDX, Immediate(kInvalidObjectPointer)); |
| 6769 __ movl(EDX, Immediate(kInvalidObjectPointer)); | |
| 6770 #endif | 6759 #endif |
| 6771 } | 6760 } |
| 6772 | 6761 |
| 6773 } // namespace dart | 6762 } // namespace dart |
| 6774 | 6763 |
| 6775 #undef __ | 6764 #undef __ |
| 6776 | 6765 |
| 6777 #endif // defined TARGET_ARCH_IA32 | 6766 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |