Commit 2cd2c488 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[no-wasm] Remove deoptimizer support

This removes all includes of src/wasm from src/deoptimizer, by #if'ing
out wasm-related parts. This will allow to later exclude the whole
src/wasm directory from compilation.

Drive-by: Inline DecodeWasmReturnKind and EncodeWasmReturnKind to avoid
more #ifs.

R=jgruber@chromium.org

Bug: v8:11238
Change-Id: Ia49ed26fc217b3e80756a363dcd397d9060f6835
Cq-Include-Trybots: luci.v8.try:v8_linux64_no_wasm_compile_rel
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2739653Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73261}
parent b1c5a9a2
......@@ -20,7 +20,10 @@
#include "src/objects/js-function-inl.h"
#include "src/objects/oddball.h"
#include "src/snapshot/embedded/embedded-data.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-linkage.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
......@@ -937,7 +940,9 @@ void Deoptimizer::DoComputeOutputFrames() {
DoComputeConstructStubFrame(translated_frame, frame_index);
break;
case TranslatedFrame::kBuiltinContinuation:
#if V8_ENABLE_WEBASSEMBLY
case TranslatedFrame::kJSToWasmBuiltinContinuation:
#endif // V8_ENABLE_WEBASSEMBLY
DoComputeBuiltinContinuation(translated_frame, frame_index,
BuiltinContinuationMode::STUB);
break;
......@@ -1562,6 +1567,7 @@ Builtins::Name Deoptimizer::TrampolineForBuiltinContinuation(
UNREACHABLE();
}
#if V8_ENABLE_WEBASSEMBLY
TranslatedValue Deoptimizer::TranslatedValueForWasmReturnKind(
base::Optional<wasm::ValueKind> wasm_call_return_kind) {
if (wasm_call_return_kind) {
......@@ -1591,6 +1597,7 @@ TranslatedValue Deoptimizer::TranslatedValueForWasmReturnKind(
return TranslatedValue::NewTagged(&translated_state_,
ReadOnlyRoots(isolate()).undefined_value());
}
#endif // V8_ENABLE_WEBASSEMBLY
// BuiltinContinuationFrames capture the machine state that is expected as input
// to a builtin, including both input register values and stack parameters. When
......@@ -1655,7 +1662,9 @@ void Deoptimizer::DoComputeBuiltinContinuation(
BuiltinContinuationMode mode) {
TranslatedFrame::iterator result_iterator = translated_frame->end();
bool is_js_to_wasm_builtin_continuation =
bool is_js_to_wasm_builtin_continuation = false;
#if V8_ENABLE_WEBASSEMBLY
is_js_to_wasm_builtin_continuation =
translated_frame->kind() == TranslatedFrame::kJSToWasmBuiltinContinuation;
if (is_js_to_wasm_builtin_continuation) {
// For JSToWasmBuiltinContinuations, add a TranslatedValue with the result
......@@ -1667,6 +1676,7 @@ void Deoptimizer::DoComputeBuiltinContinuation(
translated_frame->wasm_call_return_kind());
translated_frame->Add(result);
}
#endif // V8_ENABLE_WEBASSEMBLY
TranslatedFrame::iterator value_iterator = translated_frame->begin();
......
......@@ -15,6 +15,10 @@
#include "src/diagnostics/code-tracer.h"
#include "src/objects/js-function.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/value-type.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
......@@ -164,8 +168,10 @@ class Deoptimizer : public Malloced {
static Builtins::Name TrampolineForBuiltinContinuation(
BuiltinContinuationMode mode, bool must_handle_result);
#if V8_ENABLE_WEBASSEMBLY
TranslatedValue TranslatedValueForWasmReturnKind(
base::Optional<wasm::ValueKind> wasm_call_return_kind);
#endif // V8_ENABLE_WEBASSEMBLY
void DoComputeBuiltinContinuation(TranslatedFrame* translated_frame,
int frame_index,
......
......@@ -98,6 +98,7 @@ void TranslationArrayPrintSingleFrame(std::ostream& os,
break;
}
#if V8_ENABLE_WEBASSEMBLY
case TranslationOpcode::JS_TO_WASM_BUILTIN_CONTINUATION_FRAME: {
DCHECK_EQ(TranslationOpcodeOperandCount(opcode), 4);
int bailout_id = iterator.Next();
......@@ -111,6 +112,7 @@ void TranslationArrayPrintSingleFrame(std::ostream& os,
<< "}";
break;
}
#endif // V8_ENABLE_WEBASSEMBLY
case TranslationOpcode::ARGUMENTS_ADAPTOR_FRAME: {
DCHECK_EQ(TranslationOpcodeOperandCount(opcode), 2);
......@@ -265,19 +267,6 @@ void TranslationArrayPrintSingleFrame(std::ostream& os,
}
}
namespace {
// Decodes the return type of a Wasm function as the integer value of
// wasm::ValueKind, or kNoWasmReturnKind if the function returns void.
base::Optional<wasm::ValueKind> DecodeWasmReturnKind(int code) {
if (code != kNoWasmReturnKind) {
return {static_cast<wasm::ValueKind>(code)};
}
return {};
}
} // namespace
// static
TranslatedValue TranslatedValue::NewDeferredObject(TranslatedState* container,
int length,
......@@ -656,6 +645,7 @@ TranslatedFrame TranslatedFrame::BuiltinContinuationFrame(
return frame;
}
#if V8_ENABLE_WEBASSEMBLY
TranslatedFrame TranslatedFrame::JSToWasmBuiltinContinuationFrame(
BytecodeOffset bytecode_offset, SharedFunctionInfo shared_info, int height,
base::Optional<wasm::ValueKind> return_kind) {
......@@ -664,6 +654,7 @@ TranslatedFrame TranslatedFrame::JSToWasmBuiltinContinuationFrame(
frame.return_kind_ = return_kind;
return frame;
}
#endif // V8_ENABLE_WEBASSEMBLY
TranslatedFrame TranslatedFrame::JavaScriptBuiltinContinuationFrame(
BytecodeOffset bytecode_offset, SharedFunctionInfo shared_info,
......@@ -711,7 +702,9 @@ int TranslatedFrame::GetValueCount() {
case kConstructStub:
case kBuiltinContinuation:
#if V8_ENABLE_WEBASSEMBLY
case kJSToWasmBuiltinContinuation:
#endif // V8_ENABLE_WEBASSEMBLY
case kJavaScriptBuiltinContinuation:
case kJavaScriptBuiltinContinuationWithCatch: {
static constexpr int kTheContext = 1;
......@@ -805,13 +798,17 @@ TranslatedFrame TranslatedState::CreateNextTranslatedFrame(
shared_info, height);
}
#if V8_ENABLE_WEBASSEMBLY
case TranslationOpcode::JS_TO_WASM_BUILTIN_CONTINUATION_FRAME: {
BytecodeOffset bailout_id = BytecodeOffset(iterator->Next());
SharedFunctionInfo shared_info =
SharedFunctionInfo::cast(literal_array.get(iterator->Next()));
int height = iterator->Next();
base::Optional<wasm::ValueKind> return_kind =
DecodeWasmReturnKind(iterator->Next());
int return_kind_code = iterator->Next();
base::Optional<wasm::ValueKind> return_kind;
if (return_kind_code != kNoWasmReturnKind) {
return_kind = static_cast<wasm::ValueKind>(return_kind_code);
}
if (trace_file != nullptr) {
std::unique_ptr<char[]> name = shared_info.DebugNameCStr();
PrintF(trace_file, " reading JS to Wasm builtin continuation frame %s",
......@@ -824,6 +821,7 @@ TranslatedFrame TranslatedState::CreateNextTranslatedFrame(
return TranslatedFrame::JSToWasmBuiltinContinuationFrame(
bailout_id, shared_info, height, return_kind);
}
#endif // V8_ENABLE_WEBASSEMBLY
case TranslationOpcode::JAVA_SCRIPT_BUILTIN_CONTINUATION_FRAME: {
BytecodeOffset bytecode_offset = BytecodeOffset(iterator->Next());
......@@ -980,7 +978,9 @@ int TranslatedState::CreateNextTranslatedValue(
case TranslationOpcode::JAVA_SCRIPT_BUILTIN_CONTINUATION_FRAME:
case TranslationOpcode::JAVA_SCRIPT_BUILTIN_CONTINUATION_WITH_CATCH_FRAME:
case TranslationOpcode::BUILTIN_CONTINUATION_FRAME:
#if V8_ENABLE_WEBASSEMBLY
case TranslationOpcode::JS_TO_WASM_BUILTIN_CONTINUATION_FRAME:
#endif // V8_ENABLE_WEBASSEMBLY
case TranslationOpcode::UPDATE_FEEDBACK:
// Peeled off before getting here.
break;
......
......@@ -13,7 +13,10 @@
#include "src/objects/heap-object.h"
#include "src/objects/shared-function-info.h"
#include "src/utils/boxed-float.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/value-type.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
......@@ -175,7 +178,9 @@ class TranslatedFrame {
kArgumentsAdaptor,
kConstructStub,
kBuiltinContinuation,
#if V8_ENABLE_WEBASSEMBLY
kJSToWasmBuiltinContinuation,
#endif // V8_ENABLE_WEBASSEMBLY
kJavaScriptBuiltinContinuation,
kJavaScriptBuiltinContinuationWithCatch,
kInvalid
......@@ -250,11 +255,13 @@ class TranslatedFrame {
reference front() { return values_.front(); }
const_reference front() const { return values_.front(); }
#if V8_ENABLE_WEBASSEMBLY
// Only for Kind == kJSToWasmBuiltinContinuation
base::Optional<wasm::ValueKind> wasm_call_return_kind() const {
DCHECK_EQ(kind(), kJSToWasmBuiltinContinuation);
return return_kind_;
}
#endif // V8_ENABLE_WEBASSEMBLY
private:
friend class TranslatedState;
......@@ -274,9 +281,11 @@ class TranslatedFrame {
int height);
static TranslatedFrame BuiltinContinuationFrame(
BytecodeOffset bailout_id, SharedFunctionInfo shared_info, int height);
#if V8_ENABLE_WEBASSEMBLY
static TranslatedFrame JSToWasmBuiltinContinuationFrame(
BytecodeOffset bailout_id, SharedFunctionInfo shared_info, int height,
base::Optional<wasm::ValueKind> return_type);
#endif // V8_ENABLE_WEBASSEMBLY
static TranslatedFrame JavaScriptBuiltinContinuationFrame(
BytecodeOffset bailout_id, SharedFunctionInfo shared_info, int height);
static TranslatedFrame JavaScriptBuiltinContinuationWithCatchFrame(
......@@ -314,8 +323,10 @@ class TranslatedFrame {
ValuesContainer values_;
#if V8_ENABLE_WEBASSEMBLY
// Only for Kind == kJSToWasmBuiltinContinuation
base::Optional<wasm::ValueKind> return_kind_;
#endif // V8_ENABLE_WEBASSEMBLY
};
// Auxiliary class for translating deoptimization values.
......
......@@ -22,13 +22,6 @@ constexpr int kCompressedDataOffset =
kUncompressedSizeOffset + kUncompressedSizeSize;
constexpr int kTranslationArrayElementSize = kInt32Size;
// Encodes the return type of a Wasm function as the integer value of
// wasm::ValueKind, or kNoWasmReturnKind if the function returns void.
int EncodeWasmReturnKind(base::Optional<wasm::ValueKind> return_kind) {
return return_kind ? static_cast<int>(return_kind.value())
: kNoWasmReturnKind;
}
} // namespace
TranslationArrayIterator::TranslationArrayIterator(TranslationArray buffer,
......@@ -123,17 +116,19 @@ void TranslationArrayBuilder::BeginBuiltinContinuationFrame(
DCHECK_EQ(TranslationOpcodeOperandCount(opcode), 3);
}
#if V8_ENABLE_WEBASSEMBLY
void TranslationArrayBuilder::BeginJSToWasmBuiltinContinuationFrame(
BytecodeOffset bytecode_offset, int literal_id, unsigned height,
base::Optional<wasm::ValueKind> return_type) {
base::Optional<wasm::ValueKind> return_kind) {
auto opcode = TranslationOpcode::JS_TO_WASM_BUILTIN_CONTINUATION_FRAME;
Add(opcode);
Add(bytecode_offset.ToInt());
Add(literal_id);
Add(height);
Add(EncodeWasmReturnKind(return_type));
Add(return_kind ? static_cast<int>(return_kind.value()) : kNoWasmReturnKind);
DCHECK_EQ(TranslationOpcodeOperandCount(opcode), 4);
}
#endif // V8_ENABLE_WEBASSEMBLY
void TranslationArrayBuilder::BeginJavaScriptBuiltinContinuationFrame(
BytecodeOffset bytecode_offset, int literal_id, unsigned height) {
......
......@@ -8,9 +8,12 @@
#include "src/codegen/register-arch.h"
#include "src/deoptimizer/translation-opcode.h"
#include "src/objects/fixed-array.h"
#include "src/wasm/value-type.h"
#include "src/zone/zone-containers.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/value-type.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 {
namespace internal {
......@@ -68,9 +71,11 @@ class TranslationArrayBuilder {
unsigned height);
void BeginBuiltinContinuationFrame(BytecodeOffset bailout_id, int literal_id,
unsigned height);
#if V8_ENABLE_WEBASSEMBLY
void BeginJSToWasmBuiltinContinuationFrame(
BytecodeOffset bailout_id, int literal_id, unsigned height,
base::Optional<wasm::ValueKind> return_kind);
#endif // V8_ENABLE_WEBASSEMBLY
void BeginJavaScriptBuiltinContinuationFrame(BytecodeOffset bailout_id,
int literal_id, unsigned height);
void BeginJavaScriptBuiltinContinuationWithCatchFrame(
......
......@@ -5,6 +5,8 @@
#ifndef V8_DEOPTIMIZER_TRANSLATION_OPCODE_H_
#define V8_DEOPTIMIZER_TRANSLATION_OPCODE_H_
#include "src/base/macros.h"
namespace v8 {
namespace internal {
......@@ -31,7 +33,7 @@ namespace internal {
V(INTERPRETED_FRAME, 5) \
V(JAVA_SCRIPT_BUILTIN_CONTINUATION_FRAME, 3) \
V(JAVA_SCRIPT_BUILTIN_CONTINUATION_WITH_CATCH_FRAME, 3) \
V(JS_TO_WASM_BUILTIN_CONTINUATION_FRAME, 4) \
IF_WASM(V, JS_TO_WASM_BUILTIN_CONTINUATION_FRAME, 4) \
V(LITERAL, 1) \
V(REGISTER, 1) \
V(STACK_SLOT, 1) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment