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

Unified Diff: src/typing-asm.cc

Issue 1648063003: Revert of Accurately type foreign functions, and variables. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 | « src/typing-asm.h ('k') | 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 6e073f92047898292668b0a70c652de05bfbba9e..14db16ba94b36aeba4e97dfd503ee061f1000e4c 100644
--- a/src/typing-asm.cc
+++ b/src/typing-asm.cc
@@ -35,6 +35,7 @@
if (HasStackOverflow()) return; \
if (!valid_) return; \
} while (false)
+
AsmTyper::AsmTyper(Isolate* isolate, Zone* zone, Script* script,
FunctionLiteral* root)
@@ -61,7 +62,6 @@
ZoneAllocationPolicy(zone)),
in_function_(false),
building_function_tables_(false),
- visiting_exports_(false),
cache_(TypeCache::Get()) {
InitializeAstVisitor(isolate);
InitializeStdlib();
@@ -135,7 +135,6 @@
}
// Validate exports.
- visiting_exports_ = true;
ReturnStatement* stmt = fun->body()->last()->AsReturnStatement();
if (stmt == nullptr) {
FAIL(fun->body()->last(), "last statement in module is not a return");
@@ -490,11 +489,11 @@
void AsmTyper::VisitFunctionLiteral(FunctionLiteral* expr) {
+ Scope* scope = expr->scope();
+ DCHECK(scope->is_function_scope());
if (in_function_) {
FAIL(expr, "invalid nested function");
}
- Scope* scope = expr->scope();
- DCHECK(scope->is_function_scope());
if (!expr->bounds().upper->IsFunction()) {
FAIL(expr, "invalid function literal");
@@ -524,9 +523,6 @@
void AsmTyper::VisitConditional(Conditional* expr) {
- if (!in_function_) {
- FAIL(expr, "ternary operator inside module body");
- }
RECURSE(VisitWithExpectation(expr->condition(), Type::Number(),
"condition expected to be integer"));
if (!computed_type_->Is(cache_.kAsmInt)) {
@@ -558,18 +554,8 @@
void AsmTyper::VisitVariableProxy(VariableProxy* expr) {
- VisitVariableProxy(expr, false);
-}
-
-void AsmTyper::VisitVariableProxy(VariableProxy* expr, bool assignment) {
Variable* var = expr->var();
VariableInfo* info = GetVariableInfo(var, false);
- if (!assignment && !in_function_ && !building_function_tables_ &&
- !visiting_exports_) {
- if (var->location() != VariableLocation::PARAMETER || var->index() >= 3) {
- FAIL(expr, "illegal variable reference in module body");
- }
- }
if (info == NULL || info->type == NULL) {
if (var->mode() == TEMPORARY) {
SetType(var, Type::Any(zone()));
@@ -689,8 +675,8 @@
FAIL(expr, "intish or floatish assignment");
}
if (expr->target()->IsVariableProxy()) {
- expected_type_ = target_type;
- VisitVariableProxy(expr->target()->AsVariableProxy(), true);
+ RECURSE(VisitWithExpectation(expr->target(), target_type,
+ "assignment target expected to match value"));
} else if (expr->target()->IsProperty()) {
Property* property = expr->target()->AsProperty();
RECURSE(VisitWithExpectation(property->obj(), Type::Any(),
@@ -926,7 +912,6 @@
void AsmTyper::VisitCall(Call* expr) {
- Type* expected_type = expected_type_;
RECURSE(VisitWithExpectation(expr->expression(), Type::Any(),
"callee expected to be any"));
StandardMember standard_member = kNone;
@@ -989,17 +974,9 @@
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");
- }
}
intish_ = kMaxUncombinedAdditiveSteps;
- IntersectResult(expr, expected_type);
+ IntersectResult(expr, Type::Number());
} else {
FAIL(expr, "invalid callee");
}
@@ -1037,9 +1014,6 @@
void AsmTyper::VisitUnaryOperation(UnaryOperation* expr) {
- if (!in_function_) {
- FAIL(expr, "unary operator inside module body");
- }
switch (expr->op()) {
case Token::NOT: // Used to encode != and !==
RECURSE(VisitWithExpectation(expr->expression(), cache_.kAsmInt,
@@ -1067,7 +1041,7 @@
Type* left_expected,
Type* right_expected,
Type* result_type, bool conversion) {
- RECURSE(VisitWithExpectation(expr->left(), Type::Number(zone()),
+ RECURSE(VisitWithExpectation(expr->left(), Type::Number(),
"left bitwise operand expected to be a number"));
int left_intish = intish_;
Type* left_type = computed_type_;
@@ -1108,15 +1082,6 @@
void AsmTyper::VisitBinaryOperation(BinaryOperation* expr) {
- if (!in_function_) {
- if (expr->op() != Token::BIT_OR && expr->op() != Token::MUL) {
- FAIL(expr, "illegal binary operator inside module body");
- }
- if (!(expr->left()->IsProperty() || expr->left()->IsVariableProxy()) ||
- !expr->right()->IsLiteral()) {
- FAIL(expr, "illegal computation inside module body");
- }
- }
switch (expr->op()) {
case Token::COMMA: {
RECURSE(VisitWithExpectation(expr->left(), Type::Any(),
@@ -1133,9 +1098,6 @@
// BIT_OR allows Any since it is used as a type coercion.
VisitIntegerBitwiseOperator(expr, Type::Any(), cache_.kAsmInt,
cache_.kAsmSigned, true);
- if (expr->left()->IsCall() && expr->op() == Token::BIT_OR) {
- IntersectResult(expr->left(), cache_.kAsmSigned);
- }
return;
}
case Token::BIT_XOR: {
@@ -1222,9 +1184,6 @@
} else if (expr->op() == Token::MUL && expr->right()->IsLiteral() &&
right_type->Is(cache_.kAsmDouble)) {
// For unary +, expressed as x * 1.0
- if (expr->left()->IsCall() && expr->op() == Token::MUL) {
- IntersectResult(expr->left(), cache_.kAsmDouble);
- }
IntersectResult(expr, cache_.kAsmDouble);
return;
} else if (type->Is(cache_.kAsmFloat) && expr->op() != Token::MOD) {
@@ -1248,9 +1207,6 @@
void AsmTyper::VisitCompareOperation(CompareOperation* expr) {
- if (!in_function_) {
- FAIL(expr, "comparison inside module body");
- }
Token::Value op = expr->op();
if (op != Token::EQ && op != Token::NE && op != Token::LT &&
op != Token::LTE && op != Token::GT && op != Token::GTE) {
« no previous file with comments | « src/typing-asm.h ('k') | test/cctest/test-asm-validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698