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

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

Issue 10580024: This is https://chromiumcodereview.appspot.com/10581006/ that I forgot to submit, and messed up the… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 6638 matching lines...) Expand 10 before | Expand all | Expand 10 after
6649 return num_args_tested() + 1 /* target function*/; 6649 return num_args_tested() + 1 /* target function*/;
6650 } 6650 }
6651 6651
6652 6652
6653 intptr_t ICData::NumberOfChecks() const { 6653 intptr_t ICData::NumberOfChecks() const {
6654 // Do not count the sentinel; 6654 // Do not count the sentinel;
6655 return (Array::Handle(ic_data()).Length() / TestEntryLength()) - 1; 6655 return (Array::Handle(ic_data()).Length() / TestEntryLength()) - 1;
6656 } 6656 }
6657 6657
6658 6658
6659 void ICData::AddCheck(const GrowableArray<const Class*>& classes, 6659 void ICData::AddCheck(const GrowableArray<intptr_t>& class_ids,
6660 const Function& target) const { 6660 const Function& target) const {
6661 ASSERT(classes.length() == num_args_tested()); 6661 ASSERT(class_ids.length() == num_args_tested());
6662 intptr_t old_num = NumberOfChecks(); 6662 intptr_t old_num = NumberOfChecks();
6663 Array& data = Array::Handle(ic_data()); 6663 Array& data = Array::Handle(ic_data());
6664 intptr_t new_len = data.Length() + TestEntryLength(); 6664 intptr_t new_len = data.Length() + TestEntryLength();
6665 data = Array::Grow(data, new_len, Heap::kOld); 6665 data = Array::Grow(data, new_len, Heap::kOld);
6666 set_ic_data(data); 6666 set_ic_data(data);
6667 intptr_t data_pos = old_num * TestEntryLength(); 6667 intptr_t data_pos = old_num * TestEntryLength();
6668 for (intptr_t i = 0; i < classes.length(); i++) { 6668 for (intptr_t i = 0; i < class_ids.length(); i++) {
6669 // Null is used as terminating value, do not add it. 6669 // Null is used as terminating value, do not add it.
6670 ASSERT(!classes[i]->IsNull()); 6670 ASSERT(class_ids[i] != kNullClass);
6671 data.SetAt(data_pos++, *(classes[i])); 6671 data.SetAt(data_pos++, Smi::Handle(Smi::New(class_ids[i])));
6672 } 6672 }
6673 ASSERT(!target.IsNull()); 6673 ASSERT(!target.IsNull());
6674 data.SetAt(data_pos, target); 6674 data.SetAt(data_pos, target);
6675 } 6675 }
6676 6676
6677 6677
6678 void ICData::GetCheckAt(intptr_t index, 6678 void ICData::GetCheckAt(intptr_t index,
6679 GrowableArray<const Class*>* classes, 6679 GrowableArray<intptr_t>* class_ids,
6680 Function* target) const { 6680 Function* target) const {
6681 ASSERT(classes != NULL); 6681 ASSERT(class_ids != NULL);
6682 ASSERT(target != NULL); 6682 ASSERT(target != NULL);
6683 classes->Clear(); 6683 class_ids->Clear();
6684 const Array& data = Array::Handle(ic_data()); 6684 const Array& data = Array::Handle(ic_data());
6685 intptr_t data_pos = index * TestEntryLength(); 6685 intptr_t data_pos = index * TestEntryLength();
6686 Smi& smi = Smi::Handle();
6686 for (intptr_t i = 0; i < num_args_tested(); i++) { 6687 for (intptr_t i = 0; i < num_args_tested(); i++) {
6687 Class& cls = Class::ZoneHandle(); 6688 smi ^= data.At(data_pos++);
6688 cls ^= data.At(data_pos++); 6689 class_ids->Add(smi.Value());
6689 classes->Add(&cls);
6690 } 6690 }
6691 (*target) ^= data.At(data_pos); 6691 (*target) ^= data.At(data_pos);
6692 } 6692 }
6693 6693
6694 6694
6695 void ICData::GetOneClassCheckAt( 6695 void ICData::GetOneClassCheckAt(
6696 int index, Class* cls, Function* target) const { 6696 int index, intptr_t* class_id, Function* target) const {
6697 ASSERT(cls != NULL); 6697 ASSERT(class_id != NULL);
6698 ASSERT(target != NULL); 6698 ASSERT(target != NULL);
6699 ASSERT(num_args_tested() == 1); 6699 ASSERT(num_args_tested() == 1);
6700 const Array& data = Array::Handle(ic_data()); 6700 const Array& data = Array::Handle(ic_data());
6701 intptr_t data_pos = index * TestEntryLength(); 6701 intptr_t data_pos = index * TestEntryLength();
6702 *cls ^= data.At(data_pos); 6702 Smi& smi = Smi::Handle();
6703 smi ^= data.At(data_pos);
6704 *class_id = smi.Value();
6703 *target ^= data.At(data_pos + 1); 6705 *target ^= data.At(data_pos + 1);
6704 } 6706 }
6705 6707
6706 6708
6707 RawICData* ICData::New(const Function& function, 6709 RawICData* ICData::New(const Function& function,
6708 const String& target_name, 6710 const String& target_name,
6709 intptr_t id, 6711 intptr_t id,
6710 intptr_t num_args_tested) { 6712 intptr_t num_args_tested) {
6711 ASSERT(num_args_tested > 0); 6713 ASSERT(num_args_tested > 0);
6712 const Class& cls = Class::Handle(Object::icdata_class()); 6714 const Class& cls = Class::Handle(Object::icdata_class());
(...skipping 3413 matching lines...) Expand 10 before | Expand all | Expand 10 after
10126 const String& str = String::Handle(pattern()); 10128 const String& str = String::Handle(pattern());
10127 const char* format = "JSRegExp: pattern=%s flags=%s"; 10129 const char* format = "JSRegExp: pattern=%s flags=%s";
10128 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 10130 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
10129 char* chars = reinterpret_cast<char*>( 10131 char* chars = reinterpret_cast<char*>(
10130 Isolate::Current()->current_zone()->Allocate(len + 1)); 10132 Isolate::Current()->current_zone()->Allocate(len + 1));
10131 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 10133 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
10132 return chars; 10134 return chars;
10133 } 10135 }
10134 10136
10135 } // namespace dart 10137 } // 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