Chromium Code Reviews| 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/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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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::SetSavedICData( | |
|
Cutch
2014/06/16 21:39:42
Maybe rename to: SaveICData to go with RestoreICDa
srdjan
2014/06/16 21:58:09
Done.
| |
| 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 void Function::set_ic_data_array(const Array& value) const { | |
| 6443 StorePointer(&raw_ptr()->ic_data_array_, value.raw()); | |
| 6444 } | |
| 6445 | |
| 6446 | |
| 6447 RawArray* Function::ic_data_array() const { | |
| 6448 return raw_ptr()->ic_data_array_; | |
| 6449 } | |
| 6450 | |
| 6451 void Function::ClearICData() const { | |
| 6452 set_ic_data_array(Array::Handle()); | |
| 6453 } | |
| 6454 | |
| 6455 | |
| 6419 bool Function::CheckSourceFingerprint(int32_t fp) const { | 6456 bool Function::CheckSourceFingerprint(int32_t fp) const { |
| 6420 if (SourceFingerprint() != fp) { | 6457 if (SourceFingerprint() != fp) { |
| 6421 const bool recalculatingFingerprints = false; | 6458 const bool recalculatingFingerprints = false; |
| 6422 if (recalculatingFingerprints) { | 6459 if (recalculatingFingerprints) { |
| 6423 // This output can be copied into a file, then used with sed | 6460 // This output can be copied into a file, then used with sed |
| 6424 // to replace the old values. | 6461 // to replace the old values. |
| 6425 // sed -i .bak -f /tmp/newkeys runtime/vm/intrinsifier.h | 6462 // sed -i .bak -f /tmp/newkeys runtime/vm/intrinsifier.h |
| 6426 // sed -i .bak -f /tmp/newkeys runtime/vm/intermediate_language.h | 6463 // sed -i .bak -f /tmp/newkeys runtime/vm/intermediate_language.h |
| 6427 // sed -i .bak -f /tmp/newkeys runtime/vm/flow_graph_builder.h | 6464 // sed -i .bak -f /tmp/newkeys runtime/vm/flow_graph_builder.h |
| 6428 OS::Print("s/%d/%d/\n", fp, SourceFingerprint()); | 6465 OS::Print("s/%d/%d/\n", fp, SourceFingerprint()); |
| (...skipping 12639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 19068 return tag_label.ToCString(); | 19105 return tag_label.ToCString(); |
| 19069 } | 19106 } |
| 19070 | 19107 |
| 19071 | 19108 |
| 19072 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19109 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 19073 Instance::PrintJSONImpl(stream, ref); | 19110 Instance::PrintJSONImpl(stream, ref); |
| 19074 } | 19111 } |
| 19075 | 19112 |
| 19076 | 19113 |
| 19077 } // namespace dart | 19114 } // namespace dart |
| OLD | NEW |