Commit 58f1b315 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm][cleanup] Use Vector<Node*> instead of Node** more.

R=clemensh@chromium.org
BUG=v8:9396

Change-Id: Ic1c49aed8110b982ca793ba5ee94d5135619c2fa
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1722567Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62954}
parent ba77172b
This diff is collapsed.
......@@ -186,14 +186,14 @@ class WasmGraphBuilder {
wasm::CompilationEnv* env, Zone* zone, MachineGraph* mcgraph,
wasm::FunctionSig* sig, compiler::SourcePositionTable* spt = nullptr);
Node** Buffer(size_t count) {
Vector<Node*> Buffer(size_t count) {
if (count > cur_bufsize_) {
size_t new_size = count + cur_bufsize_ + 5;
cur_buffer_ =
reinterpret_cast<Node**>(zone_->New(new_size * sizeof(Node*)));
cur_bufsize_ = new_size;
}
return cur_buffer_;
return {cur_buffer_, count};
}
//-----------------------------------------------------------------------
......@@ -230,8 +230,8 @@ class WasmGraphBuilder {
Node* ExceptionTagEqual(Node* caught_tag, Node* expected_tag);
Node* LoadExceptionTagFromTable(uint32_t exception_index);
Node* GetExceptionTag(Node* except_obj);
Node** GetExceptionValues(Node* except_obj,
const wasm::WasmException* exception);
Vector<Node*> GetExceptionValues(Node* except_obj,
const wasm::WasmException* exception);
bool IsPhiWithMerge(Node* phi, Node* merge);
bool ThrowsException(Node* node, Node** if_success, Node** if_exception);
void AppendToMerge(Node* merge, Node* from);
......@@ -274,11 +274,11 @@ class WasmGraphBuilder {
Node* Switch(unsigned count, Node* key);
Node* IfValue(int32_t value, Node* sw);
Node* IfDefault(Node* sw);
Node* Return(unsigned count, Node** nodes);
Node* Return(Vector<Node*> nodes);
template <typename... Nodes>
Node* Return(Node* fst, Nodes*... more) {
Node* arr[] = {fst, more...};
return Return(arraysize(arr), arr);
return Return(ArrayVector(arr));
}
Node* ReturnVoid();
Node* Unreachable(wasm::WasmCodePosition position);
......@@ -606,9 +606,13 @@ class WasmGraphBuilder {
Node* BuildDecodeException32BitValue(Node* values_array, uint32_t* index);
Node* BuildDecodeException64BitValue(Node* values_array, uint32_t* index);
Node** Realloc(Node* const* buffer, size_t old_count, size_t new_count) {
Node** buf = Buffer(new_count);
if (buf != buffer) memcpy(buf, buffer, old_count * sizeof(Node*));
Vector<Node*> Realloc(Node* const* buffer, size_t old_count,
size_t new_count) {
DCHECK_GE(new_count, old_count); // Only support growing.
Vector<Node*> buf = Buffer(new_count);
if (buf.begin() != buffer) {
memcpy(buf.begin(), buffer, old_count * sizeof(Node*));
}
return buf;
}
......
......@@ -258,8 +258,8 @@ class WasmGraphBuildingInterface {
void Drop(FullDecoder* decoder, const Value& value) {}
void DoReturn(FullDecoder* decoder, Vector<Value> values) {
TFNode** nodes = GetNodes(values);
BUILD(Return, static_cast<uint32_t>(values.size()), nodes);
Vector<TFNode*> nodes = GetNodes(values);
BUILD(Return, nodes);
}
void GetLocal(FullDecoder* decoder, Value* result,
......@@ -319,10 +319,10 @@ class WasmGraphBuildingInterface {
void BrOrRet(FullDecoder* decoder, uint32_t depth) {
if (depth == decoder->control_depth() - 1) {
uint32_t ret_count = static_cast<uint32_t>(decoder->sig_->return_count());
TFNode** values =
ret_count == 0 ? nullptr
Vector<TFNode*> values =
ret_count == 0 ? Vector<TFNode*>{}
: GetNodes(decoder->stack_value(ret_count), ret_count);
BUILD(Return, ret_count, values);
BUILD(Return, values);
} else {
Br(decoder, decoder->control_at(depth));
}
......@@ -431,16 +431,16 @@ class WasmGraphBuildingInterface {
void SimdOp(FullDecoder* decoder, WasmOpcode opcode, Vector<Value> args,
Value* result) {
TFNode** inputs = GetNodes(args);
TFNode* node = BUILD(SimdOp, opcode, inputs);
Vector<TFNode*> inputs = GetNodes(args);
TFNode* node = BUILD(SimdOp, opcode, inputs.begin());
if (result) result->node = node;
}
void SimdLaneOp(FullDecoder* decoder, WasmOpcode opcode,
const SimdLaneImmediate<validate> imm, Vector<Value> inputs,
Value* result) {
TFNode** nodes = GetNodes(inputs);
result->node = BUILD(SimdLaneOp, opcode, imm.lane, nodes);
Vector<TFNode*> nodes = GetNodes(inputs);
result->node = BUILD(SimdLaneOp, opcode, imm.lane, nodes.begin());
}
void SimdShiftOp(FullDecoder* decoder, WasmOpcode opcode,
......@@ -495,7 +495,7 @@ class WasmGraphBuildingInterface {
SetEnv(if_match_env);
// TODO(mstarzinger): Can't use BUILD() here, GetExceptionValues() returns
// TFNode** rather than TFNode*. Fix to add landing pads.
TFNode** caught_values =
Vector<TFNode*> caught_values =
builder_->GetExceptionValues(exception.node, imm.exception);
for (size_t i = 0, e = values.size(); i < e; ++i) {
values[i].node = caught_values[i];
......@@ -526,9 +526,9 @@ class WasmGraphBuildingInterface {
void AtomicOp(FullDecoder* decoder, WasmOpcode opcode, Vector<Value> args,
const MemoryAccessImmediate<validate>& imm, Value* result) {
TFNode** inputs = GetNodes(args);
TFNode* node = BUILD(AtomicOp, opcode, inputs, imm.alignment, imm.offset,
decoder->position());
Vector<TFNode*> inputs = GetNodes(args);
TFNode* node = BUILD(AtomicOp, opcode, inputs.begin(), imm.alignment,
imm.offset, decoder->position());
if (result) result->node = node;
}
......@@ -598,15 +598,15 @@ class WasmGraphBuildingInterface {
->try_info;
}
TFNode** GetNodes(Value* values, size_t count) {
TFNode** nodes = builder_->Buffer(count);
Vector<TFNode*> GetNodes(Value* values, size_t count) {
Vector<TFNode*> nodes = builder_->Buffer(count);
for (size_t i = 0; i < count; ++i) {
nodes[i] = values[i].node;
}
return nodes;
}
TFNode** GetNodes(Vector<Value> values) {
Vector<TFNode*> GetNodes(Vector<Value> values) {
return GetNodes(values.begin(), values.size());
}
......@@ -885,17 +885,17 @@ class WasmGraphBuildingInterface {
FunctionSig* sig, uint32_t sig_index, const Value args[],
Value returns[]) {
int param_count = static_cast<int>(sig->parameter_count());
TFNode** arg_nodes = builder_->Buffer(param_count + 1);
Vector<TFNode*> arg_nodes = builder_->Buffer(param_count + 1);
TFNode** return_nodes = nullptr;
arg_nodes[0] = index_node;
for (int i = 0; i < param_count; ++i) {
arg_nodes[i + 1] = args[i].node;
}
if (index_node) {
BUILD(CallIndirect, table_index, sig_index, arg_nodes, &return_nodes,
decoder->position());
BUILD(CallIndirect, table_index, sig_index, arg_nodes.begin(),
&return_nodes, decoder->position());
} else {
BUILD(CallDirect, sig_index, arg_nodes, &return_nodes,
BUILD(CallDirect, sig_index, arg_nodes.begin(), &return_nodes,
decoder->position());
}
int return_count = static_cast<int>(sig->return_count());
......@@ -911,16 +911,16 @@ class WasmGraphBuildingInterface {
TFNode* index_node, FunctionSig* sig, uint32_t sig_index,
const Value args[]) {
int arg_count = static_cast<int>(sig->parameter_count());
TFNode** arg_nodes = builder_->Buffer(arg_count + 1);
Vector<TFNode*> arg_nodes = builder_->Buffer(arg_count + 1);
arg_nodes[0] = index_node;
for (int i = 0; i < arg_count; ++i) {
arg_nodes[i + 1] = args[i].node;
}
if (index_node) {
BUILD(ReturnCallIndirect, table_index, sig_index, arg_nodes,
BUILD(ReturnCallIndirect, table_index, sig_index, arg_nodes.begin(),
decoder->position());
} else {
BUILD(ReturnCall, sig_index, arg_nodes, decoder->position());
BUILD(ReturnCall, sig_index, arg_nodes.begin(), decoder->position());
}
}
};
......
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