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

Side by Side Diff: vm/object.h

Issue 10783035: Create frequently used symbols in the vm isolate (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
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
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 11 matching lines...) Expand all
22 22
23 // Forward declarations. 23 // Forward declarations.
24 #define DEFINE_FORWARD_DECLARATION(clazz) \ 24 #define DEFINE_FORWARD_DECLARATION(clazz) \
25 class clazz; 25 class clazz;
26 CLASS_LIST(DEFINE_FORWARD_DECLARATION) 26 CLASS_LIST(DEFINE_FORWARD_DECLARATION)
27 #undef DEFINE_FORWARD_DECLARATION 27 #undef DEFINE_FORWARD_DECLARATION
28 class Api; 28 class Api;
29 class Assembler; 29 class Assembler;
30 class Code; 30 class Code;
31 class LocalScope; 31 class LocalScope;
32 class Symbols;
32 33
33 #define OBJECT_IMPLEMENTATION(object, super) \ 34 #define OBJECT_IMPLEMENTATION(object, super) \
34 public: /* NOLINT */ \ 35 public: /* NOLINT */ \
35 Raw##object* raw() const { return reinterpret_cast<Raw##object*>(raw_); } \ 36 Raw##object* raw() const { return reinterpret_cast<Raw##object*>(raw_); } \
36 void operator=(Raw##object* value) { \ 37 void operator=(Raw##object* value) { \
37 initializeHandle(this, value); \ 38 initializeHandle(this, value); \
38 } \ 39 } \
39 bool Is##object() const { return true; } \ 40 bool Is##object() const { return true; } \
40 void operator^=(RawObject* value) { \ 41 void operator^=(RawObject* value) { \
41 initializeHandle(this, value); \ 42 initializeHandle(this, value); \
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 359
359 uword raw_value() const { 360 uword raw_value() const {
360 return reinterpret_cast<uword>(raw()); 361 return reinterpret_cast<uword>(raw());
361 } 362 }
362 363
363 inline void SetRaw(RawObject* value); 364 inline void SetRaw(RawObject* value);
364 365
365 cpp_vtable vtable() const { return bit_copy<cpp_vtable>(*this); } 366 cpp_vtable vtable() const { return bit_copy<cpp_vtable>(*this); }
366 void set_vtable(cpp_vtable value) { *vtable_address() = value; } 367 void set_vtable(cpp_vtable value) { *vtable_address() = value; }
367 368
368 static RawObject* Allocate(const Class& cls, 369 static RawObject* Allocate(intptr_t cls_id,
369 intptr_t size, 370 intptr_t size,
370 Heap::Space space); 371 Heap::Space space);
371 372
372 static intptr_t RoundedAllocationSize(intptr_t size) { 373 static intptr_t RoundedAllocationSize(intptr_t size) {
373 return Utils::RoundUp(size, kObjectAlignment); 374 return Utils::RoundUp(size, kObjectAlignment);
374 } 375 }
375 376
376 template<typename type> void StorePointer(type* addr, type value) const { 377 template<typename type> void StorePointer(type* addr, type value) const {
377 // TODO(iposva): Implement real store barrier here. 378 // TODO(iposva): Implement real store barrier here.
378 *addr = value; 379 *addr = value;
(...skipping 2900 matching lines...) Expand 10 before | Expand all | Expand 10 after
3279 3280
3280 static RawString* Transform(int32_t (*mapping)(int32_t ch), 3281 static RawString* Transform(int32_t (*mapping)(int32_t ch),
3281 const String& str, 3282 const String& str,
3282 Heap::Space space = Heap::kNew); 3283 Heap::Space space = Heap::kNew);
3283 3284
3284 static RawString* ToUpperCase(const String& str, 3285 static RawString* ToUpperCase(const String& str,
3285 Heap::Space space = Heap::kNew); 3286 Heap::Space space = Heap::kNew);
3286 static RawString* ToLowerCase(const String& str, 3287 static RawString* ToLowerCase(const String& str,
3287 Heap::Space space = Heap::kNew); 3288 Heap::Space space = Heap::kNew);
3288 3289
3289 static RawString* NewSymbol(const char* str);
3290 template<typename T>
3291 static RawString* NewSymbol(const T* characters, intptr_t len);
3292 static RawString* NewSymbol(const String& str);
3293 static RawString* NewSymbol(const String& str,
3294 intptr_t begin_index,
3295 intptr_t length);
3296
3297 static RawString* NewFormatted(const char* format, ...); 3290 static RawString* NewFormatted(const char* format, ...);
3298 3291
3299 protected: 3292 protected:
3300 bool HasHash() const { 3293 bool HasHash() const {
3301 ASSERT(Smi::New(0) == NULL); 3294 ASSERT(Smi::New(0) == NULL);
3302 return (raw_ptr()->hash_ != NULL); 3295 return (raw_ptr()->hash_ != NULL);
3303 } 3296 }
3304 3297
3305 void SetLength(intptr_t value) const { 3298 void SetLength(intptr_t value) const {
3306 // This is only safe because we create a new Smi, which does not cause 3299 // This is only safe because we create a new Smi, which does not cause
3307 // heap allocation. 3300 // heap allocation.
3308 raw_ptr()->length_ = Smi::New(value); 3301 raw_ptr()->length_ = Smi::New(value);
3309 } 3302 }
3310 3303
3311 void SetHash(intptr_t value) const { 3304 void SetHash(intptr_t value) const {
3312 // This is only safe because we create a new Smi, which does not cause 3305 // This is only safe because we create a new Smi, which does not cause
3313 // heap allocation. 3306 // heap allocation.
3314 raw_ptr()->hash_ = Smi::New(value); 3307 raw_ptr()->hash_ = Smi::New(value);
3315 } 3308 }
3316 3309
3317 template<typename HandleType, typename ElementType> 3310 template<typename HandleType, typename ElementType>
3318 static void ReadFromImpl(SnapshotReader* reader, 3311 static void ReadFromImpl(SnapshotReader* reader,
3319 HandleType* str_obj, 3312 HandleType* str_obj,
3320 intptr_t len, 3313 intptr_t len,
3321 intptr_t tags); 3314 intptr_t tags);
3322 3315
3323 HEAP_OBJECT_IMPLEMENTATION(String, Instance); 3316 HEAP_OBJECT_IMPLEMENTATION(String, Instance);
3317
3318 friend class Symbols;
3324 }; 3319 };
3325 3320
3326 3321
3327 class OneByteString : public String { 3322 class OneByteString : public String {
3328 public: 3323 public:
3329 virtual int32_t CharAt(intptr_t index) const { 3324 virtual int32_t CharAt(intptr_t index) const {
3330 return *CharAddr(index); 3325 return *CharAddr(index);
3331 } 3326 }
3332 3327
3333 virtual intptr_t CharSize() const { 3328 virtual intptr_t CharSize() const {
(...skipping 1834 matching lines...) Expand 10 before | Expand all | Expand 10 after
5168 if (this->CharAt(i) != str.CharAt(begin_index + i)) { 5163 if (this->CharAt(i) != str.CharAt(begin_index + i)) {
5169 return false; 5164 return false;
5170 } 5165 }
5171 } 5166 }
5172 return true; 5167 return true;
5173 } 5168 }
5174 5169
5175 } // namespace dart 5170 } // namespace dart
5176 5171
5177 #endif // VM_OBJECT_H_ 5172 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698