Support constant CALL_INDIRECT.

This commit is contained in:
Ben Vanik 2014-06-09 21:15:13 -07:00
parent 95508273f6
commit 5343cab851
1 changed files with 14 additions and 0 deletions

View File

@ -9,6 +9,9 @@
#include <alloy/compiler/passes/constant_propagation_pass.h>
#include <alloy/runtime/function.h>
#include <alloy/runtime/runtime.h>
using namespace alloy;
using namespace alloy::compiler;
using namespace alloy::compiler::passes;
@ -89,6 +92,17 @@ int ConstantPropagationPass::Run(HIRBuilder* builder) {
}
}
break;
case OPCODE_CALL_INDIRECT:
if (i->src1.value->IsConstant()) {
runtime::FunctionInfo* symbol_info;
if (runtime_->LookupFunctionInfo(
(uint32_t)i->src1.value->constant.i32, &symbol_info)) {
break;
}
i->Replace(&OPCODE_CALL_info, i->flags);
i->src1.symbol_info = symbol_info;
}
break;
case OPCODE_CALL_INDIRECT_TRUE:
if (i->src1.value->IsConstant()) {
if (i->src1.value->IsConstantTrue()) {