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

Unified Diff: src/typing-asm.cc

Issue 1652963004: Switch to using Function(Any) for foreign functions, label declarations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: merge Created 4 years, 11 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 | « no previous file | test/cctest/test-asm-validator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/typing-asm.cc
diff --git a/src/typing-asm.cc b/src/typing-asm.cc
index 0528ee78d09c2ce93c3450c965a984ad88a92256..3eb986c3cf1e92bf637f3750e2c9d578c9ca4292 100644
--- a/src/typing-asm.cc
+++ b/src/typing-asm.cc
@@ -908,13 +908,16 @@ void AsmTyper::VisitProperty(Property* expr) {
return;
}
- // stdlib.x or foreign.x
VariableProxy* proxy = expr->obj()->AsVariableProxy();
if (proxy != NULL) {
Variable* var = proxy->var();
if (var->location() == VariableLocation::PARAMETER && var->index() == 1) {
- // foreign.x is ok.
- SetResult(expr, expected_type_);
+ // foreign.x - Function represent as () -> Any
+ if (Type::Any()->Is(expected_type_)) {
+ SetResult(expr, Type::Function(Type::Any(), zone()));
+ } else {
+ SetResult(expr, expected_type_);
+ }
return;
}
}
@@ -942,63 +945,66 @@ void AsmTyper::VisitCall(Call* expr) {
FunctionType* fun_type = computed_type_->AsFunction();
Type* result_type = fun_type->Result();
ZoneList<Expression*>* args = expr->arguments();
- if (fun_type->Arity() != args->length()) {
- FAIL(expr, "call with wrong arity");
- }
- for (int i = 0; i < args->length(); ++i) {
- Expression* arg = args->at(i);
- RECURSE(VisitWithExpectation(
- arg, fun_type->Parameter(i),
- "call argument expected to match callee parameter"));
- if (standard_member != kNone && standard_member != kMathFround &&
- i == 0) {
- result_type = computed_type_;
- }
- }
- // Handle polymorphic stdlib functions specially.
- if (standard_member == kMathCeil || standard_member == kMathFloor ||
- standard_member == kMathSqrt) {
- if (!args->at(0)->bounds().upper->Is(cache_.kAsmFloat) &&
- !args->at(0)->bounds().upper->Is(cache_.kAsmDouble)) {
- FAIL(expr, "illegal function argument type");
+ if (Type::Any()->Is(result_type)) {
+ // For foreign calls.
+ ZoneList<Expression*>* args = expr->arguments();
brucedawson 2016/02/05 23:35:50 Not a serious problem, but this line of code is re
bradn 2016/02/06 00:32:54 Ah, bad merge. Thanks!
+ for (int i = 0; i < args->length(); ++i) {
+ Expression* arg = args->at(i);
+ RECURSE(VisitWithExpectation(
+ arg, Type::Any(), "foreign call argument expected to be any"));
+ // Checking for asm extern types explicitly, as the type system
+ // doesn't correctly check their inheritance relationship.
+ if (!computed_type_->Is(cache_.kAsmSigned) &&
+ !computed_type_->Is(cache_.kAsmFixnum) &&
+ !computed_type_->Is(cache_.kAsmDouble)) {
+ FAIL(arg,
+ "foreign call argument expected to be int, double, or fixnum");
+ }
}
- } else if (standard_member == kMathAbs || standard_member == kMathMin ||
- standard_member == kMathMax) {
- if (!args->at(0)->bounds().upper->Is(cache_.kAsmFloat) &&
- !args->at(0)->bounds().upper->Is(cache_.kAsmDouble) &&
- !args->at(0)->bounds().upper->Is(cache_.kAsmSigned)) {
- FAIL(expr, "illegal function argument type");
+ intish_ = 0;
+ expr->expression()->set_bounds(
+ Bounds(Type::Function(Type::Any(), zone())));
+ IntersectResult(expr, expected_type);
+ } else {
+ if (fun_type->Arity() != args->length()) {
+ FAIL(expr, "call with wrong arity");
}
- if (args->length() > 1) {
- Type* other = Type::Intersect(args->at(0)->bounds().upper,
- args->at(1)->bounds().upper, zone());
- if (!other->Is(cache_.kAsmFloat) && !other->Is(cache_.kAsmDouble) &&
- !other->Is(cache_.kAsmSigned)) {
- FAIL(expr, "function arguments types don't match");
+ for (int i = 0; i < args->length(); ++i) {
+ Expression* arg = args->at(i);
+ RECURSE(VisitWithExpectation(
+ arg, fun_type->Parameter(i),
+ "call argument expected to match callee parameter"));
+ if (standard_member != kNone && standard_member != kMathFround &&
+ i == 0) {
+ result_type = computed_type_;
}
}
- }
- intish_ = 0;
- IntersectResult(expr, result_type);
- } else if (computed_type_->Is(Type::Any())) {
- // For foreign calls.
- ZoneList<Expression*>* args = expr->arguments();
- for (int i = 0; i < args->length(); ++i) {
- Expression* arg = args->at(i);
- RECURSE(VisitWithExpectation(arg, Type::Any(),
- "foreign call argument expected to be any"));
- // Checking for asm extern types explicitly, as the type system
- // doesn't correctly check their inheritance relationship.
- if (!computed_type_->Is(cache_.kAsmSigned) &&
- !computed_type_->Is(cache_.kAsmFixnum) &&
- !computed_type_->Is(cache_.kAsmDouble)) {
- FAIL(arg,
- "foreign call argument expected to be int, double, or fixnum");
+ // Handle polymorphic stdlib functions specially.
+ if (standard_member == kMathCeil || standard_member == kMathFloor ||
+ standard_member == kMathSqrt) {
+ if (!args->at(0)->bounds().upper->Is(cache_.kAsmFloat) &&
+ !args->at(0)->bounds().upper->Is(cache_.kAsmDouble)) {
+ FAIL(expr, "illegal function argument type");
+ }
+ } else if (standard_member == kMathAbs || standard_member == kMathMin ||
+ standard_member == kMathMax) {
+ if (!args->at(0)->bounds().upper->Is(cache_.kAsmFloat) &&
+ !args->at(0)->bounds().upper->Is(cache_.kAsmDouble) &&
+ !args->at(0)->bounds().upper->Is(cache_.kAsmSigned)) {
+ FAIL(expr, "illegal function argument type");
+ }
+ if (args->length() > 1) {
+ Type* other = Type::Intersect(args->at(0)->bounds().upper,
+ args->at(1)->bounds().upper, zone());
+ if (!other->Is(cache_.kAsmFloat) && !other->Is(cache_.kAsmDouble) &&
+ !other->Is(cache_.kAsmSigned)) {
+ FAIL(expr, "function arguments types don't match");
+ }
+ }
}
+ intish_ = 0;
+ IntersectResult(expr, result_type);
}
- intish_ = kMaxUncombinedAdditiveSteps;
- expr->expression()->set_bounds(Bounds(Type::Function()));
- IntersectResult(expr, expected_type);
} else {
FAIL(expr, "invalid callee");
}
« no previous file with comments | « no previous file | test/cctest/test-asm-validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698