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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 208443002: Use a bit in the handle structure to indicate if it is a prologue weak handle instead of the taggin… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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 | runtime/vm/dart_api_state.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
===================================================================
--- runtime/vm/dart_api_impl.cc (revision 34251)
+++ runtime/vm/dart_api_impl.cc (working copy)
@@ -365,28 +365,23 @@
ASSERT(state->IsValidWeakPersistentHandle(handle) ||
state->IsValidPrologueWeakPersistentHandle(handle));
#endif
- uword addr = reinterpret_cast<uword>(handle);
- return reinterpret_cast<FinalizablePersistentHandle*>(
- addr & ~kWeakPersistentTagMask);
+ return reinterpret_cast<FinalizablePersistentHandle*>(handle);
}
-void FinalizablePersistentHandle::Finalize(Isolate* isolate,
- FinalizablePersistentHandle* handle,
- bool is_prologue_weak) {
+void FinalizablePersistentHandle::Finalize(
+ Isolate* isolate, FinalizablePersistentHandle* handle) {
if (!handle->raw()->IsHeapObject()) {
return;
}
Dart_WeakPersistentHandleFinalizer callback = handle->callback();
ASSERT(callback != NULL);
void* peer = handle->peer();
- Dart_WeakPersistentHandle object = is_prologue_weak ?
- handle->apiPrologueHandle() :
- handle->apiHandle();
+ Dart_WeakPersistentHandle object = handle->apiHandle();
(*callback)(isolate->init_callback_data(), object, peer);
ApiState* state = isolate->api_state();
ASSERT(state != NULL);
- if (is_prologue_weak) {
+ if (handle->IsPrologueWeakPersistent()) {
state->prologue_weak_persistent_handles().FreeHandle(handle);
} else {
state->weak_persistent_handles().FreeHandle(handle);
@@ -662,11 +657,8 @@
finalizable_ref->set_peer(peer);
finalizable_ref->set_callback(callback);
finalizable_ref->SetExternalSize(external_allocation_size, isolate);
- if (is_prologue) {
- return finalizable_ref->apiPrologueHandle();
- } else {
- return finalizable_ref->apiHandle();
- }
+ finalizable_ref->SetPrologueWeakPersistent(is_prologue);
+ return finalizable_ref->apiHandle();
}
@@ -729,17 +721,14 @@
ASSERT(isolate == Isolate::Current());
ApiState* state = isolate->api_state();
ASSERT(state != NULL);
- if (FinalizablePersistentHandle::IsPrologueWeakPersistentHandle(object)) {
+ FinalizablePersistentHandle* weak_ref =
+ FinalizablePersistentHandle::Cast(object);
+ weak_ref->EnsureFreeExternal(isolate);
+ if (weak_ref->IsPrologueWeakPersistent()) {
ASSERT(state->IsValidPrologueWeakPersistentHandle(object));
- FinalizablePersistentHandle* weak_ref =
- FinalizablePersistentHandle::Cast(object);
- weak_ref->EnsureFreeExternal(isolate);
state->prologue_weak_persistent_handles().FreeHandle(weak_ref);
} else {
ASSERT(!state->IsValidPrologueWeakPersistentHandle(object));
- FinalizablePersistentHandle* weak_ref =
- FinalizablePersistentHandle::Cast(object);
- weak_ref->EnsureFreeExternal(isolate);
state->weak_persistent_handles().FreeHandle(weak_ref);
}
}
@@ -747,15 +736,9 @@
DART_EXPORT bool Dart_IsPrologueWeakPersistentHandle(
Dart_WeakPersistentHandle object) {
-#if defined(DEBUG)
- Isolate* isolate = Isolate::Current();
- CHECK_ISOLATE(isolate);
- ApiState* state = isolate->api_state();
- ASSERT(state != NULL);
- ASSERT(state->IsValidPrologueWeakPersistentHandle(object) ==
- FinalizablePersistentHandle::IsPrologueWeakPersistentHandle(object));
-#endif
- return FinalizablePersistentHandle::IsPrologueWeakPersistentHandle(object);
+ FinalizablePersistentHandle* weak_ref =
+ FinalizablePersistentHandle::Cast(object);
+ return weak_ref->IsPrologueWeakPersistent();
}
« no previous file with comments | « no previous file | runtime/vm/dart_api_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698