summaryrefslogtreecommitdiff
path: root/src/interpreter.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/interpreter.h')
-rw-r--r--src/interpreter.h42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/interpreter.h b/src/interpreter.h
index cccf5897..91deeedb 100644
--- a/src/interpreter.h
+++ b/src/interpreter.h
@@ -152,6 +152,8 @@ struct TypedValue {
Value value;
};
+typedef std::vector<TypedValue> TypedValues;
+
struct Global {
Global() : mutable_(false), import_index(kInvalidIndex) {}
Global(const TypedValue& typed_value, bool mutable_)
@@ -467,11 +469,13 @@ class Thread {
explicit Options(uint32_t value_stack_size = kDefaultValueStackSize,
uint32_t call_stack_size = kDefaultCallStackSize,
- IstreamOffset pc = kInvalidIstreamOffset);
+ IstreamOffset pc = kInvalidIstreamOffset,
+ Stream* trace_stream = nullptr);
uint32_t value_stack_size;
uint32_t call_stack_size;
IstreamOffset pc;
+ Stream* trace_stream;
};
explicit Thread(Environment*, const Options& = Options());
@@ -479,19 +483,22 @@ class Thread {
Environment* env() { return env_; }
Result RunFunction(Index func_index,
- const std::vector<TypedValue>& args,
- std::vector<TypedValue>* out_results);
-
- Result TraceFunction(Index func_index,
- Stream*,
- const std::vector<TypedValue>& args,
- std::vector<TypedValue>* out_results);
+ const TypedValues& args,
+ TypedValues* out_results);
+ Result RunStartFunction(DefinedModule* module);
+ Result RunExport(const Export*,
+ const TypedValues& args,
+ TypedValues* out_results);
+ Result RunExportByName(Module* module,
+ string_view name,
+ const TypedValues& args,
+ TypedValues* out_results);
private:
const uint8_t* GetIstream() const { return env_->istream_->data.data(); }
- Result PushArgs(const FuncSignature*, const std::vector<TypedValue>& args);
- void CopyResults(const FuncSignature*, std::vector<TypedValue>* out_results);
+ Result PushArgs(const FuncSignature*, const TypedValues& args);
+ void CopyResults(const FuncSignature*, TypedValues* out_results);
Result Run(int num_instructions, IstreamOffset* call_stack_return_top);
void Trace(Stream*);
@@ -559,7 +566,6 @@ class Thread {
Result BinopTrap(BinopTrapFunc<R, T> func) WABT_WARN_UNUSED;
Result RunDefinedFunction(IstreamOffset);
- Result TraceDefinedFunction(IstreamOffset, Stream*);
Result CallHost(HostFunc*);
@@ -571,6 +577,7 @@ class Thread {
IstreamOffset* call_stack_top_;
IstreamOffset* call_stack_end_;
IstreamOffset pc_;
+ Stream* trace_stream_;
};
bool IsCanonicalNan(uint32_t f32_bits);
@@ -578,6 +585,19 @@ bool IsCanonicalNan(uint64_t f64_bits);
bool IsArithmeticNan(uint32_t f32_bits);
bool IsArithmeticNan(uint64_t f64_bits);
+std::string TypedValueToString(const TypedValue&);
+const char* ResultToString(Result);
+
+void WriteTypedValue(Stream* stream, const TypedValue&);
+void WriteTypedValues(Stream* stream, const TypedValues&);
+void WriteResult(Stream* stream, const char* desc, Result);
+void WriteCall(Stream* stream,
+ string_view module_name,
+ string_view func_name,
+ const TypedValues& args,
+ const TypedValues& results,
+ Result);
+
} // namespace interpreter
} // namespace wabt