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

Side by Side Diff: src/frames.cc

Issue 1909353002: [wasm] Make wasm info available on the stack trace (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@wasm-offset-table-3
Patch Set: more gcmole problems 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/frames.h" 5 #include "src/frames.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/ast/ast.h" 9 #include "src/ast/ast.h"
10 #include "src/ast/scopeinfo.h" 10 #include "src/ast/scopeinfo.h"
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 state->fp = fp; 610 state->fp = fp;
611 state->pc_address = ResolveReturnAddressLocation( 611 state->pc_address = ResolveReturnAddressLocation(
612 reinterpret_cast<Address*>(sp - 1 * kPCOnStackSize)); 612 reinterpret_cast<Address*>(sp - 1 * kPCOnStackSize));
613 // The constant pool recorded in the exit frame is not associated 613 // The constant pool recorded in the exit frame is not associated
614 // with the pc in this state (the return address into a C entry 614 // with the pc in this state (the return address into a C entry
615 // stub). ComputeCallerState will retrieve the constant pool 615 // stub). ComputeCallerState will retrieve the constant pool
616 // together with the associated caller pc. 616 // together with the associated caller pc.
617 state->constant_pool_address = NULL; 617 state->constant_pool_address = NULL;
618 } 618 }
619 619
620 void StandardFrame::Summarize(List<FrameSummary>* functions) const {
621 DCHECK(functions->length() == 0);
622 // default implementation: no summary added
623 }
624
625 JSFunction* StandardFrame::function() const {
626 // this default implementation is overridden by JS and WASM frames
627 return nullptr;
628 }
629
630 Object* StandardFrame::receiver() const {
631 return isolate()->heap()->undefined_value();
632 }
633
634 Address StandardFrame::GetExpressionAddress(int n) const { 620 Address StandardFrame::GetExpressionAddress(int n) const {
635 const int offset = StandardFrameConstants::kExpressionsOffset; 621 const int offset = StandardFrameConstants::kExpressionsOffset;
636 return fp() + offset - n * kPointerSize; 622 return fp() + offset - n * kPointerSize;
637 } 623 }
638 624
639 Address InterpretedFrame::GetExpressionAddress(int n) const { 625 Address InterpretedFrame::GetExpressionAddress(int n) const {
640 const int offset = InterpreterFrameConstants::kExpressionsOffset; 626 const int offset = InterpreterFrameConstants::kExpressionsOffset;
641 return fp() + offset - n * kPointerSize; 627 return fp() + offset - n * kPointerSize;
642 } 628 }
643 629
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 1303
1318 void WasmFrame::Print(StringStream* accumulator, PrintMode mode, 1304 void WasmFrame::Print(StringStream* accumulator, PrintMode mode,
1319 int index) const { 1305 int index) const {
1320 accumulator->Add("wasm frame"); 1306 accumulator->Add("wasm frame");
1321 } 1307 }
1322 1308
1323 Code* WasmFrame::unchecked_code() const { 1309 Code* WasmFrame::unchecked_code() const {
1324 return static_cast<Code*>(isolate()->FindCodeObject(pc())); 1310 return static_cast<Code*>(isolate()->FindCodeObject(pc()));
1325 } 1311 }
1326 1312
1327 JSFunction* WasmFrame::function() const {
1328 // TODO(clemensh): generate the right JSFunctions once per wasm function and
1329 // cache them
1330 Factory* factory = isolate()->factory();
1331 Handle<JSFunction> fun =
1332 factory->NewFunction(factory->NewStringFromAsciiChecked("<WASM>"));
1333 return *fun;
1334 }
1335
1336 void WasmFrame::Summarize(List<FrameSummary>* functions) const {
1337 DCHECK(functions->length() == 0);
1338 Code* code = LookupCode();
1339 int offset = static_cast<int>(pc() - code->instruction_start());
1340 AbstractCode* abstract_code = AbstractCode::cast(code);
1341 Handle<JSFunction> fun(function(), isolate());
1342 FrameSummary summary(receiver(), *fun, abstract_code, offset, false);
1343 functions->Add(summary);
1344 }
1345
1346 void WasmFrame::Iterate(ObjectVisitor* v) const { IterateCompiledFrame(v); } 1313 void WasmFrame::Iterate(ObjectVisitor* v) const { IterateCompiledFrame(v); }
1347 1314
1348 Address WasmFrame::GetCallerStackPointer() const { 1315 Address WasmFrame::GetCallerStackPointer() const {
1349 return fp() + ExitFrameConstants::kCallerSPOffset; 1316 return fp() + ExitFrameConstants::kCallerSPOffset;
1350 } 1317 }
1351 1318
1319 Object* WasmFrame::wasm_obj(Handle<Code> code) {
1320 DCHECK_IMPLIES(!code.is_null(), *code == LookupCode());
1321 if (code.is_null()) code = Handle<Code>(LookupCode(), isolate());
1322 Handle<FixedArray> deopt_data(code->deoptimization_data(), isolate());
1323 DCHECK(deopt_data->length() == 2);
1324 return deopt_data->get(0);
1325 }
1326
1327 uint32_t WasmFrame::function_index(Handle<Code> code) {
1328 DCHECK_IMPLIES(!code.is_null(), *code == LookupCode());
1329 if (code.is_null()) code = Handle<Code>(LookupCode(), isolate());
1330 Handle<FixedArray> deopt_data(code->deoptimization_data(), isolate());
1331 DCHECK(deopt_data->length() == 2);
1332 Object* func_index_obj = deopt_data->get(1);
1333 if (func_index_obj->IsUndefined()) return static_cast<uint32_t>(-1);
1334 if (func_index_obj->IsSmi()) return Smi::cast(func_index_obj)->value();
1335 DCHECK(func_index_obj->IsHeapNumber());
1336 uint32_t val = static_cast<uint32_t>(-1);
1337 func_index_obj->ToUint32(&val);
1338 DCHECK(val != static_cast<uint32_t>(-1));
1339 return val;
1340 }
1341
1342 Object* WasmFrame::function_name(Handle<Code> code) {
1343 DCHECK_IMPLIES(!code.is_null(), *code == LookupCode());
1344 if (code.is_null()) code = Handle<Code>(LookupCode(), isolate());
1345 Object* wasm_obj_or_string = wasm_obj();
1346 if (wasm_obj_or_string->IsString()) return wasm_obj_or_string;
1347 DCHECK(wasm_obj_or_string->IsJSObject());
1348 Handle<JSObject> wasm = handle(JSObject::cast(wasm_obj()));
1349 MaybeHandle<Object> fun_names_prop = JSObject::GetDataProperty(
1350 wasm, isolate()->factory()->InternalizeUtf8String(
1351 Vector<const char>("function_names")));
1352 Handle<FixedArray> func_names =
1353 Handle<FixedArray>::cast(fun_names_prop.ToHandleChecked());
1354 uint32_t func_index = function_index();
1355 DCHECK(func_index < static_cast<uint32_t>(func_names->length()));
1356 return func_names->get(func_index);
1357 }
1358
1352 namespace { 1359 namespace {
1353 1360
1354 1361
1355 void PrintFunctionSource(StringStream* accumulator, SharedFunctionInfo* shared, 1362 void PrintFunctionSource(StringStream* accumulator, SharedFunctionInfo* shared,
1356 Code* code) { 1363 Code* code) {
1357 if (FLAG_max_stack_trace_source_length != 0 && code != NULL) { 1364 if (FLAG_max_stack_trace_source_length != 0 && code != NULL) {
1358 std::ostringstream os; 1365 std::ostringstream os;
1359 os << "--------- s o u r c e c o d e ---------\n" 1366 os << "--------- s o u r c e c o d e ---------\n"
1360 << SourceCodeOf(shared, FLAG_max_stack_trace_source_length) 1367 << SourceCodeOf(shared, FLAG_max_stack_trace_source_length)
1361 << "\n-----------------------------------------\n"; 1368 << "\n-----------------------------------------\n";
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1779 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { 1786 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) {
1780 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); 1787 StackFrame* frame = AllocateFrameCopy(it.frame(), zone);
1781 list.Add(frame, zone); 1788 list.Add(frame, zone);
1782 } 1789 }
1783 return list.ToVector(); 1790 return list.ToVector();
1784 } 1791 }
1785 1792
1786 1793
1787 } // namespace internal 1794 } // namespace internal
1788 } // namespace v8 1795 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698