#include <optional>
#include "src/builtins/builtins-inl.h"
#include "src/builtins/data-view-ops.h"
#include "src/common/assert-scope.h"
#include "src/common/message-template.h"
#include "src/compiler/wasm-compiler.h"
#include "src/debug/debug.h"
#include "src/deoptimizer/deoptimizer.h"
#include "src/execution/arguments-inl.h"
#include "src/execution/frames.h"
#include "src/heap/factory.h"
#include "src/numbers/conversions.h"
#include "src/objects/objects-inl.h"
#include "src/strings/unicode-inl.h"
#include "src/trap-handler/trap-handler.h"
#include "src/wasm/compilation-environment-inl.h"
#include "src/wasm/module-compiler.h"
#include "src/wasm/serialized-signature-inl.h"
#include "src/wasm/value-type.h"
#include "src/wasm/wasm-code-manager.h"
#include "src/wasm/wasm-constants.h"
#include "src/wasm/wasm-debug.h"
#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-objects.h"
#include "src/wasm/wasm-opcodes-inl.h"
#include "src/wasm/wasm-subtyping.h"
#include "src/wasm/wasm-value.h"
#if V8_ENABLE_WEBASSEMBLY && V8_ENABLE_DRUMBRAKE
#include "src/wasm/interpreter/wasm-interpreter.h"
#endif
namespace v8::internal {
class RuntimeArgumentsWithoutHandles : public RuntimeArguments { … };
#define RuntimeArguments …
namespace {
template <typename FrameType>
class FrameFinder { … };
Tagged<WasmTrustedInstanceData> GetWasmInstanceDataOnStackTop(
Isolate* isolate) { … }
Tagged<Context> GetNativeContextFromWasmInstanceOnStackTop(Isolate* isolate) { … }
class V8_NODISCARD ClearThreadInWasmScope { … };
Tagged<Object> ThrowWasmError(
Isolate* isolate, MessageTemplate message,
std::initializer_list<DirectHandle<Object>> args = { … }
}
RUNTIME_FUNCTION(Runtime_WasmGenericWasmToJSObject) { … }
RUNTIME_FUNCTION(Runtime_WasmGenericJSToWasmObject) { … }
RUNTIME_FUNCTION(Runtime_WasmJSToWasmObject) { … }
RUNTIME_FUNCTION(Runtime_WasmMemoryGrow) { … }
RUNTIME_FUNCTION(Runtime_TrapHandlerThrowWasmError) { … }
RUNTIME_FUNCTION(Runtime_ThrowWasmError) { … }
RUNTIME_FUNCTION(Runtime_ThrowWasmStackOverflow) { … }
RUNTIME_FUNCTION(Runtime_WasmThrowJSTypeError) { … }
RUNTIME_FUNCTION(Runtime_ThrowBadSuspenderError) { … }
RUNTIME_FUNCTION(Runtime_WasmThrowRangeError) { … }
RUNTIME_FUNCTION(Runtime_WasmThrowDataViewTypeError) { … }
RUNTIME_FUNCTION(Runtime_WasmThrowDataViewDetachedError) { … }
RUNTIME_FUNCTION(Runtime_WasmThrowTypeError) { … }
RUNTIME_FUNCTION(Runtime_WasmThrow) { … }
RUNTIME_FUNCTION(Runtime_WasmReThrow) { … }
RUNTIME_FUNCTION(Runtime_WasmStackGuard) { … }
RUNTIME_FUNCTION(Runtime_WasmCompileLazy) { … }
namespace {
Tagged<FixedArray> AllocateFeedbackVector(
Isolate* isolate,
DirectHandle<WasmTrustedInstanceData> trusted_instance_data,
int declared_func_index) { … }
}
RUNTIME_FUNCTION(Runtime_WasmAllocateFeedbackVector) { … }
RUNTIME_FUNCTION(Runtime_WasmLiftoffDeoptFinish) { … }
namespace {
void ReplaceJSToWasmWrapper(
Isolate* isolate,
DirectHandle<WasmTrustedInstanceData> trusted_instance_data,
int function_index, DirectHandle<Code> wrapper_code) { … }
}
RUNTIME_FUNCTION(Runtime_TierUpJSToWasmWrapper) { … }
RUNTIME_FUNCTION(…) { …
RUNTIME_FUNCTION(Runtime_TierUpWasmToJSWrapper) { … }
RUNTIME_FUNCTION(Runtime_WasmTriggerTierUp) { … }
RUNTIME_FUNCTION(Runtime_WasmI32AtomicWait) { … }
RUNTIME_FUNCTION(Runtime_WasmI64AtomicWait) { … }
namespace {
Tagged<Object> ThrowTableOutOfBounds(
Isolate* isolate,
DirectHandle<WasmTrustedInstanceData> trusted_instance_data) { … }
}
RUNTIME_FUNCTION(Runtime_WasmRefFunc) { … }
RUNTIME_FUNCTION(Runtime_WasmInternalFunctionCreateExternal) { … }
RUNTIME_FUNCTION(Runtime_WasmFunctionTableGet) { … }
RUNTIME_FUNCTION(Runtime_WasmFunctionTableSet) { … }
RUNTIME_FUNCTION(Runtime_WasmTableInit) { … }
RUNTIME_FUNCTION(Runtime_WasmTableCopy) { … }
RUNTIME_FUNCTION(Runtime_WasmTableGrow) { … }
RUNTIME_FUNCTION(Runtime_WasmTableFill) { … }
namespace {
bool ExecuteWasmDebugBreaks(
Isolate* isolate,
DirectHandle<WasmTrustedInstanceData> trusted_instance_data,
WasmFrame* frame) { … }
}
RUNTIME_FUNCTION(Runtime_WasmDebugBreak) { … }
RUNTIME_FUNCTION(Runtime_WasmArrayCopy) { … }
RUNTIME_FUNCTION(Runtime_WasmArrayNewSegment) { … }
RUNTIME_FUNCTION(Runtime_WasmArrayInitSegment) { … }
RUNTIME_FUNCTION(Runtime_WasmAllocateSuspender) { … }
#define RETURN_RESULT_OR_TRAP(call) …
RUNTIME_FUNCTION(Runtime_WasmCastToSpecialPrimitiveArray) { … }
RUNTIME_FUNCTION(Runtime_WasmStringNewWtf8) { … }
RUNTIME_FUNCTION(Runtime_WasmStringNewWtf8Array) { … }
RUNTIME_FUNCTION(Runtime_WasmStringNewWtf16) { … }
RUNTIME_FUNCTION(Runtime_WasmStringNewWtf16Array) { … }
RUNTIME_FUNCTION(Runtime_WasmSubstring) { … }
RUNTIME_FUNCTION(Runtime_WasmStringConst) { … }
RUNTIME_FUNCTION(Runtime_WasmStringNewSegmentWtf8) { … }
namespace {
template <typename T>
int MeasureWtf8(base::Vector<const T> wtf16) { … }
int MeasureWtf8(Isolate* isolate, Handle<String> string) { … }
size_t MaxEncodedSize(base::Vector<const uint8_t> wtf16) { … }
size_t MaxEncodedSize(base::Vector<const base::uc16> wtf16) { … }
bool HasUnpairedSurrogate(base::Vector<const uint8_t> wtf16) { … }
bool HasUnpairedSurrogate(base::Vector<const base::uc16> wtf16) { … }
template <typename T>
int EncodeWtf8(base::Vector<char> bytes, size_t offset,
base::Vector<const T> wtf16, unibrow::Utf8Variant variant,
MessageTemplate* message, MessageTemplate out_of_bounds) { … }
template <typename GetWritableBytes>
Tagged<Object> EncodeWtf8(Isolate* isolate, unibrow::Utf8Variant variant,
Handle<String> string,
GetWritableBytes get_writable_bytes, size_t offset,
MessageTemplate out_of_bounds_message) { … }
}
void ToUtf8Lossy(Isolate* isolate, Handle<String> string, std::string& out) { … }
RUNTIME_FUNCTION(Runtime_WasmStringMeasureUtf8) { … }
RUNTIME_FUNCTION(Runtime_WasmStringMeasureWtf8) { … }
RUNTIME_FUNCTION(Runtime_WasmStringEncodeWtf8) { … }
RUNTIME_FUNCTION(Runtime_WasmStringEncodeWtf8Array) { … }
RUNTIME_FUNCTION(Runtime_WasmStringToUtf8Array) { … }
RUNTIME_FUNCTION(Runtime_WasmStringEncodeWtf16) { … }
RUNTIME_FUNCTION(Runtime_WasmStringAsWtf8) { … }
RUNTIME_FUNCTION(Runtime_WasmStringViewWtf8Encode) { … }
RUNTIME_FUNCTION(Runtime_WasmStringViewWtf8Slice) { … }
#ifdef V8_ENABLE_DRUMBRAKE
RUNTIME_FUNCTION(Runtime_WasmTraceBeginExecution) {
DCHECK(v8_flags.slow_histograms && !v8_flags.wasm_jitless &&
v8_flags.wasm_enable_exec_time_histograms);
DCHECK_EQ(0, args.length());
HandleScope scope(isolate);
wasm::WasmExecutionTimer* timer = isolate->wasm_execution_timer();
timer->Start();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_WasmTraceEndExecution) {
DCHECK(v8_flags.slow_histograms && !v8_flags.wasm_jitless &&
v8_flags.wasm_enable_exec_time_histograms);
DCHECK_EQ(0, args.length());
HandleScope scope(isolate);
wasm::WasmExecutionTimer* timer = isolate->wasm_execution_timer();
timer->Stop();
return ReadOnlyRoots(isolate).undefined_value();
}
#endif
RUNTIME_FUNCTION(Runtime_WasmStringFromCodePoint) { … }
RUNTIME_FUNCTION(Runtime_WasmStringHash) { … }
}