Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(619)

Unified Diff: src/builtins/builtins-callsite.cc

Issue 2230953002: Use a custom Struct for stack trace storage (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Tweaks Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/v8.h ('k') | src/execution.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/builtins-callsite.cc
diff --git a/src/builtins/builtins-callsite.cc b/src/builtins/builtins-callsite.cc
index 7fc2f987162537345da5dcbadd9602c24bf86873..7b984d43d880c8285b85c32e4e24ce00cddf5e8a 100644
--- a/src/builtins/builtins-callsite.cc
+++ b/src/builtins/builtins-callsite.cc
@@ -11,15 +11,22 @@
namespace v8 {
namespace internal {
-#define CHECK_CALLSITE(recv, method) \
- CHECK_RECEIVER(JSObject, recv, method); \
- if (!JSReceiver::HasOwnProperty( \
- recv, isolate->factory()->call_site_position_symbol()) \
- .FromMaybe(false)) { \
- THROW_NEW_ERROR_RETURN_FAILURE( \
- isolate, \
- NewTypeError(MessageTemplate::kCallSiteMethod, \
- isolate->factory()->NewStringFromAsciiChecked(method))); \
+#define CHECK_CALLSITE(recv, method) \
+ CHECK_RECEIVER(JSObject, recv, method); \
+ Handle<StackTraceFrame> frame; \
+ { \
+ Handle<Object> frame_obj; \
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( \
+ isolate, frame_obj, \
+ JSObject::GetProperty(recv, \
+ isolate->factory()->call_site_frame_symbol())); \
+ if (!frame_obj->IsStackTraceFrame()) { \
+ THROW_NEW_ERROR_RETURN_FAILURE( \
+ isolate, NewTypeError(MessageTemplate::kCallSiteMethod, \
+ isolate->factory()->NewStringFromAsciiChecked( \
+ method))); \
+ } \
+ frame = Handle<StackTraceFrame>::cast(frame_obj); \
}
namespace {
@@ -34,167 +41,107 @@ Object* PositiveNumberOrNull(int value, Isolate* isolate) {
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);
+ return PositiveNumberOrNull(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();
+ return *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();
-}
-
-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();
+ return *frame->GetFileName();
}
-} // namespace
-
BUILTIN(CallSitePrototypeGetFunction) {
HandleScope scope(isolate);
CHECK_CALLSITE(recv, "getFunction");
- if (CallSiteIsStrict(isolate, recv))
+ if (frame->IsStrict() || frame->IsWasmFrame()) {
return *isolate->factory()->undefined_value();
+ }
- Handle<Symbol> symbol = isolate->factory()->call_site_function_symbol();
- RETURN_RESULT_OR_FAILURE(isolate, JSObject::GetProperty(recv, symbol));
+ return frame->function();
}
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();
+ return *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);
+ return PositiveNumberOrNull(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();
+ return *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));
+ return Smi::FromInt(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();
+ return *frame->GetScriptNameOrSourceUrl();
}
BUILTIN(CallSitePrototypeGetThis) {
HandleScope scope(isolate);
CHECK_CALLSITE(recv, "getThis");
- 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())
+ if (frame->IsStrict() || frame->ForceConstructor() || frame->IsWasmFrame()) {
return *isolate->factory()->undefined_value();
+ }
- return *receiver;
+ return frame->receiver();
}
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();
+ return *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());
+ return isolate->heap()->ToBoolean(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());
+ return isolate->heap()->ToBoolean(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());
+ return isolate->heap()->ToBoolean(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());
+ return isolate->heap()->ToBoolean(frame->IsToplevel());
}
BUILTIN(CallSitePrototypeToString) {
HandleScope scope(isolate);
CHECK_CALLSITE(recv, "toString");
- RETURN_RESULT_OR_FAILURE(isolate, CallSiteUtils::ToString(isolate, recv));
+ return *frame->ToString();
}
#undef CHECK_CALLSITE
« no previous file with comments | « include/v8.h ('k') | src/execution.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698