Add explicit Isolate parameter to Exception::CreateMessage()
This way, we can also capture a stack trace for SMIs BUG=chromium:495801 R=yangguo@chromium.org LOG=y Review URL: https://codereview.chromium.org/1472143006 Cr-Commit-Position: refs/heads/master@{#32331}
This commit is contained in:
parent
b5d50296ed
commit
c47ce4cc8e
@ -4931,7 +4931,10 @@ class V8_EXPORT Exception {
|
||||
* Will try to reconstruct the original stack trace from the exception value,
|
||||
* or capture the current stack trace if not available.
|
||||
*/
|
||||
static Local<Message> CreateMessage(Local<Value> exception);
|
||||
static Local<Message> CreateMessage(Isolate* isolate, Local<Value> exception);
|
||||
V8_DEPRECATE_SOON(
|
||||
"Use version with an Isolate*",
|
||||
static Local<Message> CreateMessage(Local<Value> exception));
|
||||
|
||||
/**
|
||||
* Returns the original stack trace that was captured at the creation time
|
||||
|
16
src/api.cc
16
src/api.cc
@ -7725,14 +7725,22 @@ DEFINE_ERROR(Error, error)
|
||||
#undef DEFINE_ERROR
|
||||
|
||||
|
||||
Local<Message> Exception::CreateMessage(Isolate* isolate,
|
||||
Local<Value> exception) {
|
||||
i::Handle<i::Object> obj = Utils::OpenHandle(*exception);
|
||||
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
|
||||
ENTER_V8(i_isolate);
|
||||
i::HandleScope scope(i_isolate);
|
||||
return Utils::MessageToLocal(
|
||||
scope.CloseAndEscape(i_isolate->CreateMessage(obj, NULL)));
|
||||
}
|
||||
|
||||
|
||||
Local<Message> Exception::CreateMessage(Local<Value> exception) {
|
||||
i::Handle<i::Object> obj = Utils::OpenHandle(*exception);
|
||||
if (!obj->IsHeapObject()) return Local<Message>();
|
||||
i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
|
||||
ENTER_V8(isolate);
|
||||
i::HandleScope scope(isolate);
|
||||
return Utils::MessageToLocal(
|
||||
scope.CloseAndEscape(isolate->CreateMessage(obj, NULL)));
|
||||
return CreateMessage(reinterpret_cast<Isolate*>(isolate), exception);
|
||||
}
|
||||
|
||||
|
||||
|
@ -7666,7 +7666,8 @@ THREADED_TEST(ExceptionCreateMessage) {
|
||||
CHECK(error->IsObject());
|
||||
CHECK(error.As<v8::Object>()->Get(message_str)->Equals(foo_str));
|
||||
|
||||
v8::Handle<v8::Message> message = v8::Exception::CreateMessage(error);
|
||||
v8::Handle<v8::Message> message =
|
||||
v8::Exception::CreateMessage(context->GetIsolate(), error);
|
||||
CHECK(!message.IsEmpty());
|
||||
CHECK_EQ(2, message->GetLineNumber());
|
||||
CHECK_EQ(2, message->GetStartColumn());
|
||||
@ -7696,7 +7697,7 @@ THREADED_TEST(ExceptionCreateMessage) {
|
||||
CHECK(error->IsObject());
|
||||
CHECK(error.As<v8::Object>()->Get(message_str)->Equals(foo_str));
|
||||
|
||||
message = v8::Exception::CreateMessage(error);
|
||||
message = v8::Exception::CreateMessage(context->GetIsolate(), error);
|
||||
CHECK(!message.IsEmpty());
|
||||
CHECK_EQ(2, message->GetLineNumber());
|
||||
CHECK_EQ(9, message->GetStartColumn());
|
||||
@ -14913,8 +14914,8 @@ void PromiseRejectCallback(v8::PromiseRejectMessage reject_message) {
|
||||
promise_reject_counter++;
|
||||
CcTest::global()->Set(v8_str("rejected"), reject_message.GetPromise());
|
||||
CcTest::global()->Set(v8_str("value"), reject_message.GetValue());
|
||||
v8::Handle<v8::Message> message =
|
||||
v8::Exception::CreateMessage(reject_message.GetValue());
|
||||
v8::Handle<v8::Message> message = v8::Exception::CreateMessage(
|
||||
CcTest::isolate(), reject_message.GetValue());
|
||||
v8::Handle<v8::StackTrace> stack_trace = message->GetStackTrace();
|
||||
|
||||
promise_reject_msg_line_number = message->GetLineNumber();
|
||||
|
Loading…
Reference in New Issue
Block a user