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

Side by Side Diff: runtime/vm/object.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/object.h ('k') | runtime/vm/raw_object.h » ('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) 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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 2505 matching lines...) Expand 10 before | Expand all | Expand 10 after
2516 continue; 2516 continue;
2517 } 2517 }
2518 2518
2519 function ^= code.function(); 2519 function ^= code.function();
2520 // If function uses dependent code switch it to unoptimized. 2520 // If function uses dependent code switch it to unoptimized.
2521 if (code.is_optimized() && (function.CurrentCode() == code.raw())) { 2521 if (code.is_optimized() && (function.CurrentCode() == code.raw())) {
2522 ReportSwitchingCode(code); 2522 ReportSwitchingCode(code);
2523 function.SwitchToUnoptimizedCode(); 2523 function.SwitchToUnoptimizedCode();
2524 } else if (function.unoptimized_code() == code.raw()) { 2524 } else if (function.unoptimized_code() == code.raw()) {
2525 ReportSwitchingCode(code); 2525 ReportSwitchingCode(code);
2526 function.ClearICData();
2526 // Remove the code object from the function. The next time the 2527 // Remove the code object from the function. The next time the
2527 // function is invoked, it will be compiled again. 2528 // function is invoked, it will be compiled again.
2528 function.ClearCode(); 2529 function.ClearCode();
2529 // Invalidate the old code object so existing references to it 2530 // Invalidate the old code object so existing references to it
2530 // (from optimized code) will fail when invoked. 2531 // (from optimized code) will fail when invoked.
2531 if (!CodePatcher::IsEntryPatched(code)) { 2532 if (!CodePatcher::IsEntryPatched(code)) {
2532 CodePatcher::PatchEntry(code); 2533 CodePatcher::PatchEntry(code);
2533 } 2534 }
2534 } else { 2535 } else {
2535 // Make non-OSR code non-entrant. 2536 // Make non-OSR code non-entrant.
(...skipping 3474 matching lines...) Expand 10 before | Expand all | Expand 10 after
6010 clone ^= Object::Clone(*this, Heap::kOld); 6011 clone ^= Object::Clone(*this, Heap::kOld);
6011 const Class& origin = Class::Handle(this->origin()); 6012 const Class& origin = Class::Handle(this->origin());
6012 const PatchClass& clone_owner = 6013 const PatchClass& clone_owner =
6013 PatchClass::Handle(PatchClass::New(new_owner, origin)); 6014 PatchClass::Handle(PatchClass::New(new_owner, origin));
6014 clone.set_owner(clone_owner); 6015 clone.set_owner(clone_owner);
6015 clone.ClearCode(); 6016 clone.ClearCode();
6016 clone.set_usage_counter(0); 6017 clone.set_usage_counter(0);
6017 clone.set_deoptimization_counter(0); 6018 clone.set_deoptimization_counter(0);
6018 clone.set_optimized_instruction_count(0); 6019 clone.set_optimized_instruction_count(0);
6019 clone.set_optimized_call_site_count(0); 6020 clone.set_optimized_call_site_count(0);
6021 clone.set_ic_data_array(Array::Handle());
6020 return clone.raw(); 6022 return clone.raw();
6021 } 6023 }
6022 6024
6023 6025
6024 RawFunction* Function::NewClosureFunction(const String& name, 6026 RawFunction* Function::NewClosureFunction(const String& name,
6025 const Function& parent, 6027 const Function& parent,
6026 intptr_t token_pos) { 6028 intptr_t token_pos) {
6027 ASSERT(!parent.IsNull()); 6029 ASSERT(!parent.IsNull());
6028 // Use the owner defining the parent function and not the class containing it. 6030 // Use the owner defining the parent function and not the class containing it.
6029 const Object& parent_owner = Object::Handle(parent.raw_ptr()->owner_); 6031 const Object& parent_owner = Object::Handle(parent.raw_ptr()->owner_);
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
6409 } 6411 }
6410 result = 31 * result + val; 6412 result = 31 * result + val;
6411 tokens_iterator.Advance(); 6413 tokens_iterator.Advance();
6412 } 6414 }
6413 result = result & ((static_cast<uint32_t>(1) << 31) - 1); 6415 result = result & ((static_cast<uint32_t>(1) << 31) - 1);
6414 ASSERT(result <= static_cast<uint32_t>(kMaxInt32)); 6416 ASSERT(result <= static_cast<uint32_t>(kMaxInt32));
6415 return result; 6417 return result;
6416 } 6418 }
6417 6419
6418 6420
6421 void Function::SaveICDataMap(
6422 const ZoneGrowableArray<const ICData*>& deopt_id_to_ic_data) const {
6423 // Compute number of ICData objectsto save.
6424 intptr_t count = 0;
6425 for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) {
6426 if (deopt_id_to_ic_data[i] != NULL) {
6427 count++;
6428 }
6429 }
6430
6431 const Array& a = Array::Handle(Array::New(count, Heap::kOld));
6432 count = 0;
6433 for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) {
6434 if (deopt_id_to_ic_data[i] != NULL) {
6435 a.SetAt(count++, *deopt_id_to_ic_data[i]);
6436 }
6437 }
6438 set_ic_data_array(a);
6439 }
6440
6441
6442 RawArray* Function::RestoreICDataMap() const {
6443 const Array& saved_icd = Array::Handle(ic_data_array());
6444 if (saved_icd.Length() == 0) {
6445 return Array::empty_array().raw();
6446 }
6447 ICData& icd = ICData::Handle();
6448 icd ^= saved_icd.At(saved_icd.Length() - 1);
6449 const Array& result = Array::Handle(Array::New(icd.deopt_id() + 1));
6450 for (intptr_t i = 0; i < saved_icd.Length(); i++) {
6451 icd ^= saved_icd.At(i);
6452 result.SetAt(icd.deopt_id(), icd);
6453 }
6454 return result.raw();
6455 }
6456
6457
6458 void Function::set_ic_data_array(const Array& value) const {
6459 StorePointer(&raw_ptr()->ic_data_array_, value.raw());
6460 }
6461
6462
6463 RawArray* Function::ic_data_array() const {
6464 return raw_ptr()->ic_data_array_;
6465 }
6466
6467 void Function::ClearICData() const {
6468 set_ic_data_array(Array::Handle());
6469 }
6470
6471
6419 bool Function::CheckSourceFingerprint(int32_t fp) const { 6472 bool Function::CheckSourceFingerprint(int32_t fp) const {
6420 if (SourceFingerprint() != fp) { 6473 if (SourceFingerprint() != fp) {
6421 const bool recalculatingFingerprints = false; 6474 const bool recalculatingFingerprints = false;
6422 if (recalculatingFingerprints) { 6475 if (recalculatingFingerprints) {
6423 // This output can be copied into a file, then used with sed 6476 // This output can be copied into a file, then used with sed
6424 // to replace the old values. 6477 // to replace the old values.
6425 // sed -i .bak -f /tmp/newkeys runtime/vm/intrinsifier.h 6478 // sed -i .bak -f /tmp/newkeys runtime/vm/intrinsifier.h
6426 // sed -i .bak -f /tmp/newkeys runtime/vm/intermediate_language.h 6479 // sed -i .bak -f /tmp/newkeys runtime/vm/intermediate_language.h
6427 // sed -i .bak -f /tmp/newkeys runtime/vm/flow_graph_builder.h 6480 // sed -i .bak -f /tmp/newkeys runtime/vm/flow_graph_builder.h
6428 OS::Print("s/%d/%d/\n", fp, SourceFingerprint()); 6481 OS::Print("s/%d/%d/\n", fp, SourceFingerprint());
(...skipping 12639 matching lines...) Expand 10 before | Expand all | Expand 10 after
19068 return tag_label.ToCString(); 19121 return tag_label.ToCString();
19069 } 19122 }
19070 19123
19071 19124
19072 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 19125 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
19073 Instance::PrintJSONImpl(stream, ref); 19126 Instance::PrintJSONImpl(stream, ref);
19074 } 19127 }
19075 19128
19076 19129
19077 } // namespace dart 19130 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698