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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | vm/dart_api_impl.cc » ('j') | vm/object.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/dart_api_impl.h
===================================================================
--- vm/dart_api_impl.h (revision 6600)
+++ vm/dart_api_impl.h (working copy)
@@ -111,6 +111,18 @@
// Gets the handle used to designate successful return.
static Dart_Handle Success(Isolate* isolate);
+ // Returns true if the handle holds a Smi.
+ static bool IsSmi(Dart_Handle handle) {
+ RawObject* raw = *(reinterpret_cast<RawObject**>(handle));
+ return !raw->IsHeapObject();
+ }
+
+ // Returns the value of a Smi.
+ static intptr_t SmiValue(Dart_Handle handle) {
+ uword value = *(reinterpret_cast<uword*>(handle));
+ return Smi::ValueFromRaw(value);
+ }
+
// Generates a handle used to designate an error return.
static Dart_Handle NewError(const char* format, ...);
« no previous file with comments | « no previous file | vm/dart_api_impl.cc » ('j') | vm/object.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698