| Index: src/asmjs/asm-typer.cc
|
| diff --git a/src/asmjs/asm-typer.cc b/src/asmjs/asm-typer.cc
|
| index 20b8d96053d31477ff81d9e9e54a8daa035706e1..a98c18b5328d4ae12dc5746130b9a56afeffdfa2 100644
|
| --- a/src/asmjs/asm-typer.cc
|
| +++ b/src/asmjs/asm-typer.cc
|
| @@ -128,6 +128,7 @@ AsmTyper::AsmTyper(Isolate* isolate, Zone* zone, Script* script,
|
| script_(script),
|
| root_(root),
|
| forward_definitions_(zone),
|
| + ffi_use_signatures_(zone),
|
| stdlib_types_(zone),
|
| stdlib_math_types_(zone),
|
| module_info_(VariableInfo::ForSpecialSymbol(zone_, kModule)),
|
| @@ -329,8 +330,8 @@ AsmTyper::VariableInfo* AsmTyper::ImportLookup(Property* import) {
|
| return i->second;
|
| }
|
|
|
| -AsmTyper::VariableInfo* AsmTyper::Lookup(Variable* variable) {
|
| - ZoneHashMap* scope = in_function_ ? &local_scope_ : &global_scope_;
|
| +AsmTyper::VariableInfo* AsmTyper::Lookup(Variable* variable) const {
|
| + const ZoneHashMap* scope = in_function_ ? &local_scope_ : &global_scope_;
|
| ZoneHashMap::Entry* entry =
|
| scope->Lookup(variable, ComputePointerHash(variable));
|
| if (entry == nullptr && in_function_) {
|
| @@ -423,6 +424,8 @@ AsmType* AsmTyper::TypeOf(AstNode* node) const {
|
| return AsmType::None();
|
| }
|
|
|
| +AsmType* AsmTyper::TypeOf(Variable* v) const { return Lookup(v)->type(); }
|
| +
|
| AsmTyper::StandardMember AsmTyper::VariableAsStandardMember(Variable* var) {
|
| auto* var_info = Lookup(var);
|
| if (var_info == nullptr) {
|
| @@ -2306,9 +2309,20 @@ AsmType* AsmTyper::ValidateCall(AsmType* return_type, Call* call) {
|
| FAIL(call, "Calling something that's not a function.");
|
| }
|
|
|
| - if (callee_type->AsFFIType() != nullptr &&
|
| - return_type == AsmType::Float()) {
|
| - FAIL(call, "Foreign functions can't return float.");
|
| + if (callee_type->AsFFIType() != nullptr) {
|
| + if (return_type == AsmType::Float()) {
|
| + FAIL(call, "Foreign functions can't return float.");
|
| + }
|
| + // Record FFI use signature, since the asm->wasm translator must know
|
| + // all uses up-front.
|
| + ffi_use_signatures_.emplace_back(
|
| + FFIUseSignature(call_var_proxy->var(), zone_));
|
| + FFIUseSignature* sig = &ffi_use_signatures_.back();
|
| + sig->return_type_ = return_type;
|
| + sig->arg_types_.reserve(args.size());
|
| + for (size_t i = 0; i < args.size(); ++i) {
|
| + sig->arg_types_.emplace_back(args[i]);
|
| + }
|
| }
|
|
|
| if (!callee_type->CanBeInvokedWith(return_type, args)) {
|
|
|