Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Side by Side Diff: runtime/vm/flow_graph_compiler_ia32.cc

Issue 2941643002: Check for a passed-in type argument vector in the prolog of generic functions. (Closed)
Patch Set: address review comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/flow_graph_compiler_dbc.cc ('k') | runtime/vm/flow_graph_compiler_mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/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 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 reinterpret_cast<intptr_t>(Object::empty_context().raw())); 1082 reinterpret_cast<intptr_t>(Object::empty_context().raw()));
1083 __ movl(Address(EBP, (slot_base - i) * kWordSize), raw_empty_context); 1083 __ movl(Address(EBP, (slot_base - i) * kWordSize), raw_empty_context);
1084 } 1084 }
1085 } else { 1085 } else {
1086 ASSERT(num_locals > 1); 1086 ASSERT(num_locals > 1);
1087 __ movl(Address(EBP, (slot_base - i) * kWordSize), EAX); 1087 __ movl(Address(EBP, (slot_base - i) * kWordSize), EAX);
1088 } 1088 }
1089 } 1089 }
1090 } 1090 }
1091 1091
1092 // Check for a passed type argument vector if the function is generic.
1093 if (FLAG_reify_generic_functions && function.IsGeneric()) {
1094 __ Comment("Check passed-in type args");
1095 Label store_type_args, ok;
1096 __ cmpl(FieldAddress(EDX, ArgumentsDescriptor::type_args_len_offset()),
1097 Immediate(0));
1098 if (is_optimizing()) {
1099 // Initialize type_args to null if none passed in.
1100 const Immediate& raw_null =
1101 Immediate(reinterpret_cast<intptr_t>(Object::null()));
1102 __ movl(EAX, raw_null);
1103 __ j(EQUAL, &store_type_args, Assembler::kNearJump);
1104 } else {
1105 __ j(EQUAL, &ok, Assembler::kNearJump); // Already initialized to null.
1106 }
1107 // TODO(regis): Verify that type_args_len is correct.
1108 // Load the passed type args vector in EAX from
1109 // fp[kParamEndSlotFromFp + num_args + 1]; num_args (EBX) is Smi.
1110 __ movl(EBX, FieldAddress(EDX, ArgumentsDescriptor::count_offset()));
1111 __ movl(EAX,
1112 Address(EBP, EBX, TIMES_2, (kParamEndSlotFromFp + 1) * kWordSize));
1113 // Store EAX into the stack slot reserved for the function type arguments.
1114 // If the function type arguments variable is captured, a copy will happen
1115 // after the context is allocated.
1116 const intptr_t slot_base = parsed_function().first_stack_local_index();
1117 ASSERT(parsed_function().function_type_arguments()->is_captured() ||
1118 parsed_function().function_type_arguments()->index() == slot_base);
1119 __ Bind(&store_type_args);
1120 __ movl(Address(EBP, slot_base * kWordSize), EAX);
1121 __ Bind(&ok);
1122 }
1123
1124 // TODO(regis): Verify that no vector is passed if not generic, unless already
1125 // checked during resolution.
1126
1092 EndCodeSourceRange(TokenPosition::kDartCodePrologue); 1127 EndCodeSourceRange(TokenPosition::kDartCodePrologue);
1093 ASSERT(!block_order().is_empty()); 1128 ASSERT(!block_order().is_empty());
1094 VisitBlocks(); 1129 VisitBlocks();
1095 1130
1096 __ int3(); 1131 __ int3();
1097 GenerateDeferredCode(); 1132 GenerateDeferredCode();
1098 } 1133 }
1099 1134
1100 1135
1101 void FlowGraphCompiler::GenerateCall(TokenPosition token_pos, 1136 void FlowGraphCompiler::GenerateCall(TokenPosition token_pos,
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 } 1305 }
1271 1306
1272 1307
1273 void FlowGraphCompiler::EmitOptimizedStaticCall( 1308 void FlowGraphCompiler::EmitOptimizedStaticCall(
1274 const Function& function, 1309 const Function& function,
1275 const Array& arguments_descriptor, 1310 const Array& arguments_descriptor,
1276 intptr_t argument_count, 1311 intptr_t argument_count,
1277 intptr_t deopt_id, 1312 intptr_t deopt_id,
1278 TokenPosition token_pos, 1313 TokenPosition token_pos,
1279 LocationSummary* locs) { 1314 LocationSummary* locs) {
1280 if (function.HasOptionalParameters()) { 1315 if (function.HasOptionalParameters() ||
1316 (FLAG_reify_generic_functions && function.IsGeneric())) {
1281 __ LoadObject(EDX, arguments_descriptor); 1317 __ LoadObject(EDX, arguments_descriptor);
1282 } else { 1318 } else {
1283 __ xorl(EDX, EDX); // GC safe smi zero because of stub. 1319 __ xorl(EDX, EDX); // GC safe smi zero because of stub.
1284 } 1320 }
1285 // Do not use the code from the function, but let the code be patched so that 1321 // Do not use the code from the function, but let the code be patched so that
1286 // we can record the outgoing edges to other code. 1322 // we can record the outgoing edges to other code.
1287 GenerateDartCall(deopt_id, token_pos, *StubCode::CallStaticFunction_entry(), 1323 GenerateDartCall(deopt_id, token_pos, *StubCode::CallStaticFunction_entry(),
1288 RawPcDescriptors::kOther, locs); 1324 RawPcDescriptors::kOther, locs);
1289 AddStaticCallTarget(function); 1325 AddStaticCallTarget(function);
1290 __ Drop(argument_count); 1326 __ Drop(argument_count);
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1723 __ movups(reg, Address(ESP, 0)); 1759 __ movups(reg, Address(ESP, 0));
1724 __ addl(ESP, Immediate(kFpuRegisterSize)); 1760 __ addl(ESP, Immediate(kFpuRegisterSize));
1725 } 1761 }
1726 1762
1727 1763
1728 #undef __ 1764 #undef __
1729 1765
1730 } // namespace dart 1766 } // namespace dart
1731 1767
1732 #endif // defined TARGET_ARCH_IA32 1768 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_dbc.cc ('k') | runtime/vm/flow_graph_compiler_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698