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

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

Issue 335173002: Save ICData of unoptimized code in the function, thus preserving it across repated unoptimized comp… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/flow_graph_compiler.h ('k') | runtime/vm/flow_graph_optimizer.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_XXX. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX.
6 6
7 #include "vm/flow_graph_compiler.h" 7 #include "vm/flow_graph_compiler.h"
8 8
9 #include "vm/cha.h" 9 #include "vm/cha.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 int32x4_class_(Class::ZoneHandle( 101 int32x4_class_(Class::ZoneHandle(
102 isolate_->object_store()->int32x4_class())), 102 isolate_->object_store()->int32x4_class())),
103 list_class_(Class::ZoneHandle( 103 list_class_(Class::ZoneHandle(
104 Library::Handle(Library::CoreLibrary()). 104 Library::Handle(Library::CoreLibrary()).
105 LookupClass(Symbols::List()))), 105 LookupClass(Symbols::List()))),
106 parallel_move_resolver_(this), 106 parallel_move_resolver_(this),
107 pending_deoptimization_env_(NULL), 107 pending_deoptimization_env_(NULL),
108 entry_patch_pc_offset_(Code::kInvalidPc), 108 entry_patch_pc_offset_(Code::kInvalidPc),
109 patch_code_pc_offset_(Code::kInvalidPc), 109 patch_code_pc_offset_(Code::kInvalidPc),
110 lazy_deopt_pc_offset_(Code::kInvalidPc) { 110 lazy_deopt_pc_offset_(Code::kInvalidPc) {
111 if (!is_optimizing) {
112 const intptr_t len = isolate()->deopt_id();
113 deopt_id_to_ic_data_ = new(isolate()) ZoneGrowableArray<const ICData*>(len);
114 deopt_id_to_ic_data_->SetLength(len);
115 for (intptr_t i = 0; i < len; i++) {
116 (*deopt_id_to_ic_data_)[i] = NULL;
117 }
118 const Array& old_saved_icdata = Array::Handle(isolate(),
119 flow_graph->parsed_function().function().ic_data_array());
120 const intptr_t saved_len =
121 old_saved_icdata.IsNull() ? 0 : old_saved_icdata.Length();
122 for (intptr_t i = 0; i < saved_len; i++) {
123 ICData& icd = ICData::ZoneHandle(isolate());
124 icd ^= old_saved_icdata.At(i);
125 (*deopt_id_to_ic_data_)[icd.deopt_id()] = &icd;
126 }
127 }
111 ASSERT(assembler != NULL); 128 ASSERT(assembler != NULL);
112 ASSERT(!list_class_.IsNull()); 129 ASSERT(!list_class_.IsNull());
113 } 130 }
114 131
115 132
116 void FlowGraphCompiler::InitCompiler() { 133 void FlowGraphCompiler::InitCompiler() {
117 pc_descriptors_list_ = new DescriptorList(64); 134 pc_descriptors_list_ = new DescriptorList(64);
118 exception_handlers_list_ = new ExceptionHandlerList(); 135 exception_handlers_list_ = new ExceptionHandlerList();
119 block_info_.Clear(); 136 block_info_.Clear();
120 // Conservative detection of leaf routines used to remove the stack check 137 // Conservative detection of leaf routines used to remove the stack check
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 // may therefore prevent the optimization of some static calls. 916 // may therefore prevent the optimization of some static calls.
900 if (is_optimizing() && 917 if (is_optimizing() &&
901 !(FLAG_warn_on_javascript_compatibility && 918 !(FLAG_warn_on_javascript_compatibility &&
902 (MethodRecognizer::RecognizeKind(function) == 919 (MethodRecognizer::RecognizeKind(function) ==
903 MethodRecognizer::kObjectIdentical))) { 920 MethodRecognizer::kObjectIdentical))) {
904 EmitOptimizedStaticCall(function, arguments_descriptor, 921 EmitOptimizedStaticCall(function, arguments_descriptor,
905 argument_count, deopt_id, token_pos, locs); 922 argument_count, deopt_id, token_pos, locs);
906 } else { 923 } else {
907 ICData& call_ic_data = ICData::ZoneHandle(ic_data.raw()); 924 ICData& call_ic_data = ICData::ZoneHandle(ic_data.raw());
908 if (call_ic_data.IsNull()) { 925 if (call_ic_data.IsNull()) {
909 call_ic_data = ICData::New(parsed_function().function(), // Caller fun. 926 const intptr_t kNumArgsChecked = 0;
910 String::Handle(function.name()), 927 call_ic_data = GetOrAddStaticCallICData(deopt_id,
911 arguments_descriptor, 928 function,
912 deopt_id, 929 arguments_descriptor,
913 0); // No arguments checked. 930 kNumArgsChecked)->raw();
914 call_ic_data.AddTarget(function);
915 } 931 }
916 EmitUnoptimizedStaticCall(argument_count, deopt_id, token_pos, locs, 932 EmitUnoptimizedStaticCall(argument_count, deopt_id, token_pos, locs,
917 call_ic_data); 933 call_ic_data);
918 } 934 }
919 } 935 }
920 936
921 937
922 void FlowGraphCompiler::GenerateNumberTypeCheck(Register kClassIdReg, 938 void FlowGraphCompiler::GenerateNumberTypeCheck(Register kClassIdReg,
923 const AbstractType& type, 939 const AbstractType& type,
924 Label* is_instance_lbl, 940 Label* is_instance_lbl,
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 sorted->Clear(); 1349 sorted->Clear();
1334 1350
1335 for (int i = 0; i < len; i++) { 1351 for (int i = 0; i < len; i++) {
1336 sorted->Add(CidTarget(ic_data.GetReceiverClassIdAt(i), 1352 sorted->Add(CidTarget(ic_data.GetReceiverClassIdAt(i),
1337 &Function::ZoneHandle(ic_data.GetTargetAt(i)), 1353 &Function::ZoneHandle(ic_data.GetTargetAt(i)),
1338 ic_data.GetCountAt(i))); 1354 ic_data.GetCountAt(i)));
1339 } 1355 }
1340 sorted->Sort(HighestCountFirst); 1356 sorted->Sort(HighestCountFirst);
1341 } 1357 }
1342 1358
1359
1360 const ICData* FlowGraphCompiler::GetOrAddInstanceCallICData(
1361 intptr_t deopt_id,
1362 const String& target_name,
1363 const Array& arguments_descriptor,
1364 intptr_t num_args_tested) {
1365 if ((deopt_id_to_ic_data_ != NULL) &&
1366 ((*deopt_id_to_ic_data_)[deopt_id] != NULL)) {
1367 const ICData* res = (*deopt_id_to_ic_data_)[deopt_id];
1368 ASSERT(res->deopt_id() == deopt_id);
1369 ASSERT(res->target_name() == target_name.raw());
1370 ASSERT(res->NumArgsTested() == num_args_tested);
1371 return res;
1372 }
1373 const ICData& ic_data = ICData::ZoneHandle(isolate(), ICData::New(
1374 parsed_function().function(), target_name,
1375 arguments_descriptor, deopt_id, num_args_tested));
1376 (*deopt_id_to_ic_data_)[deopt_id] = &ic_data;
1377 return &ic_data;
1378 }
1379
1380
1381 const ICData* FlowGraphCompiler::GetOrAddStaticCallICData(
1382 intptr_t deopt_id,
1383 const Function& target,
1384 const Array& arguments_descriptor,
1385 intptr_t num_args_tested) {
1386 if ((deopt_id_to_ic_data_ != NULL) &&
1387 ((*deopt_id_to_ic_data_)[deopt_id] != NULL)) {
1388 const ICData* res = (*deopt_id_to_ic_data_)[deopt_id];
1389 ASSERT(res->deopt_id() == deopt_id);
1390 ASSERT(res->target_name() == target.name());
1391 ASSERT(res->NumArgsTested() == num_args_tested);
1392 return res;
1393 }
1394 const ICData& ic_data = ICData::ZoneHandle(isolate(), ICData::New(
1395 parsed_function().function(), String::Handle(isolate(), target.name()),
1396 arguments_descriptor, deopt_id, num_args_tested));
1397 ic_data.AddTarget(target);
1398 (*deopt_id_to_ic_data_)[deopt_id] = &ic_data;
1399 return &ic_data;
1400 }
1401
1343 } // namespace dart 1402 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler.h ('k') | runtime/vm/flow_graph_optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698