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

Unified Diff: src/frames.cc

Issue 1861283002: Prepare StackFrame hierarchy & iterators for WASM (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address Ben's comments Created 4 years, 8 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/frames.h ('k') | src/frames-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/frames.cc
diff --git a/src/frames.cc b/src/frames.cc
index 51f5bf57159ae068f0850e068ade85a8c923d205..d9fa728b07a3bcf01b18f93545ced149cea8dd65 100644
--- a/src/frames.cc
+++ b/src/frames.cc
@@ -160,28 +160,29 @@ void JavaScriptFrameIterator::AdvanceToArgumentsFrame() {
// -------------------------------------------------------------------------
-
StackTraceFrameIterator::StackTraceFrameIterator(Isolate* isolate)
- : JavaScriptFrameIterator(isolate) {
- if (!done() && !IsValidFrame()) Advance();
+ : iterator_(isolate) {
+ if (!done() && !IsValidFrame(iterator_.frame())) Advance();
}
void StackTraceFrameIterator::Advance() {
- while (true) {
- JavaScriptFrameIterator::Advance();
- if (done()) return;
- if (IsValidFrame()) return;
- }
+ do {
+ iterator_.Advance();
+ } while (!done() && !IsValidFrame(iterator_.frame()));
}
-
-bool StackTraceFrameIterator::IsValidFrame() {
- if (!frame()->function()->IsJSFunction()) return false;
- Object* script = frame()->function()->shared()->script();
+bool StackTraceFrameIterator::IsValidFrame(StackFrame* frame) const {
+ if (frame->is_java_script()) {
+ JavaScriptFrame* jsFrame = static_cast<JavaScriptFrame*>(frame);
+ if (!jsFrame->function()->IsJSFunction()) return false;
+ Object* script = jsFrame->function()->shared()->script();
// Don't show functions from native scripts to user.
return (script->IsScript() &&
Script::TYPE_NATIVE != Script::cast(script)->type());
+ }
+ // apart from javascript, only wasm is valid
+ return frame->is_wasm();
}
@@ -616,6 +617,19 @@ void ExitFrame::FillState(Address fp, Address sp, State* state) {
state->constant_pool_address = NULL;
}
+void StandardFrame::Summarize(List<FrameSummary>* functions) const {
+ DCHECK(functions->length() == 0);
+ // default implementation: no summary added
+}
+
+JSFunction* StandardFrame::function() const {
+ // this default implementation is overridden by JS and WASM frames
+ return nullptr;
+}
+
+Object* StandardFrame::receiver() const {
+ return isolate()->heap()->undefined_value();
+}
Address StandardFrame::GetExpressionAddress(int n) const {
const int offset = StandardFrameConstants::kExpressionsOffset;
@@ -846,8 +860,7 @@ void JavaScriptFrame::GetFunctions(List<JSFunction*>* functions) const {
functions->Add(function());
}
-
-void JavaScriptFrame::Summarize(List<FrameSummary>* functions) {
+void JavaScriptFrame::Summarize(List<FrameSummary>* functions) const {
DCHECK(functions->length() == 0);
Code* code = LookupCode();
int offset = static_cast<int>(pc() - code->instruction_start());
@@ -857,6 +870,12 @@ void JavaScriptFrame::Summarize(List<FrameSummary>* functions) {
functions->Add(summary);
}
+JSFunction* JavaScriptFrame::function() const {
+ return JSFunction::cast(function_slot_object());
+}
+
+Object* JavaScriptFrame::receiver() const { return GetParameter(-1); }
+
int JavaScriptFrame::LookupExceptionHandlerInTable(
int* stack_depth, HandlerTable::CatchPrediction* prediction) {
Code* code = LookupCode();
@@ -978,8 +997,7 @@ void FrameSummary::Print() {
PrintF("\npc: %d\n", code_offset_);
}
-
-void OptimizedFrame::Summarize(List<FrameSummary>* frames) {
+void OptimizedFrame::Summarize(List<FrameSummary>* frames) const {
DCHECK(frames->length() == 0);
DCHECK(is_optimized());
@@ -1234,7 +1252,7 @@ Object* InterpretedFrame::GetInterpreterRegister(int register_index) const {
return GetExpression(index + register_index);
}
-void InterpretedFrame::Summarize(List<FrameSummary>* functions) {
+void InterpretedFrame::Summarize(List<FrameSummary>* functions) const {
DCHECK(functions->length() == 0);
AbstractCode* abstract_code =
AbstractCode::cast(function()->shared()->bytecode_array());
@@ -1291,6 +1309,15 @@ Code* WasmFrame::unchecked_code() const {
return static_cast<Code*>(isolate()->FindCodeObject(pc()));
}
+JSFunction* WasmFrame::function() const {
+ // TODO(clemensh): generate the right JSFunctions once per wasm function and
+ // cache them
+ Factory* factory = isolate()->factory();
+ Handle<JSFunction> fun =
+ factory->NewFunction(factory->NewStringFromAsciiChecked("<WASM>"));
+ return *fun;
+}
+
void WasmFrame::Iterate(ObjectVisitor* v) const { IterateCompiledFrame(v); }
Address WasmFrame::GetCallerStackPointer() const {
« no previous file with comments | « src/frames.h ('k') | src/frames-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698