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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 11028145: Changed StackZone and ApiZone to be containers for Zone. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed double-linking from zone list, code review feedback. Created 8 years, 2 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/code_descriptors_test.cc ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | 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 1400d12c093615a09a15ea4494aac94cece0ee06..48e602b55be223d7816b07cca992edfcb259a7a0 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -200,7 +200,7 @@ Dart_Handle Api::NewError(const char* format, ...) {
intptr_t len = OS::VSNPrint(NULL, 0, format, args);
va_end(args);
- char* buffer = zone.Alloc<char>(len + 1);
+ char* buffer = isolate->current_zone()->Alloc<char>(len + 1);
va_list args2;
va_start(args2, format);
OS::VSNPrint(buffer, (len + 1), format, args2);
@@ -410,7 +410,7 @@ DART_EXPORT Dart_Handle Dart_Error(const char* format, ...) {
intptr_t len = OS::VSNPrint(NULL, 0, format, args);
va_end(args);
- char* buffer = zone.Alloc<char>(len + 1);
+ char* buffer = isolate->current_zone()->Alloc<char>(len + 1);
va_list args2;
va_start(args2, format);
OS::VSNPrint(buffer, (len + 1), format, args2);
@@ -432,7 +432,7 @@ DART_EXPORT Dart_Handle Dart_NewApiError(const char* format, ...) {
intptr_t len = OS::VSNPrint(NULL, 0, format, args);
va_end(args);
- char* buffer = zone.Alloc<char>(len + 1);
+ char* buffer = isolate->current_zone()->Alloc<char>(len + 1);
va_list args2;
va_start(args2, format);
OS::VSNPrint(buffer, (len + 1), format, args2);
@@ -457,13 +457,15 @@ DART_EXPORT Dart_Handle Dart_NewUnhandledExceptionError(Dart_Handle exception) {
DART_EXPORT Dart_Handle Dart_PropagateError(Dart_Handle handle) {
Isolate* isolate = Isolate::Current();
- CHECK_ISOLATE(isolate);
- const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(handle));
- if (!obj.IsError()) {
- return Api::NewError(
- "%s expects argument 'handle' to be an error handle. "
- "Did you forget to check Dart_IsError first?",
- CURRENT_FUNC);
+ RawObject* raw_obj = Api::UnwrapHandle(handle);
Ivan Posva 2012/10/12 23:04:27 Please wrap the area where you keep the raw object
Tom Ball 2012/10/15 17:17:40 Done.
+ {
+ const Object& obj = Object::Handle(isolate, raw_obj);
+ if (!obj.IsError()) {
+ return Api::NewError(
Ivan Posva 2012/10/12 23:04:27 Which will make you fail here. You are allocating
Tom Ball 2012/10/15 17:17:40 Moved allocation to where you suggested.
+ "%s expects argument 'handle' to be an error handle. "
+ "Did you forget to check Dart_IsError first?",
+ CURRENT_FUNC);
+ }
}
if (isolate->top_exit_frame_info() == 0) {
// There are no dart frames on the stack so it would be illegal to
@@ -475,6 +477,7 @@ DART_EXPORT Dart_Handle Dart_PropagateError(Dart_Handle handle) {
ApiState* state = isolate->api_state();
ASSERT(state != NULL);
state->UnwindScopes(isolate->top_exit_frame_info());
Ivan Posva 2012/10/12 23:04:27 Get the raw_obj out of the handle just before unwi
Tom Ball 2012/10/15 17:17:40 Done.
+ const Object& obj = Object::Handle(isolate, raw_obj);
Exceptions::PropagateError(Error::Cast(obj));
UNREACHABLE();
@@ -1142,7 +1145,7 @@ DART_EXPORT void Dart_ExitScope() {
DART_EXPORT uint8_t* Dart_ScopeAllocate(intptr_t size) {
- ApiZone* zone;
+ Zone* zone;
Isolate* isolate = Isolate::Current();
if (isolate != NULL) {
ApiState* state = isolate->api_state();
@@ -3896,10 +3899,12 @@ DART_EXPORT Dart_Handle Dart_SetNativeInstanceField(Dart_Handle obj,
DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception) {
Isolate* isolate = Isolate::Current();
- DARTSCOPE(isolate);
- const Instance& excp = Api::UnwrapInstanceHandle(isolate, exception);
- if (excp.IsNull()) {
- RETURN_TYPE_ERROR(isolate, exception, Instance);
+ CHECK_ISOLATE(isolate);
+ {
+ const Instance& excp = Api::UnwrapInstanceHandle(isolate, exception);
+ if (excp.IsNull()) {
+ RETURN_TYPE_ERROR(isolate, exception, Instance);
+ }
}
if (isolate->top_exit_frame_info() == 0) {
// There are no dart frames on the stack so it would be illegal to
@@ -3910,7 +3915,12 @@ DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception) {
// exception.
ApiState* state = isolate->api_state();
ASSERT(state != NULL);
+
+ // Unwind all the API scopes till the exit frame before throwing an
+ // exception.
+ RawObject* raw_excp = Api::UnwrapHandle(exception);
Ivan Posva 2012/10/12 23:04:27 NoGCScope while you hold on to raw objects.
state->UnwindScopes(isolate->top_exit_frame_info());
+ const Instance& excp = Instance::Cast(Object::Handle(isolate, raw_excp));
Exceptions::Throw(excp);
return Api::NewError("Exception was not thrown, internal error");
}
@@ -3920,14 +3930,15 @@ DART_EXPORT Dart_Handle Dart_ReThrowException(Dart_Handle exception,
Dart_Handle stacktrace) {
Isolate* isolate = Isolate::Current();
CHECK_ISOLATE(isolate);
- DARTSCOPE(isolate);
- const Instance& excp = Api::UnwrapInstanceHandle(isolate, exception);
- if (excp.IsNull()) {
- RETURN_TYPE_ERROR(isolate, exception, Instance);
- }
- const Instance& stk = Api::UnwrapInstanceHandle(isolate, stacktrace);
- if (stk.IsNull()) {
- RETURN_TYPE_ERROR(isolate, stacktrace, Instance);
+ {
+ const Instance& excp = Api::UnwrapInstanceHandle(isolate, exception);
+ if (excp.IsNull()) {
+ RETURN_TYPE_ERROR(isolate, exception, Instance);
+ }
+ const Instance& stk = Api::UnwrapInstanceHandle(isolate, stacktrace);
+ if (stk.IsNull()) {
+ RETURN_TYPE_ERROR(isolate, stacktrace, Instance);
+ }
}
if (isolate->top_exit_frame_info() == 0) {
// There are no dart frames on the stack so it would be illegal to
@@ -3938,7 +3949,11 @@ DART_EXPORT Dart_Handle Dart_ReThrowException(Dart_Handle exception,
// exception.
ApiState* state = isolate->api_state();
ASSERT(state != NULL);
+ RawObject* raw_excp = Api::UnwrapHandle(exception);
Ivan Posva 2012/10/12 23:04:27 ditto: NoGCScope is needed.
+ RawObject* raw_stk = Api::UnwrapHandle(stacktrace);
state->UnwindScopes(isolate->top_exit_frame_info());
+ const Instance& excp = Instance::Cast(Object::Handle(isolate, raw_excp));
+ const Instance& stk = Instance::Cast(Object::Handle(isolate, raw_stk));
Exceptions::ReThrow(excp, stk);
return Api::NewError("Exception was not re thrown, internal error");
}
@@ -4422,7 +4437,7 @@ DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size) {
pprof_symbol_generator->WriteToMemory(debug_region);
*buffer_size = debug_region->size();
if (*buffer_size != 0) {
- ApiZone* zone = Api::TopScope(isolate)->zone();
+ Zone* zone = Api::TopScope(isolate)->zone();
*buffer = reinterpret_cast<void*>(zone->AllocUnsafe(*buffer_size));
memmove(*buffer, debug_region->data(), *buffer_size);
} else {
« no previous file with comments | « runtime/vm/code_descriptors_test.cc ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698