| 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 2034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2045 } | 2045 } |
| 2046 | 2046 |
| 2047 | 2047 |
| 2048 // --- E x c e p t i o n s --- | 2048 // --- E x c e p t i o n s --- |
| 2049 | 2049 |
| 2050 | 2050 |
| 2051 v8::TryCatch::TryCatch() | 2051 v8::TryCatch::TryCatch() |
| 2052 : isolate_(i::Isolate::Current()), | 2052 : isolate_(i::Isolate::Current()), |
| 2053 next_(isolate_->try_catch_handler_address()), | 2053 next_(isolate_->try_catch_handler_address()), |
| 2054 exception_(isolate_->heap()->the_hole_value()), | 2054 exception_(isolate_->heap()->the_hole_value()), |
| 2055 message_(i::Smi::FromInt(0)), | 2055 message_obj_(i::Smi::FromInt(0)), |
| 2056 message_script_(i::Smi::FromInt(0)), |
| 2057 message_start_pos_(0), |
| 2058 message_end_pos_(0), |
| 2056 is_verbose_(false), | 2059 is_verbose_(false), |
| 2057 can_continue_(true), | 2060 can_continue_(true), |
| 2058 capture_message_(true), | 2061 capture_message_(true), |
| 2059 rethrow_(false), | 2062 rethrow_(false), |
| 2060 has_terminated_(false) { | 2063 has_terminated_(false) { |
| 2061 isolate_->RegisterTryCatchHandler(this); | 2064 isolate_->RegisterTryCatchHandler(this); |
| 2062 } | 2065 } |
| 2063 | 2066 |
| 2064 | 2067 |
| 2065 v8::TryCatch::~TryCatch() { | 2068 v8::TryCatch::~TryCatch() { |
| 2066 ASSERT(isolate_ == i::Isolate::Current()); | 2069 ASSERT(isolate_ == i::Isolate::Current()); |
| 2067 if (rethrow_) { | 2070 if (rethrow_) { |
| 2068 v8::HandleScope scope(reinterpret_cast<Isolate*>(isolate_)); | 2071 v8::HandleScope scope(reinterpret_cast<Isolate*>(isolate_)); |
| 2069 v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(Exception()); | 2072 v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(Exception()); |
| 2070 isolate_->UnregisterTryCatchHandler(this); | 2073 isolate_->UnregisterTryCatchHandler(this); |
| 2074 if (HasCaught() && capture_message_) { |
| 2075 // If an exception was caught and rethrow_ is indicated, the saved |
| 2076 // message, script, and location need to be restored to Isolate TLS |
| 2077 // so that DoThrow() does not overwrite the values from the original |
| 2078 // exception with new ones computed at the current location. |
| 2079 i::Object* message = reinterpret_cast<i::Object*>(message_obj_); |
| 2080 i::Script* script = message_script_ ? |
| 2081 reinterpret_cast<i::Script*>(message_script_) : NULL; |
| 2082 isolate_->RestoreMessage(message, script, |
| 2083 message_start_pos_, message_end_pos_); |
| 2084 } |
| 2071 v8::ThrowException(exc); | 2085 v8::ThrowException(exc); |
| 2072 } else { | 2086 } else { |
| 2073 isolate_->UnregisterTryCatchHandler(this); | 2087 isolate_->UnregisterTryCatchHandler(this); |
| 2074 } | 2088 } |
| 2075 } | 2089 } |
| 2076 | 2090 |
| 2077 | 2091 |
| 2078 bool v8::TryCatch::HasCaught() const { | 2092 bool v8::TryCatch::HasCaught() const { |
| 2079 return !reinterpret_cast<i::Object*>(exception_)->IsTheHole(); | 2093 return !reinterpret_cast<i::Object*>(exception_)->IsTheHole(); |
| 2080 } | 2094 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2122 if (value.is_null()) return v8::Local<Value>(); | 2136 if (value.is_null()) return v8::Local<Value>(); |
| 2123 return v8::Utils::ToLocal(scope.CloseAndEscape(value)); | 2137 return v8::Utils::ToLocal(scope.CloseAndEscape(value)); |
| 2124 } else { | 2138 } else { |
| 2125 return v8::Local<Value>(); | 2139 return v8::Local<Value>(); |
| 2126 } | 2140 } |
| 2127 } | 2141 } |
| 2128 | 2142 |
| 2129 | 2143 |
| 2130 v8::Local<v8::Message> v8::TryCatch::Message() const { | 2144 v8::Local<v8::Message> v8::TryCatch::Message() const { |
| 2131 ASSERT(isolate_ == i::Isolate::Current()); | 2145 ASSERT(isolate_ == i::Isolate::Current()); |
| 2132 if (HasCaught() && message_ != i::Smi::FromInt(0)) { | 2146 if (HasCaught() && message_obj_ != i::Smi::FromInt(0)) { |
| 2133 i::Object* message = reinterpret_cast<i::Object*>(message_); | 2147 i::Object* message = reinterpret_cast<i::Object*>(message_obj_); |
| 2134 return v8::Utils::MessageToLocal(i::Handle<i::Object>(message, isolate_)); | 2148 return v8::Utils::MessageToLocal(i::Handle<i::Object>(message, isolate_)); |
| 2135 } else { | 2149 } else { |
| 2136 return v8::Local<v8::Message>(); | 2150 return v8::Local<v8::Message>(); |
| 2137 } | 2151 } |
| 2138 } | 2152 } |
| 2139 | 2153 |
| 2140 | 2154 |
| 2141 void v8::TryCatch::Reset() { | 2155 void v8::TryCatch::Reset() { |
| 2142 ASSERT(isolate_ == i::Isolate::Current()); | 2156 ASSERT(isolate_ == i::Isolate::Current()); |
| 2143 exception_ = isolate_->heap()->the_hole_value(); | 2157 exception_ = isolate_->heap()->the_hole_value(); |
| 2144 message_ = i::Smi::FromInt(0); | 2158 message_obj_ = i::Smi::FromInt(0); |
| 2159 message_script_ = i::Smi::FromInt(0); |
| 2160 message_start_pos_ = 0; |
| 2161 message_end_pos_ = 0; |
| 2145 } | 2162 } |
| 2146 | 2163 |
| 2147 | 2164 |
| 2148 void v8::TryCatch::SetVerbose(bool value) { | 2165 void v8::TryCatch::SetVerbose(bool value) { |
| 2149 is_verbose_ = value; | 2166 is_verbose_ = value; |
| 2150 } | 2167 } |
| 2151 | 2168 |
| 2152 | 2169 |
| 2153 void v8::TryCatch::SetCaptureMessage(bool value) { | 2170 void v8::TryCatch::SetCaptureMessage(bool value) { |
| 2154 capture_message_ = value; | 2171 capture_message_ = value; |
| (...skipping 5702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7857 | 7874 |
| 7858 v->VisitPointers(blocks_.first(), first_block_limit_); | 7875 v->VisitPointers(blocks_.first(), first_block_limit_); |
| 7859 | 7876 |
| 7860 for (int i = 1; i < blocks_.length(); i++) { | 7877 for (int i = 1; i < blocks_.length(); i++) { |
| 7861 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); | 7878 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); |
| 7862 } | 7879 } |
| 7863 } | 7880 } |
| 7864 | 7881 |
| 7865 | 7882 |
| 7866 } } // namespace v8::internal | 7883 } } // namespace v8::internal |
| OLD | NEW |