diff options
Diffstat (limited to 'deps/v8/src/frames.cc')
-rw-r--r-- | deps/v8/src/frames.cc | 133 |
1 files changed, 72 insertions, 61 deletions
diff --git a/deps/v8/src/frames.cc b/deps/v8/src/frames.cc index 23713197f5..d5a04ad933 100644 --- a/deps/v8/src/frames.cc +++ b/deps/v8/src/frames.cc @@ -16,7 +16,8 @@ #include "src/string-stream.h" #include "src/visitors.h" #include "src/vm-state-inl.h" -#include "src/wasm/wasm-heap.h" +#include "src/wasm/wasm-code-manager.h" +#include "src/wasm/wasm-engine.h" #include "src/wasm/wasm-objects-inl.h" #include "src/zone/zone-containers.h" @@ -424,7 +425,7 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator, Memory::Object_at(state->fp + StandardFrameConstants::kFunctionOffset); if (!StackFrame::IsTypeMarker(marker)) { if (maybe_function->IsSmi()) { - return NONE; + return NATIVE; } else if (IsInterpreterFramePc(iterator->isolate(), *(state->pc_address))) { return INTERPRETED; @@ -439,19 +440,19 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator, // than checking the flag, then getting the code, and then, if both are true // (non-null, respectivelly), going down the wasm_code path. wasm::WasmCode* wasm_code = - iterator->isolate()->wasm_code_manager()->LookupCode(pc); + iterator->isolate()->wasm_engine()->code_manager()->LookupCode(pc); if (wasm_code != nullptr) { switch (wasm_code->kind()) { - case wasm::WasmCode::InterpreterStub: + case wasm::WasmCode::kInterpreterStub: return WASM_INTERPRETER_ENTRY; - case wasm::WasmCode::Function: - case wasm::WasmCode::CopiedStub: + case wasm::WasmCode::kFunction: + case wasm::WasmCode::kCopiedStub: return WASM_COMPILED; - case wasm::WasmCode::LazyStub: + case wasm::WasmCode::kLazyStub: if (StackFrame::IsTypeMarker(marker)) break; return BUILTIN; - case wasm::WasmCode::WasmToJsWrapper: - case wasm::WasmCode::WasmToWasmWrapper: + case wasm::WasmCode::kWasmToJsWrapper: + case wasm::WasmCode::kWasmToWasmWrapper: return WASM_TO_JS; default: UNREACHABLE(); @@ -491,7 +492,7 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator, break; } } else { - return NONE; + return NATIVE; } } } @@ -519,7 +520,7 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator, // interpreted frames, should never have a StackFrame::Type // marker. If we find one, we're likely being called from the // profiler in a bogus stack frame. - return NONE; + return NATIVE; } } @@ -541,6 +542,14 @@ Address StackFrame::UnpaddedFP() const { return fp(); } +void NativeFrame::ComputeCallerState(State* state) const { + state->sp = caller_sp(); + state->fp = Memory::Address_at(fp() + CommonFrameConstants::kCallerFPOffset); + state->pc_address = ResolveReturnAddressLocation( + reinterpret_cast<Address*>(fp() + CommonFrameConstants::kCallerPCOffset)); + state->callee_pc_address = nullptr; + state->constant_pool_address = nullptr; +} Code* EntryFrame::unchecked_code() const { return isolate()->heap()->js_entry_code(); @@ -777,7 +786,7 @@ void StandardFrame::IterateCompiledFrame(RootVisitor* v) const { Address inner_pointer = pc(); const wasm::WasmCode* wasm_code = FLAG_wasm_jit_to_native - ? isolate()->wasm_code_manager()->LookupCode(inner_pointer) + ? isolate()->wasm_engine()->code_manager()->LookupCode(inner_pointer) : nullptr; SafepointEntry safepoint_entry; uint32_t stack_slots; @@ -789,7 +798,7 @@ void StandardFrame::IterateCompiledFrame(RootVisitor* v) const { wasm_code->stack_slots()); safepoint_entry = table.FindEntry(inner_pointer); stack_slots = wasm_code->stack_slots(); - has_tagged_params = wasm_code->kind() != wasm::WasmCode::Function; + has_tagged_params = wasm_code->kind() != wasm::WasmCode::kFunction; } else { InnerPointerToCodeCache::InnerPointerToCodeCacheEntry* entry = isolate()->inner_pointer_to_code_cache()->GetCacheEntry(inner_pointer); @@ -840,6 +849,7 @@ void StandardFrame::IterateCompiledFrame(RootVisitor* v) const { // in the place on the stack that one finds the frame type. UNREACHABLE(); break; + case NATIVE: case NONE: case NUMBER_OF_TYPES: case MANUAL: @@ -1236,26 +1246,26 @@ WASM_SUMMARY_DISPATCH(int, byte_offset) #undef WASM_SUMMARY_DISPATCH int FrameSummary::WasmFrameSummary::SourcePosition() const { - Handle<WasmCompiledModule> compiled_module(wasm_instance()->compiled_module(), - isolate()); - return WasmCompiledModule::GetSourcePosition(compiled_module, - function_index(), byte_offset(), - at_to_number_conversion()); + Handle<WasmSharedModuleData> shared( + wasm_instance()->compiled_module()->shared(), isolate()); + return WasmSharedModuleData::GetSourcePosition( + shared, function_index(), byte_offset(), at_to_number_conversion()); } Handle<Script> FrameSummary::WasmFrameSummary::script() const { - return handle(wasm_instance()->compiled_module()->script()); + return handle(wasm_instance()->compiled_module()->shared()->script()); } Handle<String> FrameSummary::WasmFrameSummary::FunctionName() const { - Handle<WasmCompiledModule> compiled_module( - wasm_instance()->compiled_module()); - return WasmCompiledModule::GetFunctionName(compiled_module->GetIsolate(), - compiled_module, function_index()); + Handle<WasmSharedModuleData> shared( + wasm_instance()->compiled_module()->shared(), isolate()); + return WasmSharedModuleData::GetFunctionName(isolate(), shared, + function_index()); } Handle<Context> FrameSummary::WasmFrameSummary::native_context() const { - return wasm_instance()->compiled_module()->native_context(); + return handle(wasm_instance()->compiled_module()->native_context(), + isolate()); } FrameSummary::WasmCompiledFrameSummary::WasmCompiledFrameSummary( @@ -1535,6 +1545,7 @@ void OptimizedFrame::GetFunctions( DCHECK_EQ(Translation::BEGIN, opcode); it.Next(); // Skip frame count. int jsframe_count = it.Next(); + it.Next(); // Skip update feedback count. // We insert the frames in reverse order because the frames // in the deoptimization translation are ordered bottom-to-top. @@ -1691,11 +1702,18 @@ void WasmCompiledFrame::Print(StringStream* accumulator, PrintMode mode, accumulator->Add("WASM ["); Script* script = this->script(); accumulator->PrintName(script->name()); - int pc = static_cast<int>(this->pc() - LookupCode()->instruction_start()); - Object* instance = this->wasm_instance(); + Address instruction_start = FLAG_wasm_jit_to_native + ? isolate() + ->wasm_engine() + ->code_manager() + ->LookupCode(pc()) + ->instructions() + .start() + : LookupCode()->instruction_start(); + int pc = static_cast<int>(this->pc() - instruction_start); + WasmSharedModuleData* shared = wasm_instance()->compiled_module()->shared(); Vector<const uint8_t> raw_func_name = - WasmInstanceObject::cast(instance)->compiled_module()->GetRawFunctionName( - this->function_index()); + shared->GetRawFunctionName(this->function_index()); const int kMaxPrintedFunctionName = 64; char func_name[kMaxPrintedFunctionName + 1]; int func_name_len = std::min(kMaxPrintedFunctionName, raw_func_name.length()); @@ -1718,11 +1736,18 @@ Address WasmCompiledFrame::GetCallerStackPointer() const { return fp() + ExitFrameConstants::kCallerSPOffset; } +WasmCodeWrapper WasmCompiledFrame::wasm_code() const { + return FLAG_wasm_jit_to_native + ? WasmCodeWrapper( + isolate()->wasm_engine()->code_manager()->LookupCode(pc())) + : WasmCodeWrapper(Handle<Code>(LookupCode(), isolate())); +} + WasmInstanceObject* WasmCompiledFrame::wasm_instance() const { WasmInstanceObject* obj = FLAG_wasm_jit_to_native ? WasmInstanceObject::GetOwningInstance( - isolate()->wasm_code_manager()->LookupCode(pc())) + isolate()->wasm_engine()->code_manager()->LookupCode(pc())) : WasmInstanceObject::GetOwningInstanceGC(LookupCode()); // This is a live stack frame; it must have a live instance. DCHECK_NOT_NULL(obj); @@ -1734,7 +1759,7 @@ uint32_t WasmCompiledFrame::function_index() const { } Script* WasmCompiledFrame::script() const { - return wasm_instance()->compiled_module()->script(); + return wasm_instance()->compiled_module()->shared()->script(); } int WasmCompiledFrame::position() const { @@ -1743,25 +1768,9 @@ int WasmCompiledFrame::position() const { void WasmCompiledFrame::Summarize(std::vector<FrameSummary>* functions) const { DCHECK(functions->empty()); - WasmCodeWrapper code; - Handle<WasmInstanceObject> instance; - int offset = -1; - if (FLAG_wasm_jit_to_native) { - code = WasmCodeWrapper(isolate()->wasm_code_manager()->LookupCode(pc())); - offset = - static_cast<int>(pc() - code.GetWasmCode()->instructions().start()); - instance = Handle<WasmInstanceObject>( - WasmInstanceObject::cast(code.GetWasmCode() - ->owner() - ->compiled_module() - ->weak_owning_instance() - ->value()), - isolate()); - } else { - code = WasmCodeWrapper(Handle<Code>(LookupCode(), isolate())); - offset = static_cast<int>(pc() - code.GetCode()->instruction_start()); - instance = Handle<WasmInstanceObject>(wasm_instance(), isolate()); - } + WasmCodeWrapper code = wasm_code(); + int offset = static_cast<int>(pc() - code.instructions().start()); + Handle<WasmInstanceObject> instance = code.wasm_instance(); FrameSummary::WasmCompiledFrameSummary summary( isolate(), instance, code, offset, at_to_number_conversion()); functions->push_back(summary); @@ -1774,9 +1783,10 @@ bool WasmCompiledFrame::at_to_number_conversion() const { int pos = -1; if (FLAG_wasm_jit_to_native) { wasm::WasmCode* code = - callee_pc ? isolate()->wasm_code_manager()->LookupCode(callee_pc) - : nullptr; - if (!code || code->kind() != wasm::WasmCode::WasmToJsWrapper) return false; + callee_pc + ? isolate()->wasm_engine()->code_manager()->LookupCode(callee_pc) + : nullptr; + if (!code || code->kind() != wasm::WasmCode::kWasmToJsWrapper) return false; int offset = static_cast<int>(callee_pc - code->instructions().start()); pos = FrameSummary::WasmCompiledFrameSummary::GetWasmSourcePosition(code, offset); @@ -1800,11 +1810,11 @@ int WasmCompiledFrame::LookupExceptionHandlerInTable(int* stack_slots) { *stack_slots = code->stack_slots(); return table->LookupReturn(pc_offset); } - wasm::WasmCode* code = isolate()->wasm_code_manager()->LookupCode(pc()); + wasm::WasmCode* code = + isolate()->wasm_engine()->code_manager()->LookupCode(pc()); if (!code->IsAnonymous()) { Object* table_entry = - code->owner()->compiled_module()->ptr_to_handler_table()->get( - code->index()); + code->owner()->compiled_module()->handler_table()->get(code->index()); if (table_entry->IsHandlerTable()) { HandlerTable* table = HandlerTable::cast(table_entry); int pc_offset = static_cast<int>(pc() - code->instructions().start()); @@ -1854,7 +1864,7 @@ WasmInstanceObject* WasmInterpreterEntryFrame::wasm_instance() const { WasmInstanceObject* ret = FLAG_wasm_jit_to_native ? WasmInstanceObject::GetOwningInstance( - isolate()->wasm_code_manager()->LookupCode(pc())) + isolate()->wasm_engine()->code_manager()->LookupCode(pc())) : WasmInstanceObject::GetOwningInstanceGC(LookupCode()); // This is a live stack frame, there must be a live wasm instance available. DCHECK_NOT_NULL(ret); @@ -1862,7 +1872,7 @@ WasmInstanceObject* WasmInterpreterEntryFrame::wasm_instance() const { } Script* WasmInterpreterEntryFrame::script() const { - return wasm_instance()->compiled_module()->script(); + return wasm_instance()->compiled_module()->shared()->script(); } int WasmInterpreterEntryFrame::position() const { @@ -1870,7 +1880,7 @@ int WasmInterpreterEntryFrame::position() const { } Object* WasmInterpreterEntryFrame::context() const { - return wasm_instance()->compiled_module()->ptr_to_native_context(); + return wasm_instance()->compiled_module()->native_context(); } Address WasmInterpreterEntryFrame::GetCallerStackPointer() const { @@ -2081,10 +2091,11 @@ void JavaScriptFrame::Iterate(RootVisitor* v) const { void InternalFrame::Iterate(RootVisitor* v) const { wasm::WasmCode* wasm_code = - FLAG_wasm_jit_to_native ? isolate()->wasm_code_manager()->LookupCode(pc()) - : nullptr; + FLAG_wasm_jit_to_native + ? isolate()->wasm_engine()->code_manager()->LookupCode(pc()) + : nullptr; if (wasm_code != nullptr) { - DCHECK(wasm_code->kind() == wasm::WasmCode::LazyStub); + DCHECK(wasm_code->kind() == wasm::WasmCode::kLazyStub); } else { Code* code = LookupCode(); IteratePc(v, pc_address(), constant_pool_address(), code); |