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

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

Issue 666993002: Fix test timeout; faster DEBUG String::CharAt by not using mutable accessor. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 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 | « no previous file | runtime/vm/object.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 #ifndef VM_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/utils.h" 10 #include "platform/utils.h"
(...skipping 5823 matching lines...) Expand 10 before | Expand all | Expand 10 after
5834 friend class ExternalOneByteString; 5834 friend class ExternalOneByteString;
5835 friend class ExternalTwoByteString; 5835 friend class ExternalTwoByteString;
5836 // So that the MarkingVisitor can print a debug string from a NoHandleScope. 5836 // So that the MarkingVisitor can print a debug string from a NoHandleScope.
5837 friend class MarkingVisitor; 5837 friend class MarkingVisitor;
5838 }; 5838 };
5839 5839
5840 5840
5841 class OneByteString : public AllStatic { 5841 class OneByteString : public AllStatic {
5842 public: 5842 public:
5843 static uint16_t CharAt(const String& str, intptr_t index) { 5843 static uint16_t CharAt(const String& str, intptr_t index) {
5844 NoGCScope no_gc; 5844 ASSERT((index >= 0) && (index < str.Length()));
5845 return *CharAddr(str, index); 5845 ASSERT(str.IsOneByteString());
5846 return raw_ptr(str)->data()[index];
5846 } 5847 }
5847 5848
5848 static void SetCharAt(const String& str, intptr_t index, uint8_t code_unit) { 5849 static void SetCharAt(const String& str, intptr_t index, uint8_t code_unit) {
5849 NoGCScope no_gc; 5850 NoGCScope no_gc;
5850 *CharAddr(str, index) = code_unit; 5851 *CharAddr(str, index) = code_unit;
5851 } 5852 }
5852 static RawOneByteString* EscapeSpecialCharacters(const String& str); 5853 static RawOneByteString* EscapeSpecialCharacters(const String& str);
5853 // We use the same maximum elements for all strings. 5854 // We use the same maximum elements for all strings.
5854 static const intptr_t kBytesPerElement = 1; 5855 static const intptr_t kBytesPerElement = 1;
5855 static const intptr_t kMaxElements = String::kMaxElements; 5856 static const intptr_t kMaxElements = String::kMaxElements;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
5965 friend class ExternalOneByteString; 5966 friend class ExternalOneByteString;
5966 friend class SnapshotReader; 5967 friend class SnapshotReader;
5967 friend class StringHasher; 5968 friend class StringHasher;
5968 }; 5969 };
5969 5970
5970 5971
5971 class TwoByteString : public AllStatic { 5972 class TwoByteString : public AllStatic {
5972 public: 5973 public:
5973 static uint16_t CharAt(const String& str, intptr_t index) { 5974 static uint16_t CharAt(const String& str, intptr_t index) {
5974 NoGCScope no_gc; 5975 NoGCScope no_gc;
5975 return *CharAddr(str, index); 5976 return *CharAddr(str, index);
Ivan Posva 2014/10/20 21:15:10 How about fixing it here as well?
koda 2014/10/20 23:58:28 Done.
5976 } 5977 }
5977 5978
5978 static void SetCharAt(const String& str, intptr_t index, uint16_t ch) { 5979 static void SetCharAt(const String& str, intptr_t index, uint16_t ch) {
5979 NoGCScope no_gc; 5980 NoGCScope no_gc;
5980 *CharAddr(str, index) = ch; 5981 *CharAddr(str, index) = ch;
5981 } 5982 }
5982 5983
5983 static RawTwoByteString* EscapeSpecialCharacters(const String& str); 5984 static RawTwoByteString* EscapeSpecialCharacters(const String& str);
5984 5985
5985 // We use the same maximum elements for all strings. 5986 // We use the same maximum elements for all strings.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
6066 friend class Class; 6067 friend class Class;
6067 friend class String; 6068 friend class String;
6068 friend class SnapshotReader; 6069 friend class SnapshotReader;
6069 }; 6070 };
6070 6071
6071 6072
6072 class ExternalOneByteString : public AllStatic { 6073 class ExternalOneByteString : public AllStatic {
6073 public: 6074 public:
6074 static uint16_t CharAt(const String& str, intptr_t index) { 6075 static uint16_t CharAt(const String& str, intptr_t index) {
6075 NoGCScope no_gc; 6076 NoGCScope no_gc;
6076 return *CharAddr(str, index); 6077 return *CharAddr(str, index);
Ivan Posva 2014/10/20 21:15:10 Ditto, here and other places.
koda 2014/10/20 23:58:28 Not needed for external strings, since their CharA
6077 } 6078 }
6078 6079
6079 static void* GetPeer(const String& str) { 6080 static void* GetPeer(const String& str) {
6080 return raw_ptr(str)->external_data_->peer(); 6081 return raw_ptr(str)->external_data_->peer();
6081 } 6082 }
6082 6083
6083 // We use the same maximum elements for all strings. 6084 // We use the same maximum elements for all strings.
6084 static const intptr_t kBytesPerElement = 1; 6085 static const intptr_t kBytesPerElement = 1;
6085 static const intptr_t kMaxElements = String::kMaxElements; 6086 static const intptr_t kMaxElements = String::kMaxElements;
6086 6087
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after
7557 7558
7558 7559
7559 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 7560 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
7560 intptr_t index) { 7561 intptr_t index) {
7561 return array.At((index * kEntryLength) + kTargetFunctionIndex); 7562 return array.At((index * kEntryLength) + kTargetFunctionIndex);
7562 } 7563 }
7563 7564
7564 } // namespace dart 7565 } // namespace dart
7565 7566
7566 #endif // VM_OBJECT_H_ 7567 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698