Commit 7f38011a authored by dcarney's avatar dcarney Committed by Commit bot

convert last api functions which try to handle exceptions to maybes

BUG=v8:3929
LOG=n

Review URL: https://codereview.chromium.org/1015083002

Cr-Commit-Position: refs/heads/master@{#27270}
parent 16c8485a
......@@ -3605,7 +3605,9 @@ class V8_EXPORT DataView : public ArrayBufferView {
*/
class V8_EXPORT Date : public Object {
public:
static Local<Value> New(Isolate* isolate, double time);
static V8_DEPRECATE_SOON("Use maybe version.",
Local<Value> New(Isolate* isolate, double time));
static MaybeLocal<Value> New(Local<Context> context, double time);
/**
* A specialization of Value::NumberValue that is more efficient
......@@ -6094,7 +6096,8 @@ class V8_EXPORT TryCatch {
* Returns the .stack property of the thrown object. If no .stack
* property is present an empty handle is returned.
*/
Local<Value> StackTrace() const;
V8_DEPRECATE_SOON("Use maybe version.", Local<Value> StackTrace()) const;
MaybeLocal<Value> StackTrace(Local<Context> context) const;
/**
* Returns the message associated with this exception. If there is
......
......@@ -52,30 +52,12 @@
#include "src/vm-state-inl.h"
#define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr))
#define ENTER_V8(isolate) \
i::VMState<v8::OTHER> __state__((isolate))
namespace v8 {
#define EXCEPTION_PREAMBLE(isolate) \
(isolate)->handle_scope_implementer()->IncrementCallDepth(); \
DCHECK(!(isolate)->external_caught_exception()); \
bool has_pending_exception = false
#define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr))
#define EXCEPTION_BAILOUT_CHECK(isolate, value) \
do { \
i::HandleScopeImplementer* handle_scope_implementer = \
(isolate)->handle_scope_implementer(); \
handle_scope_implementer->DecrementCallDepth(); \
if (has_pending_exception) { \
bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \
(isolate)->OptionalRescheduleException(call_depth_is_zero); \
return value; \
} \
} while (false)
#define ENTER_V8(isolate) i::VMState<v8::OTHER> __state__((isolate))
#define PREPARE_FOR_EXECUTION_GENERIC(isolate, context, function_name, \
......@@ -2096,28 +2078,28 @@ v8::Local<Value> v8::TryCatch::Exception() const {
}
v8::Local<Value> v8::TryCatch::StackTrace() const {
if (HasCaught()) {
MaybeLocal<Value> v8::TryCatch::StackTrace(Local<Context> context) const {
if (!HasCaught()) return v8::Local<Value>();
i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_);
if (!raw_obj->IsJSObject()) return v8::Local<Value>();
i::HandleScope scope(isolate_);
PREPARE_FOR_EXECUTION(context, "v8::TryCatch::StackTrace", Value);
i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_);
i::Handle<i::String> name = isolate_->factory()->stack_string();
{
EXCEPTION_PREAMBLE(isolate_);
i::Handle<i::String> name = isolate->factory()->stack_string();
Maybe<bool> maybe = i::JSReceiver::HasProperty(obj, name);
has_pending_exception = !maybe.IsJust();
EXCEPTION_BAILOUT_CHECK(isolate_, v8::Local<Value>());
RETURN_ON_FAILED_EXECUTION(Value);
if (!maybe.FromJust()) return v8::Local<Value>();
}
i::Handle<i::Object> value;
EXCEPTION_PREAMBLE(isolate_);
has_pending_exception = !i::Object::GetProperty(obj, name).ToHandle(&value);
EXCEPTION_BAILOUT_CHECK(isolate_, v8::Local<Value>());
return v8::Utils::ToLocal(scope.CloseAndEscape(value));
} else {
return v8::Local<Value>();
}
Local<Value> result;
has_pending_exception =
!ToLocal<Value>(i::Object::GetProperty(obj, name), &result);
RETURN_ON_FAILED_EXECUTION(Value);
RETURN_ESCAPED(result);
}
v8::Local<Value> v8::TryCatch::StackTrace() const {
auto context = reinterpret_cast<v8::Isolate*>(isolate_)->GetCurrentContext();
RETURN_TO_LOCAL_UNCHECKED(StackTrace(context), Value);
}
......@@ -6004,20 +5986,23 @@ Local<v8::Symbol> v8::SymbolObject::ValueOf() const {
}
Local<v8::Value> v8::Date::New(Isolate* isolate, double time) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
LOG_API(i_isolate, "Date::New");
MaybeLocal<v8::Value> v8::Date::New(Local<Context> context, double time) {
if (std::isnan(time)) {
// Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
time = std::numeric_limits<double>::quiet_NaN();
}
ENTER_V8(i_isolate);
EXCEPTION_PREAMBLE(i_isolate);
i::Handle<i::Object> obj;
has_pending_exception = !i::Execution::NewDate(
i_isolate, time).ToHandle(&obj);
EXCEPTION_BAILOUT_CHECK(i_isolate, Local<v8::Value>());
return Utils::ToLocal(obj);
PREPARE_FOR_EXECUTION(context, "Date::New", Value);
Local<Value> result;
has_pending_exception =
!ToLocal<Value>(i::Execution::NewDate(isolate, time), &result);
RETURN_ON_FAILED_EXECUTION(Value);
RETURN_ESCAPED(result);
}
Local<v8::Value> v8::Date::New(Isolate* isolate, double time) {
auto context = isolate->GetCurrentContext();
RETURN_TO_LOCAL_UNCHECKED(New(context, time), Value);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment