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

Unified Diff: src/typing-asm.cc

Issue 1564393003: Fixing asm validation of switch statements. (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 | « 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 b969d45166586ae35feb774bee642f6662c0e52a..bc302bda6b4c33b1ded6f23b537bb425524e0546 100644
--- a/src/typing-asm.cc
+++ b/src/typing-asm.cc
@@ -381,14 +381,15 @@ void AsmTyper::VisitSwitchStatement(SwitchStatement* stmt) {
ZoneList<CaseClause*>* clauses = stmt->cases();
for (int i = 0; i < clauses->length(); ++i) {
CaseClause* clause = clauses->at(i);
- if (clause->is_default()) continue;
- Expression* label = clause->label();
- RECURSE(VisitWithExpectation(label, cache_.kAsmSigned,
- "case label non-integer"));
- if (!label->IsLiteral()) FAIL(label, "non-literal case label");
- Handle<Object> value = label->AsLiteral()->value();
- int32_t value32;
- if (!value->ToInt32(&value32)) FAIL(label, "illegal case label value");
+ if (!clause->is_default()) {
+ Expression* label = clause->label();
+ RECURSE(VisitWithExpectation(label, cache_.kAsmSigned,
+ "case label non-integer"));
+ if (!label->IsLiteral()) FAIL(label, "non-literal case label");
+ Handle<Object> value = label->AsLiteral()->value();
+ int32_t value32;
+ if (!value->ToInt32(&value32)) FAIL(label, "illegal case label value");
+ }
// TODO(bradnelson): Detect duplicates.
ZoneList<Statement*>* stmts = clause->statements();
RECURSE(VisitStatements(stmts));
@@ -531,7 +532,12 @@ void AsmTyper::VisitVariableProxy(VariableProxy* expr) {
Variable* var = expr->var();
VariableInfo* info = GetVariableInfo(var, false);
if (info == NULL || info->type == NULL) {
- FAIL(expr, "unbound variable");
+ if (var->mode() == TEMPORARY) {
+ SetType(var, Type::Any(zone()));
+ info = GetVariableInfo(var, false);
+ } else {
+ FAIL(expr, "unbound variable");
+ }
}
if (property_info_ != NULL) {
SetVariableInfo(var, property_info_);
« 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