Refactor call site handling for stack formatting
This commit introduces several new types: * JSStackFrame and WasmStackFrame are wrapper classes around a single frame in a FrameArray. * They both inherit from StackFrameBase, which uses virtual dispatch to call the correct implementation. * FrameArrayIterator contains a static instance of JSStackFrame and WasmStackFrame and returns a pointer to the corresponding type for each frame. * The JS callsite object now contains the frame array and frame index as internal fields. Internal stack formatting now relies completely on FrameArrayIterator and the {JS,Wasm}StackFrame types. JS callsite instances are allocated only for custom user formatting through Error.prepareStackTrace. BUG= Review-Url: https://codereview.chromium.org/2275233002 Cr-Commit-Position: refs/heads/master@{#39015}
This commit is contained in:
parent
510246f6e2
commit
f7bc1fc733
@ -14,7 +14,7 @@ namespace internal {
|
||||
#define CHECK_CALLSITE(recv, method) \
|
||||
CHECK_RECEIVER(JSObject, recv, method); \
|
||||
if (!JSReceiver::HasOwnProperty( \
|
||||
recv, isolate->factory()->call_site_position_symbol()) \
|
||||
recv, isolate->factory()->call_site_frame_array_symbol()) \
|
||||
.FromMaybe(false)) { \
|
||||
THROW_NEW_ERROR_RETURN_FAILURE( \
|
||||
isolate, \
|
||||
@ -29,172 +29,152 @@ Object* PositiveNumberOrNull(int value, Isolate* isolate) {
|
||||
return isolate->heap()->null_value();
|
||||
}
|
||||
|
||||
Handle<FrameArray> GetFrameArray(Isolate* isolate, Handle<JSObject> object) {
|
||||
Handle<Object> frame_array_obj = JSObject::GetDataProperty(
|
||||
object, isolate->factory()->call_site_frame_array_symbol());
|
||||
return Handle<FrameArray>::cast(frame_array_obj);
|
||||
}
|
||||
|
||||
int GetFrameIndex(Isolate* isolate, Handle<JSObject> object) {
|
||||
Handle<Object> frame_index_obj = JSObject::GetDataProperty(
|
||||
object, isolate->factory()->call_site_frame_index_symbol());
|
||||
return Smi::cast(*frame_index_obj)->value();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
BUILTIN(CallSitePrototypeGetColumnNumber) {
|
||||
HandleScope scope(isolate);
|
||||
CHECK_CALLSITE(recv, "getColumnNumber");
|
||||
|
||||
CallSite call_site(isolate, recv);
|
||||
CHECK(call_site.IsJavaScript() || call_site.IsWasm());
|
||||
return PositiveNumberOrNull(call_site.GetColumnNumber(), isolate);
|
||||
FrameArrayIterator it(isolate, GetFrameArray(isolate, recv),
|
||||
GetFrameIndex(isolate, recv));
|
||||
return PositiveNumberOrNull(it.Frame()->GetColumnNumber(), isolate);
|
||||
}
|
||||
|
||||
BUILTIN(CallSitePrototypeGetEvalOrigin) {
|
||||
HandleScope scope(isolate);
|
||||
CHECK_CALLSITE(recv, "getEvalOrigin");
|
||||
|
||||
CallSite call_site(isolate, recv);
|
||||
CHECK(call_site.IsJavaScript() || call_site.IsWasm());
|
||||
return *call_site.GetEvalOrigin();
|
||||
FrameArrayIterator it(isolate, GetFrameArray(isolate, recv),
|
||||
GetFrameIndex(isolate, recv));
|
||||
return *it.Frame()->GetEvalOrigin();
|
||||
}
|
||||
|
||||
BUILTIN(CallSitePrototypeGetFileName) {
|
||||
HandleScope scope(isolate);
|
||||
CHECK_CALLSITE(recv, "getFileName");
|
||||
|
||||
CallSite call_site(isolate, recv);
|
||||
CHECK(call_site.IsJavaScript() || call_site.IsWasm());
|
||||
return *call_site.GetFileName();
|
||||
FrameArrayIterator it(isolate, GetFrameArray(isolate, recv),
|
||||
GetFrameIndex(isolate, recv));
|
||||
return *it.Frame()->GetFileName();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
bool CallSiteIsStrict(Isolate* isolate, Handle<JSObject> receiver) {
|
||||
Handle<Object> strict;
|
||||
Handle<Symbol> symbol = isolate->factory()->call_site_strict_symbol();
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, strict,
|
||||
JSObject::GetProperty(receiver, symbol));
|
||||
return strict->BooleanValue();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
BUILTIN(CallSitePrototypeGetFunction) {
|
||||
HandleScope scope(isolate);
|
||||
CHECK_CALLSITE(recv, "getFunction");
|
||||
FrameArrayIterator it(isolate, GetFrameArray(isolate, recv),
|
||||
GetFrameIndex(isolate, recv));
|
||||
|
||||
if (CallSiteIsStrict(isolate, recv))
|
||||
return *isolate->factory()->undefined_value();
|
||||
|
||||
Handle<Symbol> symbol = isolate->factory()->call_site_function_symbol();
|
||||
RETURN_RESULT_OR_FAILURE(isolate, JSObject::GetProperty(recv, symbol));
|
||||
StackFrameBase* frame = it.Frame();
|
||||
if (frame->IsStrict()) return isolate->heap()->undefined_value();
|
||||
return *frame->GetFunction();
|
||||
}
|
||||
|
||||
BUILTIN(CallSitePrototypeGetFunctionName) {
|
||||
HandleScope scope(isolate);
|
||||
CHECK_CALLSITE(recv, "getFunctionName");
|
||||
|
||||
CallSite call_site(isolate, recv);
|
||||
CHECK(call_site.IsJavaScript() || call_site.IsWasm());
|
||||
return *call_site.GetFunctionName();
|
||||
FrameArrayIterator it(isolate, GetFrameArray(isolate, recv),
|
||||
GetFrameIndex(isolate, recv));
|
||||
return *it.Frame()->GetFunctionName();
|
||||
}
|
||||
|
||||
BUILTIN(CallSitePrototypeGetLineNumber) {
|
||||
HandleScope scope(isolate);
|
||||
CHECK_CALLSITE(recv, "getLineNumber");
|
||||
|
||||
CallSite call_site(isolate, recv);
|
||||
CHECK(call_site.IsJavaScript() || call_site.IsWasm());
|
||||
|
||||
int line_number = call_site.IsWasm() ? call_site.wasm_func_index()
|
||||
: call_site.GetLineNumber();
|
||||
return PositiveNumberOrNull(line_number, isolate);
|
||||
FrameArrayIterator it(isolate, GetFrameArray(isolate, recv),
|
||||
GetFrameIndex(isolate, recv));
|
||||
return PositiveNumberOrNull(it.Frame()->GetLineNumber(), isolate);
|
||||
}
|
||||
|
||||
BUILTIN(CallSitePrototypeGetMethodName) {
|
||||
HandleScope scope(isolate);
|
||||
CHECK_CALLSITE(recv, "getMethodName");
|
||||
|
||||
CallSite call_site(isolate, recv);
|
||||
CHECK(call_site.IsJavaScript() || call_site.IsWasm());
|
||||
return *call_site.GetMethodName();
|
||||
FrameArrayIterator it(isolate, GetFrameArray(isolate, recv),
|
||||
GetFrameIndex(isolate, recv));
|
||||
return *it.Frame()->GetMethodName();
|
||||
}
|
||||
|
||||
BUILTIN(CallSitePrototypeGetPosition) {
|
||||
HandleScope scope(isolate);
|
||||
CHECK_CALLSITE(recv, "getPosition");
|
||||
|
||||
Handle<Symbol> symbol = isolate->factory()->call_site_position_symbol();
|
||||
RETURN_RESULT_OR_FAILURE(isolate, JSObject::GetProperty(recv, symbol));
|
||||
FrameArrayIterator it(isolate, GetFrameArray(isolate, recv),
|
||||
GetFrameIndex(isolate, recv));
|
||||
return Smi::FromInt(it.Frame()->GetPosition());
|
||||
}
|
||||
|
||||
BUILTIN(CallSitePrototypeGetScriptNameOrSourceURL) {
|
||||
HandleScope scope(isolate);
|
||||
CHECK_CALLSITE(recv, "getScriptNameOrSourceUrl");
|
||||
|
||||
CallSite call_site(isolate, recv);
|
||||
CHECK(call_site.IsJavaScript() || call_site.IsWasm());
|
||||
return *call_site.GetScriptNameOrSourceUrl();
|
||||
FrameArrayIterator it(isolate, GetFrameArray(isolate, recv),
|
||||
GetFrameIndex(isolate, recv));
|
||||
return *it.Frame()->GetScriptNameOrSourceUrl();
|
||||
}
|
||||
|
||||
BUILTIN(CallSitePrototypeGetThis) {
|
||||
HandleScope scope(isolate);
|
||||
CHECK_CALLSITE(recv, "getThis");
|
||||
FrameArrayIterator it(isolate, GetFrameArray(isolate, recv),
|
||||
GetFrameIndex(isolate, recv));
|
||||
|
||||
if (CallSiteIsStrict(isolate, recv))
|
||||
return *isolate->factory()->undefined_value();
|
||||
|
||||
Handle<Object> receiver;
|
||||
Handle<Symbol> symbol = isolate->factory()->call_site_receiver_symbol();
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver,
|
||||
JSObject::GetProperty(recv, symbol));
|
||||
|
||||
if (*receiver == isolate->heap()->call_site_constructor_symbol())
|
||||
return *isolate->factory()->undefined_value();
|
||||
|
||||
return *receiver;
|
||||
StackFrameBase* frame = it.Frame();
|
||||
if (frame->IsStrict()) return isolate->heap()->undefined_value();
|
||||
return *frame->GetReceiver();
|
||||
}
|
||||
|
||||
BUILTIN(CallSitePrototypeGetTypeName) {
|
||||
HandleScope scope(isolate);
|
||||
CHECK_CALLSITE(recv, "getTypeName");
|
||||
|
||||
CallSite call_site(isolate, recv);
|
||||
CHECK(call_site.IsJavaScript() || call_site.IsWasm());
|
||||
return *call_site.GetTypeName();
|
||||
FrameArrayIterator it(isolate, GetFrameArray(isolate, recv),
|
||||
GetFrameIndex(isolate, recv));
|
||||
return *it.Frame()->GetTypeName();
|
||||
}
|
||||
|
||||
BUILTIN(CallSitePrototypeIsConstructor) {
|
||||
HandleScope scope(isolate);
|
||||
CHECK_CALLSITE(recv, "isConstructor");
|
||||
|
||||
CallSite call_site(isolate, recv);
|
||||
CHECK(call_site.IsJavaScript() || call_site.IsWasm());
|
||||
return isolate->heap()->ToBoolean(call_site.IsConstructor());
|
||||
FrameArrayIterator it(isolate, GetFrameArray(isolate, recv),
|
||||
GetFrameIndex(isolate, recv));
|
||||
return isolate->heap()->ToBoolean(it.Frame()->IsConstructor());
|
||||
}
|
||||
|
||||
BUILTIN(CallSitePrototypeIsEval) {
|
||||
HandleScope scope(isolate);
|
||||
CHECK_CALLSITE(recv, "isEval");
|
||||
|
||||
CallSite call_site(isolate, recv);
|
||||
CHECK(call_site.IsJavaScript() || call_site.IsWasm());
|
||||
return isolate->heap()->ToBoolean(call_site.IsEval());
|
||||
FrameArrayIterator it(isolate, GetFrameArray(isolate, recv),
|
||||
GetFrameIndex(isolate, recv));
|
||||
return isolate->heap()->ToBoolean(it.Frame()->IsEval());
|
||||
}
|
||||
|
||||
BUILTIN(CallSitePrototypeIsNative) {
|
||||
HandleScope scope(isolate);
|
||||
CHECK_CALLSITE(recv, "isNative");
|
||||
|
||||
CallSite call_site(isolate, recv);
|
||||
CHECK(call_site.IsJavaScript() || call_site.IsWasm());
|
||||
return isolate->heap()->ToBoolean(call_site.IsNative());
|
||||
FrameArrayIterator it(isolate, GetFrameArray(isolate, recv),
|
||||
GetFrameIndex(isolate, recv));
|
||||
return isolate->heap()->ToBoolean(it.Frame()->IsNative());
|
||||
}
|
||||
|
||||
BUILTIN(CallSitePrototypeIsToplevel) {
|
||||
HandleScope scope(isolate);
|
||||
CHECK_CALLSITE(recv, "isToplevel");
|
||||
|
||||
CallSite call_site(isolate, recv);
|
||||
CHECK(call_site.IsJavaScript() || call_site.IsWasm());
|
||||
return isolate->heap()->ToBoolean(call_site.IsToplevel());
|
||||
FrameArrayIterator it(isolate, GetFrameArray(isolate, recv),
|
||||
GetFrameIndex(isolate, recv));
|
||||
return isolate->heap()->ToBoolean(it.Frame()->IsToplevel());
|
||||
}
|
||||
|
||||
BUILTIN(CallSitePrototypeToString) {
|
||||
HandleScope scope(isolate);
|
||||
CHECK_CALLSITE(recv, "toString");
|
||||
RETURN_RESULT_OR_FAILURE(isolate, CallSiteUtils::ToString(isolate, recv));
|
||||
FrameArrayIterator it(isolate, GetFrameArray(isolate, recv),
|
||||
GetFrameIndex(isolate, recv));
|
||||
RETURN_RESULT_OR_FAILURE(isolate, it.Frame()->ToString());
|
||||
}
|
||||
|
||||
#undef CHECK_CALLSITE
|
||||
|
@ -436,31 +436,6 @@ void StackGuard::InitThread(const ExecutionAccess& lock) {
|
||||
// --- C a l l s t o n a t i v e s ---
|
||||
|
||||
|
||||
Handle<String> Execution::GetStackTraceLine(Handle<Object> recv,
|
||||
Handle<JSFunction> fun,
|
||||
Handle<Object> pos,
|
||||
Handle<Object> is_global) {
|
||||
Isolate* isolate = fun->GetIsolate();
|
||||
Handle<Object> strict_mode = isolate->factory()->ToBoolean(false);
|
||||
|
||||
MaybeHandle<Object> maybe_callsite =
|
||||
CallSiteUtils::Construct(isolate, recv, fun, pos, strict_mode);
|
||||
if (maybe_callsite.is_null()) {
|
||||
isolate->clear_pending_exception();
|
||||
return isolate->factory()->empty_string();
|
||||
}
|
||||
|
||||
MaybeHandle<String> maybe_to_string =
|
||||
CallSiteUtils::ToString(isolate, maybe_callsite.ToHandleChecked());
|
||||
if (maybe_to_string.is_null()) {
|
||||
isolate->clear_pending_exception();
|
||||
return isolate->factory()->empty_string();
|
||||
}
|
||||
|
||||
return maybe_to_string.ToHandleChecked();
|
||||
}
|
||||
|
||||
|
||||
void StackGuard::HandleGCInterrupt() {
|
||||
if (CheckAndClearInterrupt(GC_REQUEST)) {
|
||||
isolate_->heap()->HandleGCRequest();
|
||||
|
@ -48,11 +48,6 @@ class Execution final : public AllStatic {
|
||||
Handle<Object> receiver, int argc,
|
||||
Handle<Object> argv[],
|
||||
MaybeHandle<Object>* exception_out = NULL);
|
||||
|
||||
static Handle<String> GetStackTraceLine(Handle<Object> recv,
|
||||
Handle<JSFunction> fun,
|
||||
Handle<Object> pos,
|
||||
Handle<Object> is_global);
|
||||
};
|
||||
|
||||
|
||||
|
@ -162,13 +162,8 @@
|
||||
V(array_iteration_kind_symbol) \
|
||||
V(array_iterator_next_symbol) \
|
||||
V(array_iterator_object_symbol) \
|
||||
V(call_site_constructor_symbol) \
|
||||
V(call_site_function_symbol) \
|
||||
V(call_site_position_symbol) \
|
||||
V(call_site_receiver_symbol) \
|
||||
V(call_site_strict_symbol) \
|
||||
V(call_site_wasm_obj_symbol) \
|
||||
V(call_site_wasm_func_index_symbol) \
|
||||
V(call_site_frame_array_symbol) \
|
||||
V(call_site_frame_index_symbol) \
|
||||
V(class_end_position_symbol) \
|
||||
V(class_start_position_symbol) \
|
||||
V(detailed_stack_trace_symbol) \
|
||||
|
@ -501,7 +501,7 @@ Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSReceiver> error_object,
|
||||
|
||||
Handle<Object> recv(exit_frame->receiver(), this);
|
||||
Handle<Code> code(exit_frame->LookupCode(), this);
|
||||
int offset =
|
||||
const int offset =
|
||||
static_cast<int>(exit_frame->pc() - code->instruction_start());
|
||||
|
||||
int flags = 0;
|
||||
@ -1395,36 +1395,20 @@ Object* Isolate::PromoteScheduledException() {
|
||||
|
||||
|
||||
void Isolate::PrintCurrentStackTrace(FILE* out) {
|
||||
StackTraceFrameIterator it(this);
|
||||
while (!it.done()) {
|
||||
for (StackTraceFrameIterator it(this); !it.done(); it.Advance()) {
|
||||
if (!it.is_javascript()) continue;
|
||||
|
||||
HandleScope scope(this);
|
||||
// Find code position if recorded in relocation info.
|
||||
StandardFrame* frame = it.frame();
|
||||
AbstractCode* abstract_code;
|
||||
int code_offset;
|
||||
if (frame->is_interpreted()) {
|
||||
InterpretedFrame* iframe = reinterpret_cast<InterpretedFrame*>(frame);
|
||||
abstract_code = AbstractCode::cast(iframe->GetBytecodeArray());
|
||||
code_offset = iframe->GetBytecodeOffset();
|
||||
} else {
|
||||
DCHECK(frame->is_java_script() || frame->is_wasm());
|
||||
Code* code = frame->LookupCode();
|
||||
abstract_code = AbstractCode::cast(code);
|
||||
code_offset = static_cast<int>(frame->pc() - code->instruction_start());
|
||||
}
|
||||
int pos = abstract_code->SourcePosition(code_offset);
|
||||
JavaScriptFrame* js_frame = JavaScriptFrame::cast(frame);
|
||||
Handle<Object> pos_obj(Smi::FromInt(pos), this);
|
||||
// Fetch function and receiver.
|
||||
Handle<JSFunction> fun(js_frame->function(), this);
|
||||
Handle<Object> recv(js_frame->receiver(), this);
|
||||
// Advance to the next JavaScript frame and determine if the
|
||||
// current frame is the top-level frame.
|
||||
it.Advance();
|
||||
Handle<Object> is_top_level = factory()->ToBoolean(it.done());
|
||||
// Generate and print stack trace line.
|
||||
Handle<String> line =
|
||||
Execution::GetStackTraceLine(recv, fun, pos_obj, is_top_level);
|
||||
JavaScriptFrame* frame = it.javascript_frame();
|
||||
|
||||
Handle<Object> receiver(frame->receiver(), this);
|
||||
Handle<JSFunction> function(frame->function(), this);
|
||||
Handle<AbstractCode> code(AbstractCode::cast(frame->LookupCode()), this);
|
||||
const int offset =
|
||||
static_cast<int>(frame->pc() - code->instruction_start());
|
||||
|
||||
JSStackFrame site(this, receiver, function, code, offset);
|
||||
Handle<String> line = site.ToString().ToHandleChecked();
|
||||
if (line->length() > 0) {
|
||||
line->PrintOn(out);
|
||||
PrintF(out, "\n");
|
||||
|
833
src/messages.cc
833
src/messages.cc
@ -164,71 +164,63 @@ std::unique_ptr<char[]> MessageHandler::GetLocalizedMessage(
|
||||
return GetMessage(isolate, data)->ToCString(DISALLOW_NULLS);
|
||||
}
|
||||
|
||||
void JSStackFrame::FromFrameArray(Isolate* isolate, Handle<FrameArray> array,
|
||||
int frame_ix) {
|
||||
DCHECK(!array->IsWasmFrame(frame_ix));
|
||||
isolate_ = isolate;
|
||||
receiver_ = handle(array->Receiver(frame_ix), isolate);
|
||||
function_ = handle(array->Function(frame_ix), isolate);
|
||||
code_ = handle(array->Code(frame_ix), isolate);
|
||||
offset_ = array->Offset(frame_ix)->value();
|
||||
|
||||
CallSite::CallSite(Isolate* isolate, Handle<JSObject> call_site_obj)
|
||||
: isolate_(isolate) {
|
||||
Handle<Object> maybe_function = JSObject::GetDataProperty(
|
||||
call_site_obj, isolate->factory()->call_site_function_symbol());
|
||||
if (maybe_function->IsJSFunction()) {
|
||||
// javascript
|
||||
fun_ = Handle<JSFunction>::cast(maybe_function);
|
||||
receiver_ = JSObject::GetDataProperty(
|
||||
call_site_obj, isolate->factory()->call_site_receiver_symbol());
|
||||
} else {
|
||||
Handle<Object> maybe_wasm_func_index = JSObject::GetDataProperty(
|
||||
call_site_obj, isolate->factory()->call_site_wasm_func_index_symbol());
|
||||
if (!maybe_wasm_func_index->IsSmi()) {
|
||||
// invalid: neither javascript nor wasm
|
||||
return;
|
||||
}
|
||||
// wasm
|
||||
wasm_obj_ = Handle<JSObject>::cast(JSObject::GetDataProperty(
|
||||
call_site_obj, isolate->factory()->call_site_wasm_obj_symbol()));
|
||||
wasm_func_index_ = Smi::cast(*maybe_wasm_func_index)->value();
|
||||
DCHECK(static_cast<int>(wasm_func_index_) >= 0);
|
||||
}
|
||||
|
||||
CHECK(JSObject::GetDataProperty(
|
||||
call_site_obj, isolate->factory()->call_site_position_symbol())
|
||||
->ToInt32(&pos_));
|
||||
const int flags = array->Flags(frame_ix)->value();
|
||||
force_constructor_ = (flags & FrameArray::kForceConstructor) != 0;
|
||||
is_strict_ = (flags & FrameArray::kIsStrict) != 0;
|
||||
}
|
||||
|
||||
JSStackFrame::JSStackFrame(Isolate* isolate, Handle<Object> receiver,
|
||||
Handle<JSFunction> function,
|
||||
Handle<AbstractCode> code, int offset)
|
||||
: isolate_(isolate),
|
||||
receiver_(receiver),
|
||||
function_(function),
|
||||
code_(code),
|
||||
offset_(offset),
|
||||
force_constructor_(false),
|
||||
is_strict_(false) {}
|
||||
|
||||
Handle<Object> CallSite::GetFileName() {
|
||||
if (!IsJavaScript()) return isolate_->factory()->null_value();
|
||||
Object* script = fun_->shared()->script();
|
||||
if (!script->IsScript()) return isolate_->factory()->null_value();
|
||||
return Handle<Object>(Script::cast(script)->name(), isolate_);
|
||||
JSStackFrame::JSStackFrame() {}
|
||||
|
||||
Handle<Object> JSStackFrame::GetFunction() const {
|
||||
return Handle<Object>::cast(function_);
|
||||
}
|
||||
|
||||
Handle<Object> JSStackFrame::GetFileName() {
|
||||
if (!HasScript()) return isolate_->factory()->null_value();
|
||||
return handle(GetScript()->name(), isolate_);
|
||||
}
|
||||
|
||||
Handle<Object> CallSite::GetFunctionName() {
|
||||
if (IsWasm()) {
|
||||
return wasm::GetWasmFunctionNameOrNull(isolate_, wasm_obj_,
|
||||
wasm_func_index_);
|
||||
}
|
||||
Handle<String> result = JSFunction::GetName(fun_);
|
||||
Handle<Object> JSStackFrame::GetFunctionName() {
|
||||
Handle<String> result = JSFunction::GetName(function_);
|
||||
if (result->length() != 0) return result;
|
||||
|
||||
Handle<Object> script(fun_->shared()->script(), isolate_);
|
||||
if (script->IsScript() &&
|
||||
Handle<Script>::cast(script)->compilation_type() ==
|
||||
Script::COMPILATION_TYPE_EVAL) {
|
||||
if (HasScript() &&
|
||||
GetScript()->compilation_type() == Script::COMPILATION_TYPE_EVAL) {
|
||||
return isolate_->factory()->eval_string();
|
||||
}
|
||||
return isolate_->factory()->null_value();
|
||||
}
|
||||
|
||||
Handle<Object> CallSite::GetScriptNameOrSourceUrl() {
|
||||
if (!IsJavaScript()) return isolate_->factory()->null_value();
|
||||
Object* script_obj = fun_->shared()->script();
|
||||
if (!script_obj->IsScript()) return isolate_->factory()->null_value();
|
||||
Handle<Script> script(Script::cast(script_obj), isolate_);
|
||||
Handle<Object> JSStackFrame::GetScriptNameOrSourceUrl() {
|
||||
if (!HasScript()) return isolate_->factory()->null_value();
|
||||
Handle<Script> script = GetScript();
|
||||
Object* source_url = script->source_url();
|
||||
if (source_url->IsString()) return Handle<Object>(source_url, isolate_);
|
||||
return Handle<Object>(script->name(), isolate_);
|
||||
return (source_url->IsString()) ? handle(source_url, isolate_)
|
||||
: handle(script->name(), isolate_);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
bool CheckMethodName(Isolate* isolate, Handle<JSObject> obj, Handle<Name> name,
|
||||
Handle<JSFunction> fun,
|
||||
LookupIterator::Configuration config) {
|
||||
@ -246,12 +238,13 @@ bool CheckMethodName(Isolate* isolate, Handle<JSObject> obj, Handle<Name> name,
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Handle<Object> CallSite::GetMethodName() {
|
||||
if (!IsJavaScript() || receiver_->IsNull(isolate_) ||
|
||||
receiver_->IsUndefined(isolate_)) {
|
||||
Handle<Object> JSStackFrame::GetMethodName() {
|
||||
if (receiver_->IsNull(isolate_) || receiver_->IsUndefined(isolate_)) {
|
||||
return isolate_->factory()->null_value();
|
||||
}
|
||||
|
||||
Handle<JSReceiver> receiver =
|
||||
Object::ToObject(isolate_, receiver_).ToHandleChecked();
|
||||
if (!receiver->IsJSObject()) {
|
||||
@ -259,7 +252,7 @@ Handle<Object> CallSite::GetMethodName() {
|
||||
}
|
||||
|
||||
Handle<JSObject> obj = Handle<JSObject>::cast(receiver);
|
||||
Handle<Object> function_name(fun_->shared()->name(), isolate_);
|
||||
Handle<Object> function_name(function_->shared()->name(), isolate_);
|
||||
if (function_name->IsString()) {
|
||||
Handle<String> name = Handle<String>::cast(function_name);
|
||||
// ES2015 gives getters and setters name prefixes which must
|
||||
@ -268,7 +261,7 @@ Handle<Object> CallSite::GetMethodName() {
|
||||
name->IsUtf8EqualTo(CStrVector("set "), true)) {
|
||||
name = isolate_->factory()->NewProperSubString(name, 4, name->length());
|
||||
}
|
||||
if (CheckMethodName(isolate_, obj, name, fun_,
|
||||
if (CheckMethodName(isolate_, obj, name, function_,
|
||||
LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR)) {
|
||||
return name;
|
||||
}
|
||||
@ -288,7 +281,7 @@ Handle<Object> CallSite::GetMethodName() {
|
||||
HandleScope inner_scope(isolate_);
|
||||
if (!keys->get(i)->IsName()) continue;
|
||||
Handle<Name> name_key(Name::cast(keys->get(i)), isolate_);
|
||||
if (!CheckMethodName(isolate_, current_obj, name_key, fun_,
|
||||
if (!CheckMethodName(isolate_, current_obj, name_key, function_,
|
||||
LookupIterator::OWN_SKIP_INTERCEPTOR))
|
||||
continue;
|
||||
// Return null in case of duplicates to avoid confusion.
|
||||
@ -301,20 +294,6 @@ Handle<Object> CallSite::GetMethodName() {
|
||||
return isolate_->factory()->null_value();
|
||||
}
|
||||
|
||||
Handle<Object> CallSite::GetTypeName() {
|
||||
// TODO(jgruber): Check for strict/constructor here as in
|
||||
// CallSitePrototypeGetThis.
|
||||
|
||||
if (receiver_->IsNull(isolate_) || receiver_->IsUndefined(isolate_))
|
||||
return isolate_->factory()->null_value();
|
||||
|
||||
if (receiver_->IsJSProxy()) return isolate_->factory()->Proxy_string();
|
||||
|
||||
Handle<JSReceiver> receiver_object =
|
||||
Object::ToObject(isolate_, receiver_).ToHandleChecked();
|
||||
return JSReceiver::GetConstructorName(receiver_object);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
Object* EvalFromFunctionName(Isolate* isolate, Handle<Script> script) {
|
||||
@ -414,136 +393,344 @@ MaybeHandle<String> FormatEvalOrigin(Isolate* isolate, Handle<Script> script) {
|
||||
|
||||
} // namespace
|
||||
|
||||
Handle<Object> CallSite::GetEvalOrigin() {
|
||||
if (IsWasm()) return isolate_->factory()->undefined_value();
|
||||
DCHECK(IsJavaScript());
|
||||
Handle<Object> JSStackFrame::GetTypeName() {
|
||||
// TODO(jgruber): Check for strict/constructor here as in
|
||||
// CallSitePrototypeGetThis.
|
||||
|
||||
Handle<Object> script = handle(fun_->shared()->script(), isolate_);
|
||||
if (!script->IsScript()) return isolate_->factory()->undefined_value();
|
||||
if (receiver_->IsNull(isolate_) || receiver_->IsUndefined(isolate_))
|
||||
return isolate_->factory()->null_value();
|
||||
|
||||
return FormatEvalOrigin(isolate_, Handle<Script>::cast(script))
|
||||
.ToHandleChecked();
|
||||
if (receiver_->IsJSProxy()) return isolate_->factory()->Proxy_string();
|
||||
|
||||
Handle<JSReceiver> receiver_object =
|
||||
Object::ToObject(isolate_, receiver_).ToHandleChecked();
|
||||
return JSReceiver::GetConstructorName(receiver_object);
|
||||
}
|
||||
|
||||
int CallSite::GetLineNumber() {
|
||||
if (pos_ >= 0 && IsJavaScript()) {
|
||||
Handle<Object> script_obj(fun_->shared()->script(), isolate_);
|
||||
if (script_obj->IsScript()) {
|
||||
Handle<Script> script = Handle<Script>::cast(script_obj);
|
||||
return Script::GetLineNumber(script, pos_) + 1;
|
||||
}
|
||||
Handle<Object> JSStackFrame::GetEvalOrigin() {
|
||||
if (!HasScript()) return isolate_->factory()->undefined_value();
|
||||
return FormatEvalOrigin(isolate_, GetScript()).ToHandleChecked();
|
||||
}
|
||||
|
||||
int JSStackFrame::GetLineNumber() {
|
||||
DCHECK_LE(0, GetPosition());
|
||||
if (HasScript()) return Script::GetLineNumber(GetScript(), GetPosition()) + 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int JSStackFrame::GetColumnNumber() {
|
||||
DCHECK_LE(0, GetPosition());
|
||||
if (HasScript()) {
|
||||
return Script::GetColumnNumber(GetScript(), GetPosition()) + 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int CallSite::GetColumnNumber() {
|
||||
if (pos_ >= 0 && IsJavaScript()) {
|
||||
Handle<Object> script_obj(fun_->shared()->script(), isolate_);
|
||||
if (script_obj->IsScript()) {
|
||||
Handle<Script> script = Handle<Script>::cast(script_obj);
|
||||
return Script::GetColumnNumber(script, pos_) + 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
bool JSStackFrame::IsNative() {
|
||||
return HasScript() && GetScript()->type() == Script::TYPE_NATIVE;
|
||||
}
|
||||
|
||||
|
||||
bool CallSite::IsNative() {
|
||||
if (!IsJavaScript()) return false;
|
||||
Handle<Object> script(fun_->shared()->script(), isolate_);
|
||||
return script->IsScript() &&
|
||||
Handle<Script>::cast(script)->type() == Script::TYPE_NATIVE;
|
||||
}
|
||||
|
||||
|
||||
bool CallSite::IsToplevel() {
|
||||
if (IsWasm()) return false;
|
||||
bool JSStackFrame::IsToplevel() {
|
||||
return receiver_->IsJSGlobalProxy() || receiver_->IsNull(isolate_) ||
|
||||
receiver_->IsUndefined(isolate_);
|
||||
}
|
||||
|
||||
|
||||
bool CallSite::IsEval() {
|
||||
if (!IsJavaScript()) return false;
|
||||
Handle<Object> script(fun_->shared()->script(), isolate_);
|
||||
return script->IsScript() &&
|
||||
Handle<Script>::cast(script)->compilation_type() ==
|
||||
Script::COMPILATION_TYPE_EVAL;
|
||||
bool JSStackFrame::IsEval() {
|
||||
return HasScript() &&
|
||||
GetScript()->compilation_type() == Script::COMPILATION_TYPE_EVAL;
|
||||
}
|
||||
|
||||
|
||||
bool CallSite::IsConstructor() {
|
||||
// Builtin exit frames mark constructors by passing a special symbol as the
|
||||
// receiver.
|
||||
Object* ctor_symbol = isolate_->heap()->call_site_constructor_symbol();
|
||||
if (*receiver_ == ctor_symbol) return true;
|
||||
if (!IsJavaScript() || !receiver_->IsJSObject()) return false;
|
||||
bool JSStackFrame::IsConstructor() {
|
||||
if (force_constructor_) return true;
|
||||
if (!receiver_->IsJSObject()) return false;
|
||||
Handle<Object> constructor =
|
||||
JSReceiver::GetDataProperty(Handle<JSObject>::cast(receiver_),
|
||||
isolate_->factory()->constructor_string());
|
||||
return constructor.is_identical_to(fun_);
|
||||
return constructor.is_identical_to(function_);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
bool IsNonEmptyString(Handle<Object> object) {
|
||||
return (object->IsString() && String::cast(*object)->length() > 0);
|
||||
}
|
||||
|
||||
void AppendFileLocation(Isolate* isolate, JSStackFrame* call_site,
|
||||
IncrementalStringBuilder* builder) {
|
||||
if (call_site->IsNative()) {
|
||||
builder->AppendCString("native");
|
||||
return;
|
||||
}
|
||||
|
||||
Handle<Object> file_name = call_site->GetScriptNameOrSourceUrl();
|
||||
if (!file_name->IsString() && call_site->IsEval()) {
|
||||
Handle<Object> eval_origin = call_site->GetEvalOrigin();
|
||||
DCHECK(eval_origin->IsString());
|
||||
builder->AppendString(Handle<String>::cast(eval_origin));
|
||||
builder->AppendCString(", "); // Expecting source position to follow.
|
||||
}
|
||||
|
||||
if (IsNonEmptyString(file_name)) {
|
||||
builder->AppendString(Handle<String>::cast(file_name));
|
||||
} else {
|
||||
// Source code does not originate from a file and is not native, but we
|
||||
// can still get the source position inside the source string, e.g. in
|
||||
// an eval string.
|
||||
builder->AppendCString("<anonymous>");
|
||||
}
|
||||
|
||||
int line_number = call_site->GetLineNumber();
|
||||
if (line_number != -1) {
|
||||
builder->AppendCharacter(':');
|
||||
Handle<String> line_string = isolate->factory()->NumberToString(
|
||||
handle(Smi::FromInt(line_number), isolate), isolate);
|
||||
builder->AppendString(line_string);
|
||||
|
||||
int column_number = call_site->GetColumnNumber();
|
||||
if (column_number != -1) {
|
||||
builder->AppendCharacter(':');
|
||||
Handle<String> column_string = isolate->factory()->NumberToString(
|
||||
handle(Smi::FromInt(column_number), isolate), isolate);
|
||||
builder->AppendString(column_string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int StringIndexOf(Isolate* isolate, Handle<String> subject,
|
||||
Handle<String> pattern) {
|
||||
if (pattern->length() > subject->length()) return -1;
|
||||
return String::IndexOf(isolate, subject, pattern, 0);
|
||||
}
|
||||
|
||||
// Returns true iff
|
||||
// 1. the subject ends with '.' + pattern, or
|
||||
// 2. subject == pattern.
|
||||
bool StringEndsWithMethodName(Isolate* isolate, Handle<String> subject,
|
||||
Handle<String> pattern) {
|
||||
if (String::Equals(subject, pattern)) return true;
|
||||
|
||||
FlatStringReader subject_reader(isolate, String::Flatten(subject));
|
||||
FlatStringReader pattern_reader(isolate, String::Flatten(pattern));
|
||||
|
||||
int pattern_index = pattern_reader.length() - 1;
|
||||
int subject_index = subject_reader.length() - 1;
|
||||
for (int i = 0; i <= pattern_reader.length(); i++) { // Iterate over len + 1.
|
||||
if (subject_index < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const uc32 subject_char = subject_reader.Get(subject_index);
|
||||
if (i == pattern_reader.length()) {
|
||||
if (subject_char != '.') return false;
|
||||
} else if (subject_char != pattern_reader.Get(pattern_index)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pattern_index--;
|
||||
subject_index--;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AppendMethodCall(Isolate* isolate, JSStackFrame* call_site,
|
||||
IncrementalStringBuilder* builder) {
|
||||
Handle<Object> type_name = call_site->GetTypeName();
|
||||
Handle<Object> method_name = call_site->GetMethodName();
|
||||
Handle<Object> function_name = call_site->GetFunctionName();
|
||||
|
||||
if (IsNonEmptyString(function_name)) {
|
||||
Handle<String> function_string = Handle<String>::cast(function_name);
|
||||
if (IsNonEmptyString(type_name)) {
|
||||
Handle<String> type_string = Handle<String>::cast(type_name);
|
||||
bool starts_with_type_name =
|
||||
(StringIndexOf(isolate, function_string, type_string) == 0);
|
||||
if (!starts_with_type_name) {
|
||||
builder->AppendString(type_string);
|
||||
builder->AppendCharacter('.');
|
||||
}
|
||||
}
|
||||
builder->AppendString(function_string);
|
||||
|
||||
if (IsNonEmptyString(method_name)) {
|
||||
Handle<String> method_string = Handle<String>::cast(method_name);
|
||||
if (!StringEndsWithMethodName(isolate, function_string, method_string)) {
|
||||
builder->AppendCString(" [as ");
|
||||
builder->AppendString(method_string);
|
||||
builder->AppendCharacter(']');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
builder->AppendString(Handle<String>::cast(type_name));
|
||||
builder->AppendCharacter('.');
|
||||
if (IsNonEmptyString(method_name)) {
|
||||
builder->AppendString(Handle<String>::cast(method_name));
|
||||
} else {
|
||||
builder->AppendCString("<anonymous>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
MaybeHandle<String> JSStackFrame::ToString() {
|
||||
IncrementalStringBuilder builder(isolate_);
|
||||
|
||||
Handle<Object> function_name = GetFunctionName();
|
||||
|
||||
const bool is_toplevel = IsToplevel();
|
||||
const bool is_constructor = IsConstructor();
|
||||
const bool is_method_call = !(is_toplevel || is_constructor);
|
||||
|
||||
if (is_method_call) {
|
||||
AppendMethodCall(isolate_, this, &builder);
|
||||
} else if (is_constructor) {
|
||||
builder.AppendCString("new ");
|
||||
if (IsNonEmptyString(function_name)) {
|
||||
builder.AppendString(Handle<String>::cast(function_name));
|
||||
} else {
|
||||
builder.AppendCString("<anonymous>");
|
||||
}
|
||||
} else if (IsNonEmptyString(function_name)) {
|
||||
builder.AppendString(Handle<String>::cast(function_name));
|
||||
} else {
|
||||
AppendFileLocation(isolate_, this, &builder);
|
||||
RETURN_RESULT(isolate_, builder.Finish(), String);
|
||||
}
|
||||
|
||||
builder.AppendCString(" (");
|
||||
AppendFileLocation(isolate_, this, &builder);
|
||||
builder.AppendCString(")");
|
||||
|
||||
RETURN_RESULT(isolate_, builder.Finish(), String);
|
||||
}
|
||||
|
||||
int JSStackFrame::GetPosition() const { return code_->SourcePosition(offset_); }
|
||||
|
||||
bool JSStackFrame::HasScript() const {
|
||||
return function_->shared()->script()->IsScript();
|
||||
}
|
||||
|
||||
Handle<Script> JSStackFrame::GetScript() const {
|
||||
return handle(Script::cast(function_->shared()->script()), isolate_);
|
||||
}
|
||||
|
||||
void WasmStackFrame::FromFrameArray(Isolate* isolate, Handle<FrameArray> array,
|
||||
int frame_ix) {
|
||||
DCHECK(array->IsWasmFrame(frame_ix));
|
||||
isolate_ = isolate;
|
||||
wasm_obj_ = handle(array->WasmObject(frame_ix), isolate);
|
||||
wasm_func_index_ = array->WasmFunctionIndex(frame_ix)->value();
|
||||
code_ = handle(array->Code(frame_ix), isolate);
|
||||
offset_ = array->Offset(frame_ix)->value();
|
||||
}
|
||||
|
||||
Handle<Object> WasmStackFrame::GetFunction() const {
|
||||
Handle<Object> obj(Smi::FromInt(wasm_func_index_), isolate_);
|
||||
return obj;
|
||||
}
|
||||
|
||||
Handle<Object> WasmStackFrame::GetFunctionName() {
|
||||
return wasm::GetWasmFunctionNameOrNull(isolate_, wasm_obj_, wasm_func_index_);
|
||||
}
|
||||
|
||||
MaybeHandle<String> WasmStackFrame::ToString() {
|
||||
IncrementalStringBuilder builder(isolate_);
|
||||
|
||||
Handle<Object> name = GetFunctionName();
|
||||
if (name->IsNull(isolate_)) {
|
||||
builder.AppendCString("<WASM UNNAMED>");
|
||||
} else {
|
||||
DCHECK(name->IsString());
|
||||
builder.AppendString(Handle<String>::cast(name));
|
||||
}
|
||||
|
||||
builder.AppendCString(" (<WASM>[");
|
||||
|
||||
Handle<Smi> ix(Smi::FromInt(wasm_func_index_), isolate_);
|
||||
builder.AppendString(isolate_->factory()->NumberToString(ix));
|
||||
|
||||
builder.AppendCString("]+");
|
||||
|
||||
Handle<Object> pos(Smi::FromInt(GetPosition()), isolate_);
|
||||
builder.AppendString(isolate_->factory()->NumberToString(pos));
|
||||
builder.AppendCString(")");
|
||||
|
||||
return builder.Finish();
|
||||
}
|
||||
|
||||
int WasmStackFrame::GetPosition() const {
|
||||
return (offset_ < 0) ? (-1 - offset_) : code_->SourcePosition(offset_);
|
||||
}
|
||||
|
||||
Handle<Object> WasmStackFrame::Null() const {
|
||||
return isolate_->factory()->null_value();
|
||||
}
|
||||
|
||||
FrameArrayIterator::FrameArrayIterator(Isolate* isolate,
|
||||
Handle<FrameArray> array, int frame_ix)
|
||||
: isolate_(isolate), array_(array), next_frame_ix_(frame_ix) {}
|
||||
|
||||
bool FrameArrayIterator::HasNext() const {
|
||||
return (next_frame_ix_ < array_->FrameCount());
|
||||
}
|
||||
|
||||
void FrameArrayIterator::Next() { next_frame_ix_++; }
|
||||
|
||||
StackFrameBase* FrameArrayIterator::Frame() {
|
||||
DCHECK(HasNext());
|
||||
const int flags = array_->Flags(next_frame_ix_)->value();
|
||||
const bool is_js_frame = (flags & FrameArray::kIsWasmFrame) == 0;
|
||||
if (is_js_frame) {
|
||||
js_frame_.FromFrameArray(isolate_, array_, next_frame_ix_);
|
||||
return &js_frame_;
|
||||
} else {
|
||||
wasm_frame_.FromFrameArray(isolate_, array_, next_frame_ix_);
|
||||
return &wasm_frame_;
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
MaybeHandle<Object> ConstructCallSite(Isolate* isolate,
|
||||
Handle<FrameArray> frame_array,
|
||||
int frame_index) {
|
||||
Handle<JSFunction> target =
|
||||
handle(isolate->native_context()->callsite_function(), isolate);
|
||||
|
||||
Handle<JSObject> obj;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(isolate, obj, JSObject::New(target, target),
|
||||
Object);
|
||||
|
||||
Handle<Symbol> key = isolate->factory()->call_site_frame_array_symbol();
|
||||
RETURN_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes(
|
||||
obj, key, frame_array, DONT_ENUM),
|
||||
Object);
|
||||
|
||||
key = isolate->factory()->call_site_frame_index_symbol();
|
||||
Handle<Object> value(Smi::FromInt(frame_index), isolate);
|
||||
RETURN_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes(
|
||||
obj, key, value, DONT_ENUM),
|
||||
Object);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
// Convert the raw frames as written by Isolate::CaptureSimpleStackTrace into
|
||||
// a vector of JS CallSite objects.
|
||||
MaybeHandle<FixedArray> GetStackFrames(Isolate* isolate,
|
||||
Handle<Object> raw_stack) {
|
||||
DCHECK(raw_stack->IsJSArray());
|
||||
Handle<JSArray> raw_stack_array = Handle<JSArray>::cast(raw_stack);
|
||||
|
||||
DCHECK(raw_stack_array->elements()->IsFixedArray());
|
||||
Handle<FrameArray> elems(FrameArray::cast(raw_stack_array->elements()));
|
||||
|
||||
// a JSArray of JSCallSite objects.
|
||||
MaybeHandle<JSArray> GetStackFrames(Isolate* isolate,
|
||||
Handle<FrameArray> elems) {
|
||||
const int frame_count = elems->FrameCount();
|
||||
|
||||
Handle<FixedArray> frames = isolate->factory()->NewFixedArray(frame_count);
|
||||
for (int i = 0; i < frame_count; i++) {
|
||||
const int flags = elems->Flags(i)->value();
|
||||
Handle<AbstractCode> code(elems->Code(i), isolate);
|
||||
Handle<Smi> pc(elems->Offset(i), isolate);
|
||||
Handle<Object> strict =
|
||||
isolate->factory()->ToBoolean(flags & FrameArray::kIsStrict);
|
||||
|
||||
if (elems->IsWasmFrame(i)) {
|
||||
Handle<Object> wasm_obj(elems->WasmObject(i), isolate);
|
||||
Handle<Smi> wasm_fun_ix(elems->WasmFunctionIndex(i), isolate);
|
||||
|
||||
Handle<Object> pos((pc->value() < 0)
|
||||
? Smi::FromInt(-1 - pc->value())
|
||||
: Smi::FromInt(code->SourcePosition(pc->value())),
|
||||
isolate);
|
||||
|
||||
Handle<Object> callsite;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(
|
||||
isolate, callsite,
|
||||
CallSiteUtils::Construct(isolate, wasm_obj, wasm_fun_ix, pos, strict),
|
||||
FixedArray);
|
||||
|
||||
frames->set(i, *callsite);
|
||||
} else {
|
||||
Handle<Object> recv(elems->Receiver(i), isolate);
|
||||
Handle<Object> fun(elems->Function(i), isolate);
|
||||
Handle<Object> pos(Smi::FromInt(code->SourcePosition(pc->value())),
|
||||
isolate);
|
||||
|
||||
if (flags & FrameArray::kForceConstructor) {
|
||||
recv = handle(isolate->heap()->call_site_constructor_symbol());
|
||||
}
|
||||
|
||||
Handle<Object> callsite;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(
|
||||
isolate, callsite,
|
||||
CallSiteUtils::Construct(isolate, recv, fun, pos, strict),
|
||||
FixedArray);
|
||||
|
||||
frames->set(i, *callsite);
|
||||
}
|
||||
Handle<Object> site;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(isolate, site,
|
||||
ConstructCallSite(isolate, elems, i), JSArray);
|
||||
frames->set(i, *site);
|
||||
}
|
||||
|
||||
return frames;
|
||||
return isolate->factory()->NewJSArrayWithElements(frames);
|
||||
}
|
||||
|
||||
MaybeHandle<Object> AppendErrorString(Isolate* isolate, Handle<Object> error,
|
||||
@ -600,11 +787,11 @@ class PrepareStackTraceScope {
|
||||
MaybeHandle<Object> ErrorUtils::FormatStackTrace(Isolate* isolate,
|
||||
Handle<JSObject> error,
|
||||
Handle<Object> raw_stack) {
|
||||
// Create JS CallSite objects from the raw stack frame array.
|
||||
DCHECK(raw_stack->IsJSArray());
|
||||
Handle<JSArray> raw_stack_array = Handle<JSArray>::cast(raw_stack);
|
||||
|
||||
Handle<FixedArray> frames;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(isolate, frames,
|
||||
GetStackFrames(isolate, raw_stack), Object);
|
||||
DCHECK(raw_stack_array->elements()->IsFixedArray());
|
||||
Handle<FrameArray> elems(FrameArray::cast(raw_stack_array->elements()));
|
||||
|
||||
// If there's a user-specified "prepareStackFrames" function, call it on the
|
||||
// frames and use its result.
|
||||
@ -619,12 +806,16 @@ MaybeHandle<Object> ErrorUtils::FormatStackTrace(Isolate* isolate,
|
||||
const bool in_recursion = isolate->formatting_stack_trace();
|
||||
if (prepare_stack_trace->IsJSFunction() && !in_recursion) {
|
||||
PrepareStackTraceScope scope(isolate);
|
||||
Handle<JSArray> array = isolate->factory()->NewJSArrayWithElements(frames);
|
||||
|
||||
Handle<JSArray> sites;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(isolate, sites, GetStackFrames(isolate, elems),
|
||||
Object);
|
||||
|
||||
const int argc = 2;
|
||||
ScopedVector<Handle<Object>> argv(argc);
|
||||
|
||||
argv[0] = error;
|
||||
argv[1] = array;
|
||||
argv[1] = sites;
|
||||
|
||||
Handle<Object> result;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(
|
||||
@ -635,17 +826,18 @@ MaybeHandle<Object> ErrorUtils::FormatStackTrace(Isolate* isolate,
|
||||
return result;
|
||||
}
|
||||
|
||||
// Otherwise, run our internal formatting logic.
|
||||
|
||||
IncrementalStringBuilder builder(isolate);
|
||||
|
||||
RETURN_ON_EXCEPTION(isolate, AppendErrorString(isolate, error, &builder),
|
||||
Object);
|
||||
|
||||
for (int i = 0; i < frames->length(); i++) {
|
||||
for (FrameArrayIterator it(isolate, elems); it.HasNext(); it.Next()) {
|
||||
builder.AppendCString("\n at ");
|
||||
|
||||
Handle<Object> frame = FixedArray::get(*frames, i, isolate);
|
||||
MaybeHandle<String> maybe_frame_string =
|
||||
CallSiteUtils::ToString(isolate, frame);
|
||||
StackFrameBase* frame = it.Frame();
|
||||
MaybeHandle<String> maybe_frame_string = frame->ToString();
|
||||
if (maybe_frame_string.is_null()) {
|
||||
// CallSite.toString threw. Try to return a string representation of the
|
||||
// thrown exception instead.
|
||||
@ -912,290 +1104,5 @@ MaybeHandle<Object> ErrorUtils::MakeGenericError(
|
||||
no_caller, false);
|
||||
}
|
||||
|
||||
#define SET_CALLSITE_PROPERTY(target, key, value) \
|
||||
RETURN_ON_EXCEPTION( \
|
||||
isolate, JSObject::SetOwnPropertyIgnoreAttributes( \
|
||||
target, isolate->factory()->key(), value, DONT_ENUM), \
|
||||
Object)
|
||||
|
||||
MaybeHandle<Object> CallSiteUtils::Construct(Isolate* isolate,
|
||||
Handle<Object> receiver,
|
||||
Handle<Object> fun,
|
||||
Handle<Object> pos,
|
||||
Handle<Object> strict_mode) {
|
||||
// Create the JS object.
|
||||
|
||||
Handle<JSFunction> target =
|
||||
handle(isolate->native_context()->callsite_function(), isolate);
|
||||
|
||||
Handle<JSObject> obj;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(isolate, obj, JSObject::New(target, target),
|
||||
Object);
|
||||
|
||||
// For wasm frames, receiver is the wasm object and fun is the function index
|
||||
// instead of an actual function.
|
||||
const bool is_wasm_object =
|
||||
receiver->IsJSObject() && wasm::IsWasmObject(JSObject::cast(*receiver));
|
||||
if (!fun->IsJSFunction() && !is_wasm_object) {
|
||||
THROW_NEW_ERROR(isolate,
|
||||
NewTypeError(MessageTemplate::kCallSiteExpectsFunction,
|
||||
Object::TypeOf(isolate, receiver),
|
||||
Object::TypeOf(isolate, fun)),
|
||||
Object);
|
||||
}
|
||||
|
||||
if (is_wasm_object) {
|
||||
DCHECK(fun->IsSmi());
|
||||
DCHECK(wasm::GetNumberOfFunctions(JSObject::cast(*receiver)) >
|
||||
Smi::cast(*fun)->value());
|
||||
|
||||
SET_CALLSITE_PROPERTY(obj, call_site_wasm_obj_symbol, receiver);
|
||||
SET_CALLSITE_PROPERTY(obj, call_site_wasm_func_index_symbol, fun);
|
||||
} else {
|
||||
DCHECK(fun->IsJSFunction());
|
||||
SET_CALLSITE_PROPERTY(obj, call_site_receiver_symbol, receiver);
|
||||
SET_CALLSITE_PROPERTY(obj, call_site_function_symbol, fun);
|
||||
}
|
||||
|
||||
DCHECK(pos->IsSmi());
|
||||
SET_CALLSITE_PROPERTY(obj, call_site_position_symbol, pos);
|
||||
SET_CALLSITE_PROPERTY(
|
||||
obj, call_site_strict_symbol,
|
||||
isolate->factory()->ToBoolean(strict_mode->BooleanValue()));
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
#undef SET_CALLSITE_PROPERTY
|
||||
|
||||
namespace {
|
||||
|
||||
bool IsNonEmptyString(Handle<Object> object) {
|
||||
return (object->IsString() && String::cast(*object)->length() > 0);
|
||||
}
|
||||
|
||||
MaybeHandle<JSObject> AppendWasmToString(Isolate* isolate,
|
||||
Handle<JSObject> recv,
|
||||
CallSite* call_site,
|
||||
IncrementalStringBuilder* builder) {
|
||||
Handle<Object> name = call_site->GetFunctionName();
|
||||
if (name->IsNull(isolate)) {
|
||||
builder->AppendCString("<WASM UNNAMED>");
|
||||
} else {
|
||||
DCHECK(name->IsString());
|
||||
builder->AppendString(Handle<String>::cast(name));
|
||||
}
|
||||
|
||||
builder->AppendCString(" (<WASM>[");
|
||||
|
||||
Handle<String> ix = isolate->factory()->NumberToString(
|
||||
handle(Smi::FromInt(call_site->wasm_func_index()), isolate));
|
||||
builder->AppendString(ix);
|
||||
|
||||
builder->AppendCString("]+");
|
||||
|
||||
Handle<Object> pos;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(
|
||||
isolate, pos, JSObject::GetProperty(
|
||||
recv, isolate->factory()->call_site_position_symbol()),
|
||||
JSObject);
|
||||
DCHECK(pos->IsNumber());
|
||||
builder->AppendString(isolate->factory()->NumberToString(pos));
|
||||
builder->AppendCString(")");
|
||||
|
||||
return recv;
|
||||
}
|
||||
|
||||
MaybeHandle<JSObject> AppendFileLocation(Isolate* isolate,
|
||||
Handle<JSObject> recv,
|
||||
CallSite* call_site,
|
||||
IncrementalStringBuilder* builder) {
|
||||
if (call_site->IsNative()) {
|
||||
builder->AppendCString("native");
|
||||
return recv;
|
||||
}
|
||||
|
||||
Handle<Object> file_name = call_site->GetScriptNameOrSourceUrl();
|
||||
if (!file_name->IsString() && call_site->IsEval()) {
|
||||
Handle<Object> eval_origin = call_site->GetEvalOrigin();
|
||||
DCHECK(eval_origin->IsString());
|
||||
builder->AppendString(Handle<String>::cast(eval_origin));
|
||||
builder->AppendCString(", "); // Expecting source position to follow.
|
||||
}
|
||||
|
||||
if (IsNonEmptyString(file_name)) {
|
||||
builder->AppendString(Handle<String>::cast(file_name));
|
||||
} else {
|
||||
// Source code does not originate from a file and is not native, but we
|
||||
// can still get the source position inside the source string, e.g. in
|
||||
// an eval string.
|
||||
builder->AppendCString("<anonymous>");
|
||||
}
|
||||
|
||||
int line_number = call_site->GetLineNumber();
|
||||
if (line_number != -1) {
|
||||
builder->AppendCharacter(':');
|
||||
Handle<String> line_string = isolate->factory()->NumberToString(
|
||||
handle(Smi::FromInt(line_number), isolate), isolate);
|
||||
builder->AppendString(line_string);
|
||||
|
||||
int column_number = call_site->GetColumnNumber();
|
||||
if (column_number != -1) {
|
||||
builder->AppendCharacter(':');
|
||||
Handle<String> column_string = isolate->factory()->NumberToString(
|
||||
handle(Smi::FromInt(column_number), isolate), isolate);
|
||||
builder->AppendString(column_string);
|
||||
}
|
||||
}
|
||||
|
||||
return recv;
|
||||
}
|
||||
|
||||
int StringIndexOf(Isolate* isolate, Handle<String> subject,
|
||||
Handle<String> pattern) {
|
||||
if (pattern->length() > subject->length()) return -1;
|
||||
return String::IndexOf(isolate, subject, pattern, 0);
|
||||
}
|
||||
|
||||
// Returns true iff
|
||||
// 1. the subject ends with '.' + pattern, or
|
||||
// 2. subject == pattern.
|
||||
bool StringEndsWithMethodName(Isolate* isolate, Handle<String> subject,
|
||||
Handle<String> pattern) {
|
||||
if (String::Equals(subject, pattern)) return true;
|
||||
|
||||
FlatStringReader subject_reader(isolate, String::Flatten(subject));
|
||||
FlatStringReader pattern_reader(isolate, String::Flatten(pattern));
|
||||
|
||||
int pattern_index = pattern_reader.length() - 1;
|
||||
int subject_index = subject_reader.length() - 1;
|
||||
for (int i = 0; i <= pattern_reader.length(); i++) { // Iterate over len + 1.
|
||||
if (subject_index < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const uc32 subject_char = subject_reader.Get(subject_index);
|
||||
if (i == pattern_reader.length()) {
|
||||
if (subject_char != '.') return false;
|
||||
} else if (subject_char != pattern_reader.Get(pattern_index)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pattern_index--;
|
||||
subject_index--;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
MaybeHandle<JSObject> AppendMethodCall(Isolate* isolate, Handle<JSObject> recv,
|
||||
CallSite* call_site,
|
||||
IncrementalStringBuilder* builder) {
|
||||
Handle<Object> type_name = call_site->GetTypeName();
|
||||
Handle<Object> method_name = call_site->GetMethodName();
|
||||
Handle<Object> function_name = call_site->GetFunctionName();
|
||||
|
||||
if (IsNonEmptyString(function_name)) {
|
||||
Handle<String> function_string = Handle<String>::cast(function_name);
|
||||
if (IsNonEmptyString(type_name)) {
|
||||
Handle<String> type_string = Handle<String>::cast(type_name);
|
||||
bool starts_with_type_name =
|
||||
(StringIndexOf(isolate, function_string, type_string) == 0);
|
||||
if (!starts_with_type_name) {
|
||||
builder->AppendString(type_string);
|
||||
builder->AppendCharacter('.');
|
||||
}
|
||||
}
|
||||
builder->AppendString(function_string);
|
||||
|
||||
if (IsNonEmptyString(method_name)) {
|
||||
Handle<String> method_string = Handle<String>::cast(method_name);
|
||||
if (!StringEndsWithMethodName(isolate, function_string, method_string)) {
|
||||
builder->AppendCString(" [as ");
|
||||
builder->AppendString(method_string);
|
||||
builder->AppendCharacter(']');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
builder->AppendString(Handle<String>::cast(type_name));
|
||||
builder->AppendCharacter('.');
|
||||
if (IsNonEmptyString(method_name)) {
|
||||
builder->AppendString(Handle<String>::cast(method_name));
|
||||
} else {
|
||||
builder->AppendCString("<anonymous>");
|
||||
}
|
||||
}
|
||||
|
||||
return recv;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
MaybeHandle<String> CallSiteUtils::ToString(Isolate* isolate,
|
||||
Handle<Object> receiver) {
|
||||
if (!receiver->IsJSObject()) {
|
||||
THROW_NEW_ERROR(
|
||||
isolate,
|
||||
NewTypeError(MessageTemplate::kIncompatibleMethodReceiver,
|
||||
isolate->factory()->NewStringFromAsciiChecked("toString"),
|
||||
receiver),
|
||||
String);
|
||||
}
|
||||
Handle<JSObject> recv = Handle<JSObject>::cast(receiver);
|
||||
|
||||
if (!JSReceiver::HasOwnProperty(
|
||||
recv, isolate->factory()->call_site_position_symbol())
|
||||
.FromMaybe(false)) {
|
||||
THROW_NEW_ERROR(
|
||||
isolate,
|
||||
NewTypeError(MessageTemplate::kCallSiteMethod,
|
||||
isolate->factory()->NewStringFromAsciiChecked("toString")),
|
||||
String);
|
||||
}
|
||||
|
||||
IncrementalStringBuilder builder(isolate);
|
||||
|
||||
CallSite call_site(isolate, recv);
|
||||
if (call_site.IsWasm()) {
|
||||
RETURN_ON_EXCEPTION(isolate,
|
||||
AppendWasmToString(isolate, recv, &call_site, &builder),
|
||||
String);
|
||||
RETURN_RESULT(isolate, builder.Finish(), String);
|
||||
}
|
||||
|
||||
DCHECK(!call_site.IsWasm());
|
||||
Handle<Object> function_name = call_site.GetFunctionName();
|
||||
|
||||
const bool is_toplevel = call_site.IsToplevel();
|
||||
const bool is_constructor = call_site.IsConstructor();
|
||||
const bool is_method_call = !(is_toplevel || is_constructor);
|
||||
|
||||
if (is_method_call) {
|
||||
RETURN_ON_EXCEPTION(
|
||||
isolate, AppendMethodCall(isolate, recv, &call_site, &builder), String);
|
||||
} else if (is_constructor) {
|
||||
builder.AppendCString("new ");
|
||||
if (IsNonEmptyString(function_name)) {
|
||||
builder.AppendString(Handle<String>::cast(function_name));
|
||||
} else {
|
||||
builder.AppendCString("<anonymous>");
|
||||
}
|
||||
} else if (IsNonEmptyString(function_name)) {
|
||||
builder.AppendString(Handle<String>::cast(function_name));
|
||||
} else {
|
||||
RETURN_ON_EXCEPTION(isolate,
|
||||
AppendFileLocation(isolate, recv, &call_site, &builder),
|
||||
String);
|
||||
RETURN_RESULT(isolate, builder.Finish(), String);
|
||||
}
|
||||
|
||||
builder.AppendCString(" (");
|
||||
RETURN_ON_EXCEPTION(
|
||||
isolate, AppendFileLocation(isolate, recv, &call_site, &builder), String);
|
||||
builder.AppendCString(")");
|
||||
|
||||
RETURN_RESULT(isolate, builder.Finish(), String);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
162
src/messages.h
162
src/messages.h
@ -19,6 +19,8 @@ namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
// Forward declarations.
|
||||
class AbstractCode;
|
||||
class FrameArray;
|
||||
class JSMessageObject;
|
||||
class LookupIterator;
|
||||
class SourceInfo;
|
||||
@ -42,38 +44,142 @@ class MessageLocation {
|
||||
Handle<JSFunction> function_;
|
||||
};
|
||||
|
||||
|
||||
class CallSite {
|
||||
class StackFrameBase {
|
||||
public:
|
||||
CallSite(Isolate* isolate, Handle<JSObject> call_site_obj);
|
||||
virtual ~StackFrameBase() {}
|
||||
|
||||
Handle<Object> GetFileName();
|
||||
Handle<Object> GetFunctionName();
|
||||
Handle<Object> GetScriptNameOrSourceUrl();
|
||||
Handle<Object> GetMethodName();
|
||||
Handle<Object> GetTypeName();
|
||||
Handle<Object> GetEvalOrigin();
|
||||
virtual Handle<Object> GetReceiver() const = 0;
|
||||
virtual Handle<Object> GetFunction() const = 0;
|
||||
|
||||
virtual Handle<Object> GetFileName() = 0;
|
||||
virtual Handle<Object> GetFunctionName() = 0;
|
||||
virtual Handle<Object> GetScriptNameOrSourceUrl() = 0;
|
||||
virtual Handle<Object> GetMethodName() = 0;
|
||||
virtual Handle<Object> GetTypeName() = 0;
|
||||
virtual Handle<Object> GetEvalOrigin() = 0;
|
||||
|
||||
virtual int GetPosition() const = 0;
|
||||
// Return 1-based line number, including line offset.
|
||||
int GetLineNumber();
|
||||
virtual int GetLineNumber() = 0;
|
||||
// Return 1-based column number, including column offset if first line.
|
||||
int GetColumnNumber();
|
||||
bool IsNative();
|
||||
bool IsToplevel();
|
||||
bool IsEval();
|
||||
bool IsConstructor();
|
||||
virtual int GetColumnNumber() = 0;
|
||||
|
||||
bool IsJavaScript() { return !fun_.is_null(); }
|
||||
bool IsWasm() { return !wasm_obj_.is_null(); }
|
||||
virtual bool IsNative() = 0;
|
||||
virtual bool IsToplevel() = 0;
|
||||
virtual bool IsEval() = 0;
|
||||
virtual bool IsConstructor() = 0;
|
||||
virtual bool IsStrict() const = 0;
|
||||
|
||||
int wasm_func_index() const { return wasm_func_index_; }
|
||||
virtual MaybeHandle<String> ToString() = 0;
|
||||
};
|
||||
|
||||
class JSStackFrame : public StackFrameBase {
|
||||
public:
|
||||
JSStackFrame(Isolate* isolate, Handle<Object> receiver,
|
||||
Handle<JSFunction> function, Handle<AbstractCode> code,
|
||||
int offset);
|
||||
virtual ~JSStackFrame() {}
|
||||
|
||||
Handle<Object> GetReceiver() const override { return receiver_; }
|
||||
Handle<Object> GetFunction() const override;
|
||||
|
||||
Handle<Object> GetFileName() override;
|
||||
Handle<Object> GetFunctionName() override;
|
||||
Handle<Object> GetScriptNameOrSourceUrl() override;
|
||||
Handle<Object> GetMethodName() override;
|
||||
Handle<Object> GetTypeName() override;
|
||||
Handle<Object> GetEvalOrigin() override;
|
||||
|
||||
int GetPosition() const override;
|
||||
int GetLineNumber() override;
|
||||
int GetColumnNumber() override;
|
||||
|
||||
bool IsNative() override;
|
||||
bool IsToplevel() override;
|
||||
bool IsEval() override;
|
||||
bool IsConstructor() override;
|
||||
bool IsStrict() const override { return is_strict_; }
|
||||
|
||||
MaybeHandle<String> ToString() override;
|
||||
|
||||
private:
|
||||
JSStackFrame();
|
||||
void FromFrameArray(Isolate* isolate, Handle<FrameArray> array, int frame_ix);
|
||||
|
||||
bool HasScript() const;
|
||||
Handle<Script> GetScript() const;
|
||||
|
||||
Isolate* isolate_;
|
||||
|
||||
Handle<Object> receiver_;
|
||||
Handle<JSFunction> function_;
|
||||
Handle<AbstractCode> code_;
|
||||
int offset_;
|
||||
|
||||
bool force_constructor_;
|
||||
bool is_strict_;
|
||||
|
||||
friend class FrameArrayIterator;
|
||||
};
|
||||
|
||||
class WasmStackFrame : public StackFrameBase {
|
||||
public:
|
||||
virtual ~WasmStackFrame() {}
|
||||
|
||||
Handle<Object> GetReceiver() const override { return wasm_obj_; }
|
||||
Handle<Object> GetFunction() const override;
|
||||
|
||||
Handle<Object> GetFileName() override { return Null(); }
|
||||
Handle<Object> GetFunctionName() override;
|
||||
Handle<Object> GetScriptNameOrSourceUrl() override { return Null(); }
|
||||
Handle<Object> GetMethodName() override { return Null(); }
|
||||
Handle<Object> GetTypeName() override { return Null(); }
|
||||
Handle<Object> GetEvalOrigin() override { return Null(); }
|
||||
|
||||
int GetPosition() const override;
|
||||
int GetLineNumber() override { return wasm_func_index_; }
|
||||
int GetColumnNumber() override { return -1; }
|
||||
|
||||
bool IsNative() override { return false; }
|
||||
bool IsToplevel() override { return false; }
|
||||
bool IsEval() override { return false; }
|
||||
bool IsConstructor() override { return false; }
|
||||
bool IsStrict() const override { return false; }
|
||||
|
||||
MaybeHandle<String> ToString() override;
|
||||
|
||||
private:
|
||||
void FromFrameArray(Isolate* isolate, Handle<FrameArray> array, int frame_ix);
|
||||
Handle<Object> Null() const;
|
||||
|
||||
Isolate* isolate_;
|
||||
|
||||
Handle<Object> wasm_obj_;
|
||||
uint32_t wasm_func_index_;
|
||||
Handle<AbstractCode> code_;
|
||||
int offset_;
|
||||
|
||||
friend class FrameArrayIterator;
|
||||
};
|
||||
|
||||
class FrameArrayIterator {
|
||||
public:
|
||||
FrameArrayIterator(Isolate* isolate, Handle<FrameArray> array,
|
||||
int frame_ix = 0);
|
||||
|
||||
StackFrameBase* Frame();
|
||||
|
||||
bool HasNext() const;
|
||||
void Next();
|
||||
|
||||
private:
|
||||
Isolate* isolate_;
|
||||
Handle<Object> receiver_;
|
||||
Handle<JSFunction> fun_;
|
||||
int32_t pos_ = -1;
|
||||
Handle<JSObject> wasm_obj_;
|
||||
uint32_t wasm_func_index_ = static_cast<uint32_t>(-1);
|
||||
|
||||
Handle<FrameArray> array_;
|
||||
int next_frame_ix_;
|
||||
|
||||
WasmStackFrame wasm_frame_;
|
||||
JSStackFrame js_frame_;
|
||||
};
|
||||
|
||||
// Determines how stack trace collection skips frames.
|
||||
@ -107,16 +213,6 @@ class ErrorUtils : public AllStatic {
|
||||
Handle<Object> stack_trace);
|
||||
};
|
||||
|
||||
class CallSiteUtils : public AllStatic {
|
||||
public:
|
||||
static MaybeHandle<Object> Construct(Isolate* isolate,
|
||||
Handle<Object> receiver,
|
||||
Handle<Object> fun, Handle<Object> pos,
|
||||
Handle<Object> strict_mode);
|
||||
|
||||
static MaybeHandle<String> ToString(Isolate* isolate, Handle<Object> recv);
|
||||
};
|
||||
|
||||
#define MESSAGE_TEMPLATES(T) \
|
||||
/* Error */ \
|
||||
T(None, "") \
|
||||
|
Loading…
Reference in New Issue
Block a user