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

Side by Side Diff: vm/dart_api_impl.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 | « no previous file | vm/dart_api_impl.cc » ('j') | vm/dart_api_impl.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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_DART_API_IMPL_H_ 5 #ifndef VM_DART_API_IMPL_H_
6 #define VM_DART_API_IMPL_H_ 6 #define VM_DART_API_IMPL_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 10
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 static FinalizablePersistentHandle* UnwrapAsPrologueWeakPersistentHandle( 104 static FinalizablePersistentHandle* UnwrapAsPrologueWeakPersistentHandle(
105 const ApiState& state, 105 const ApiState& state,
106 Dart_Handle object); 106 Dart_Handle object);
107 107
108 // Casts the internal Isolate* type to the external Dart_Isolate type. 108 // Casts the internal Isolate* type to the external Dart_Isolate type.
109 static Dart_Isolate CastIsolate(Isolate* isolate); 109 static Dart_Isolate CastIsolate(Isolate* isolate);
110 110
111 // Gets the handle used to designate successful return. 111 // Gets the handle used to designate successful return.
112 static Dart_Handle Success(Isolate* isolate); 112 static Dart_Handle Success(Isolate* isolate);
113 113
114 // Returns true if the handle holds a Smi.
115 static bool IsSmi(Dart_Handle handle) {
cshapiro 2012/04/11 23:29:09 Why not call the existing predicate after casing t
turnidge 2012/04/16 20:07:24 Done.
116 uword value = *(reinterpret_cast<uword*>(handle));
117 return (value & kSmiTagMask) == kSmiTag;
118 }
119
120 // Returns the value of a Smi.
121 static intptr_t SmiValue(Dart_Handle handle) {
122 intptr_t value = *(reinterpret_cast<intptr_t*>(handle));
cshapiro 2012/04/11 23:29:09 This may be another opportunity to reuse existing
turnidge 2012/04/16 20:07:24 Done. Had to add friend permission though...
123 ASSERT((value & kSmiTagMask) == kSmiTag);
124 return (value >> kSmiTagShift);
125 }
126
114 // Generates a handle used to designate an error return. 127 // Generates a handle used to designate an error return.
115 static Dart_Handle NewError(const char* format, ...); 128 static Dart_Handle NewError(const char* format, ...);
116 129
117 // Gets a handle to Null. 130 // Gets a handle to Null.
118 static Dart_Handle Null(Isolate* isolate); 131 static Dart_Handle Null(Isolate* isolate);
119 132
120 // Gets a handle to True. 133 // Gets a handle to True.
121 static Dart_Handle True(Isolate* isolate); 134 static Dart_Handle True(Isolate* isolate);
122 135
123 // Gets a handle to False 136 // Gets a handle to False
(...skipping 29 matching lines...) Expand all
153 } 166 }
154 private: 167 private:
155 Isolate* saved_isolate_; 168 Isolate* saved_isolate_;
156 169
157 DISALLOW_COPY_AND_ASSIGN(IsolateSaver); 170 DISALLOW_COPY_AND_ASSIGN(IsolateSaver);
158 }; 171 };
159 172
160 } // namespace dart. 173 } // namespace dart.
161 174
162 #endif // VM_DART_API_IMPL_H_ 175 #endif // VM_DART_API_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | vm/dart_api_impl.cc » ('j') | vm/dart_api_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698