Reviewers: ulan,
Message:
Exceptions can no longer be a failure. This change is to reflect that.
Description:
Change exception type to Object.
Please review this at https://codereview.chromium.org/227163008/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+27, -37 lines):
M src/isolate.h
M src/isolate.cc
M src/liveedit.cc
M src/messages.cc
M src/runtime.cc
M test/cctest/test-compiler.cc
M test/cctest/test-parsing.cc
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index
c7eb173981c0e2d7e986d456754be9633a883875..20d148e2850e1dc82abc55326967271a15482d35
100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -264,21 +264,11 @@ void Isolate::IterateThread(ThreadVisitor* v, char*
t) {
void Isolate::Iterate(ObjectVisitor* v, ThreadLocalTop* thread) {
// Visit the roots from the top for a given thread.
- Object* pending;
- // The pending exception can sometimes be a failure. We can't show
- // that to the GC, which only understands objects.
- if (thread->pending_exception_->ToObject(&pending)) {
- v->VisitPointer(&pending);
- thread->pending_exception_ = pending; // In case GC updated it.
- }
+ v->VisitPointer(&thread->pending_exception_);
v->VisitPointer(&(thread->pending_message_obj_));
v->VisitPointer(BitCast<Object**>(&(thread->pending_message_script_)));
v->VisitPointer(BitCast<Object**>(&(thread->context_)));
- Object* scheduled;
- if (thread->scheduled_exception_->ToObject(&scheduled)) {
- v->VisitPointer(&scheduled);
- thread->scheduled_exception_ = scheduled;
- }
+ v->VisitPointer(&thread->scheduled_exception_);
for (v8::TryCatch* block = thread->TryCatchHandler();
block != NULL;
@@ -912,7 +902,7 @@ Failure* Isolate::Throw(Object* exception,
MessageLocation* location) {
}
-Failure* Isolate::ReThrow(MaybeObject* exception) {
+Failure* Isolate::ReThrow(Object* exception) {
bool can_be_caught_externally = false;
bool catchable_by_javascript = is_catchable_by_javascript(exception);
ShouldReportException(&can_be_caught_externally,
catchable_by_javascript);
@@ -969,7 +959,7 @@ void
Isolate::RestorePendingMessageFromTryCatch(v8::TryCatch* handler) {
Failure* Isolate::PromoteScheduledException() {
- MaybeObject* thrown = scheduled_exception();
+ Object* thrown = scheduled_exception();
clear_scheduled_exception();
// Re-throw the exception to avoid getting repeated error reporting.
return ReThrow(thrown);
@@ -1813,9 +1803,6 @@ void
Isolate::PropagatePendingExceptionToExternalTryCatch() {
try_catch_handler()->exception_ = heap()->null_value();
} else {
v8::TryCatch* handler = try_catch_handler();
- // At this point all non-object (failure) exceptions have
- // been dealt with so this shouldn't fail.
- ASSERT(!pending_exception()->IsFailure());
ASSERT(thread_local_top_.pending_message_obj_->IsJSMessageObject() ||
thread_local_top_.pending_message_obj_->IsTheHole());
ASSERT(thread_local_top_.pending_message_script_->IsScript() ||
Index: src/isolate.h
diff --git a/src/isolate.h b/src/isolate.h
index
67edad3fa7df7dae3ec2072338116566b83d3d9a..7035b06f84f0bf6c4c9d61d8001ac2d96994335b
100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -292,7 +292,7 @@ class ThreadLocalTop BASE_EMBEDDED {
// lookups.
Context* context_;
ThreadId thread_id_;
- MaybeObject* pending_exception_;
+ Object* pending_exception_;
bool has_pending_message_;
bool rethrowing_message_;
Object* pending_message_obj_;
@@ -302,7 +302,7 @@ class ThreadLocalTop BASE_EMBEDDED {
// Use a separate value for scheduled exceptions to preserve the
// invariants that hold about pending_exception. We may want to
// unify them later.
- MaybeObject* scheduled_exception_;
+ Object* scheduled_exception_;
bool external_caught_exception_;
SaveContext* save_context_;
v8::TryCatch* catcher_;
@@ -608,24 +608,28 @@ class Isolate {
THREAD_LOCAL_TOP_ACCESSOR(ThreadId, thread_id)
// Interface to pending exception.
- MaybeObject* pending_exception() {
+ Object* pending_exception() {
ASSERT(has_pending_exception());
+ ASSERT(!thread_local_top_.pending_exception_->IsFailure());
return thread_local_top_.pending_exception_;
}
- void set_pending_exception(MaybeObject* exception) {
+ void set_pending_exception(Object* exception) {
+ ASSERT(!exception->IsFailure());
thread_local_top_.pending_exception_ = exception;
}
void clear_pending_exception() {
+ ASSERT(!thread_local_top_.pending_exception_->IsFailure());
thread_local_top_.pending_exception_ = heap_.the_hole_value();
}
- MaybeObject** pending_exception_address() {
+ Object** pending_exception_address() {
return &thread_local_top_.pending_exception_;
}
bool has_pending_exception() {
+ ASSERT(!thread_local_top_.pending_exception_->IsFailure());
return !thread_local_top_.pending_exception_->IsTheHole();
}
@@ -648,7 +652,7 @@ class Isolate {
THREAD_LOCAL_TOP_ACCESSOR(v8::TryCatch*, catcher)
- MaybeObject** scheduled_exception_address() {
+ Object** scheduled_exception_address() {
return &thread_local_top_.scheduled_exception_;
}
@@ -665,20 +669,23 @@ class Isolate {
&thread_local_top_.pending_message_script_);
}
- MaybeObject* scheduled_exception() {
+ Object* scheduled_exception() {
ASSERT(has_scheduled_exception());
+ ASSERT(!thread_local_top_.scheduled_exception_->IsFailure());
return thread_local_top_.scheduled_exception_;
}
bool has_scheduled_exception() {
+ ASSERT(!thread_local_top_.scheduled_exception_->IsFailure());
return thread_local_top_.scheduled_exception_ !=
heap_.the_hole_value();
}
void clear_scheduled_exception() {
+ ASSERT(!thread_local_top_.scheduled_exception_->IsFailure());
thread_local_top_.scheduled_exception_ = heap_.the_hole_value();
}
bool IsExternallyCaught();
- bool is_catchable_by_javascript(MaybeObject* exception) {
+ bool is_catchable_by_javascript(Object* exception) {
return exception != heap()->termination_exception();
}
@@ -737,8 +744,7 @@ class Isolate {
// Scope currently can only be used for regular exceptions, not
// failures like OOM or termination exception.
isolate_(isolate),
-
pending_exception_(isolate_->pending_exception()->ToObjectUnchecked(),
- isolate_),
+ pending_exception_(isolate_->pending_exception(), isolate_),
catcher_(isolate_->catcher())
{ }
@@ -819,7 +825,7 @@ class Isolate {
// Re-throw an exception. This involves no error reporting since
// error reporting was handled when the exception was thrown
// originally.
- Failure* ReThrow(MaybeObject* exception);
+ Failure* ReThrow(Object* exception);
void ScheduleThrow(Object* exception);
// Re-set pending message, script and positions reported to the TryCatch
// back to the TLS for re-use when rethrowing.
Index: src/liveedit.cc
diff --git a/src/liveedit.cc b/src/liveedit.cc
index
6fb917caeaae72046bdbf812b2c254003881bb81..0f5a46d5236bede0154da50ce367b9f1aa5ad963
100644
--- a/src/liveedit.cc
+++ b/src/liveedit.cc
@@ -835,8 +835,7 @@ MaybeHandle<JSArray>
LiveEdit::GatherCompileInfo(Handle<Script> script,
// A logical 'catch' section.
Handle<JSObject> rethrow_exception;
if (isolate->has_pending_exception()) {
- Handle<Object>
exception(isolate->pending_exception()->ToObjectChecked(),
- isolate);
+ Handle<Object> exception(isolate->pending_exception(), isolate);
MessageLocation message_location = isolate->GetMessageLocation();
isolate->clear_pending_message();
Index: src/messages.cc
diff --git a/src/messages.cc b/src/messages.cc
index
0077d0309f0794b38f7c1ea77f5e11aa46d20f02..12ad4205d5a65920a30df59c856dc1305c398474
100644
--- a/src/messages.cc
+++ b/src/messages.cc
@@ -107,7 +107,7 @@ void MessageHandler::ReportMessage(Isolate* isolate,
// We pass the exception object into the message handler callback though.
Object* exception_object = isolate->heap()->undefined_value();
if (isolate->has_pending_exception()) {
- isolate->pending_exception()->ToObject(&exception_object);
+ exception_object = isolate->pending_exception();
}
Handle<Object> exception_handle(exception_object, isolate);
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
e176951a7da6ab0d326120340ea1472361938696..4297ab17572661adfd6797f0e54008e913557e2e
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -10836,7 +10836,7 @@ static MaybeObject* DebugLookupResultValue(Heap*
heap,
handle(name, isolate));
Handle<Object> value;
if (maybe_value.ToHandle(&value)) return *value;
- MaybeObject* exception = heap->isolate()->pending_exception();
+ Object* exception = heap->isolate()->pending_exception();
heap->isolate()->clear_pending_exception();
if (caught_exception != NULL) *caught_exception = true;
return exception;
Index: test/cctest/test-compiler.cc
diff --git a/test/cctest/test-compiler.cc b/test/cctest/test-compiler.cc
index
787645a634c4b72c8c105ff39f7ed57eeb2b8844..5482a44d0584098e8b6fa48f2d3da338fa6be779
100644
--- a/test/cctest/test-compiler.cc
+++ b/test/cctest/test-compiler.cc
@@ -220,7 +220,7 @@ TEST(UncaughtThrow) {
Handle<JSObject> global(isolate->context()->global_object());
Execution::Call(isolate, fun, global, 0, NULL, &has_pending_exception);
CHECK(has_pending_exception);
- CHECK_EQ(42.0,
isolate->pending_exception()->ToObjectChecked()->Number());
+ CHECK_EQ(42.0, isolate->pending_exception()->Number());
}
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index
7c07ee22eb7bf165b217f5f175cdcb62a4603b68..ea18624179bfa2f1fe2844bc11f48ebaa865df0a
100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -1339,10 +1339,8 @@ void TestParserSyncWithFlags(i::Handle<i::String>
source,
if (function == NULL) {
// Extract exception from the parser.
CHECK(isolate->has_pending_exception());
- i::MaybeObject* maybe_object = isolate->pending_exception();
- i::JSObject* exception = NULL;
- CHECK(maybe_object->To(&exception));
- i::Handle<i::JSObject> exception_handle(exception);
+ i::Handle<i::JSObject> exception_handle(
+ i::JSObject::cast(isolate->pending_exception()));
i::Handle<i::String> message_string =
i::Handle<i::String>::cast(i::GetProperty(exception_handle, "message"));
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.