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

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

Issue 17554003: Change static calls in unoptimized code to always call via a stub. Using ICData, the call count of … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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/object_test.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) 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 8511 matching lines...) Expand 10 before | Expand all | Expand 10 after
8522 } 8522 }
8523 if (matches) { 8523 if (matches) {
8524 return true; 8524 return true;
8525 } 8525 }
8526 } 8526 }
8527 return false; 8527 return false;
8528 } 8528 }
8529 #endif // DEBUG 8529 #endif // DEBUG
8530 8530
8531 8531
8532 // Used for unoptimized static calls when no class-ids are checked.
8533 void ICData::AddTarget(const Function& target) const {
8534 ASSERT(num_args_tested() == 0);
8535 // Can add only once.
8536 const intptr_t old_num = NumberOfChecks();
8537 ASSERT(old_num == 0);
8538 Array& data = Array::Handle(ic_data());
8539 const intptr_t new_len = data.Length() + TestEntryLength();
8540 data = Array::Grow(data, new_len, Heap::kOld);
8541 set_ic_data(data);
8542 WriteSentinel(data);
8543 intptr_t data_pos = old_num * TestEntryLength();
8544 ASSERT(!target.IsNull());
8545 data.SetAt(data_pos++, target);
8546 const Smi& value = Smi::Handle(Smi::New(0));
8547 data.SetAt(data_pos, value);
8548 }
8549
8550
8532 void ICData::AddCheck(const GrowableArray<intptr_t>& class_ids, 8551 void ICData::AddCheck(const GrowableArray<intptr_t>& class_ids,
8533 const Function& target) const { 8552 const Function& target) const {
8534 DEBUG_ASSERT(!HasCheck(class_ids)); 8553 DEBUG_ASSERT(!HasCheck(class_ids));
8535 ASSERT(num_args_tested() > 1); // Otherwise use 'AddReceiverCheck'. 8554 ASSERT(num_args_tested() > 1); // Otherwise use 'AddReceiverCheck'.
8536 ASSERT(class_ids.length() == num_args_tested()); 8555 ASSERT(class_ids.length() == num_args_tested());
8537 const intptr_t old_num = NumberOfChecks(); 8556 const intptr_t old_num = NumberOfChecks();
8538 Array& data = Array::Handle(ic_data()); 8557 Array& data = Array::Handle(ic_data());
8539 const intptr_t new_len = data.Length() + TestEntryLength(); 8558 const intptr_t new_len = data.Length() + TestEntryLength();
8540 data = Array::Grow(data, new_len, Heap::kOld); 8559 data = Array::Grow(data, new_len, Heap::kOld);
8541 set_ic_data(data); 8560 set_ic_data(data);
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
8792 return true; 8811 return true;
8793 } 8812 }
8794 8813
8795 8814
8796 RawICData* ICData::New(const Function& function, 8815 RawICData* ICData::New(const Function& function,
8797 const String& target_name, 8816 const String& target_name,
8798 const Array& arguments_descriptor, 8817 const Array& arguments_descriptor,
8799 intptr_t deopt_id, 8818 intptr_t deopt_id,
8800 intptr_t num_args_tested) { 8819 intptr_t num_args_tested) {
8801 ASSERT(Object::icdata_class() != Class::null()); 8820 ASSERT(Object::icdata_class() != Class::null());
8802 ASSERT(num_args_tested > 0); 8821 ASSERT(num_args_tested >= 0);
8803 ICData& result = ICData::Handle(); 8822 ICData& result = ICData::Handle();
8804 { 8823 {
8805 // IC data objects are long living objects, allocate them in old generation. 8824 // IC data objects are long living objects, allocate them in old generation.
8806 RawObject* raw = Object::Allocate(ICData::kClassId, 8825 RawObject* raw = Object::Allocate(ICData::kClassId,
8807 ICData::InstanceSize(), 8826 ICData::InstanceSize(),
8808 Heap::kOld); 8827 Heap::kOld);
8809 NoGCScope no_gc; 8828 NoGCScope no_gc;
8810 result ^= raw; 8829 result ^= raw;
8811 } 8830 }
8812 result.set_function(function); 8831 result.set_function(function);
(...skipping 4816 matching lines...) Expand 10 before | Expand all | Expand 10 after
13629 space); 13648 space);
13630 return reinterpret_cast<RawWeakProperty*>(raw); 13649 return reinterpret_cast<RawWeakProperty*>(raw);
13631 } 13650 }
13632 13651
13633 13652
13634 const char* WeakProperty::ToCString() const { 13653 const char* WeakProperty::ToCString() const {
13635 return "_WeakProperty"; 13654 return "_WeakProperty";
13636 } 13655 }
13637 13656
13638 } // namespace dart 13657 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698