| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. | 
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without | 
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are | 
| 4 // met: | 4 // met: | 
| 5 // | 5 // | 
| 6 //     * Redistributions of source code must retain the above copyright | 6 //     * Redistributions of source code must retain the above copyright | 
| 7 //       notice, this list of conditions and the following disclaimer. | 7 //       notice, this list of conditions and the following disclaimer. | 
| 8 //     * Redistributions in binary form must reproduce the above | 8 //     * Redistributions in binary form must reproduce the above | 
| 9 //       copyright notice, this list of conditions and the following | 9 //       copyright notice, this list of conditions and the following | 
| 10 //       disclaimer in the documentation and/or other materials provided | 10 //       disclaimer in the documentation and/or other materials provided | 
| (...skipping 2056 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2067   } | 2067   } | 
| 2068 } | 2068 } | 
| 2069 | 2069 | 
| 2070 | 2070 | 
| 2071 // --- E x c e p t i o n s --- | 2071 // --- E x c e p t i o n s --- | 
| 2072 | 2072 | 
| 2073 | 2073 | 
| 2074 v8::TryCatch::TryCatch() | 2074 v8::TryCatch::TryCatch() | 
| 2075     : isolate_(i::Isolate::Current()), | 2075     : isolate_(i::Isolate::Current()), | 
| 2076       next_(isolate_->try_catch_handler_address()), | 2076       next_(isolate_->try_catch_handler_address()), | 
| 2077       exception_(isolate_->heap()->the_hole_value()), |  | 
| 2078       message_(i::Smi::FromInt(0)), |  | 
| 2079       is_verbose_(false), | 2077       is_verbose_(false), | 
| 2080       can_continue_(true), | 2078       can_continue_(true), | 
| 2081       capture_message_(true), | 2079       capture_message_(true), | 
| 2082       rethrow_(false), | 2080       rethrow_(false), | 
| 2083       has_terminated_(false) { | 2081       has_terminated_(false) { | 
|  | 2082   Reset(); | 
| 2084   isolate_->RegisterTryCatchHandler(this); | 2083   isolate_->RegisterTryCatchHandler(this); | 
| 2085 } | 2084 } | 
| 2086 | 2085 | 
| 2087 | 2086 | 
| 2088 v8::TryCatch::~TryCatch() { | 2087 v8::TryCatch::~TryCatch() { | 
| 2089   ASSERT(isolate_ == i::Isolate::Current()); | 2088   ASSERT(isolate_ == i::Isolate::Current()); | 
| 2090   if (rethrow_) { | 2089   if (rethrow_) { | 
| 2091     v8::HandleScope scope(reinterpret_cast<Isolate*>(isolate_)); | 2090     v8::HandleScope scope(reinterpret_cast<Isolate*>(isolate_)); | 
| 2092     v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(Exception()); | 2091     v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(Exception()); | 
|  | 2092     if (HasCaught() && capture_message_) { | 
|  | 2093       // If an exception was caught and rethrow_ is indicated, the saved | 
|  | 2094       // message, script, and location need to be restored to Isolate TLS | 
|  | 2095       // for reuse.  capture_message_ needs to be disabled so that DoThrow() | 
|  | 2096       // does not create a new message. | 
|  | 2097       isolate_->thread_local_top()->rethrowing_message_ = true; | 
|  | 2098       isolate_->RestorePendingMessageFromTryCatch(this); | 
|  | 2099     } | 
| 2093     isolate_->UnregisterTryCatchHandler(this); | 2100     isolate_->UnregisterTryCatchHandler(this); | 
| 2094     v8::ThrowException(exc); | 2101     v8::ThrowException(exc); | 
|  | 2102     ASSERT(!isolate_->thread_local_top()->rethrowing_message_); | 
| 2095   } else { | 2103   } else { | 
| 2096     isolate_->UnregisterTryCatchHandler(this); | 2104     isolate_->UnregisterTryCatchHandler(this); | 
| 2097   } | 2105   } | 
| 2098 } | 2106 } | 
| 2099 | 2107 | 
| 2100 | 2108 | 
| 2101 bool v8::TryCatch::HasCaught() const { | 2109 bool v8::TryCatch::HasCaught() const { | 
| 2102   return !reinterpret_cast<i::Object*>(exception_)->IsTheHole(); | 2110   return !reinterpret_cast<i::Object*>(exception_)->IsTheHole(); | 
| 2103 } | 2111 } | 
| 2104 | 2112 | 
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2145     if (value.is_null()) return v8::Local<Value>(); | 2153     if (value.is_null()) return v8::Local<Value>(); | 
| 2146     return v8::Utils::ToLocal(scope.CloseAndEscape(value)); | 2154     return v8::Utils::ToLocal(scope.CloseAndEscape(value)); | 
| 2147   } else { | 2155   } else { | 
| 2148     return v8::Local<Value>(); | 2156     return v8::Local<Value>(); | 
| 2149   } | 2157   } | 
| 2150 } | 2158 } | 
| 2151 | 2159 | 
| 2152 | 2160 | 
| 2153 v8::Local<v8::Message> v8::TryCatch::Message() const { | 2161 v8::Local<v8::Message> v8::TryCatch::Message() const { | 
| 2154   ASSERT(isolate_ == i::Isolate::Current()); | 2162   ASSERT(isolate_ == i::Isolate::Current()); | 
| 2155   if (HasCaught() && message_ != i::Smi::FromInt(0)) { | 2163   i::Object* message = reinterpret_cast<i::Object*>(message_obj_); | 
| 2156     i::Object* message = reinterpret_cast<i::Object*>(message_); | 2164   ASSERT(message->IsJSMessageObject() || message->IsTheHole()); | 
|  | 2165   if (HasCaught() && !message->IsTheHole()) { | 
| 2157     return v8::Utils::MessageToLocal(i::Handle<i::Object>(message, isolate_)); | 2166     return v8::Utils::MessageToLocal(i::Handle<i::Object>(message, isolate_)); | 
| 2158   } else { | 2167   } else { | 
| 2159     return v8::Local<v8::Message>(); | 2168     return v8::Local<v8::Message>(); | 
| 2160   } | 2169   } | 
| 2161 } | 2170 } | 
| 2162 | 2171 | 
| 2163 | 2172 | 
| 2164 void v8::TryCatch::Reset() { | 2173 void v8::TryCatch::Reset() { | 
| 2165   ASSERT(isolate_ == i::Isolate::Current()); | 2174   ASSERT(isolate_ == i::Isolate::Current()); | 
| 2166   exception_ = isolate_->heap()->the_hole_value(); | 2175   i::Object* the_hole = isolate_->heap()->the_hole_value(); | 
| 2167   message_ = i::Smi::FromInt(0); | 2176   exception_ = the_hole; | 
|  | 2177   message_obj_ = the_hole; | 
|  | 2178   message_script_ = the_hole; | 
|  | 2179   message_start_pos_ = 0; | 
|  | 2180   message_end_pos_ = 0; | 
| 2168 } | 2181 } | 
| 2169 | 2182 | 
| 2170 | 2183 | 
| 2171 void v8::TryCatch::SetVerbose(bool value) { | 2184 void v8::TryCatch::SetVerbose(bool value) { | 
| 2172   is_verbose_ = value; | 2185   is_verbose_ = value; | 
| 2173 } | 2186 } | 
| 2174 | 2187 | 
| 2175 | 2188 | 
| 2176 void v8::TryCatch::SetCaptureMessage(bool value) { | 2189 void v8::TryCatch::SetCaptureMessage(bool value) { | 
| 2177   capture_message_ = value; | 2190   capture_message_ = value; | 
| (...skipping 5790 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 7968   Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7981   Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 
| 7969   Address callback_address = | 7982   Address callback_address = | 
| 7970       reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7983       reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 
| 7971   VMState<EXTERNAL> state(isolate); | 7984   VMState<EXTERNAL> state(isolate); | 
| 7972   ExternalCallbackScope call_scope(isolate, callback_address); | 7985   ExternalCallbackScope call_scope(isolate, callback_address); | 
| 7973   return callback(info); | 7986   return callback(info); | 
| 7974 } | 7987 } | 
| 7975 | 7988 | 
| 7976 | 7989 | 
| 7977 } }  // namespace v8::internal | 7990 } }  // namespace v8::internal | 
| OLD | NEW | 
|---|