[wasm] Distinguish WASM_TO_WASM_FUNCTION

Identify wasm-to-wasm wrappers separately from wasm-to-js ones.

Bug: 
Change-Id: I853ed8fb999297f8a951ebb0e5be1c99bfacc18c
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Reviewed-on: https://chromium-review.googlesource.com/782680
Reviewed-by: Brad Nelson <bradnelson@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Mircea Trofin <mtrofin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49580}
This commit is contained in:
Mircea Trofin 2017-11-21 10:21:22 -08:00 committed by Commit Bot
parent 3ae2b9ebf0
commit 85ce824003
15 changed files with 38 additions and 5 deletions

View File

@ -152,6 +152,8 @@ StackFrame::Type CompilationInfo::GetOutputStackFrameType() const {
return StackFrame::WASM_COMPILED;
case Code::JS_TO_WASM_FUNCTION:
return StackFrame::JS_TO_WASM;
case Code::WASM_TO_WASM_FUNCTION:
return StackFrame::WASM_TO_WASM;
case Code::WASM_TO_JS_FUNCTION:
return StackFrame::WASM_TO_JS;
case Code::WASM_INTERPRETER_ENTRY:

View File

@ -1013,7 +1013,8 @@ void PipelineWasmCompilationJob::ValidateImmovableEmbeddedObjects() const {
target->IsSmi() || Heap::IsImmovable(HeapObject::cast(target));
bool is_wasm = target->IsCode() &&
(Code::cast(target)->kind() == Code::WASM_FUNCTION ||
Code::cast(target)->kind() == Code::WASM_TO_JS_FUNCTION);
Code::cast(target)->kind() == Code::WASM_TO_JS_FUNCTION ||
Code::cast(target)->kind() == Code::WASM_TO_WASM_FUNCTION);
bool is_allowed_stub = false;
if (target->IsCode()) {
Code* code = Code::cast(target);
@ -1750,6 +1751,7 @@ struct VerifyGraphPhase {
switch (data->info()->code_kind()) {
case Code::WASM_FUNCTION:
case Code::WASM_TO_JS_FUNCTION:
case Code::WASM_TO_WASM_FUNCTION:
case Code::JS_TO_WASM_FUNCTION:
case Code::WASM_INTERPRETER_ENTRY:
case Code::C_WASM_ENTRY:

View File

@ -4492,7 +4492,7 @@ Handle<Code> CompileWasmToWasmWrapper(Isolate* isolate, Handle<Code> target,
func_name = Vector<const char>::cast(buffer.SubVector(0, chars));
}
CompilationInfo info(func_name, &zone, Code::WASM_FUNCTION);
CompilationInfo info(func_name, &zone, Code::WASM_TO_WASM_FUNCTION);
Handle<Code> code =
Pipeline::GenerateCodeForTesting(&info, isolate, incoming, &graph);
#ifdef ENABLE_DISASSEMBLER

View File

@ -202,6 +202,9 @@ inline WasmToJsFrame::WasmToJsFrame(StackFrameIteratorBase* iterator)
inline JsToWasmFrame::JsToWasmFrame(StackFrameIteratorBase* iterator)
: StubFrame(iterator) {}
inline WasmToWasmFrame::WasmToWasmFrame(StackFrameIteratorBase* iterator)
: StubFrame(iterator) {}
inline CWasmEntryFrame::CWasmEntryFrame(StackFrameIteratorBase* iterator)
: StubFrame(iterator) {}

View File

@ -789,6 +789,7 @@ void StandardFrame::IterateCompiledFrame(RootVisitor* v) const {
case CONSTRUCT:
case JS_TO_WASM:
case WASM_TO_JS:
case WASM_TO_WASM:
case WASM_COMPILED:
case WASM_INTERPRETER_ENTRY:
case C_WASM_ENTRY:

View File

@ -92,6 +92,7 @@ class StackHandler BASE_EMBEDDED {
V(OPTIMIZED, OptimizedFrame) \
V(WASM_COMPILED, WasmCompiledFrame) \
V(WASM_TO_JS, WasmToJsFrame) \
V(WASM_TO_WASM, WasmToWasmFrame) \
V(JS_TO_WASM, JsToWasmFrame) \
V(WASM_INTERPRETER_ENTRY, WasmInterpreterEntryFrame) \
V(C_WASM_ENTRY, CWasmEntryFrame) \
@ -1027,6 +1028,17 @@ class JsToWasmFrame : public StubFrame {
friend class StackFrameIteratorBase;
};
class WasmToWasmFrame : public StubFrame {
public:
Type type() const override { return WASM_TO_WASM; }
protected:
inline explicit WasmToWasmFrame(StackFrameIteratorBase* iterator);
private:
friend class StackFrameIteratorBase;
};
class CWasmEntryFrame : public StubFrame {
public:
Type type() const override { return C_WASM_ENTRY; }

View File

@ -1554,6 +1554,10 @@ void Logger::LogCodeObject(Object* object) {
description = "A JavaScript to Wasm adapter";
tag = CodeEventListener::STUB_TAG;
break;
case AbstractCode::WASM_TO_WASM_FUNCTION:
description = "A cross-instance Wasm adapter";
tag = CodeEventListener::STUB_TAG;
break;
case AbstractCode::WASM_TO_JS_FUNCTION:
description = "A Wasm to JavaScript adapter";
tag = CodeEventListener::STUB_TAG;

View File

@ -118,6 +118,7 @@ class Code : public HeapObject {
V(REGEXP) \
V(WASM_FUNCTION) \
V(WASM_TO_JS_FUNCTION) \
V(WASM_TO_WASM_FUNCTION) \
V(JS_TO_WASM_FUNCTION) \
V(WASM_INTERPRETER_ENTRY) \
V(C_WASM_ENTRY)

View File

@ -513,8 +513,8 @@ RUNTIME_FUNCTION(Runtime_CheckWasmWrapperElision) {
Handle<Code> imported_fct;
CHECK(type->value() == 0 || type->value() == 1);
Code::Kind target_kind =
type->value() == 0 ? Code::WASM_FUNCTION : Code::WASM_TO_JS_FUNCTION;
Code::Kind target_kind = type->value() == 0 ? Code::WASM_TO_WASM_FUNCTION
: Code::WASM_TO_JS_FUNCTION;
count = 0;
for (RelocIterator it(*intermediate_fct, mask); !it.done(); it.next()) {
RelocInfo* rinfo = it.rinfo();

View File

@ -281,6 +281,7 @@ void WasmCompiledModuleSerializer::SerializeCodeObject(
}
case Code::WASM_INTERPRETER_ENTRY:
case Code::WASM_TO_JS_FUNCTION:
case Code::WASM_TO_WASM_FUNCTION:
// Serialize the illegal builtin instead. On instantiation of a
// deserialized module, these will be replaced again.
SerializeBuiltinReference(*BUILTIN_CODE(isolate(), Illegal), how_to_code,

View File

@ -246,6 +246,7 @@ class JSToWasmWrapperCache {
Code::GetCodeFromTargetAddress(it.rinfo()->target_address());
if (target->kind() == Code::WASM_FUNCTION ||
target->kind() == Code::WASM_TO_JS_FUNCTION ||
target->kind() == Code::WASM_TO_WASM_FUNCTION ||
target->builtin_index() == Builtins::kIllegal ||
target->builtin_index() == Builtins::kWasmCompileLazy) {
it.rinfo()->set_target_address(isolate,
@ -1251,6 +1252,7 @@ Handle<Code> EnsureExportedLazyDeoptData(Isolate* isolate,
// instantiation time).
DCHECK(code->kind() == Code::WASM_FUNCTION ||
code->kind() == Code::WASM_TO_JS_FUNCTION ||
code->kind() == Code::WASM_TO_WASM_FUNCTION ||
code->builtin_index() == Builtins::kIllegal);
return code;
}
@ -1656,6 +1658,7 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
Handle<Code> orig_code(Code::cast(code_table->get(i)), isolate_);
switch (orig_code->kind()) {
case Code::WASM_TO_JS_FUNCTION:
case Code::WASM_TO_WASM_FUNCTION:
// Imports will be overwritten with newly compiled wrappers.
break;
case Code::BUILTIN:

View File

@ -63,6 +63,7 @@ bool IsAtWasmDirectCallTarget(RelocIterator& it) {
Code* code = Code::GetCodeFromTargetAddress(it.rinfo()->target_address());
return code->kind() == Code::WASM_FUNCTION ||
code->kind() == Code::WASM_TO_JS_FUNCTION ||
code->kind() == Code::WASM_TO_WASM_FUNCTION ||
code->kind() == Code::WASM_INTERPRETER_ENTRY ||
code->builtin_index() == Builtins::kIllegal ||
code->builtin_index() == Builtins::kWasmCompileLazy;

View File

@ -2404,7 +2404,8 @@ class ThreadImpl {
DCHECK(AllowHandleAllocation::IsAllowed());
DCHECK(AllowHeapAllocation::IsAllowed());
if (code->kind() == Code::WASM_FUNCTION) {
if (code->kind() == Code::WASM_FUNCTION ||
code->kind() == Code::WASM_TO_WASM_FUNCTION) {
FixedArray* deopt_data = code->deoptimization_data();
DCHECK_EQ(2, deopt_data->length());
WasmInstanceObject* target_instance =

View File

@ -686,6 +686,7 @@ Handle<Code> WasmExportedFunction::GetWasmCode() {
auto IsWasmFunctionCode = [](Code* code) {
return code->kind() == Code::WASM_FUNCTION ||
code->kind() == Code::WASM_TO_JS_FUNCTION ||
code->kind() == Code::WASM_TO_WASM_FUNCTION ||
code->kind() == Code::WASM_INTERPRETER_ENTRY ||
code->builtin_index() == Builtins::kWasmCompileLazy;
};

View File

@ -335,6 +335,7 @@ FRAME_MARKERS = (
"OPTIMIZED",
"WASM_COMPILED",
"WASM_TO_JS",
"WASM_TO_WASM",
"JS_TO_WASM",
"WASM_INTERPRETER_ENTRY",
"C_WASM_ENTRY",