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

Unified Diff: src/api.cc

Issue 2789073002: [inspector] store stack frame in struct instead of JSObject (Closed)
Patch Set: gcmole should be happy Created 3 years, 9 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 | « src/api.h ('k') | src/ast/ast-types.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 6a3ecdbdac298350e6d5e1de3bd821e5a2a67c21..0dc8c1946e2f5973a4922ded1ead08e51e91be29 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -2844,8 +2844,8 @@ Local<StackFrame> StackTrace::GetFrame(uint32_t index) const {
EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
auto self = Utils::OpenHandle(this);
auto obj = i::JSReceiver::GetElement(isolate, self, index).ToHandleChecked();
- auto jsobj = i::Handle<i::JSObject>::cast(obj);
- return scope.Escape(Utils::StackFrameToLocal(jsobj));
+ auto info = i::Handle<i::StackFrameInfo>::cast(obj);
+ return scope.Escape(Utils::StackFrameToLocal(info));
}
@@ -2873,77 +2873,59 @@ Local<StackTrace> StackTrace::CurrentStackTrace(
// --- S t a c k F r a m e ---
-static int getIntProperty(const StackFrame* f, const char* propertyName,
- int defaultValue) {
- i::Isolate* isolate = Utils::OpenHandle(f)->GetIsolate();
- ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
- i::HandleScope scope(isolate);
- i::Handle<i::JSObject> self = Utils::OpenHandle(f);
- i::Handle<i::Object> obj =
- i::JSReceiver::GetProperty(isolate, self, propertyName).ToHandleChecked();
- return obj->IsSmi() ? i::Smi::cast(*obj)->value() : defaultValue;
-}
-
-
int StackFrame::GetLineNumber() const {
- return getIntProperty(this, "lineNumber", Message::kNoLineNumberInfo);
+ int v = Utils::OpenHandle(this)->line_number();
+ return v ? v : Message::kNoLineNumberInfo;
}
int StackFrame::GetColumn() const {
- return getIntProperty(this, "column", Message::kNoColumnInfo);
+ int v = Utils::OpenHandle(this)->column_number();
+ return v ? v : Message::kNoLineNumberInfo;
}
int StackFrame::GetScriptId() const {
- return getIntProperty(this, "scriptId", Message::kNoScriptIdInfo);
+ int v = Utils::OpenHandle(this)->script_id();
+ return v ? v : Message::kNoScriptIdInfo;
}
-
-static Local<String> getStringProperty(const StackFrame* f,
- const char* propertyName) {
- i::Isolate* isolate = Utils::OpenHandle(f)->GetIsolate();
- ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
+Local<String> StackFrame::GetScriptName() const {
+ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
- i::Handle<i::JSObject> self = Utils::OpenHandle(f);
- i::Handle<i::Object> obj =
- i::JSReceiver::GetProperty(isolate, self, propertyName).ToHandleChecked();
+ i::Handle<i::StackFrameInfo> self = Utils::OpenHandle(this);
+ i::Handle<i::Object> obj(self->script_name(), isolate);
return obj->IsString()
? scope.Escape(Local<String>::Cast(Utils::ToLocal(obj)))
: Local<String>();
}
-Local<String> StackFrame::GetScriptName() const {
- return getStringProperty(this, "scriptName");
-}
-
-
Local<String> StackFrame::GetScriptNameOrSourceURL() const {
- return getStringProperty(this, "scriptNameOrSourceURL");
+ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
+ EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
+ i::Handle<i::StackFrameInfo> self = Utils::OpenHandle(this);
+ i::Handle<i::Object> obj(self->script_name_or_source_url(), isolate);
+ return obj->IsString()
+ ? scope.Escape(Local<String>::Cast(Utils::ToLocal(obj)))
+ : Local<String>();
}
Local<String> StackFrame::GetFunctionName() const {
- return getStringProperty(this, "functionName");
-}
-
-
-static bool getBoolProperty(const StackFrame* f, const char* propertyName) {
- i::Isolate* isolate = Utils::OpenHandle(f)->GetIsolate();
- ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
- i::HandleScope scope(isolate);
- i::Handle<i::JSObject> self = Utils::OpenHandle(f);
- i::Handle<i::Object> obj =
- i::JSReceiver::GetProperty(isolate, self, propertyName).ToHandleChecked();
- return obj->IsTrue(isolate);
+ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
+ EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
+ i::Handle<i::StackFrameInfo> self = Utils::OpenHandle(this);
+ i::Handle<i::Object> obj(self->function_name(), isolate);
+ return obj->IsString()
+ ? scope.Escape(Local<String>::Cast(Utils::ToLocal(obj)))
+ : Local<String>();
}
-bool StackFrame::IsEval() const { return getBoolProperty(this, "isEval"); }
-
+bool StackFrame::IsEval() const { return Utils::OpenHandle(this)->is_eval(); }
bool StackFrame::IsConstructor() const {
- return getBoolProperty(this, "isConstructor");
+ return Utils::OpenHandle(this)->is_constructor();
}
« no previous file with comments | « src/api.h ('k') | src/ast/ast-types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698