|
16 | 16 | #include "src/safepoint-table.h" |
17 | 17 | #include "src/string-stream.h" |
18 | 18 | #include "src/vm-state-inl.h" |
| 19 | +#include "src/wasm/wasm-module.h" |
19 | 20 |
|
20 | 21 | namespace v8 { |
21 | 22 | namespace internal { |
@@ -617,21 +618,6 @@ void ExitFrame::FillState(Address fp, Address sp, State* state) { |
617 | 618 | state->constant_pool_address = NULL; |
618 | 619 | } |
619 | 620 |
|
620 | | -void StandardFrame::Summarize(List<FrameSummary>* functions, |
621 | | - FrameSummary::Mode mode) const { |
622 | | - DCHECK(functions->length() == 0); |
623 | | - // default implementation: no summary added |
624 | | -} |
625 | | - |
626 | | -JSFunction* StandardFrame::function() const { |
627 | | - // this default implementation is overridden by JS and WASM frames |
628 | | - return nullptr; |
629 | | -} |
630 | | - |
631 | | -Object* StandardFrame::receiver() const { |
632 | | - return isolate()->heap()->undefined_value(); |
633 | | -} |
634 | | - |
635 | 621 | Address StandardFrame::GetExpressionAddress(int n) const { |
636 | 622 | const int offset = StandardFrameConstants::kExpressionsOffset; |
637 | 623 | return fp() + offset - n * kPointerSize; |
@@ -1343,30 +1329,36 @@ Code* WasmFrame::unchecked_code() const { |
1343 | 1329 | return static_cast<Code*>(isolate()->FindCodeObject(pc())); |
1344 | 1330 | } |
1345 | 1331 |
|
1346 | | -JSFunction* WasmFrame::function() const { |
1347 | | - // TODO(clemensh): generate the right JSFunctions once per wasm function and |
1348 | | - // cache them |
1349 | | - Factory* factory = isolate()->factory(); |
1350 | | - Handle<JSFunction> fun = |
1351 | | - factory->NewFunction(factory->NewStringFromAsciiChecked("<WASM>")); |
1352 | | - return *fun; |
| 1332 | +void WasmFrame::Iterate(ObjectVisitor* v) const { IterateCompiledFrame(v); } |
| 1333 | + |
| 1334 | +Address WasmFrame::GetCallerStackPointer() const { |
| 1335 | + return fp() + ExitFrameConstants::kCallerSPOffset; |
1353 | 1336 | } |
1354 | 1337 |
|
1355 | | -void WasmFrame::Summarize(List<FrameSummary>* functions, |
1356 | | - FrameSummary::Mode mode) const { |
1357 | | - DCHECK(functions->length() == 0); |
1358 | | - Code* code = LookupCode(); |
1359 | | - int offset = static_cast<int>(pc() - code->instruction_start()); |
1360 | | - AbstractCode* abstract_code = AbstractCode::cast(code); |
1361 | | - Handle<JSFunction> fun(function(), isolate()); |
1362 | | - FrameSummary summary(receiver(), *fun, abstract_code, offset, false); |
1363 | | - functions->Add(summary); |
| 1338 | +Object* WasmFrame::wasm_obj() { |
| 1339 | + FixedArray* deopt_data = LookupCode()->deoptimization_data(); |
| 1340 | + DCHECK(deopt_data->length() == 2); |
| 1341 | + return deopt_data->get(0); |
1364 | 1342 | } |
1365 | 1343 |
|
1366 | | -void WasmFrame::Iterate(ObjectVisitor* v) const { IterateCompiledFrame(v); } |
| 1344 | +uint32_t WasmFrame::function_index() { |
| 1345 | + FixedArray* deopt_data = LookupCode()->deoptimization_data(); |
| 1346 | + DCHECK(deopt_data->length() == 2); |
| 1347 | + Object* func_index_obj = deopt_data->get(1); |
| 1348 | + if (func_index_obj->IsUndefined()) return static_cast<uint32_t>(-1); |
| 1349 | + if (func_index_obj->IsSmi()) return Smi::cast(func_index_obj)->value(); |
| 1350 | + DCHECK(func_index_obj->IsHeapNumber()); |
| 1351 | + uint32_t val = static_cast<uint32_t>(-1); |
| 1352 | + func_index_obj->ToUint32(&val); |
| 1353 | + DCHECK(val != static_cast<uint32_t>(-1)); |
| 1354 | + return val; |
| 1355 | +} |
1367 | 1356 |
|
1368 | | -Address WasmFrame::GetCallerStackPointer() const { |
1369 | | - return fp() + ExitFrameConstants::kCallerSPOffset; |
| 1357 | +Object* WasmFrame::function_name() { |
| 1358 | + Object* wasm_object = wasm_obj(); |
| 1359 | + if (wasm_object->IsUndefined()) return wasm_object; |
| 1360 | + Handle<JSObject> wasm = handle(JSObject::cast(wasm_object)); |
| 1361 | + return *wasm::GetWasmFunctionName(wasm, function_index()); |
1370 | 1362 | } |
1371 | 1363 |
|
1372 | 1364 | namespace { |
|
0 commit comments