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 { ...@@ -3605,7 +3605,9 @@ class V8_EXPORT DataView : public ArrayBufferView {
*/ */
class V8_EXPORT Date : public Object { class V8_EXPORT Date : public Object {
public: 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 * A specialization of Value::NumberValue that is more efficient
...@@ -6094,7 +6096,8 @@ class V8_EXPORT TryCatch { ...@@ -6094,7 +6096,8 @@ class V8_EXPORT TryCatch {
* Returns the .stack property of the thrown object. If no .stack * Returns the .stack property of the thrown object. If no .stack
* property is present an empty handle is returned. * 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 * Returns the message associated with this exception. If there is
......
...@@ -52,30 +52,12 @@ ...@@ -52,30 +52,12 @@
#include "src/vm-state-inl.h" #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 { namespace v8 {
#define EXCEPTION_PREAMBLE(isolate) \ #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr))
(isolate)->handle_scope_implementer()->IncrementCallDepth(); \
DCHECK(!(isolate)->external_caught_exception()); \
bool has_pending_exception = false
#define EXCEPTION_BAILOUT_CHECK(isolate, value) \ #define ENTER_V8(isolate) i::VMState<v8::OTHER> __state__((isolate))
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 PREPARE_FOR_EXECUTION_GENERIC(isolate, context, function_name, \ #define PREPARE_FOR_EXECUTION_GENERIC(isolate, context, function_name, \
...@@ -2096,28 +2078,28 @@ v8::Local<Value> v8::TryCatch::Exception() const { ...@@ -2096,28 +2078,28 @@ v8::Local<Value> v8::TryCatch::Exception() const {
} }
v8::Local<Value> v8::TryCatch::StackTrace() const { MaybeLocal<Value> v8::TryCatch::StackTrace(Local<Context> context) const {
if (HasCaught()) { if (!HasCaught()) return v8::Local<Value>();
i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_);
if (!raw_obj->IsJSObject()) return v8::Local<Value>(); 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::JSObject> obj(i::JSObject::cast(raw_obj), isolate_);
i::Handle<i::String> name = isolate_->factory()->stack_string(); i::Handle<i::String> name = isolate->factory()->stack_string();
{
EXCEPTION_PREAMBLE(isolate_);
Maybe<bool> maybe = i::JSReceiver::HasProperty(obj, name); Maybe<bool> maybe = i::JSReceiver::HasProperty(obj, name);
has_pending_exception = !maybe.IsJust(); has_pending_exception = !maybe.IsJust();
EXCEPTION_BAILOUT_CHECK(isolate_, v8::Local<Value>()); RETURN_ON_FAILED_EXECUTION(Value);
if (!maybe.FromJust()) return v8::Local<Value>(); if (!maybe.FromJust()) return v8::Local<Value>();
} Local<Value> result;
i::Handle<i::Object> value; has_pending_exception =
EXCEPTION_PREAMBLE(isolate_); !ToLocal<Value>(i::Object::GetProperty(obj, name), &result);
has_pending_exception = !i::Object::GetProperty(obj, name).ToHandle(&value); RETURN_ON_FAILED_EXECUTION(Value);
EXCEPTION_BAILOUT_CHECK(isolate_, v8::Local<Value>()); RETURN_ESCAPED(result);
return v8::Utils::ToLocal(scope.CloseAndEscape(value)); }
} else {
return v8::Local<Value>();
} 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 { ...@@ -6004,20 +5986,23 @@ Local<v8::Symbol> v8::SymbolObject::ValueOf() const {
} }
Local<v8::Value> v8::Date::New(Isolate* isolate, double time) { MaybeLocal<v8::Value> v8::Date::New(Local<Context> context, double time) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
LOG_API(i_isolate, "Date::New");
if (std::isnan(time)) { if (std::isnan(time)) {
// Introduce only canonical NaN value into the VM, to avoid signaling NaNs. // Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
time = std::numeric_limits<double>::quiet_NaN(); time = std::numeric_limits<double>::quiet_NaN();
} }
ENTER_V8(i_isolate); PREPARE_FOR_EXECUTION(context, "Date::New", Value);
EXCEPTION_PREAMBLE(i_isolate); Local<Value> result;
i::Handle<i::Object> obj; has_pending_exception =
has_pending_exception = !i::Execution::NewDate( !ToLocal<Value>(i::Execution::NewDate(isolate, time), &result);
i_isolate, time).ToHandle(&obj); RETURN_ON_FAILED_EXECUTION(Value);
EXCEPTION_BAILOUT_CHECK(i_isolate, Local<v8::Value>()); RETURN_ESCAPED(result);
return Utils::ToLocal(obj); }
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