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

Side by Side Diff: vm/object.h

Issue 10052027: Add fast paths for Smi values in the dart embedding api. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 8 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 | « vm/dart_api_impl.cc ('k') | 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"
11 #include "vm/bitmap.h" 11 #include "vm/bitmap.h"
12 #include "vm/dart.h" 12 #include "vm/dart.h"
13 #include "vm/globals.h" 13 #include "vm/globals.h"
14 #include "vm/handles.h" 14 #include "vm/handles.h"
15 #include "vm/heap.h" 15 #include "vm/heap.h"
16 #include "vm/isolate.h" 16 #include "vm/isolate.h"
17 #include "vm/os.h" 17 #include "vm/os.h"
18 #include "vm/raw_object.h" 18 #include "vm/raw_object.h"
19 #include "vm/scanner.h" 19 #include "vm/scanner.h"
20 20
21 namespace dart { 21 namespace dart {
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 Assembler; 29 class Assembler;
29 class Code; 30 class Code;
30 class LocalScope; 31 class LocalScope;
31 32
32 #define OBJECT_IMPLEMENTATION(object, super) \ 33 #define OBJECT_IMPLEMENTATION(object, super) \
33 public: /* NOLINT */ \ 34 public: /* NOLINT */ \
34 Raw##object* raw() const { return reinterpret_cast<Raw##object*>(raw_); } \ 35 Raw##object* raw() const { return reinterpret_cast<Raw##object*>(raw_); } \
35 void operator=(Raw##object* value) { \ 36 void operator=(Raw##object* value) { \
36 initializeHandle(this, value); \ 37 initializeHandle(this, value); \
37 } \ 38 } \
(...skipping 2692 matching lines...) Expand 10 before | Expand all | Expand 10 after
2730 static RawClass* Class(); 2731 static RawClass* Class();
2731 2732
2732 static intptr_t Value(RawSmi* raw_smi) { 2733 static intptr_t Value(RawSmi* raw_smi) {
2733 return ValueFromRaw(reinterpret_cast<uword>(raw_smi)); 2734 return ValueFromRaw(reinterpret_cast<uword>(raw_smi));
2734 } 2735 }
2735 2736
2736 static intptr_t RawValue(intptr_t value) { 2737 static intptr_t RawValue(intptr_t value) {
2737 return reinterpret_cast<intptr_t>(New(value)); 2738 return reinterpret_cast<intptr_t>(New(value));
2738 } 2739 }
2739 2740
2740 static bool IsValid(intptr_t value); 2741 static bool IsValid(intptr_t value) {
2741 static bool IsValid64(int64_t value); 2742 return (value >= kMinValue) && (value <= kMaxValue);
2743 }
2744
2745 static bool IsValid64(int64_t value) {
2746 return (value >= kMinValue) && (value <= kMaxValue);
2747 }
2742 2748
2743 private: 2749 private:
2750 friend class Api; // For ValueFromRaw
cshapiro 2012/04/16 20:32:45 Co-locate this with the other friend classes below
2751
2744 static intptr_t ValueFromRaw(uword raw_value) { 2752 static intptr_t ValueFromRaw(uword raw_value) {
2745 intptr_t value = raw_value; 2753 intptr_t value = raw_value;
2746 ASSERT((value & kSmiTagMask) == kSmiTag); 2754 ASSERT((value & kSmiTagMask) == kSmiTag);
2747 return (value >> kSmiTagShift); 2755 return (value >> kSmiTagShift);
2748 } 2756 }
2749 static cpp_vtable handle_vtable_; 2757 static cpp_vtable handle_vtable_;
2750 2758
2751 OBJECT_IMPLEMENTATION(Smi, Integer); 2759 OBJECT_IMPLEMENTATION(Smi, Integer);
2752 friend class Object; 2760 friend class Object;
2753 friend class Class; 2761 friend class Class;
(...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after
3986 } 3994 }
3987 3995
3988 3996
3989 intptr_t Stackmap::SizeInBits() const { 3997 intptr_t Stackmap::SizeInBits() const {
3990 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); 3998 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte);
3991 } 3999 }
3992 4000
3993 } // namespace dart 4001 } // namespace dart
3994 4002
3995 #endif // VM_OBJECT_H_ 4003 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « vm/dart_api_impl.cc ('k') | vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698