Chromium Code Reviews| Index: src/frames.cc |
| diff --git a/src/frames.cc b/src/frames.cc |
| index 2a1a26461d3b032b0efd5afa995cc363e20762e5..0a7005ee458795e696a21e60c9b75d3c327fcf25 100644 |
| --- a/src/frames.cc |
| +++ b/src/frames.cc |
| @@ -16,6 +16,7 @@ |
| #include "src/safepoint-table.h" |
| #include "src/string-stream.h" |
| #include "src/vm-state-inl.h" |
| +#include "src/wasm/wasm-module.h" |
| namespace v8 { |
| namespace internal { |
| @@ -617,21 +618,6 @@ void ExitFrame::FillState(Address fp, Address sp, State* state) { |
| state->constant_pool_address = NULL; |
| } |
| -void StandardFrame::Summarize(List<FrameSummary>* functions, |
| - FrameSummary::Mode mode) 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; |
| return fp() + offset - n * kPointerSize; |
| @@ -1342,32 +1328,45 @@ 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::Summarize(List<FrameSummary>* functions, |
| - FrameSummary::Mode mode) const { |
| - DCHECK(functions->length() == 0); |
| - Code* code = LookupCode(); |
| - int offset = static_cast<int>(pc() - code->instruction_start()); |
| - AbstractCode* abstract_code = AbstractCode::cast(code); |
| - Handle<JSFunction> fun(function(), isolate()); |
| - FrameSummary summary(receiver(), *fun, abstract_code, offset, false); |
| - functions->Add(summary); |
| -} |
| - |
| void WasmFrame::Iterate(ObjectVisitor* v) const { IterateCompiledFrame(v); } |
| Address WasmFrame::GetCallerStackPointer() const { |
| return fp() + ExitFrameConstants::kCallerSPOffset; |
| } |
| +Object* WasmFrame::wasm_obj(Handle<Code> code) { |
| + DCHECK_IMPLIES(!code.is_null(), *code == LookupCode()); |
|
Yang
2016/05/03 18:59:07
I assume this is a performance optimization. Is th
Clemens Hammacher
2016/05/04 09:06:20
Yes it's a performance optimization, and no, it's
|
| + if (code.is_null()) code = Handle<Code>(LookupCode(), isolate()); |
| + FixedArray* deopt_data = code->deoptimization_data(); |
| + DCHECK(deopt_data->length() == 2); |
| + return deopt_data->get(0); |
| +} |
| + |
| +uint32_t WasmFrame::function_index(Handle<Code> code) { |
| + DCHECK_IMPLIES(!code.is_null(), *code == LookupCode()); |
| + if (code.is_null()) code = Handle<Code>(LookupCode(), isolate()); |
| + FixedArray* deopt_data = code->deoptimization_data(); |
| + DCHECK(deopt_data->length() == 2); |
| + Object* func_index_obj = deopt_data->get(1); |
| + if (func_index_obj->IsUndefined()) return static_cast<uint32_t>(-1); |
| + if (func_index_obj->IsSmi()) return Smi::cast(func_index_obj)->value(); |
| + DCHECK(func_index_obj->IsHeapNumber()); |
| + uint32_t val = static_cast<uint32_t>(-1); |
| + func_index_obj->ToUint32(&val); |
| + DCHECK(val != static_cast<uint32_t>(-1)); |
| + return val; |
| +} |
| + |
| +Object* WasmFrame::function_name(Handle<Code> code) { |
|
Yang
2016/05/03 18:59:07
Isn't this always going to return a String?
Clemens Hammacher
2016/05/04 09:06:20
No, it returns undefined if the the wasm module do
Yang
2016/05/04 12:04:27
No I think this is fine. MaybeHandle would only wo
|
| + DCHECK_IMPLIES(!code.is_null(), *code == LookupCode()); |
| + if (code.is_null()) code = Handle<Code>(LookupCode(), isolate()); |
| + Object* wasm_obj_or_string = wasm_obj(); |
| + if (wasm_obj_or_string->IsString()) return wasm_obj_or_string; |
| + DCHECK(wasm_obj_or_string->IsJSObject()); |
| + Handle<JSObject> wasm = handle(JSObject::cast(wasm_obj())); |
| + return *wasm::GetWasmFunctionName(wasm, function_index(code)); |
| +} |
| + |
| namespace { |