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

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

Issue 10702195: Equality compare should record two arguments in IC data. INline double equality comparison. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 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') | no next file » | 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 7172 matching lines...) Expand 10 before | Expand all | Expand 10 after
7183 const Array& data = Array::Handle(ic_data()); 7183 const Array& data = Array::Handle(ic_data());
7184 intptr_t data_pos = index * TestEntryLength(); 7184 intptr_t data_pos = index * TestEntryLength();
7185 Smi& smi = Smi::Handle(); 7185 Smi& smi = Smi::Handle();
7186 smi ^= data.At(data_pos); 7186 smi ^= data.At(data_pos);
7187 *class_id = smi.Value(); 7187 *class_id = smi.Value();
7188 *target ^= data.At(data_pos + 1); 7188 *target ^= data.At(data_pos + 1);
7189 } 7189 }
7190 7190
7191 7191
7192 intptr_t ICData::GetReceiverClassIdAt(intptr_t index) const { 7192 intptr_t ICData::GetReceiverClassIdAt(intptr_t index) const {
7193 ASSERT(index < NumberOfChecks());
7193 const Array& data = Array::Handle(ic_data()); 7194 const Array& data = Array::Handle(ic_data());
7194 const intptr_t data_pos = index * TestEntryLength(); 7195 const intptr_t data_pos = index * TestEntryLength();
7195 Smi& smi = Smi::Handle(); 7196 Smi& smi = Smi::Handle();
7196 smi ^= data.At(data_pos); 7197 smi ^= data.At(data_pos);
7197 return smi.Value(); 7198 return smi.Value();
7198 } 7199 }
7199 7200
7200 7201
7201 RawFunction* ICData::GetTargetAt(intptr_t index) const { 7202 RawFunction* ICData::GetTargetAt(intptr_t index) const {
7202 const Array& data = Array::Handle(ic_data()); 7203 const Array& data = Array::Handle(ic_data());
7203 const intptr_t data_pos = index * TestEntryLength() + num_args_tested(); 7204 const intptr_t data_pos = index * TestEntryLength() + num_args_tested();
7204 Function& target = Function::Handle(); 7205 Function& target = Function::Handle();
7205 target ^= data.At(data_pos); 7206 target ^= data.At(data_pos);
7206 return target.raw(); 7207 return target.raw();
7207 } 7208 }
7208 7209
7209 7210
7210 RawFunction* ICData::GetTargetForReceiverClassId(intptr_t class_id) const { 7211 RawFunction* ICData::GetTargetForReceiverClassId(intptr_t class_id) const {
7211 for (intptr_t i = 0; i < NumberOfChecks(); i++) { 7212 for (intptr_t i = 0; i < NumberOfChecks(); i++) {
7212 if (GetReceiverClassIdAt(i) == class_id) { 7213 if (GetReceiverClassIdAt(i) == class_id) {
7213 return GetTargetAt(i); 7214 return GetTargetAt(i);
7214 } 7215 }
7215 } 7216 }
7216 return Function::null(); 7217 return Function::null();
7217 } 7218 }
7218 7219
7219 7220
7221 RawICData* ICData::AsUnaryClassChecks() const {
7222 ASSERT(!IsNull());
7223 ASSERT(num_args_tested() > 0);
7224 if (num_args_tested() == 1) return raw();
7225 const intptr_t kNumArgsTested = 1;
7226 ICData& result = ICData::Handle(ICData::New(
7227 Function::Handle(function()),
7228 String::Handle(target_name()),
7229 id(),
7230 kNumArgsTested));
7231 for (intptr_t i = 0; i < NumberOfChecks(); i++) {
7232 const intptr_t class_id = GetReceiverClassIdAt(i);
7233 intptr_t duplicate_class_id = -1;
7234 for (intptr_t k = 0; k < result.NumberOfChecks(); k++) {
7235 if (class_id == result.GetReceiverClassIdAt(k)) {
7236 duplicate_class_id = k;
7237 break;
7238 }
7239 }
7240 if (duplicate_class_id >= 0) {
7241 ASSERT(result.GetTargetAt(duplicate_class_id) == GetTargetAt(i));
7242 } else {
7243 // This will make sure that Smi is first if it exists.
7244 result.AddReceiverCheck(class_id,
7245 Function::Handle(GetTargetAt(i)));
7246 }
7247 }
7248 return result.raw();
7249 }
7250
7251
7220 RawICData* ICData::New(const Function& function, 7252 RawICData* ICData::New(const Function& function,
7221 const String& target_name, 7253 const String& target_name,
7222 intptr_t id, 7254 intptr_t id,
7223 intptr_t num_args_tested) { 7255 intptr_t num_args_tested) {
7224 ASSERT(num_args_tested > 0); 7256 ASSERT(num_args_tested > 0);
7225 const Class& cls = Class::Handle(Object::icdata_class()); 7257 const Class& cls = Class::Handle(Object::icdata_class());
7226 ASSERT(!cls.IsNull()); 7258 ASSERT(!cls.IsNull());
7227 ICData& result = ICData::Handle(); 7259 ICData& result = ICData::Handle();
7228 { 7260 {
7229 // IC data objects are long living objects, allocate them in old generation. 7261 // IC data objects are long living objects, allocate them in old generation.
(...skipping 3481 matching lines...) Expand 10 before | Expand all | Expand 10 after
10711 const String& str = String::Handle(pattern()); 10743 const String& str = String::Handle(pattern());
10712 const char* format = "JSRegExp: pattern=%s flags=%s"; 10744 const char* format = "JSRegExp: pattern=%s flags=%s";
10713 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 10745 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
10714 char* chars = reinterpret_cast<char*>( 10746 char* chars = reinterpret_cast<char*>(
10715 Isolate::Current()->current_zone()->Allocate(len + 1)); 10747 Isolate::Current()->current_zone()->Allocate(len + 1));
10716 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 10748 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
10717 return chars; 10749 return chars;
10718 } 10750 }
10719 10751
10720 } // namespace dart 10752 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698