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

Unified Diff: runtime/vm/code_generator.cc

Issue 9316071: Dart_PropagateError, take 2. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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
« no previous file with comments | « runtime/vm/bootstrap_nocorelib.cc ('k') | runtime/vm/code_generator_ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/code_generator.cc
===================================================================
--- runtime/vm/code_generator.cc (revision 3862)
+++ 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));
+ if (!error.IsNull()) {
+ Exceptions::PropagateError(error);
+ }
}
functions_cache.AddCompiledFunction(function,
num_arguments,
@@ -443,13 +446,9 @@
// 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()) {
+ Exceptions::PropagateError(result);
}
}
@@ -482,7 +481,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 +709,19 @@
}
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.
+ arguments.SetReturn(code);
+ return;
+ } else {
+ Exceptions::PropagateError(result);
+ }
}
if (!result.IsSmi()) {
const Class& cls = Class::Handle(result.clazz());
@@ -743,7 +749,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 +801,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 +842,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);
}
@@ -918,7 +927,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());
@@ -1025,7 +1038,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
« no previous file with comments | « runtime/vm/bootstrap_nocorelib.cc ('k') | runtime/vm/code_generator_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698