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/flow_graph_compiler.h" | 8 #include "vm/flow_graph_compiler.h" |
9 | 9 |
10 #include "lib/error.h" | 10 #include "lib/error.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 __ movsd(FieldAddress(EAX, Double::value_offset()), XMM0); | 88 __ movsd(FieldAddress(EAX, Double::value_offset()), XMM0); |
89 __ jmp(done); | 89 __ jmp(done); |
90 __ Bind(&smi_to_double); | 90 __ Bind(&smi_to_double); |
91 __ SmiUntag(EAX); | 91 __ SmiUntag(EAX); |
92 __ cvtsi2sd(XMM1, EAX); | 92 __ cvtsi2sd(XMM1, EAX); |
93 __ jmp(&double_op); | 93 __ jmp(&double_op); |
94 __ Bind(&call_method); | 94 __ Bind(&call_method); |
95 } | 95 } |
96 | 96 |
97 | 97 |
| 98 void FlowGraphCompiler::GenerateCall(intptr_t token_index, |
| 99 intptr_t try_index, |
| 100 const ExternalLabel* label, |
| 101 PcDescriptors::Kind kind) { |
| 102 ASSERT(frame_register_allocator()->IsSpilled()); |
| 103 __ call(label); |
| 104 AddCurrentDescriptor(kind, AstNode::kNoId, token_index, try_index); |
| 105 } |
| 106 |
| 107 |
98 void FlowGraphCompiler::GenerateCallRuntime(intptr_t cid, | 108 void FlowGraphCompiler::GenerateCallRuntime(intptr_t cid, |
99 intptr_t token_index, | 109 intptr_t token_index, |
100 intptr_t try_index, | 110 intptr_t try_index, |
101 const RuntimeEntry& entry) { | 111 const RuntimeEntry& entry) { |
| 112 ASSERT(frame_register_allocator()->IsSpilled()); |
102 __ CallRuntime(entry); | 113 __ CallRuntime(entry); |
103 AddCurrentDescriptor(PcDescriptors::kOther, cid, token_index, try_index); | 114 AddCurrentDescriptor(PcDescriptors::kOther, cid, token_index, try_index); |
104 } | 115 } |
105 | 116 |
106 | 117 |
107 void FlowGraphCompiler::CopyParameters() { | 118 void FlowGraphCompiler::CopyParameters() { |
108 const Function& function = parsed_function().function(); | 119 const Function& function = parsed_function().function(); |
109 LocalScope* scope = parsed_function().node_sequence()->scope(); | 120 LocalScope* scope = parsed_function().node_sequence()->scope(); |
110 const int num_fixed_params = function.num_fixed_parameters(); | 121 const int num_fixed_params = function.num_fixed_parameters(); |
111 const int num_opt_params = function.num_optional_parameters(); | 122 const int num_opt_params = function.num_optional_parameters(); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 intptr_t argument_count) { | 418 intptr_t argument_count) { |
408 __ LoadObject(ECX, function); | 419 __ LoadObject(ECX, function); |
409 __ LoadObject(EDX, arguments_descriptor); | 420 __ LoadObject(EDX, arguments_descriptor); |
410 __ call(&StubCode::CallStaticFunctionLabel()); | 421 __ call(&StubCode::CallStaticFunctionLabel()); |
411 const intptr_t descr_offset = assembler()->CodeSize(); | 422 const intptr_t descr_offset = assembler()->CodeSize(); |
412 __ Drop(argument_count); | 423 __ Drop(argument_count); |
413 return descr_offset; | 424 return descr_offset; |
414 } | 425 } |
415 | 426 |
416 | 427 |
417 void FlowGraphCompiler::GenerateCall(intptr_t token_index, | |
418 intptr_t try_index, | |
419 const ExternalLabel* label, | |
420 PcDescriptors::Kind kind) { | |
421 __ call(label); | |
422 AddCurrentDescriptor(kind, AstNode::kNoId, token_index, try_index); | |
423 } | |
424 | |
425 | |
426 // Fall through if bool_register contains null. | 428 // Fall through if bool_register contains null. |
427 void FlowGraphCompiler::GenerateBoolToJump(Register bool_register, | 429 void FlowGraphCompiler::GenerateBoolToJump(Register bool_register, |
428 Label* is_true, | 430 Label* is_true, |
429 Label* is_false) { | 431 Label* is_false) { |
430 const Immediate raw_null = | 432 const Immediate raw_null = |
431 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 433 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
432 Label fall_through; | 434 Label fall_through; |
433 __ cmpl(bool_register, raw_null); | 435 __ cmpl(bool_register, raw_null); |
434 __ j(EQUAL, &fall_through, Assembler::kNearJump); | 436 __ j(EQUAL, &fall_through, Assembler::kNearJump); |
435 __ CompareObject(bool_register, bool_true()); | 437 __ CompareObject(bool_register, bool_true()); |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 __ Bind(&is_assignable); | 966 __ Bind(&is_assignable); |
965 __ popl(EDX); // Remove pushed instantiator type arguments.. | 967 __ popl(EDX); // Remove pushed instantiator type arguments.. |
966 __ popl(ECX); // Remove pushed instantiator. | 968 __ popl(ECX); // Remove pushed instantiator. |
967 } | 969 } |
968 | 970 |
969 | 971 |
970 void FlowGraphCompiler::EmitInstructionPrologue(Instruction* instr) { | 972 void FlowGraphCompiler::EmitInstructionPrologue(Instruction* instr) { |
971 LocationSummary* locs = instr->locs(); | 973 LocationSummary* locs = instr->locs(); |
972 ASSERT(locs != NULL); | 974 ASSERT(locs != NULL); |
973 | 975 |
974 locs->AllocateRegisters(); | 976 frame_register_allocator()->AllocateRegisters(instr); |
975 | 977 |
976 // Load instruction inputs into allocated registers. | 978 // TODO(vegorov): adjust assertion when we start removing comparison from the |
977 for (intptr_t i = locs->input_count() - 1; i >= 0; i--) { | 979 // graph when it is merged with a branch. |
978 Location loc = locs->in(i); | 980 ASSERT(locs->is_call() || |
979 ASSERT(loc.kind() == Location::kRegister); | 981 (instr->IsBranch() && instr->AsBranch()->is_fused_with_comparison()) || |
980 __ popl(loc.reg()); | 982 (locs->input_count() == instr->InputCount())); |
981 } | |
982 } | 983 } |
983 | 984 |
984 | 985 |
985 // Checks class id of instance against all 'class_ids'. Jump to 'deopt' label | 986 // Checks class id of instance against all 'class_ids'. Jump to 'deopt' label |
986 // if no match or instance is Smi. | 987 // if no match or instance is Smi. |
987 void FlowGraphCompiler::EmitClassChecksNoSmi( | 988 void FlowGraphCompiler::EmitClassChecksNoSmi( |
988 const ZoneGrowableArray<intptr_t>& class_ids, | 989 const ZoneGrowableArray<intptr_t>& class_ids, |
989 Register instance_reg, | 990 Register instance_reg, |
990 Register temp_reg, | 991 Register temp_reg, |
991 Label* deopt) { | 992 Label* deopt) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 __ cvtsi2sd(result, temp); | 1031 __ cvtsi2sd(result, temp); |
1031 __ Bind(&done); | 1032 __ Bind(&done); |
1032 } | 1033 } |
1033 | 1034 |
1034 | 1035 |
1035 #undef __ | 1036 #undef __ |
1036 | 1037 |
1037 } // namespace dart | 1038 } // namespace dart |
1038 | 1039 |
1039 #endif // defined TARGET_ARCH_IA32 | 1040 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |