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

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

Issue 10695136: Use class id instead of class in subtype test cache. (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') | 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 7202 matching lines...) Expand 10 before | Expand all | Expand 10 after
7213 } 7213 }
7214 7214
7215 7215
7216 intptr_t SubtypeTestCache::NumberOfChecks() const { 7216 intptr_t SubtypeTestCache::NumberOfChecks() const {
7217 // Do not count the sentinel; 7217 // Do not count the sentinel;
7218 return (Array::Handle(cache()).Length() / kTestEntryLength) - 1; 7218 return (Array::Handle(cache()).Length() / kTestEntryLength) - 1;
7219 } 7219 }
7220 7220
7221 7221
7222 void SubtypeTestCache::AddCheck( 7222 void SubtypeTestCache::AddCheck(
7223 const Class& instance_class, 7223 intptr_t instance_class_id,
7224 const AbstractTypeArguments& instance_type_arguments, 7224 const AbstractTypeArguments& instance_type_arguments,
7225 const AbstractTypeArguments& instantiator_type_arguments, 7225 const AbstractTypeArguments& instantiator_type_arguments,
7226 const Bool& test_result) const { 7226 const Bool& test_result) const {
7227 intptr_t old_num = NumberOfChecks(); 7227 intptr_t old_num = NumberOfChecks();
7228 Array& data = Array::Handle(cache()); 7228 Array& data = Array::Handle(cache());
7229 intptr_t new_len = data.Length() + kTestEntryLength; 7229 intptr_t new_len = data.Length() + kTestEntryLength;
7230 data = Array::Grow(data, new_len); 7230 data = Array::Grow(data, new_len);
7231 set_cache(data); 7231 set_cache(data);
7232 intptr_t data_pos = old_num * kTestEntryLength; 7232 intptr_t data_pos = old_num * kTestEntryLength;
7233 data.SetAt(data_pos + kInstanceClass, instance_class); 7233 data.SetAt(data_pos + kInstanceClassId,
7234 Smi::Handle(Smi::New(instance_class_id)));
7234 data.SetAt(data_pos + kInstanceTypeArguments, instance_type_arguments); 7235 data.SetAt(data_pos + kInstanceTypeArguments, instance_type_arguments);
7235 data.SetAt(data_pos + kInstantiatorTypeArguments, 7236 data.SetAt(data_pos + kInstantiatorTypeArguments,
7236 instantiator_type_arguments); 7237 instantiator_type_arguments);
7237 data.SetAt(data_pos + kTestResult, test_result); 7238 data.SetAt(data_pos + kTestResult, test_result);
7238 } 7239 }
7239 7240
7240 7241
7241 void SubtypeTestCache::GetCheck( 7242 void SubtypeTestCache::GetCheck(
7242 intptr_t ix, 7243 intptr_t ix,
7243 Class* instance_class, 7244 intptr_t* instance_class_id,
7244 AbstractTypeArguments* instance_type_arguments, 7245 AbstractTypeArguments* instance_type_arguments,
7245 AbstractTypeArguments* instantiator_type_arguments, 7246 AbstractTypeArguments* instantiator_type_arguments,
7246 Bool* test_result) const { 7247 Bool* test_result) const {
7247 Array& data = Array::Handle(cache()); 7248 Array& data = Array::Handle(cache());
7248 intptr_t data_pos = ix * kTestEntryLength; 7249 intptr_t data_pos = ix * kTestEntryLength;
7249 *instance_class ^= data.At(data_pos + kInstanceClass); 7250 Smi& instance_class_id_handle = Smi::Handle();
7251 instance_class_id_handle ^= data.At(data_pos + kInstanceClassId);
7252 *instance_class_id = instance_class_id_handle.Value();
7250 *instance_type_arguments ^= data.At(data_pos + kInstanceTypeArguments); 7253 *instance_type_arguments ^= data.At(data_pos + kInstanceTypeArguments);
7251 *instantiator_type_arguments ^= 7254 *instantiator_type_arguments ^=
7252 data.At(data_pos + kInstantiatorTypeArguments); 7255 data.At(data_pos + kInstantiatorTypeArguments);
7253 *test_result ^= data.At(data_pos + kTestResult); 7256 *test_result ^= data.At(data_pos + kTestResult);
7254 } 7257 }
7255 7258
7256 7259
7257 const char* SubtypeTestCache::ToCString() const { 7260 const char* SubtypeTestCache::ToCString() const {
7258 return "SubtypeTestCache"; 7261 return "SubtypeTestCache";
7259 } 7262 }
(...skipping 3392 matching lines...) Expand 10 before | Expand all | Expand 10 after
10652 const String& str = String::Handle(pattern()); 10655 const String& str = String::Handle(pattern());
10653 const char* format = "JSRegExp: pattern=%s flags=%s"; 10656 const char* format = "JSRegExp: pattern=%s flags=%s";
10654 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 10657 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
10655 char* chars = reinterpret_cast<char*>( 10658 char* chars = reinterpret_cast<char*>(
10656 Isolate::Current()->current_zone()->Allocate(len + 1)); 10659 Isolate::Current()->current_zone()->Allocate(len + 1));
10657 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 10660 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
10658 return chars; 10661 return chars;
10659 } 10662 }
10660 10663
10661 } // namespace dart 10664 } // 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