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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 1186353004: Move allocation of static API handles Dart_True, etc. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 | « runtime/vm/dart.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index d7c58186dc713586dc432186815d607d64e1be4d..a7660389d9e5ad7e879812541f31c25e47b92c17 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -493,23 +493,32 @@ void Api::InitOnce() {
}
+static Dart_Handle InitNewReadOnlyApiHandle(RawObject* raw) {
+ ASSERT(raw->IsVMHeapObject());
+ LocalHandle* ref = Dart::AllocateReadOnlyApiHandle();
+ ref->set_raw(raw);
+ return reinterpret_cast<Dart_Handle>(ref);
Ivan Posva 2015/06/17 16:58:57 Not sure how often we need to make LocalHandles in
+}
+
+
void Api::InitHandles() {
Isolate* isolate = Isolate::Current();
ASSERT(isolate != NULL);
ASSERT(isolate == Dart::vm_isolate());
ApiState* state = isolate->api_state();
ASSERT(state != NULL);
+
ASSERT(true_handle_ == NULL);
- true_handle_ = Api::InitNewHandle(isolate, Bool::True().raw());
+ true_handle_ = InitNewReadOnlyApiHandle(Bool::True().raw());
ASSERT(false_handle_ == NULL);
- false_handle_ = Api::InitNewHandle(isolate, Bool::False().raw());
+ false_handle_ = InitNewReadOnlyApiHandle(Bool::False().raw());
ASSERT(null_handle_ == NULL);
- null_handle_ = Api::InitNewHandle(isolate, Object::null());
+ null_handle_ = InitNewReadOnlyApiHandle(Object::null());
ASSERT(empty_string_handle_ == NULL);
- empty_string_handle_ = Api::InitNewHandle(isolate, Symbols::Empty().raw());
+ empty_string_handle_ = InitNewReadOnlyApiHandle(Symbols::Empty().raw());
}
« no previous file with comments | « runtime/vm/dart.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698