| 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_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/flow_graph_compiler.h" | 8 #include "vm/flow_graph_compiler.h" |
| 9 | 9 |
| 10 #include "vm/ast_printer.h" | 10 #include "vm/ast_printer.h" |
| (...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1078 __ StoreObject(Address(RBP, (slot_base - i) * kWordSize), | 1078 __ StoreObject(Address(RBP, (slot_base - i) * kWordSize), |
| 1079 Object::empty_context()); | 1079 Object::empty_context()); |
| 1080 } | 1080 } |
| 1081 } else { | 1081 } else { |
| 1082 ASSERT(num_locals > 1); | 1082 ASSERT(num_locals > 1); |
| 1083 __ movq(Address(RBP, (slot_base - i) * kWordSize), RAX); | 1083 __ movq(Address(RBP, (slot_base - i) * kWordSize), RAX); |
| 1084 } | 1084 } |
| 1085 } | 1085 } |
| 1086 } | 1086 } |
| 1087 | 1087 |
| 1088 if (FLAG_reify_generic_functions) { | 1088 // Check for a passed type argument vector if the function is generic. |
| 1089 // TODO(regis): Check function type arguments of a generic function. | 1089 if (FLAG_reify_generic_functions && function.IsGeneric()) { |
| 1090 // For now, verify that a local variable has been allocated when necessary. | 1090 __ Comment("Check passed-in type args"); |
| 1091 ASSERT((function.NumTypeParameters() == 0) || | 1091 Label store_type_args, ok; |
| 1092 (parsed_function().function_type_arguments() != NULL)); | 1092 __ cmpq(FieldAddress(R10, ArgumentsDescriptor::type_args_len_offset()), |
| 1093 // TODO(regis): Allocate and prepend parent type arguments when necessary. | 1093 Immediate(0)); |
| 1094 ASSERT(!function.HasGenericParent() || | 1094 if (is_optimizing()) { |
| 1095 (parsed_function().parent_type_arguments() != NULL)); | 1095 // Initialize type_args to null if none passed in. |
| 1096 __ LoadObject(RAX, Object::null_object()); |
| 1097 __ j(EQUAL, &store_type_args, Assembler::kNearJump); |
| 1098 } else { |
| 1099 __ j(EQUAL, &ok, Assembler::kNearJump); // Already initialized to null. |
| 1100 } |
| 1101 // TODO(regis): Verify that type_args_len is correct. |
| 1102 // Load the passed type args vector in RAX from |
| 1103 // fp[kParamEndSlotFromFp + num_args + 1]; num_args (RBX) is Smi. |
| 1104 __ movq(RBX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); |
| 1105 __ movq(RAX, |
| 1106 Address(RBP, RBX, TIMES_4, (kParamEndSlotFromFp + 1) * kWordSize)); |
| 1107 // Store RAX into the stack slot reserved for the function type arguments. |
| 1108 // If the function type arguments variable is captured, a copy will happen |
| 1109 // after the context is allocated. |
| 1110 const intptr_t slot_base = parsed_function().first_stack_local_index(); |
| 1111 ASSERT(parsed_function().function_type_arguments()->is_captured() || |
| 1112 parsed_function().function_type_arguments()->index() == slot_base); |
| 1113 __ Bind(&store_type_args); |
| 1114 __ movq(Address(RBP, slot_base * kWordSize), RAX); |
| 1115 __ Bind(&ok); |
| 1096 } | 1116 } |
| 1097 | 1117 |
| 1118 // TODO(regis): Verify that no vector is passed if not generic, unless already |
| 1119 // checked during resolution. |
| 1120 |
| 1098 EndCodeSourceRange(TokenPosition::kDartCodePrologue); | 1121 EndCodeSourceRange(TokenPosition::kDartCodePrologue); |
| 1099 ASSERT(!block_order().is_empty()); | 1122 ASSERT(!block_order().is_empty()); |
| 1100 VisitBlocks(); | 1123 VisitBlocks(); |
| 1101 | 1124 |
| 1102 __ int3(); | 1125 __ int3(); |
| 1103 ASSERT(assembler()->constant_pool_allowed()); | 1126 ASSERT(assembler()->constant_pool_allowed()); |
| 1104 GenerateDeferredCode(); | 1127 GenerateDeferredCode(); |
| 1105 } | 1128 } |
| 1106 | 1129 |
| 1107 | 1130 |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 | 1354 |
| 1332 | 1355 |
| 1333 void FlowGraphCompiler::EmitOptimizedStaticCall( | 1356 void FlowGraphCompiler::EmitOptimizedStaticCall( |
| 1334 const Function& function, | 1357 const Function& function, |
| 1335 const Array& arguments_descriptor, | 1358 const Array& arguments_descriptor, |
| 1336 intptr_t argument_count, | 1359 intptr_t argument_count, |
| 1337 intptr_t deopt_id, | 1360 intptr_t deopt_id, |
| 1338 TokenPosition token_pos, | 1361 TokenPosition token_pos, |
| 1339 LocationSummary* locs) { | 1362 LocationSummary* locs) { |
| 1340 ASSERT(!function.IsClosureFunction()); | 1363 ASSERT(!function.IsClosureFunction()); |
| 1341 if (function.HasOptionalParameters()) { | 1364 if (function.HasOptionalParameters() || |
| 1365 (FLAG_reify_generic_functions && function.IsGeneric())) { |
| 1342 __ LoadObject(R10, arguments_descriptor); | 1366 __ LoadObject(R10, arguments_descriptor); |
| 1343 } else { | 1367 } else { |
| 1344 __ xorq(R10, R10); // GC safe smi zero because of stub. | 1368 __ xorq(R10, R10); // GC safe smi zero because of stub. |
| 1345 } | 1369 } |
| 1346 // Do not use the code from the function, but let the code be patched so that | 1370 // Do not use the code from the function, but let the code be patched so that |
| 1347 // we can record the outgoing edges to other code. | 1371 // we can record the outgoing edges to other code. |
| 1348 GenerateStaticDartCall(deopt_id, token_pos, | 1372 GenerateStaticDartCall(deopt_id, token_pos, |
| 1349 *StubCode::CallStaticFunction_entry(), | 1373 *StubCode::CallStaticFunction_entry(), |
| 1350 RawPcDescriptors::kOther, locs, function); | 1374 RawPcDescriptors::kOther, locs, function); |
| 1351 __ Drop(argument_count, RCX); | 1375 __ Drop(argument_count, RCX); |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1714 __ movups(reg, Address(RSP, 0)); | 1738 __ movups(reg, Address(RSP, 0)); |
| 1715 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); | 1739 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); |
| 1716 } | 1740 } |
| 1717 | 1741 |
| 1718 | 1742 |
| 1719 #undef __ | 1743 #undef __ |
| 1720 | 1744 |
| 1721 } // namespace dart | 1745 } // namespace dart |
| 1722 | 1746 |
| 1723 #endif // defined TARGET_ARCH_X64 | 1747 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |