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

Unified Diff: src/execution.cc

Issue 516913003: Do not expose termination exceptions to the Exception API. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: address comment Created 6 years, 4 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 | « src/execution.h ('k') | src/factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/execution.cc
diff --git a/src/execution.cc b/src/execution.cc
index 12dd8624526a51d930929d56dd72bea4a0f5b63d..7aa4f3341d68a4bfd3c569f4537df3db8593f3a4 100644
--- a/src/execution.cc
+++ b/src/execution.cc
@@ -150,40 +150,43 @@ MaybeHandle<Object> Execution::New(Handle<JSFunction> func,
MaybeHandle<Object> Execution::TryCall(Handle<JSFunction> func,
- Handle<Object> receiver,
- int argc,
+ Handle<Object> receiver, int argc,
Handle<Object> args[],
- Handle<Object>* exception_out) {
+ MaybeHandle<Object>* exception_out) {
+ bool is_termination = false;
+ Isolate* isolate = func->GetIsolate();
+ MaybeHandle<Object> maybe_result;
+ if (exception_out != NULL) *exception_out = MaybeHandle<Object>();
// Enter a try-block while executing the JavaScript code. To avoid
// duplicate error printing it must be non-verbose. Also, to avoid
// creating message objects during stack overflow we shouldn't
// capture messages.
- v8::TryCatch catcher;
- catcher.SetVerbose(false);
- catcher.SetCaptureMessage(false);
-
- // Get isolate now, because handle might be persistent
- // and get destroyed in the next call.
- Isolate* isolate = func->GetIsolate();
- MaybeHandle<Object> maybe_result = Invoke(false, func, receiver, argc, args);
-
- if (maybe_result.is_null()) {
- DCHECK(catcher.HasCaught());
- DCHECK(isolate->has_pending_exception());
- DCHECK(isolate->external_caught_exception());
- if (exception_out != NULL) {
- if (isolate->pending_exception() ==
- isolate->heap()->termination_exception()) {
- *exception_out = isolate->factory()->termination_exception();
- } else {
- *exception_out = v8::Utils::OpenHandle(*catcher.Exception());
+ {
+ v8::TryCatch catcher;
+ catcher.SetVerbose(false);
+ catcher.SetCaptureMessage(false);
+
+ maybe_result = Invoke(false, func, receiver, argc, args);
+
+ if (maybe_result.is_null()) {
+ DCHECK(catcher.HasCaught());
+ DCHECK(isolate->has_pending_exception());
+ DCHECK(isolate->external_caught_exception());
+ if (exception_out != NULL) {
+ if (isolate->pending_exception() ==
+ isolate->heap()->termination_exception()) {
+ is_termination = true;
+ } else {
+ *exception_out = v8::Utils::OpenHandle(*catcher.Exception());
+ }
}
+ isolate->OptionalRescheduleException(true);
}
- isolate->OptionalRescheduleException(true);
- }
- DCHECK(!isolate->has_pending_exception());
- DCHECK(!isolate->external_caught_exception());
+ DCHECK(!isolate->has_pending_exception());
+ DCHECK(!isolate->external_caught_exception());
+ }
+ if (is_termination) isolate->TerminateExecution();
return maybe_result;
}
@@ -236,10 +239,9 @@ MaybeHandle<Object> Execution::TryGetFunctionDelegate(Isolate* isolate,
// If the Object doesn't have an instance-call handler we should
// throw a non-callable exception.
- i::Handle<i::Object> error_obj = isolate->factory()->NewTypeError(
- "called_non_callable", i::HandleVector<i::Object>(&object, 1));
-
- return isolate->Throw<Object>(error_obj);
+ THROW_NEW_ERROR(isolate, NewTypeError("called_non_callable",
+ i::HandleVector<i::Object>(&object, 1)),
+ Object);
}
@@ -293,9 +295,9 @@ MaybeHandle<Object> Execution::TryGetConstructorDelegate(
// If the Object doesn't have an instance-call handler we should
// throw a non-callable exception.
- i::Handle<i::Object> error_obj = isolate->factory()->NewTypeError(
- "called_non_callable", i::HandleVector<i::Object>(&object, 1));
- return isolate->Throw<Object>(error_obj);
+ THROW_NEW_ERROR(isolate, NewTypeError("called_non_callable",
+ i::HandleVector<i::Object>(&object, 1)),
+ Object);
}
« no previous file with comments | « src/execution.h ('k') | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698