Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Unified Diff: src/asmjs/asm-typer.cc

Issue 2345593003: [wasm] Master CL for Binary 0xC changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix test failures and TSAN races. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/asmjs/asm-typer.h ('k') | src/asmjs/asm-wasm-builder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)) {
« no previous file with comments | « src/asmjs/asm-typer.h ('k') | src/asmjs/asm-wasm-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698