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

Unified Diff: runtime/vm/code_generator.cc

Issue 9169102: Add Dart_PropagateError. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Removed some unneeded includes Created 8 years, 11 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
Index: runtime/vm/code_generator.cc
===================================================================
--- runtime/vm/code_generator.cc (revision 3415)
+++ runtime/vm/code_generator.cc (working copy)
@@ -431,7 +431,10 @@
return Code::null();
} else {
if (!function.HasCode()) {
- Compiler::CompileFunction(function);
+ const Error& error = Error::Handle(Compiler::CompileFunction(function));
siva 2012/01/31 00:52:34 Would it make sense to have a version of CompileFu
turnidge 2012/01/31 21:56:31 I sort of find the current version less magical.
siva 2012/02/01 19:09:38 Sure.
+ if (!error.IsNull()) {
+ Exceptions::PropagateError(error);
+ }
}
functions_cache.AddCompiledFunction(function,
num_arguments,
@@ -443,13 +446,11 @@
// Result of an invoke may be an unhandled exception, in which case we
// rethrow it.
-static void CheckResultException(const Instance& result) {
- if (result.IsUnhandledException()) {
- const UnhandledException& unhandled = UnhandledException::Handle(
- reinterpret_cast<RawUnhandledException*>(result.raw()));
- const Instance& excp = Instance::Handle(unhandled.exception());
- const Instance& stack = Instance::Handle(unhandled.stacktrace());
- Exceptions::ReThrow(excp, stack);
+static void CheckResultError(const Object& result) {
+ if (result.IsError()) {
+ Error& error = Error::Handle();
+ error ^= result.raw();
+ Exceptions::PropagateError(error);
}
siva 2012/01/31 00:52:34 ASSERT(result.IsNull());
turnidge 2012/01/31 21:56:31 Why should the result be null?
siva 2012/02/01 19:09:38 You are right the result does not have to be NULL,
}
@@ -482,7 +483,10 @@
// further tests.
const Function& function = Function::CheckedHandle(arguments.At(0));
if (!function.HasCode()) {
- Compiler::CompileFunction(function);
+ const Error& error = Error::Handle(Compiler::CompileFunction(function));
+ if (!error.IsNull()) {
+ Exceptions::PropagateError(error);
+ }
}
}
@@ -707,15 +711,23 @@
}
GrowableArray<const Object*> invoke_arguments(0);
const Array& kNoArgumentNames = Array::Handle();
- const Instance& result =
- Instance::Handle(
- DartEntry::InvokeDynamic(receiver,
- function,
- invoke_arguments,
- kNoArgumentNames));
- if (result.IsUnhandledException()) {
- arguments.SetReturn(code);
- return; // Error accessing getter, treat as no such method.
+ const Object& result =
+ Object::Handle(DartEntry::InvokeDynamic(receiver,
+ function,
+ invoke_arguments,
+ kNoArgumentNames));
+ if (result.IsError()) {
+ if (result.IsUnhandledException()) {
+ // If the getter throws an exception, treat as no such method.
+ //
+ // TODO(turnidge): Is this the desired behavior?
siva 2012/01/31 00:52:34 Yes this is the desired behaviour.
turnidge 2012/01/31 21:56:31 Thanks. Updated comment.
+ arguments.SetReturn(code);
+ return;
+ } else {
+ Error& error = Error::Handle();
+ error ^= result.raw();
+ Exceptions::PropagateError(error);
+ }
}
if (!result.IsSmi()) {
const Class& cls = Class::Handle(result.clazz());
@@ -743,7 +755,10 @@
const Function& function = Function::Handle(closure.function());
ASSERT(!function.IsNull());
if (!function.HasCode()) {
- Compiler::CompileFunction(function);
+ const Error& error = Error::Handle(Compiler::CompileFunction(function));
+ if (!error.IsNull()) {
+ Exceptions::PropagateError(error);
+ }
}
const Context& context = Context::Handle(closure.context());
const Code& code = Code::Handle(function.code());
@@ -792,12 +807,12 @@
DartEntry::invokestub entrypoint = reinterpret_cast<DartEntry::invokestub>(
StubCode::InvokeDartCodeEntryPoint());
ASSERT(context.isolate() == Isolate::Current());
- const Instance& result = Instance::Handle(
+ const Object& result = Object::Handle(
entrypoint(instrs.EntryPoint(),
adjusted_arg_descriptor,
invoke_arguments.data(),
context));
- CheckResultException(result);
+ CheckResultError(result);
arguments.SetReturn(result);
}
@@ -833,12 +848,12 @@
GrowableArray<const Object*> invoke_arguments(2);
invoke_arguments.Add(&original_function_name);
invoke_arguments.Add(&orig_arguments);
- const Instance& result = Instance::Handle(
+ const Object& result = Object::Handle(
DartEntry::InvokeDynamic(receiver,
function,
invoke_arguments,
kNoArgumentNames));
- CheckResultException(result);
+ CheckResultError(result);
arguments.SetReturn(result);
}
@@ -915,7 +930,11 @@
ASSERT(!Code::Handle(function.code()).is_optimized());
const Code& unoptimized_code = Code::Handle(function.code());
// Compilation patches the entry of unoptimized code.
- Compiler::CompileOptimizedFunction(function);
+ const Error& error =
+ Error::Handle(Compiler::CompileOptimizedFunction(function));
+ if (!error.IsNull()) {
+ Exceptions::PropagateError(error);
+ }
const Code& optimized_code = Code::Handle(function.code());
ASSERT(!optimized_code.IsNull());
ASSERT(!unoptimized_code.IsNull());
@@ -1022,7 +1041,10 @@
if (Code::Handle(function.code()).is_optimized()) {
// Get unoptimized code. Compilation restores (reenables) the entry of
// unoptimized code.
- Compiler::CompileFunction(function);
+ const Error& error = Error::Handle(Compiler::CompileFunction(function));
+ if (!error.IsNull()) {
+ Exceptions::PropagateError(error);
+ }
}
// TODO(srdjan): Handle better complex cases, e.g. when an older optimized
// code is alive on frame and gets deoptimized after the function was

Powered by Google App Engine
This is Rietveld 408576698